mirror of
https://github.com/kubescape/kubescape.git
synced 2026-02-14 09:59:54 +00:00
32 lines
804 B
Go
32 lines
804 B
Go
package version
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/kubescape/kubescape/v3/core/meta"
|
|
|
|
"github.com/kubescape/backend/pkg/versioncheck"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func GetVersionCmd(ks meta.IKubescape) *cobra.Command {
|
|
versionCmd := &cobra.Command{
|
|
Use: "version",
|
|
Short: "Get current version",
|
|
Long: ``,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
v := versioncheck.NewIVersionCheckHandler(ks.Context())
|
|
versionCheckRequest := versioncheck.NewVersionCheckRequest("", versioncheck.BuildNumber, "", "", "version", nil)
|
|
if err := v.CheckLatestVersion(ks.Context(), versionCheckRequest); err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Fprintf(cmd.OutOrStdout(),
|
|
"Your current version is: %s\n",
|
|
versionCheckRequest.ClientVersion,
|
|
)
|
|
return nil
|
|
},
|
|
}
|
|
return versionCmd
|
|
}
|