(cs *iostreams.ColorScheme, filePath string)
| 242 | } |
| 243 | |
| 244 | func readConfigFromFile(cs *iostreams.ColorScheme, filePath string) (*ImportConfigJSON, error) { |
| 245 | var config *ImportConfigJSON |
| 246 | |
| 247 | jsonFile, err := os.Open(filePath) |
| 248 | if err != nil { |
| 249 | return nil, fmt.Errorf("%s An error occurred when opening file: %w", cs.FailureIcon(), err) |
| 250 | } |
| 251 | defer jsonFile.Close() |
| 252 | byteValue, err := io.ReadAll(jsonFile) |
| 253 | if err != nil { |
| 254 | return nil, fmt.Errorf( |
| 255 | "%s An error occurred when reading JSON file: %w", |
| 256 | cs.FailureIcon(), |
| 257 | err, |
| 258 | ) |
| 259 | } |
| 260 | err = json.Unmarshal(byteValue, &config) |
| 261 | if err != nil { |
| 262 | return nil, fmt.Errorf( |
| 263 | "%s An error occurred when parsing JSON file: %w", |
| 264 | cs.FailureIcon(), |
| 265 | err, |
| 266 | ) |
| 267 | } |
| 268 | |
| 269 | return config, nil |
| 270 | } |
no test coverage detected