From bfb035320f9d7c729ee76d532f549cdcafd78e2e Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 26 Aug 2021 19:01:06 -0500 Subject: [PATCH] fixed diff in publishing_options (#5045) (#9926) * fixed diff in publishing_options * Update api.yaml Signed-off-by: Modular Magician --- .changelog/5045.txt | 3 ++ google/resource_privateca_ca_pool.go | 9 ++--- google/resource_privateca_ca_pool_test.go | 42 +++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 .changelog/5045.txt diff --git a/.changelog/5045.txt b/.changelog/5045.txt new file mode 100644 index 00000000000..81bd4d0d10f --- /dev/null +++ b/.changelog/5045.txt @@ -0,0 +1,3 @@ +```release-note:bug +privateca: fixed a permadiff bug for `publishing_options` on `google_privateca_ca_pool` when both attributes set false +``` diff --git a/google/resource_privateca_ca_pool.go b/google/resource_privateca_ca_pool.go index fc35846359f..ec242b4a2ae 100644 --- a/google/resource_privateca_ca_pool.go +++ b/google/resource_privateca_ca_pool.go @@ -434,10 +434,11 @@ An object containing a list of "key": value pairs. Example: { "name": "wrench", Elem: &schema.Schema{Type: schema.TypeString}, }, "publishing_options": { - Type: schema.TypeList, - Optional: true, - Description: `The PublishingOptions to follow when issuing Certificates from any CertificateAuthority in this CaPool.`, - MaxItems: 1, + Type: schema.TypeList, + Optional: true, + DiffSuppressFunc: emptyOrUnsetBlockDiffSuppress, + Description: `The PublishingOptions to follow when issuing Certificates from any CertificateAuthority in this CaPool.`, + MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "publish_ca_cert": { diff --git a/google/resource_privateca_ca_pool_test.go b/google/resource_privateca_ca_pool_test.go index 4364ef2aebf..3a08a20b2ff 100644 --- a/google/resource_privateca_ca_pool_test.go +++ b/google/resource_privateca_ca_pool_test.go @@ -276,3 +276,45 @@ resource "google_privateca_ca_pool" "default" { } `, context) } + +func TestAccPrivatecaCaPool_privatecaCapoolEmptyPublishingOptions(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckPrivatecaCaPoolDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccPrivatecaCaPool_privatecaCapoolEmptyPublishingOptions(context), + }, + { + ResourceName: "google_privateca_ca_pool.default", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"name", "location"}, + }, + }, + }) +} + +func testAccPrivatecaCaPool_privatecaCapoolEmptyPublishingOptions(context map[string]interface{}) string { + return Nprintf(` +resource "google_privateca_ca_pool" "default" { + name = "tf-test-my-capool%{random_suffix}" + location = "us-central1" + tier = "ENTERPRISE" + publishing_options { + publish_ca_cert = false + publish_crl = false + } + labels = { + foo = "bar" + } +} +`, context) +}