mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(climc): k8s-cluster-set-kubeconfig
This commit is contained in:
@@ -87,6 +87,26 @@ func initKubeCluster() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type SetKubeconfigOptions struct {
|
||||
o.IdentOptions
|
||||
FILE string `json:"filepath of kubeconfig"`
|
||||
}
|
||||
R(new(SetKubeconfigOptions), cmdN("set-kubeconfig"), "Set kubeconfig of a cluster", func(s *mcclient.ClientSession, args *SetKubeconfigOptions) error {
|
||||
content, err := ioutil.ReadFile(args.FILE)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "read file content of %q", args.FILE)
|
||||
}
|
||||
input := map[string]string{
|
||||
"kubeconfig": string(content),
|
||||
}
|
||||
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "set-kubeconfig", jsonutils.Marshal(input))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.ClusterGetAddonsOpt{}, cmdN("addons"), "Get addon manifest of a cluster", func(s *mcclient.ClientSession, args *o.ClusterGetAddonsOpt) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user