From b23960070e8eeb9230a905c4fab085152e92aeb7 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 12 Dec 2023 15:49:04 -0800 Subject: [PATCH] The version field should be under configmanagement instead of under oci (#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 --- .changelog/9587.txt | 3 ++ .../gkehub2/resource_gke_hub_feature.go | 44 +++++++++---------- .../gkehub2/resource_gke_hub_feature_test.go | 2 + website/docs/r/gke_hub_feature.html.markdown | 8 ++-- 4 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 .changelog/9587.txt diff --git a/.changelog/9587.txt b/.changelog/9587.txt new file mode 100644 index 00000000000..58a043e04a1 --- /dev/null +++ b/.changelog/9587.txt @@ -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 +``` diff --git a/google/services/gkehub2/resource_gke_hub_feature.go b/google/services/gkehub2/resource_gke_hub_feature.go index 204a1dbe319..6516b6f0611 100644 --- a/google/services/gkehub2/resource_gke_hub_feature.go +++ b/google/services/gkehub2/resource_gke_hub_feature.go @@ -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`, - }, }, }, }, @@ -180,6 +175,11 @@ func ResourceGKEHub2Feature() *schema.Resource { }, }, }, + "version": { + Type: schema.TypeString, + Optional: true, + Description: `Version of ACM installed`, + }, }, }, }, @@ -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 @@ -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{} { @@ -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 @@ -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 @@ -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 { @@ -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 } @@ -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 { diff --git a/google/services/gkehub2/resource_gke_hub_feature_test.go b/google/services/gkehub2/resource_gke_hub_feature_test.go index 44500ddfa82..803851f839a 100644 --- a/google/services/gkehub2/resource_gke_hub_feature_test.go +++ b/google/services/gkehub2/resource_gke_hub_feature_test.go @@ -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 { @@ -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 { diff --git a/website/docs/r/gke_hub_feature.html.markdown b/website/docs/r/gke_hub_feature.html.markdown index 2b42eba2d35..18a67f990a9 100644 --- a/website/docs/r/gke_hub_feature.html.markdown +++ b/website/docs/r/gke_hub_feature.html.markdown @@ -402,6 +402,10 @@ The following arguments are supported: The `configmanagement` block supports: +* `version` - + (Optional) + Version of ACM installed + * `config_sync` - (Optional) ConfigSync configuration for the cluster @@ -481,10 +485,6 @@ The following arguments are supported: (Optional) Period in seconds between consecutive syncs. Default: 15 -* `version` - - (Optional) - Version of ACM installed - The `policycontroller` block supports: * `version` -