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

Commit

Permalink
cli/cmd: consistently use diags.HasErrors() for checking diagnostics
Browse files Browse the repository at this point in the history
Part of #994.

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
  • Loading branch information
invidian committed Sep 25, 2020
1 parent 4be26f0 commit 9a25a8e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func init() {
// and returns created objects to the caller for further use.
func initialize(contextLogger *log.Entry) (*terraform.Executor, platform.Platform, *config.Config, string) {
lokoConfig, diags := getLokoConfig()
if len(diags) > 0 {
if diags.HasErrors() {
contextLogger.Fatal(diags)
}

Expand Down
5 changes: 2 additions & 3 deletions cli/cmd/component-apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ func runApply(cmd *cobra.Command, args []string) {
}

lokoConfig, diags := getLokoConfig()
if len(diags) > 0 {
if diags.HasErrors() {
contextLogger.Fatal(diags)
}

componentsToApply := args

if len(componentsToApply) == 0 {
for _, component := range lokoConfig.RootConfig.Components {
componentsToApply = append(componentsToApply, component.Name)
Expand Down Expand Up @@ -96,7 +95,7 @@ func applyComponents(lokoConfig *config.Config, kubeconfig []byte, componentName

componentConfigBody := lokoConfig.LoadComponentConfigBody(componentName)

if diags := component.LoadConfig(componentConfigBody, lokoConfig.EvalContext); len(diags) > 0 {
if diags := component.LoadConfig(componentConfigBody, lokoConfig.EvalContext); diags.HasErrors() {
fmt.Printf("%v\n", diags)
return diags
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/component-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func runDelete(cmd *cobra.Command, args []string) {
}

lokoConfig, diags := getLokoConfig()
if len(diags) > 0 {
if diags.HasErrors() {
contextLogger.Fatal(diags)
}

Expand Down

0 comments on commit 9a25a8e

Please sign in to comment.