From d0f7911c80ff22c17d2a71d9d3c4d39f7dec4ca7 Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Fri, 9 Sep 2022 23:04:50 +0000 Subject: [PATCH 01/10] feat: adding google channel config --- ...eventarc_google_channel_config_test.go.erb | 164 ++++++++++++++++++ tpgtools/api/eventarc/samples/copy.py | 24 +++ .../eventarc/beta/google_channel_config.yaml | 0 .../samples/googlechannelconfig/basic.tf.tmpl | 31 ++++ .../samples/googlechannelconfig/basic.yaml | 11 ++ .../samples/googlechannelconfig/meta.yaml | 5 + 6 files changed, 235 insertions(+) create mode 100644 mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb create mode 100644 tpgtools/api/eventarc/samples/copy.py create mode 100644 tpgtools/overrides/eventarc/beta/google_channel_config.yaml create mode 100644 tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.tf.tmpl create mode 100644 tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.yaml create mode 100644 tpgtools/overrides/eventarc/samples/googlechannelconfig/meta.yaml diff --git a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb new file mode 100644 index 000000000000..3ab37518b1a2 --- /dev/null +++ b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb @@ -0,0 +1,164 @@ +<% autogen_exception -%> +package google + +import ( + "context" + "fmt" + "strings" + "testing" + + dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + <% if version == "ga" -%> + eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc" + <% else -%> + eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc/beta" + <% end %> + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccEventarcGoogleChannelConfig_BasicHandWritten(t *testing.T) { + t.Parallel() + + region := getTestRegionFromEnv() + key1 := BootstrapKMSKeyWithPurposeInLocationAndName(t, "ENCRYPT_DECRYPT", region, "tf-bootstrap-key1") + key2 := BootstrapKMSKeyWithPurposeInLocationAndName(t, "ENCRYPT_DECRYPT", region, "tf-bootstrap-key2") + + context := map[string]interface{}{ + "project_name": getTestProjectFromEnv(), + "region": getTestRegionFromEnv(), + "random_suffix": randString(t, 10), + "key_ring": GetResourceNameFromSelfLink(key1.KeyRing.Name), + "key1": GetResourceNameFromSelfLink(key1.CryptoKey.Name), + "key2": GetResourceNameFromSelfLink(key2.CryptoKey.Name), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckEventarcGoogleChannelConfigDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccEventarcGoogleChannelConfig_HandWritten(context), + }, + { + ResourceName: "google_eventarc_google_channel_config.primary", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccEventarcGoogleChannelConfig_BasicHandWrittenUpdate0(context), + }, + { + ResourceName: "google_eventarc_google_channel_config.primary", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccEventarcGoogleChannelConfig_HandWritten(context map[string]interface{}) string { + return Nprintf(` +data "google_project" "test_project" { + project_id = "%{project_name}" +} + +data "google_kms_key_ring" "test_key_ring" { + name = "%{key_ring}" + location = "us-central1" +} + +data "google_kms_crypto_key" "key1" { + name = "%{key2}" + key_ring = data.google_kms_key_ring.test_key_ring.id +} + +resource "google_kms_crypto_key_iam_binding" "key1_binding" { + crypto_key_id = data.google_kms_crypto_key.key1.id + role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" + + members = [ + "serviceAccount:service-${data.google_project.test_project.number}@gcp-sa-eventarc.iam.gserviceaccount.com", + ] +} + +resource "google_eventarc_google_channel_config" "primary" { + location = "%{region}" + name = "projects/%{project_name}/locations/%{region}/googleChannelConfig" + project = "%{project_name}" + crypto_key_name = "${data.google_kms_crypto_key.key1.id}" + depends_on =[google_kms_crypto_key_iam_binding.key1_binding] +} + `, context) +} + +func testAccEventarcGoogleChannelConfig_BasicHandWrittenUpdate0(context map[string]interface{}) string { + return Nprintf(` +data "google_project" "test_project" { + project_id = "%{project_name}" +} + +data "google_kms_key_ring" "test_key_ring" { + name = "%{key_ring}" + location = "us-central1" +} + +data "google_kms_crypto_key" "key2" { + name = "%{key2}" + key_ring = data.google_kms_key_ring.test_key_ring.id +} + +resource "google_kms_crypto_key_iam_binding" "key2_binding" { + crypto_key_id = data.google_kms_crypto_key.key2.id + role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" + + members = [ + "serviceAccount:service-${data.google_project.test_project.number}@gcp-sa-eventarc.iam.gserviceaccount.com", + ] +} + +resource "google_eventarc_google_channel_config" "primary" { + location = "%{region}" + name = "projects/%{project_name}/locations/%{region}/googleChannelConfig" + project = "%{project_name}" + crypto_key_name = "${data.google_kms_crypto_key.key2.id}" + depends_on =[google_kms_crypto_key_iam_binding.key2_binding] +} + `, context) +} + +func testAccCheckEventarcGoogleChannelConfigDestroyProducer(t *testing.T) func(s *terraform.State) error { + return func(s *terraform.State) error { + for name, rs := range s.RootModule().Resources { + if rs.Type != "rs.google_eventarc_google_channel_config" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + config := googleProviderConfig(t) + + billingProject := "" + if config.BillingProject != "" { + billingProject = config.BillingProject + } + + obj := &eventarc.GoogleChannelConfig{ + Location: dcl.String(rs.Primary.Attributes["location"]), + Name: dcl.String(rs.Primary.Attributes["name"]), + CryptoKeyName: dcl.String(rs.Primary.Attributes["crypto_key_name"]), + Project: dcl.StringOrNil(rs.Primary.Attributes["project"]), + UpdateTime: dcl.StringOrNil(rs.Primary.Attributes["update_time"]), + } + + client := NewDCLEventarcClient(config, config.userAgent, billingProject, 0) + _, err := client.GetGoogleChannelConfig(context.Background(), obj) + if err == nil { + return fmt.Errorf("google_eventarc_google_channel_config still exists %v", obj) + } + } + return nil + } +} \ No newline at end of file diff --git a/tpgtools/api/eventarc/samples/copy.py b/tpgtools/api/eventarc/samples/copy.py new file mode 100644 index 000000000000..81675fa01b4e --- /dev/null +++ b/tpgtools/api/eventarc/samples/copy.py @@ -0,0 +1,24 @@ +import os +import shutil +import sys +import yaml + + +def main(): + file_name = sys.argv[1] + shutil.copy(file_name, os.getcwd()) + samples_dir = os.path.split(file_name)[0] + sample = yaml.safe_load(open(file_name)) + print(yaml.dump(sample)) + all_deps = [sample['resource']] + updates = sample.get('updates') + if updates: + all_deps.append(updates[0]['resource']) + all_deps += sample.get('dependencies', []) + for dep in all_deps: + dep_file_name = f'{samples_dir}/{os.path.split(dep)[1]}' + shutil.copy(dep_file_name, os.getcwd()) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/tpgtools/overrides/eventarc/beta/google_channel_config.yaml b/tpgtools/overrides/eventarc/beta/google_channel_config.yaml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.tf.tmpl b/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.tf.tmpl new file mode 100644 index 000000000000..1f0279581764 --- /dev/null +++ b/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.tf.tmpl @@ -0,0 +1,31 @@ +data "google_project" "test_project" { + project_id = "{{project-id}}" +} + +data "google_kms_key_ring" "test_key_ring" { + name = "{{keyring}}" + location = "{{region}}" +} + +data "google_kms_crypto_key" "key" { + name = "{{key}}" + key_ring = data.google_kms_key_ring.test_key_ring.id +} + +resource "google_kms_crypto_key_iam_binding" "key1_binding" { + crypto_key_id = data.google_kms_crypto_key.key1.id + role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" + + members = [ + "serviceAccount:service-${data.google_project.test_project.number}@gcp-sa-eventarc.iam.gserviceaccount.com", + ] +} + +resource "google_eventarc_channel" "primary" { + location = "{{region}}" + name = "{{channel}}" + project = "${data.google_project.test_project.project_id}" + crypto_key_name = "${data.google_kms_crypto_key.key1.id}" + third_party_provider = "projects/${data.google_project.test_project.project_id}/locations/{{region}}/providers/datadog" + depends_on = [google_kms_crypto_key_iam_binding.key1_binding] +} \ No newline at end of file diff --git a/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.yaml b/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.yaml new file mode 100644 index 000000000000..e6e45bf2f4cd --- /dev/null +++ b/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.yaml @@ -0,0 +1,11 @@ +variables: + - name: "project-id" + type: "project" + - name: "region" + type: "region" + - name: "keyring" + type: "resource_name" + - name: "key" + type: "resource_name" + - name: "channel" + type: "resource_name" \ No newline at end of file diff --git a/tpgtools/overrides/eventarc/samples/googlechannelconfig/meta.yaml b/tpgtools/overrides/eventarc/samples/googlechannelconfig/meta.yaml new file mode 100644 index 000000000000..c7ed507491b5 --- /dev/null +++ b/tpgtools/overrides/eventarc/samples/googlechannelconfig/meta.yaml @@ -0,0 +1,5 @@ +# meta.yaml +# +# +test_hide: + - basic.tf.tmpl \ No newline at end of file From 006add5ec7ea9d754d1fd0d9279c9cb8e13af57c Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Sat, 10 Sep 2022 19:11:57 +0000 Subject: [PATCH 02/10] fix: updating dcl to v1.20.1 --- mmv1/third_party/terraform/go.mod.erb | 2 +- mmv1/third_party/terraform/go.sum | 2 ++ tpgtools/go.mod | 3 +-- tpgtools/go.sum | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mmv1/third_party/terraform/go.mod.erb b/mmv1/third_party/terraform/go.mod.erb index 9dd7c5f05e9d..4e224cd7dd99 100644 --- a/mmv1/third_party/terraform/go.mod.erb +++ b/mmv1/third_party/terraform/go.mod.erb @@ -5,7 +5,7 @@ go 1.18 require ( cloud.google.com/go/bigtable v1.16.0 - github.com/GoogleCloudPlatform/declarative-resource-client-library v1.19.0 + github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1 github.com/apparentlymart/go-cidr v1.1.0 github.com/client9/misspell v0.3.4 github.com/davecgh/go-spew v1.1.1 diff --git a/mmv1/third_party/terraform/go.sum b/mmv1/third_party/terraform/go.sum index 02b86cb57ec3..bc599aa56cb3 100644 --- a/mmv1/third_party/terraform/go.sum +++ b/mmv1/third_party/terraform/go.sum @@ -1515,3 +1515,5 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1 h1:3/A97+HDHSK35yPKsg7hEUe9wYGPM91LppirAE+Xv6M= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8= diff --git a/tpgtools/go.mod b/tpgtools/go.mod index 79d640ed7c9a..007332b6ece4 100644 --- a/tpgtools/go.mod +++ b/tpgtools/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( bitbucket.org/creachadair/stringset v0.0.9 - github.com/GoogleCloudPlatform/declarative-resource-client-library v1.19.0 + github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/hcl v1.0.0 @@ -23,7 +23,6 @@ require ( github.com/golang/protobuf v1.4.2 // indirect github.com/google/go-cmp v0.5.8 // indirect github.com/google/go-cpy v0.0.0-20211218193943-a9c933c06932 // indirect - github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect github.com/hashicorp/go-multierror v1.0.0 // indirect github.com/hashicorp/go-uuid v1.0.1 // indirect diff --git a/tpgtools/go.sum b/tpgtools/go.sum index 2dbc38d3c966..0b76d27e475b 100644 --- a/tpgtools/go.sum +++ b/tpgtools/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.19.0 h1:4YAtk4xuOCxUSkGdwlDhkX7DTP4VwLZCoebGGEsU+U4= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.19.0/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1 h1:3/A97+HDHSK35yPKsg7hEUe9wYGPM91LppirAE+Xv6M= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= From 641d7254dd9b45b5dde6c32740772d0f621269f8 Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Sat, 10 Sep 2022 19:13:29 +0000 Subject: [PATCH 03/10] fix: changed name of resource from channel to google channel config in basic.tf.tmpl file --- .../eventarc/samples/googlechannelconfig/basic.tf.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.tf.tmpl b/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.tf.tmpl index 1f0279581764..9106bc3c73e6 100644 --- a/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.tf.tmpl +++ b/tpgtools/overrides/eventarc/samples/googlechannelconfig/basic.tf.tmpl @@ -21,7 +21,7 @@ resource "google_kms_crypto_key_iam_binding" "key1_binding" { ] } -resource "google_eventarc_channel" "primary" { +resource "google_eventarc_google_channel_config" "primary" { location = "{{region}}" name = "{{channel}}" project = "${data.google_project.test_project.project_id}" From 97801248bb0b4c46a576fbea61629e312b4c2058 Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Tue, 13 Sep 2022 22:16:06 +0000 Subject: [PATCH 04/10] fix: updating pr based on changes I made for eventarc channel --- ...eventarc_google_channel_config_test.go.erb | 56 ++++++++++++++++--- .../samples/googlechannelconfig/meta.yaml | 3 +- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb index 3ab37518b1a2..0625e5c3a91f 100644 --- a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb @@ -17,7 +17,33 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccEventarcGoogleChannelConfig_BasicHandWritten(t *testing.T) { +func TestAccEventarcGoogleChannelConfig_basic(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "project_name": getTestProjectFromEnv(), + "region": getTestRegionFromEnv(), + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckEventarcGoogleChannelConfigDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccEventarcGoogleChannelConfig_basic(context), + }, + { + ResourceName: "google_eventarc_google_channel_config.primary", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccEventarcGoogleChannelConfig_cryptoKeyUpdate(t *testing.T) { t.Parallel() region := getTestRegionFromEnv() @@ -39,7 +65,7 @@ func TestAccEventarcGoogleChannelConfig_BasicHandWritten(t *testing.T) { CheckDestroy: testAccCheckEventarcGoogleChannelConfigDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccEventarcGoogleChannelConfig_HandWritten(context), + Config: testAccEventarcGoogleChannelConfig_setCryptoKey(context), }, { ResourceName: "google_eventarc_google_channel_config.primary", @@ -47,7 +73,7 @@ func TestAccEventarcGoogleChannelConfig_BasicHandWritten(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccEventarcGoogleChannelConfig_BasicHandWrittenUpdate0(context), + Config: testAccEventarcGoogleChannelConfig_cryptoKeyUpdate(context), }, { ResourceName: "google_eventarc_google_channel_config.primary", @@ -58,7 +84,21 @@ func TestAccEventarcGoogleChannelConfig_BasicHandWritten(t *testing.T) { }) } -func testAccEventarcGoogleChannelConfig_HandWritten(context map[string]interface{}) string { +func testAccEventarcGoogleChannelConfig_basic(context map[string]interface{}) string { + return Nprintf(` +data "google_project" "test_project" { + project_id = "%{project_name}" +} + +resource "google_eventarc_google_channel_config" "primary" { + location = "%{region}" + name = "projects/%{project_name}/locations/%{region}/googleChannelConfig" + project = data.google_project.test_project.project_id +} + `, context) +} + +func testAccEventarcGoogleChannelConfig_setCryptoKey(context map[string]interface{}) string { return Nprintf(` data "google_project" "test_project" { project_id = "%{project_name}" @@ -70,7 +110,7 @@ data "google_kms_key_ring" "test_key_ring" { } data "google_kms_crypto_key" "key1" { - name = "%{key2}" + name = "%{key1}" key_ring = data.google_kms_key_ring.test_key_ring.id } @@ -86,14 +126,14 @@ resource "google_kms_crypto_key_iam_binding" "key1_binding" { resource "google_eventarc_google_channel_config" "primary" { location = "%{region}" name = "projects/%{project_name}/locations/%{region}/googleChannelConfig" - project = "%{project_name}" + project = data.google_project.test_project.project_id crypto_key_name = "${data.google_kms_crypto_key.key1.id}" depends_on =[google_kms_crypto_key_iam_binding.key1_binding] } `, context) } -func testAccEventarcGoogleChannelConfig_BasicHandWrittenUpdate0(context map[string]interface{}) string { +func testAccEventarcGoogleChannelConfig_cryptoKeyUpdate(context map[string]interface{}) string { return Nprintf(` data "google_project" "test_project" { project_id = "%{project_name}" @@ -121,7 +161,7 @@ resource "google_kms_crypto_key_iam_binding" "key2_binding" { resource "google_eventarc_google_channel_config" "primary" { location = "%{region}" name = "projects/%{project_name}/locations/%{region}/googleChannelConfig" - project = "%{project_name}" + project = data.google_project.test_project.project_id crypto_key_name = "${data.google_kms_crypto_key.key2.id}" depends_on =[google_kms_crypto_key_iam_binding.key2_binding] } diff --git a/tpgtools/overrides/eventarc/samples/googlechannelconfig/meta.yaml b/tpgtools/overrides/eventarc/samples/googlechannelconfig/meta.yaml index c7ed507491b5..b587d36aff29 100644 --- a/tpgtools/overrides/eventarc/samples/googlechannelconfig/meta.yaml +++ b/tpgtools/overrides/eventarc/samples/googlechannelconfig/meta.yaml @@ -1,5 +1,6 @@ # meta.yaml # -# +# We are hiding the terraform template because the test's for an Eventarc GoogleChannelConfig are handwritten in mmv1. However we want to +# generate the docs for a channel on the registry. We make tpgtools do this without it generating a test test_hide: - basic.tf.tmpl \ No newline at end of file From 7b6780e947f24526ab1733528721c746119b0a20 Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Mon, 19 Sep 2022 12:49:44 +0000 Subject: [PATCH 05/10] nit: changed formatting based on comments on PR for channel --- ...esource_eventarc_google_channel_config_test.go.erb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb index 0625e5c3a91f..daf5b88de276 100644 --- a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb @@ -86,14 +86,9 @@ func TestAccEventarcGoogleChannelConfig_cryptoKeyUpdate(t *testing.T) { func testAccEventarcGoogleChannelConfig_basic(context map[string]interface{}) string { return Nprintf(` -data "google_project" "test_project" { - project_id = "%{project_name}" -} - resource "google_eventarc_google_channel_config" "primary" { location = "%{region}" name = "projects/%{project_name}/locations/%{region}/googleChannelConfig" - project = data.google_project.test_project.project_id } `, context) } @@ -126,8 +121,7 @@ resource "google_kms_crypto_key_iam_binding" "key1_binding" { resource "google_eventarc_google_channel_config" "primary" { location = "%{region}" name = "projects/%{project_name}/locations/%{region}/googleChannelConfig" - project = data.google_project.test_project.project_id - crypto_key_name = "${data.google_kms_crypto_key.key1.id}" + crypto_key_name = data.google_kms_crypto_key.key1.id depends_on =[google_kms_crypto_key_iam_binding.key1_binding] } `, context) @@ -161,8 +155,7 @@ resource "google_kms_crypto_key_iam_binding" "key2_binding" { resource "google_eventarc_google_channel_config" "primary" { location = "%{region}" name = "projects/%{project_name}/locations/%{region}/googleChannelConfig" - project = data.google_project.test_project.project_id - crypto_key_name = "${data.google_kms_crypto_key.key2.id}" + crypto_key_name = data.google_kms_crypto_key.key2.id depends_on =[google_kms_crypto_key_iam_binding.key2_binding] } `, context) From bd9e1a37775e871a4ce2dd82e42b06806bd7a43e Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Mon, 19 Sep 2022 23:11:05 +0000 Subject: [PATCH 06/10] fix: deleted python script --- tpgtools/api/eventarc/samples/copy.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 tpgtools/api/eventarc/samples/copy.py diff --git a/tpgtools/api/eventarc/samples/copy.py b/tpgtools/api/eventarc/samples/copy.py deleted file mode 100644 index 81675fa01b4e..000000000000 --- a/tpgtools/api/eventarc/samples/copy.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -import shutil -import sys -import yaml - - -def main(): - file_name = sys.argv[1] - shutil.copy(file_name, os.getcwd()) - samples_dir = os.path.split(file_name)[0] - sample = yaml.safe_load(open(file_name)) - print(yaml.dump(sample)) - all_deps = [sample['resource']] - updates = sample.get('updates') - if updates: - all_deps.append(updates[0]['resource']) - all_deps += sample.get('dependencies', []) - for dep in all_deps: - dep_file_name = f'{samples_dir}/{os.path.split(dep)[1]}' - shutil.copy(dep_file_name, os.getcwd()) - - -if __name__ == '__main__': - main() \ No newline at end of file From 93f963553749de676cd9ac9f5f69d80761a46e03 Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Mon, 19 Sep 2022 23:13:35 +0000 Subject: [PATCH 07/10] fix: updated format of template file of google_channel_config_test --- .../tests/resource_eventarc_google_channel_config_test.go.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb index daf5b88de276..00b720e38770 100644 --- a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb @@ -11,7 +11,7 @@ import ( <% if version == "ga" -%> eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc" <% else -%> - eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc/beta" + eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc/beta" <% end %> "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" From 9846b604769a2211b79ffa70a43e69044515ea7a Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Mon, 19 Sep 2022 23:14:53 +0000 Subject: [PATCH 08/10] fix: fix formatting issues with tabs --- .../tests/resource_eventarc_google_channel_config_test.go.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb index 00b720e38770..b58e6ba8634c 100644 --- a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb @@ -12,7 +12,7 @@ import ( eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc" <% else -%> eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc/beta" - <% end %> + <% end %> "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) From a4f58628aff93081410c9aa392a1766fab8f7492 Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Tue, 27 Sep 2022 17:22:13 +0000 Subject: [PATCH 09/10] feat: upgrade to dcl v1.22.1 --- mmv1/third_party/terraform/go.mod.erb | 2 +- mmv1/third_party/terraform/go.sum | 2 ++ tpgtools/go.mod | 2 +- tpgtools/go.sum | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mmv1/third_party/terraform/go.mod.erb b/mmv1/third_party/terraform/go.mod.erb index 4e224cd7dd99..e21ac599b905 100644 --- a/mmv1/third_party/terraform/go.mod.erb +++ b/mmv1/third_party/terraform/go.mod.erb @@ -5,7 +5,7 @@ go 1.18 require ( cloud.google.com/go/bigtable v1.16.0 - github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1 + github.com/GoogleCloudPlatform/declarative-resource-client-library v1.22.1 github.com/apparentlymart/go-cidr v1.1.0 github.com/client9/misspell v0.3.4 github.com/davecgh/go-spew v1.1.1 diff --git a/mmv1/third_party/terraform/go.sum b/mmv1/third_party/terraform/go.sum index bc599aa56cb3..e48f991d51a9 100644 --- a/mmv1/third_party/terraform/go.sum +++ b/mmv1/third_party/terraform/go.sum @@ -1517,3 +1517,5 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1 h1:3/A97+HDHSK35yPKsg7hEUe9wYGPM91LppirAE+Xv6M= github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.22.1 h1:qnGy9ZZGDqTN2kWKJPfSlCz1yYrMj8GnBeSWBTygzVk= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.22.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8= diff --git a/tpgtools/go.mod b/tpgtools/go.mod index 007332b6ece4..b1319a3606de 100644 --- a/tpgtools/go.mod +++ b/tpgtools/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( bitbucket.org/creachadair/stringset v0.0.9 - github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1 + github.com/GoogleCloudPlatform/declarative-resource-client-library v1.22.1 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/hcl v1.0.0 diff --git a/tpgtools/go.sum b/tpgtools/go.sum index 0b76d27e475b..87a6b487ef1d 100644 --- a/tpgtools/go.sum +++ b/tpgtools/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1 h1:3/A97+HDHSK35yPKsg7hEUe9wYGPM91LppirAE+Xv6M= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.20.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.22.1 h1:qnGy9ZZGDqTN2kWKJPfSlCz1yYrMj8GnBeSWBTygzVk= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.22.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= From bcd5767668604153a847f3b229834f1d1908a38e Mon Sep 17 00:00:00 2001 From: Avi Dave Date: Tue, 15 Nov 2022 00:56:41 +0000 Subject: [PATCH 10/10] fix: added google channel config yaml in GA and changed dcl version in hand written test --- .../resource_eventarc_google_channel_config_test.go.erb | 6 +----- tpgtools/overrides/eventarc/google_channel_config.yaml | 0 2 files changed, 1 insertion(+), 5 deletions(-) create mode 100644 tpgtools/overrides/eventarc/google_channel_config.yaml diff --git a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb index b58e6ba8634c..11e51b58a60f 100644 --- a/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_eventarc_google_channel_config_test.go.erb @@ -8,11 +8,7 @@ import ( "testing" dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" - <% if version == "ga" -%> - eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc" - <% else -%> - eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc/beta" - <% end %> + eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc<%= dcl_version(version) -%>" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) diff --git a/tpgtools/overrides/eventarc/google_channel_config.yaml b/tpgtools/overrides/eventarc/google_channel_config.yaml new file mode 100644 index 000000000000..e69de29bb2d1