Skip to content

Commit bdd4b3b

Browse files
updated DCL version to 1.9.0 for including changes in gkehub-configma… (#6090) (#4370)
* update DCL version to 1.9.0 for including changes for gkehub-configmanagement-configsync * added tests and doc changes for gkehub-featuremembership-configsync * cleaned go checksum * added dcl hash in go.sum * updated dcl version to 1.10 as there are errors with cloud deploy that is not related to this PR * resolved merge conflicts with origin * added skip vcr failure for "AddOns" and "ConfidentialNodes" * reverted skipvcr changes to "Addons" and "ConfidentialNodes" test cases Co-authored-by: Indu <[email protected]> Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Indu <[email protected]>
1 parent 136f672 commit bdd4b3b

File tree

8 files changed

+101
-8
lines changed

8 files changed

+101
-8
lines changed

.changelog/6090.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
google_gke_hub_feature_membership: Changes to add `prevent_drift` field to `google_gke_hub_feature_membership:configmanagement:config_sync` resource (beta)
3+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/hashicorp/terraform-provider-google-beta
22
require (
33
cloud.google.com/go/bigtable v1.13.0
4-
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.8.2
4+
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.10.0
55
github.com/apparentlymart/go-cidr v1.1.0
66
github.com/client9/misspell v0.3.4
77
github.com/davecgh/go-spew v1.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
7373
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
7474
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM=
7575
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
76-
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.8.2 h1:V2EzqYSMPUkyKTtSevKTFU0Dw7nK6uVpg40U31Y0x/8=
77-
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.8.2/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
76+
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.10.0 h1:zw07xH8x3MxhIG9dvof0FtIyr0iV3Wr7xCpGYMlgygU=
77+
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.10.0/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
7878
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
7979
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
8080
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=

google-beta/resource_gke_hub_feature_membership.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ func GkeHubFeatureMembershipConfigmanagementConfigSyncSchema() *schema.Resource
156156
Elem: GkeHubFeatureMembershipConfigmanagementConfigSyncGitSchema(),
157157
},
158158

159+
"prevent_drift": {
160+
Type: schema.TypeBool,
161+
Computed: true,
162+
Optional: true,
163+
Description: "Set to true to enable the Config Sync admission webhook to prevent drifts. If set to `false`, disables the Config Sync admission webhook and does not prevent drifts.",
164+
},
165+
159166
"source_format": {
160167
Type: schema.TypeString,
161168
Optional: true,
@@ -592,6 +599,7 @@ func expandGkeHubFeatureMembershipConfigmanagementConfigSync(o interface{}) *gke
592599
obj := objArr[0].(map[string]interface{})
593600
return &gkehub.FeatureMembershipConfigmanagementConfigSync{
594601
Git: expandGkeHubFeatureMembershipConfigmanagementConfigSyncGit(obj["git"]),
602+
PreventDrift: dcl.Bool(obj["prevent_drift"].(bool)),
595603
SourceFormat: dcl.String(obj["source_format"].(string)),
596604
}
597605
}
@@ -602,6 +610,7 @@ func flattenGkeHubFeatureMembershipConfigmanagementConfigSync(obj *gkehub.Featur
602610
}
603611
transformed := map[string]interface{}{
604612
"git": flattenGkeHubFeatureMembershipConfigmanagementConfigSyncGit(obj.Git),
613+
"prevent_drift": obj.PreventDrift,
605614
"source_format": obj.SourceFormat,
606615
}
607616

google-beta/resource_gke_hub_feature_membership_test.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,17 @@ func TestAccGkeHubFeatureMembership_gkehubFeatureAcmAllFields(t *testing.T) {
341341
ImportState: true,
342342
ImportStateVerify: true,
343343
},
344+
{
345+
Config: testAccGkeHubFeatureMembership_gkehubFeatureWithPreventDriftField(context),
346+
Check: resource.ComposeTestCheckFunc(
347+
testAccCheckGkeHubFeatureMembershipPresent(t, fmt.Sprintf("tf-test-gkehub%s", context["random_suffix"]), "global", "configmanagement", fmt.Sprintf("tf-test1%s", context["random_suffix"])),
348+
),
349+
},
350+
{
351+
ResourceName: "google_gke_hub_feature_membership.feature_member",
352+
ImportState: true,
353+
ImportStateVerify: true,
354+
},
344355
},
345356
})
346357
}
@@ -411,6 +422,73 @@ resource "google_gke_hub_feature_membership" "feature_member" {
411422
`, context)
412423
}
413424

425+
func testAccGkeHubFeatureMembership_gkehubFeatureWithPreventDriftField(context map[string]interface{}) string {
426+
return gkeHubFeatureProjectSetup(context) + Nprintf(`
427+
resource "google_container_cluster" "primary" {
428+
project = google_project.project.project_id
429+
name = "tf-test-cl%{random_suffix}"
430+
location = "us-central1-a"
431+
initial_node_count = 1
432+
provider = google-beta
433+
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
434+
}
435+
436+
resource "google_gke_hub_membership" "membership" {
437+
project = google_project.project.project_id
438+
membership_id = "tf-test1%{random_suffix}"
439+
endpoint {
440+
gke_cluster {
441+
resource_link = "//container.googleapis.com/${google_container_cluster.primary.id}"
442+
}
443+
}
444+
description = "test resource."
445+
provider = google-beta
446+
}
447+
448+
resource "google_gke_hub_feature" "feature" {
449+
project = google_project.project.project_id
450+
name = "configmanagement"
451+
location = "global"
452+
453+
labels = {
454+
foo = "bar"
455+
}
456+
provider = google-beta
457+
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
458+
}
459+
460+
resource "google_gke_hub_feature_membership" "feature_member" {
461+
project = google_project.project.project_id
462+
location = "global"
463+
feature = google_gke_hub_feature.feature.name
464+
membership = google_gke_hub_membership.membership.membership_id
465+
configmanagement {
466+
version = "1.10.1"
467+
config_sync {
468+
git {
469+
sync_repo = "https://github.com/hashicorp/terraform"
470+
https_proxy = "https://example.com"
471+
policy_dir = "google/"
472+
sync_branch = "some-branch"
473+
sync_rev = "v3.60.0"
474+
sync_wait_secs = "30"
475+
}
476+
prevent_drift = true
477+
}
478+
policy_controller {
479+
enabled = true
480+
audit_interval_seconds = "100"
481+
exemptable_namespaces = ["onetwothree", "fourfive"]
482+
template_library_installed = true
483+
referential_rules_enabled = true
484+
log_denies_enabled = true
485+
}
486+
}
487+
provider = google-beta
488+
}
489+
`, context)
490+
}
491+
414492
func testAccGkeHubFeatureMembership_gkehubFeatureAcmFewFields(context map[string]interface{}) string {
415493
return gkeHubFeatureProjectSetup(context) + Nprintf(`
416494
resource "google_container_cluster" "primary" {

website/docs/r/clouddeploy_delivery_pipeline.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ layout: "google"
1818
page_title: "Google: google_clouddeploy_delivery_pipeline"
1919
sidebar_current: "docs-google-clouddeploy-delivery-pipeline"
2020
description: |-
21-
The Clouddeploy DeliveryPipeline resource
21+
The Cloud Deploy `DeliveryPipeline` resource
2222
---
2323

2424
# google_clouddeploy_delivery_pipeline
2525

26-
The Clouddeploy DeliveryPipeline resource
26+
The Cloud Deploy `DeliveryPipeline` resource
2727

2828
## Example Usage - delivery_pipeline
2929
Creates a basic Cloud Deploy delivery pipeline

website/docs/r/clouddeploy_target.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ layout: "google"
1818
page_title: "Google: google_clouddeploy_target"
1919
sidebar_current: "docs-google-clouddeploy-target"
2020
description: |-
21-
The Clouddeploy Target resource
21+
The Cloud Deploy `Target` resource
2222
---
2323

2424
# google_clouddeploy_target
2525

26-
The Clouddeploy Target resource
26+
The Cloud Deploy `Target` resource
2727

2828
## Example Usage - target
2929
Creates a basic Cloud Deploy target

website/docs/r/gke_hub_feature_membership.html.markdown

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ The following arguments are supported:
134134

135135
* `git` -
136136
(Optional) Structure is [documented below](#nested_git).
137-
137+
138+
* `prevent_drift` -
139+
(Optional)
140+
Supported from ACM versions 1.10.0 onwards. Set to true to enable the Config Sync admission webhook to prevent drifts. If set to "false", disables the Config Sync admission webhook and does not prevent drifts.
138141

139142
* `source_format` -
140143
(Optional)

0 commit comments

Comments
 (0)