diff --git a/.goreleaser.yml b/.goreleaser.yml index 140481a..00b3f59 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -20,7 +20,7 @@ builds: - -a ldflags: - -extldflags "-static" - - -X github.com/yannh/kubeconform/pkg/config.version={{.Tag}} + - -X main.version={{.Tag}} archives: - format: tar.gz diff --git a/cmd/kubeconform/main.go b/cmd/kubeconform/main.go index dd4d813..af0cbc6 100644 --- a/cmd/kubeconform/main.go +++ b/cmd/kubeconform/main.go @@ -15,6 +15,8 @@ import ( "github.com/yannh/kubeconform/pkg/validator" ) +var version = "development" + func processResults(cancel context.CancelFunc, o output.Output, validationResults <-chan validator.Result, exitOnError bool) <-chan bool { success := true result := make(chan bool) @@ -49,6 +51,7 @@ func realMain() int { if cfg.Help { return 0 } else if cfg.Version { + fmt.Println(version) return 0 } else if out != "" { fmt.Println(out) diff --git a/pkg/config/config.go b/pkg/config/config.go index 8bc3599..22cb76d 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -8,8 +8,6 @@ import ( "strings" ) -var version = "development" - type Config struct { Cache string CPUProfileFile string @@ -102,9 +100,5 @@ func FromFlags(progName string, args []string) (Config, string, error) { flags.Usage() } - if c.Version { - fmt.Println(version) - } - return c, buf.String(), err }