Skip to content

Commit 30753f9

Browse files
committed
versionString()
1 parent a017658 commit 30753f9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cmd/kubectl-tree/rootcmd.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,17 @@ var rootCmd = &cobra.Command{
4444
" kubectl tree kservice.v1.serving.knative.dev my-app", // TODO add more examples about disambiguation etc
4545
Args: cobra.MinimumNArgs(2),
4646
RunE: run,
47-
Version: version,
47+
Version: versionString(),
48+
}
49+
50+
// versionString returns the version prefixed by 'v'
51+
// or an empty string if no version has been populated by goreleaser.
52+
// In this case, the --version flag will not be added by cobra.
53+
func versionString() string {
54+
if len(version) == 0 {
55+
return ""
56+
}
57+
return "v" + version
4858
}
4959

5060
func run(_ *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)