LoadRaw loads the raw config
()
| 572 | |
| 573 | // LoadRaw loads the raw config |
| 574 | func (l *configLoader) LoadRaw() (map[string]interface{}, error) { |
| 575 | // What path should we use |
| 576 | configPath := ConfigPath(l.absConfigPath) |
| 577 | _, err := os.Stat(configPath) |
| 578 | if err != nil { |
| 579 | return nil, errors.Errorf("Couldn't load '%s': %v", configPath, err) |
| 580 | } |
| 581 | |
| 582 | fileContent, err := os.ReadFile(configPath) |
| 583 | if err != nil { |
| 584 | return nil, err |
| 585 | } |
| 586 | |
| 587 | rawMap := map[string]interface{}{} |
| 588 | err = yamlutil.Unmarshal(fileContent, &rawMap) |
| 589 | if err != nil { |
| 590 | return nil, err |
| 591 | } |
| 592 | |
| 593 | name, ok := rawMap["name"].(string) |
| 594 | if !ok || name == "" { |
| 595 | directoryName := filepath.Base(filepath.Dir(l.absConfigPath)) |
| 596 | if directoryName != "" && len(directoryName) > 2 { |
| 597 | name = encoding.Convert(directoryName) |
| 598 | } else { |
| 599 | name = "devspace" |
| 600 | } |
| 601 | |
| 602 | rawMap["name"] = name |
| 603 | } |
| 604 | |
| 605 | return rawMap, nil |
| 606 | } |
| 607 | |
| 608 | // Exists checks whether the yaml file for the config exists or the configs.yaml exists |
| 609 | func (l *configLoader) Exists() bool { |
no test coverage detected