diff --git a/cmd/main.go b/cmd/main.go index 79f5c4d..c0287f3 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -51,32 +51,6 @@ func init() { return } projectConfig = pc - - if projectConfig.Environments == nil { - projectConfig.Environments = map[string]*project.Environment{} - } - - if projectConfig.Addons == nil { - projectConfig.Addons = map[string]project.Addon{} - } - - if projectConfig.ParsedAddons == nil { - projectConfig.ParsedAddons = map[string]template.TemplateManifest{} - } - - // load all addons, so we can use them later - for k, v := range projectConfig.Addons { - tm, err := template.LoadManifest(v.Path) - if err != nil { - fmt.Printf("An error occurred while loading the addon [%s] manifest file: %s, %v\n", k, v.Path, err) - os.Exit(1) - return - } - tm.Name = k - tm.BasePath = v.Path - tm.Group = v.Group - projectConfig.ParsedAddons[k] = *tm - } } func main() { diff --git a/internal/project/config.go b/internal/project/config.go index 90bb93d..e384bbb 100644 --- a/internal/project/config.go +++ b/internal/project/config.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/leonsteinhaeuser/openshift-gitops-cli/internal/template" "sigs.k8s.io/yaml" ) @@ -20,6 +21,29 @@ func ParseConfig(path string) (*ProjectConfig, error) { return nil, fmt.Errorf("failed to unmarshal config to ProjectConfig: %w", err) } + if pc.Environments == nil { + pc.Environments = map[string]*Environment{} + } + + if pc.Addons == nil { + pc.Addons = map[string]Addon{} + } + + if pc.ParsedAddons == nil { + pc.ParsedAddons = map[string]template.TemplateManifest{} + } + + // load all addons, so we can use them later + for k, v := range pc.Addons { + tm, err := template.LoadManifest(v.Path) + if err != nil { + return nil, fmt.Errorf("an error occurred while loading the addon [%s] manifest file: %s, %v", k, v.Path, err) + } + tm.Name = k + tm.BasePath = v.Path + tm.Group = v.Group + pc.ParsedAddons[k] = *tm + } return pc, nil }