From efb7cdb9d206b1a769299031b12f6b3c3249b7fe Mon Sep 17 00:00:00 2001 From: Yannik Daellenbach Date: Thu, 30 May 2024 16:50:50 +0200 Subject: [PATCH] Handle if "binary" flag is not set (is empty) Set `kustomize` as default --- cmd/kustomize.go | 7 +++---- cmd/kustomize/build.go | 5 +++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/kustomize.go b/cmd/kustomize.go index 3c6274c..024fe3d 100644 --- a/cmd/kustomize.go +++ b/cmd/kustomize.go @@ -1,6 +1,7 @@ package cmd import ( + "cmp" "fmt" "os/exec" @@ -25,10 +26,8 @@ var kustomizeCmd = &cobra.Command{ }, Long: `Generate a DOT file to visualize the dependencies between your kustomize components`, RunE: func(cmd *cobra.Command, args []string) error { - kustomizeCmd := "kustomize" - if *binary != "" { - kustomizeCmd = *binary - } + + kustomizeCmd := cmp.Or(*binary, "kustomize") if *version { kustomizeCmd := exec.CommandContext(cmd.Context(), kustomizeCmd, "version") diff --git a/cmd/kustomize/build.go b/cmd/kustomize/build.go index 919ef97..f228679 100644 --- a/cmd/kustomize/build.go +++ b/cmd/kustomize/build.go @@ -1,6 +1,8 @@ package kustomize import ( + "cmp" + "github.com/puzzle/goff/kustomize" "github.com/spf13/cobra" @@ -24,6 +26,9 @@ var KustomizeBuildCmd = &cobra.Command{ if err != nil { return err } + + kustomizeCommand = cmp.Or(kustomizeCommand, "kustomize") + return kustomize.BuildAll(kustomizeCommand, args[0], *outputBuildDir) }, }