add version sub command

Signed-off-by: Jeff <zw0948@gmail.com>
This commit is contained in:
Jeff
2021-04-06 02:00:33 +00:00
parent d98c4e8311
commit 2952bf4a3b
2 changed files with 13 additions and 1 deletions

View File

@@ -57,6 +57,7 @@ import (
"kubesphere.io/kubesphere/pkg/simple/client/s3"
"kubesphere.io/kubesphere/pkg/utils/metrics"
"kubesphere.io/kubesphere/pkg/utils/term"
"kubesphere.io/kubesphere/pkg/version"
)
func NewControllerManagerCommand() *cobra.Command {
@@ -112,6 +113,17 @@ func NewControllerManagerCommand() *cobra.Command {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine())
cliflag.PrintSections(cmd.OutOrStdout(), namedFlagSets, cols)
})
versionCmd := &cobra.Command{
Use: "version",
Short: "Print the version of KubeSphere ks-apiserver",
Run: func(cmd *cobra.Command, args []string) {
cmd.Println(version.Get())
},
}
cmd.AddCommand(versionCmd)
return cmd
}

View File

@@ -79,7 +79,7 @@ cluster's shared state through which all other components interact.`,
Use: "version",
Short: "Print the version of KubeSphere ks-apiserver",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Get())
cmd.Println(version.Get())
},
}