Merge pull request #3687 from zryfish/add_version_sub_command
add version sub command
This commit is contained in:
@@ -57,6 +57,7 @@ import (
|
|||||||
"kubesphere.io/kubesphere/pkg/simple/client/s3"
|
"kubesphere.io/kubesphere/pkg/simple/client/s3"
|
||||||
"kubesphere.io/kubesphere/pkg/utils/metrics"
|
"kubesphere.io/kubesphere/pkg/utils/metrics"
|
||||||
"kubesphere.io/kubesphere/pkg/utils/term"
|
"kubesphere.io/kubesphere/pkg/utils/term"
|
||||||
|
"kubesphere.io/kubesphere/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewControllerManagerCommand() *cobra.Command {
|
func NewControllerManagerCommand() *cobra.Command {
|
||||||
@@ -112,6 +113,17 @@ func NewControllerManagerCommand() *cobra.Command {
|
|||||||
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine())
|
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine())
|
||||||
cliflag.PrintSections(cmd.OutOrStdout(), namedFlagSets, cols)
|
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
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import (
|
|||||||
apiserverconfig "kubesphere.io/kubesphere/pkg/apiserver/config"
|
apiserverconfig "kubesphere.io/kubesphere/pkg/apiserver/config"
|
||||||
"kubesphere.io/kubesphere/pkg/utils/signals"
|
"kubesphere.io/kubesphere/pkg/utils/signals"
|
||||||
"kubesphere.io/kubesphere/pkg/utils/term"
|
"kubesphere.io/kubesphere/pkg/utils/term"
|
||||||
|
"kubesphere.io/kubesphere/pkg/version"
|
||||||
|
|
||||||
tracing "kubesphere.io/kubesphere/pkg/kapis/servicemesh/metrics/v1alpha2"
|
tracing "kubesphere.io/kubesphere/pkg/kapis/servicemesh/metrics/v1alpha2"
|
||||||
)
|
)
|
||||||
@@ -73,6 +74,17 @@ cluster's shared state through which all other components interact.`,
|
|||||||
fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine())
|
fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine())
|
||||||
cliflag.PrintSections(cmd.OutOrStdout(), namedFlagSets, cols)
|
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
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
@@ -45,6 +46,11 @@ type Info struct {
|
|||||||
Kubernetes *apimachineryversion.Info `json:"kubernetes,omitempty"`
|
Kubernetes *apimachineryversion.Info `json:"kubernetes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (info Info) String() string {
|
||||||
|
jsonString, _ := json.Marshal(info)
|
||||||
|
return string(jsonString)
|
||||||
|
}
|
||||||
|
|
||||||
// Get returns the overall codebase version. It's for
|
// Get returns the overall codebase version. It's for
|
||||||
// detecting what code a binary was built from.
|
// detecting what code a binary was built from.
|
||||||
func Get() Info {
|
func Get() Info {
|
||||||
@@ -52,7 +58,8 @@ func Get() Info {
|
|||||||
// in their absence fallback to the default settings
|
// in their absence fallback to the default settings
|
||||||
return Info{
|
return Info{
|
||||||
GitVersion: gitVersion,
|
GitVersion: gitVersion,
|
||||||
|
GitMajor: gitMajor,
|
||||||
|
GitMinor: gitMinor,
|
||||||
GitCommit: gitCommit,
|
GitCommit: gitCommit,
|
||||||
GitTreeState: gitTreeState,
|
GitTreeState: gitTreeState,
|
||||||
BuildDate: buildDate,
|
BuildDate: buildDate,
|
||||||
|
|||||||
Reference in New Issue
Block a user