From 2f0e3fd82c17eaa5087c22938191c14cd4ecd438 Mon Sep 17 00:00:00 2001 From: Martin Kulich Date: Wed, 28 Jun 2023 09:57:22 +0000 Subject: [PATCH] Fix: manage_storage_classes should be nullable (#1050) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Charles-Edouard Brétéché --- docs/data-sources/cluster.md | 2 +- docs/resources/cluster.md | 2 +- hack/gen-tf-code/main.go | 8 +++- ...DataSource_CloudConfiguration.generated.go | 37 +++++++++++-------- .../Resource_CloudConfiguration.generated.go | 37 +++++++++++-------- 5 files changed, 50 insertions(+), 36 deletions(-) diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md index 541864a3..9561aeab 100644 --- a/docs/data-sources/cluster.md +++ b/docs/data-sources/cluster.md @@ -1134,7 +1134,7 @@ CloudConfiguration defines the cloud provider configuration. The following arguments are supported: -- `manage_storage_classes` - (Computed) - Bool - ManageStorageClasses specifies whether kOps should create and maintain a set of
StorageClasses, one of which it nominates as the default class for the cluster. +- `manage_storage_classes` - (Computed) - Bool([Nullable](#nullable-arguments)) - ManageStorageClasses specifies whether kOps should create and maintain a set of
StorageClasses, one of which it nominates as the default class for the cluster. - `multizone` - (Computed) - Bool - GCE cloud-config options. - `node_tags` - (Computed) - String - `node_instance_prefix` - (Computed) - String diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 312bc434..8199ad62 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -1220,7 +1220,7 @@ CloudConfiguration defines the cloud provider configuration. The following arguments are supported: -- `manage_storage_classes` - (Optional) - Bool - ManageStorageClasses specifies whether kOps should create and maintain a set of
StorageClasses, one of which it nominates as the default class for the cluster. +- `manage_storage_classes` - (Optional) - Bool([Nullable](#nullable-arguments)) - ManageStorageClasses specifies whether kOps should create and maintain a set of
StorageClasses, one of which it nominates as the default class for the cluster. - `multizone` - (Optional) - Bool - GCE cloud-config options. - `node_tags` - (Optional) - String - `node_instance_prefix` - (Optional) - String diff --git a/hack/gen-tf-code/main.go b/hack/gen-tf-code/main.go index bbfd6d0c..bc1156a8 100644 --- a/hack/gen-tf-code/main.go +++ b/hack/gen-tf-code/main.go @@ -174,7 +174,9 @@ func main() { generate(kops.KubeletConfigSpec{}, nullable("AnonymousAuth", "CPUCFSQuota"), ), - generate(kops.CloudConfiguration{}), + generate(kops.CloudConfiguration{}, + nullable("ManageStorageClasses"), + ), generate(kops.ExternalDNSConfig{}), generate(kops.OpenstackLoadbalancerConfig{}), generate(kops.OpenstackMonitor{}), @@ -415,7 +417,9 @@ func main() { generate(kops.CloudControllerManagerConfig{}), generate(kops.KubeSchedulerConfig{}), generate(kops.KubeProxyConfig{}), - generate(kops.CloudConfiguration{}), + generate(kops.CloudConfiguration{}, + nullable("ManageStorageClasses"), + ), generate(kops.ExternalDNSConfig{}), generate(kops.NetworkingSpec{}, rename("Subnets", "Subnet"), diff --git a/pkg/schemas/kops/DataSource_CloudConfiguration.generated.go b/pkg/schemas/kops/DataSource_CloudConfiguration.generated.go index f7bfbe1c..2502fed0 100644 --- a/pkg/schemas/kops/DataSource_CloudConfiguration.generated.go +++ b/pkg/schemas/kops/DataSource_CloudConfiguration.generated.go @@ -13,7 +13,7 @@ var _ = Schema func DataSourceCloudConfiguration() *schema.Resource { res := &schema.Resource{ Schema: map[string]*schema.Schema{ - "manage_storage_classes": ComputedBool(), + "manage_storage_classes": Nullable(ComputedBool()), "multizone": ComputedBool(), "node_tags": ComputedString(), "node_instance_prefix": ComputedString(), @@ -37,20 +37,22 @@ func ExpandDataSourceCloudConfiguration(in map[string]interface{}) kops.CloudCon if in == nil { return nil } - if reflect.DeepEqual(in, reflect.Zero(reflect.TypeOf(in)).Interface()) { - return nil + if in, ok := in.([]interface{}); ok && len(in) == 1 { + return func(in interface{}) *bool { + return func(in interface{}) *bool { + if in == nil { + return nil + } + if _, ok := in.([]interface{}); ok && len(in.([]interface{})) == 0 { + return nil + } + return func(in bool) *bool { + return &in + }(bool(ExpandBool(in))) + }(in) + }(in[0].(map[string]interface{})["value"]) } - return func(in interface{}) *bool { - if in == nil { - return nil - } - if _, ok := in.([]interface{}); ok && len(in.([]interface{})) == 0 { - return nil - } - return func(in bool) *bool { - return &in - }(bool(ExpandBool(in))) - }(in) + return nil }(in["manage_storage_classes"]), Multizone: func(in interface{}) *bool { if in == nil { @@ -202,14 +204,17 @@ func ExpandDataSourceCloudConfiguration(in map[string]interface{}) kops.CloudCon func FlattenDataSourceCloudConfigurationInto(in kops.CloudConfiguration, out map[string]interface{}) { out["manage_storage_classes"] = func(in *bool) interface{} { - return func(in *bool) interface{} { + if in == nil { + return nil + } + return []interface{}{map[string]interface{}{"value": func(in *bool) interface{} { if in == nil { return nil } return func(in bool) interface{} { return FlattenBool(bool(in)) }(*in) - }(in) + }(in)}} }(in.ManageStorageClasses) out["multizone"] = func(in *bool) interface{} { return func(in *bool) interface{} { diff --git a/pkg/schemas/kops/Resource_CloudConfiguration.generated.go b/pkg/schemas/kops/Resource_CloudConfiguration.generated.go index 87c42899..082b8afb 100644 --- a/pkg/schemas/kops/Resource_CloudConfiguration.generated.go +++ b/pkg/schemas/kops/Resource_CloudConfiguration.generated.go @@ -13,7 +13,7 @@ var _ = Schema func ResourceCloudConfiguration() *schema.Resource { res := &schema.Resource{ Schema: map[string]*schema.Schema{ - "manage_storage_classes": OptionalBool(), + "manage_storage_classes": Nullable(OptionalBool()), "multizone": OptionalBool(), "node_tags": OptionalString(), "node_instance_prefix": OptionalString(), @@ -37,20 +37,22 @@ func ExpandResourceCloudConfiguration(in map[string]interface{}) kops.CloudConfi if in == nil { return nil } - if reflect.DeepEqual(in, reflect.Zero(reflect.TypeOf(in)).Interface()) { - return nil + if in, ok := in.([]interface{}); ok && len(in) == 1 { + return func(in interface{}) *bool { + return func(in interface{}) *bool { + if in == nil { + return nil + } + if _, ok := in.([]interface{}); ok && len(in.([]interface{})) == 0 { + return nil + } + return func(in bool) *bool { + return &in + }(bool(ExpandBool(in))) + }(in) + }(in[0].(map[string]interface{})["value"]) } - return func(in interface{}) *bool { - if in == nil { - return nil - } - if _, ok := in.([]interface{}); ok && len(in.([]interface{})) == 0 { - return nil - } - return func(in bool) *bool { - return &in - }(bool(ExpandBool(in))) - }(in) + return nil }(in["manage_storage_classes"]), Multizone: func(in interface{}) *bool { if in == nil { @@ -202,14 +204,17 @@ func ExpandResourceCloudConfiguration(in map[string]interface{}) kops.CloudConfi func FlattenResourceCloudConfigurationInto(in kops.CloudConfiguration, out map[string]interface{}) { out["manage_storage_classes"] = func(in *bool) interface{} { - return func(in *bool) interface{} { + if in == nil { + return nil + } + return []interface{}{map[string]interface{}{"value": func(in *bool) interface{} { if in == nil { return nil } return func(in bool) interface{} { return FlattenBool(bool(in)) }(*in) - }(in) + }(in)}} }(in.ManageStorageClasses) out["multizone"] = func(in *bool) interface{} { return func(in *bool) interface{} {