1 Star 0 Fork 0

powerpaas/rke

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
version.go 834 Bytes
一键复制 编辑 原始数据 按行查看 历史
package cmd
import (
"fmt"
"github.com/rancher/rke/cluster"
"github.com/rancher/rke/pki"
"github.com/urfave/cli"
)
func VersionCommand() cli.Command {
versionFlags := []cli.Flag{
cli.StringFlag{
Name: "config",
Usage: "Specify an alternate cluster YAML file",
Value: pki.ClusterConfig,
EnvVar: "RKE_CONFIG",
},
}
return cli.Command{
Name: "version",
Usage: "Show cluster Kubernetes version",
Action: getClusterVersion,
Flags: versionFlags,
}
}
func getClusterVersion(ctx *cli.Context) error {
localKubeConfig := pki.GetLocalKubeConfig(ctx.String("config"), "")
// not going to use a k8s dialer here.. this is a CLI command
serverVersion, err := cluster.GetK8sVersion(localKubeConfig, nil)
if err != nil {
return err
}
fmt.Printf("Server Version: %s\n", serverVersion)
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/powerpaas/rke.git
git@gitee.com:powerpaas/rke.git
powerpaas
rke
rke
v0.3.0-rc6

搜索帮助