From c42360a8b775b7e3c81965796d4250dfe830baaa Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Sat, 13 Oct 2018 18:05:27 +0800 Subject: [PATCH] climc: k8s v1.12 option support --- cmd/climc/shell/disks.go | 16 +++++++++++----- pkg/mcclient/options/k8s/cluster.go | 10 +++++++--- pkg/mcclient/options/k8s/tiller.go | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/cmd/climc/shell/disks.go b/cmd/climc/shell/disks.go index 716d557c08..4d5ccbde7d 100644 --- a/cmd/climc/shell/disks.go +++ b/cmd/climc/shell/disks.go @@ -74,12 +74,18 @@ func init() { return nil }) - R(&DiskDetailOptions{}, "disk-delete", "Delete a disk", func(s *mcclient.ClientSession, args *DiskDetailOptions) error { - disk, e := modules.Disks.Delete(s, args.ID, nil) - if e != nil { - return e + type DiskDeleteOptions struct { + ID []string `help:"ID of disks to delete" metavar:"DISK"` + OverridePendingDelete bool `help:"Delete disk directly instead of pending delete"` + } + + R(&DiskDeleteOptions{}, "disk-delete", "Delete a disk", func(s *mcclient.ClientSession, args *DiskDeleteOptions) error { + params := jsonutils.NewDict() + if args.OverridePendingDelete { + params.Add(jsonutils.JSONTrue, "override_pending_delete") } - printObject(disk) + ret := modules.Disks.BatchDeleteWithParam(s, args.ID, params, nil) + printBatchResults(ret, modules.Disks.GetColumns(s)) return nil }) diff --git a/pkg/mcclient/options/k8s/cluster.go b/pkg/mcclient/options/k8s/cluster.go index 18e47522f0..b26974cc58 100644 --- a/pkg/mcclient/options/k8s/cluster.go +++ b/pkg/mcclient/options/k8s/cluster.go @@ -24,10 +24,14 @@ func (o ClusterListOptions) Params() *jsonutils.JSONDict { return params } +type K8sSupportVersion struct { + K8sVersion string `help:"Cluster kubernetes components version" choices:"v1.10.5|v1.11.3|v1.12.0"` +} + type ClusterCreateOptions struct { + K8sSupportVersion NAME string `help:"Name of cluster"` Mode string `help:"Cluster mode" choices:"internal"` - K8sVersion string `help:"Cluster kubernetes components version" choices:"v1.8.10|v1.9.5|v1.10.0"` InfraImage string `help:"Cluster kubelet infra container image"` Cidr string `help:"Cluster service CIDR, e.g. 10.43.0.0/16"` Domain string `help:"Cluster pod domain, e.g. cluster.local"` @@ -70,8 +74,8 @@ func (o ClusterImportOptions) Params() (*jsonutils.JSONDict, error) { } type ClusterUpdateOptions struct { - NAME string `help:"Name of cluster"` - K8sVersion string `help:"Cluster kubernetes components version" choices:"v1.8.10|v1.9.5|v1.10.0"` + NAME string `help:"Name of cluster"` + K8sSupportVersion } func (o ClusterUpdateOptions) Params() *jsonutils.JSONDict { diff --git a/pkg/mcclient/options/k8s/tiller.go b/pkg/mcclient/options/k8s/tiller.go index a1a6a64552..4af8fbbb24 100644 --- a/pkg/mcclient/options/k8s/tiller.go +++ b/pkg/mcclient/options/k8s/tiller.go @@ -16,7 +16,7 @@ type TillerCreateOptions struct { Canary bool `json:"canary_image"` // Override Tiller image - Image string `json:"tiller_image" default:"yunion/tiller:v2.9.0"` + Image string `json:"tiller_image" default:"yunion/tiller:v2.9.1"` // Limit the maximum number of revisions saved per release. Use 0 for no limit. MaxHistory int `json:"history_max"` }