代码拉取完成,页面将自动刷新
package cmd
import (
"fmt"
"github.com/rancher/kontainer-engine/store"
"github.com/rancher/kontainer-engine/utils"
"github.com/urfave/cli"
)
// EnvCommand defines the env command
func EnvCommand() cli.Command {
return cli.Command{
Name: "env",
Usage: "Set cluster as current context",
Action: env,
}
}
func env(ctx *cli.Context) error {
name := ctx.Args().Get(0)
if name == "" || name == "--help" {
return cli.ShowCommandHelp(ctx, "env")
}
clusters, err := store.GetAllClusterFromStore()
if err != nil {
return err
}
_, ok := clusters[name]
if !ok {
return fmt.Errorf("cluster %v can't be found", name)
}
config, err := getConfigFromFile()
if err != nil {
return err
}
config.CurrentContext = name
if err := setConfigToFile(config); err != nil {
return err
}
configFile := utils.KubeConfigFilePath()
fmt.Printf("Current context is set to %s\n", name)
fmt.Printf("run `export KUBECONFIG=%v` or `--kubeconfig %s` to use the config file\n", configFile, configFile)
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。