From 81ad21d908b5fd20a44963263a9e80f00a5cc44d Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Tue, 22 Oct 2019 13:51:19 -0700 Subject: [PATCH 1/3] SaveAsTemplate action on cluster --- apis/management.cattle.io/v3/cluster_types.go | 6 ++++++ apis/management.cattle.io/v3/schema/schema.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/apis/management.cattle.io/v3/cluster_types.go b/apis/management.cattle.io/v3/cluster_types.go index 765e56db..f1574914 100644 --- a/apis/management.cattle.io/v3/cluster_types.go +++ b/apis/management.cattle.io/v3/cluster_types.go @@ -31,6 +31,7 @@ const ( ClusterActionRestoreFromEtcdBackup = "restoreFromEtcdBackup" ClusterActionRotateCertificates = "rotateCertificates" ClusterActionRunCISScan = "runSecurityScan" + ClusterActionSaveAsTemplate = "saveAsTemplate" // ClusterConditionReady Cluster ready to serve API (healthy when true, unhealthy when false) ClusterConditionReady condition.Cond = "Ready" @@ -289,3 +290,8 @@ type LocalClusterAuthEndpoint struct { type CertExpiration struct { ExpirationDate string `json:"expirationDate,omitempty"` } + +type SaveAsTemplateInput struct { + ClusterTemplateName string `json:"clusterTemplateName,omitempty"` + ClusterTemplateRevisionName string `json:"clusterTemplateRevisionName,omitempty"` +} diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index 5c549990..a4da5dae 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -215,6 +215,7 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas { MustImport(&Version, v3.MonitoringInput{}). MustImport(&Version, v3.MonitoringOutput{}). MustImport(&Version, v3.RestoreFromEtcdBackupInput{}). + MustImport(&Version, v3.SaveAsTemplateInput{}). MustImportAndCustomize(&Version, v3.ETCDService{}, func(schema *types.Schema) { schema.MustCustomizeField("extraArgs", func(field types.Field) types.Field { field.Default = map[string]interface{}{ @@ -259,6 +260,9 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas { Output: "rotateCertificateOutput", } schema.ResourceActions[v3.ClusterActionRunCISScan] = types.Action{} + schema.ResourceActions[v3.ClusterActionSaveAsTemplate] = types.Action{ + Input: "saveAsTemplateInput", + } }) } From 17b36cc9296687e0ff5ce469b69ab48c75f26962 Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Tue, 22 Oct 2019 13:51:31 -0700 Subject: [PATCH 2/3] Generated changes --- .../v3/zz_generated_deepcopy.go | 16 ++++++++++++++++ client/management/v3/zz_generated_cluster.go | 7 +++++++ .../v3/zz_generated_save_as_template_input.go | 12 ++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 client/management/v3/zz_generated_save_as_template_input.go diff --git a/apis/management.cattle.io/v3/zz_generated_deepcopy.go b/apis/management.cattle.io/v3/zz_generated_deepcopy.go index 92b20c3d..00f8f524 100644 --- a/apis/management.cattle.io/v3/zz_generated_deepcopy.go +++ b/apis/management.cattle.io/v3/zz_generated_deepcopy.go @@ -8479,6 +8479,22 @@ func (in *SamlConfigTestOutput) DeepCopy() *SamlConfigTestOutput { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SaveAsTemplateInput) DeepCopyInto(out *SaveAsTemplateInput) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SaveAsTemplateInput. +func (in *SaveAsTemplateInput) DeepCopy() *SaveAsTemplateInput { + if in == nil { + return nil + } + out := new(SaveAsTemplateInput) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SchedulerService) DeepCopyInto(out *SchedulerService) { *out = *in diff --git a/client/management/v3/zz_generated_cluster.go b/client/management/v3/zz_generated_cluster.go index 0e570320..b479561a 100644 --- a/client/management/v3/zz_generated_cluster.go +++ b/client/management/v3/zz_generated_cluster.go @@ -148,6 +148,8 @@ type ClusterOperations interface { ActionRunSecurityScan(resource *Cluster) error + ActionSaveAsTemplate(resource *Cluster, input *SaveAsTemplateInput) error + ActionViewMonitoring(resource *Cluster) (*MonitoringOutput, error) } @@ -256,6 +258,11 @@ func (c *ClusterClient) ActionRunSecurityScan(resource *Cluster) error { return err } +func (c *ClusterClient) ActionSaveAsTemplate(resource *Cluster, input *SaveAsTemplateInput) error { + err := c.apiClient.Ops.DoAction(ClusterType, "saveAsTemplate", &resource.Resource, input, nil) + return err +} + func (c *ClusterClient) ActionViewMonitoring(resource *Cluster) (*MonitoringOutput, error) { resp := &MonitoringOutput{} err := c.apiClient.Ops.DoAction(ClusterType, "viewMonitoring", &resource.Resource, nil, resp) diff --git a/client/management/v3/zz_generated_save_as_template_input.go b/client/management/v3/zz_generated_save_as_template_input.go new file mode 100644 index 00000000..b756e4fe --- /dev/null +++ b/client/management/v3/zz_generated_save_as_template_input.go @@ -0,0 +1,12 @@ +package client + +const ( + SaveAsTemplateInputType = "saveAsTemplateInput" + SaveAsTemplateInputFieldClusterTemplateName = "clusterTemplateName" + SaveAsTemplateInputFieldClusterTemplateRevisionName = "clusterTemplateRevisionName" +) + +type SaveAsTemplateInput struct { + ClusterTemplateName string `json:"clusterTemplateName,omitempty" yaml:"clusterTemplateName,omitempty"` + ClusterTemplateRevisionName string `json:"clusterTemplateRevisionName,omitempty" yaml:"clusterTemplateRevisionName,omitempty"` +} From cfefaef495d96489995d2090b508bcb6a7a80f70 Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Tue, 5 Nov 2019 12:06:48 -0800 Subject: [PATCH 3/3] Vendor update --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 69799643..0245c853 100644 --- a/go.sum +++ b/go.sum @@ -678,8 +678,6 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190926165942-a8d5d34286bd h1:L7bTtbmMojUZYEAt0OrTU0Z/KmN+uX195615ty32gkA= -golang.org/x/tools v0.0.0-20190926165942-a8d5d34286bd/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c h1:IGkKhmfzcztjm6gYkykvu/NiS8kaqbCWAEWWAyf8J5U= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=