Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
cli/cmd: make component render-manifest use errors instead of Fatalf
Browse files Browse the repository at this point in the history
To soften the dependency on log.Entry and to separate the functionality
from CLI code. This also makes code easier to move around and avoids
hiding function complexity.

Part of #630

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
  • Loading branch information
invidian committed Oct 19, 2020
1 parent 1f18676 commit 230e793
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cli/cmd/component-render-manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,28 @@ func runComponentRender(cmd *cobra.Command, args []string) {
"args": args,
})

if err := componentRenderManifest(contextLogger, args); err != nil {
contextLogger.Fatalf("Rendering component manifests failed: %v", err)
}
}

func componentRenderManifest(contextLogger *log.Entry, componentsList []string) error {
lokoConfig, diags := getLokoConfig()
if diags.HasErrors() {
for _, diagnostic := range diags {
contextLogger.Error(diagnostic.Error())
}
contextLogger.Fatal("Errors found while loading configuration")

return diags
}

componentsToRender := selectComponentNames(args, *lokoConfig.RootConfig)
componentsToRender := selectComponentNames(componentsList, *lokoConfig.RootConfig)

if err := renderComponentManifests(lokoConfig, componentsToRender); err != nil {
contextLogger.Fatal(err)
return fmt.Errorf("rendering component manifests: %w", err)
}

return nil
}

func renderComponentManifests(lokoConfig *config.Config, componentNames []string) error {
Expand Down

0 comments on commit 230e793

Please sign in to comment.