(f factory.Factory)
| 319 | } |
| 320 | |
| 321 | func parseConfig(f factory.Factory) (*RawConfig, error) { |
| 322 | // get current working dir |
| 323 | cwd, err := os.Getwd() |
| 324 | if err != nil { |
| 325 | return nil, err |
| 326 | } |
| 327 | |
| 328 | // set working dir back to original |
| 329 | defer func() { _ = os.Chdir(cwd) }() |
| 330 | |
| 331 | // Set config root |
| 332 | configLoader, err := f.NewConfigLoader("") |
| 333 | if err != nil { |
| 334 | return nil, err |
| 335 | } |
| 336 | configExists, err := configLoader.SetDevSpaceRoot(log.Discard) |
| 337 | if err != nil { |
| 338 | return nil, err |
| 339 | } else if !configExists { |
| 340 | return nil, errors.New(message.ConfigNotFound) |
| 341 | } |
| 342 | |
| 343 | // Parse commands |
| 344 | timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Second*10) |
| 345 | defer cancel() |
| 346 | |
| 347 | r := &RawConfig{ |
| 348 | resolved: map[string]string{}, |
| 349 | } |
| 350 | _, err = configLoader.LoadWithParser(timeoutCtx, nil, nil, r, &loader.ConfigOptions{ |
| 351 | Dry: true, |
| 352 | }, log.Discard) |
| 353 | if r.Resolver != nil { |
| 354 | return r, nil |
| 355 | } |
| 356 | |
| 357 | return nil, err |
| 358 | } |
| 359 | |
| 360 | type RawConfig struct { |
| 361 | Ctx context.Context |
no test coverage detected