Skip to content

Commit

Permalink
The version field should be under configmanagement instead of under o…
Browse files Browse the repository at this point in the history
…ci (#9587) (#16788)

* Adding Terraform resources for Tenancy APIs in GKEHub

* Segregating MembershipBinding and MembershipRBACRoleBinding to keep things simpler in the review

* Fixing the docu URIs

* Adding TF support for Tenancy API for Membership Binding

* Adding dependent membership binding to the same commit chain

* Making Scope un-updatable and replacing hard coded project number with the one from test env

* Making Scope RRBAC updatable

* Making Namespace immutable

* Adding update test cases

* Removing all memberships field from Scope since it is no longer supported

* Removing all_memberships field for Scope from all test cases

* Making naming in examples consistent across Tenancy APIs documentation

* Update mmv1/templates/terraform/examples/gkehub_membership_binding_basic.tf.erb



* Update mmv1/templates/terraform/examples/gkehub_membership_binding_basic.tf.erb



* Update mmv1/templates/terraform/examples/gkehub_membership_rbac_role_binding_basic.tf.erb



* Fixing typo in the resource name

* Adding state migrations for Membership

* Updating the feature_membership documentation with the current resource state. Adding membership_location field to the doc

* Fixing the version field to be directly under configmanagement instead of under the oci field

* Adding tests for the field version

* Changing version fields value to test upgradation

---------


[upstream:de7d39b50c5d9894e25770a457eb9ab2c2f96eaf]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Dec 12, 2023
1 parent bb1e863 commit b239600
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .changelog/9587.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
gkehub: added field `version` under `configmanagement` instead of a child field `oci` in `google_gke_hub_feature` resource
```
44 changes: 22 additions & 22 deletions google/services/gkehub2/resource_gke_hub_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ func ResourceGKEHub2Feature() *schema.Resource {
Optional: true,
Description: `Period in seconds between consecutive syncs. Default: 15`,
},
"version": {
Type: schema.TypeString,
Optional: true,
Description: `Version of ACM installed`,
},
},
},
},
Expand All @@ -180,6 +175,11 @@ func ResourceGKEHub2Feature() *schema.Resource {
},
},
},
"version": {
Type: schema.TypeString,
Optional: true,
Description: `Version of ACM installed`,
},
},
},
},
Expand Down Expand Up @@ -1142,10 +1142,16 @@ func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagement(v interface{}
return nil
}
transformed := make(map[string]interface{})
transformed["version"] =
flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementVersion(original["version"], d, config)
transformed["config_sync"] =
flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSync(original["configSync"], d, config)
return []interface{}{transformed}
}
func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSync(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -1245,8 +1251,6 @@ func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOci(
flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciGcpServiceAccountEmail(original["gcpServiceAccountEmail"], d, config)
transformed["sync_wait_secs"] =
flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciSyncWaitSecs(original["syncWaitSecs"], d, config)
transformed["version"] =
flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciVersion(original["version"], d, config)
return []interface{}{transformed}
}
func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciSyncRepo(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
Expand All @@ -1269,10 +1273,6 @@ func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciS
return v
}

func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenGKEHub2FeatureFleetDefaultMemberConfigPolicycontroller(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -1860,6 +1860,13 @@ func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagement(v interface{},
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedVersion, err := expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementVersion(original["version"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["version"] = transformedVersion
}

transformedConfigSync, err := expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSync(original["config_sync"], d, config)
if err != nil {
return nil, err
Expand All @@ -1870,6 +1877,10 @@ func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagement(v interface{},
return transformed, nil
}

func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSync(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down Expand Up @@ -2051,13 +2062,6 @@ func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOci(v
transformed["syncWaitSecs"] = transformedSyncWaitSecs
}

transformedVersion, err := expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciVersion(original["version"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["version"] = transformedVersion
}

return transformed, nil
}

Expand All @@ -2081,10 +2085,6 @@ func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciSy
return v, nil
}

func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncOciVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandGKEHub2FeatureFleetDefaultMemberConfigPolicycontroller(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
2 changes: 2 additions & 0 deletions google/services/gkehub2/resource_gke_hub_feature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ resource "google_gke_hub_feature" "feature" {
location = "global"
fleet_default_member_config {
configmanagement {
version = "1.16.0"
config_sync {
source_format = "hierarchy"
git {
Expand All @@ -428,6 +429,7 @@ resource "google_gke_hub_feature" "feature" {
location = "global"
fleet_default_member_config {
configmanagement {
version = "1.16.1"
config_sync {
source_format = "unstructured"
oci {
Expand Down
8 changes: 4 additions & 4 deletions website/docs/r/gke_hub_feature.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ The following arguments are supported:

<a name="nested_configmanagement"></a>The `configmanagement` block supports:

* `version` -
(Optional)
Version of ACM installed

* `config_sync` -
(Optional)
ConfigSync configuration for the cluster
Expand Down Expand Up @@ -481,10 +485,6 @@ The following arguments are supported:
(Optional)
Period in seconds between consecutive syncs. Default: 15

* `version` -
(Optional)
Version of ACM installed

<a name="nested_policycontroller"></a>The `policycontroller` block supports:

* `version` -
Expand Down

0 comments on commit b239600

Please sign in to comment.