Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: manage_storage_classes should be nullable (cherry-pick #1050) #1051

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br />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<br />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
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br />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<br />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
Expand Down
8 changes: 6 additions & 2 deletions hack/gen-tf-code/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}),
Expand Down Expand Up @@ -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"),
Expand Down
37 changes: 21 additions & 16 deletions pkg/schemas/kops/DataSource_CloudConfiguration.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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 {
Expand Down Expand Up @@ -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{} {
Expand Down
37 changes: 21 additions & 16 deletions pkg/schemas/kops/Resource_CloudConfiguration.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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 {
Expand Down Expand Up @@ -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{} {
Expand Down
Loading