Repository: GoogleCloudPlatform/terraform-validator
Pull request #1449 (2023-03-11 00:09:40)

send friendly_name
<!-- Put a description of what this PR is for here, along with any references to issues that this resolves or contributes to -->

Fixes https://github.com/hashicorp/terraform-provider-google/issues/13951


<!--
Replace each [ ] with [X] to check it. Switch to the preview view to make it easier to click on links.
These steps will speed up the review process, and we appreciate you spending time on them before sending
your code to be reviewed.
-->
If this PR is for Terraform, I acknowledge that I have:

- [x] Searched through the [issue tracker](https://github.com/hashicorp/terraform-provider-google/issues) for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
- [x] Ensured that all new fields I added that can be set by a user appear in at least one [example](https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/templates/terraform/examples) (for generated resources) or [third_party test](https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/tests) (for handwritten resources or update tests).
- [x] [Generated Terraform providers](https://github.com/GoogleCloudPlatform/magic-modules/blob/main/docs/content/docs/getting-started/generate-providers.md), and ran [`make test` and `make lint`](https://googlecloudplatform.github.io/magic-modules/docs/getting-started/run-provider-tests/#run-unit-tests) in the generated providers to ensure it passes unit and linter tests.
- [x] [Ran](https://github.com/GoogleCloudPlatform/magic-modules/blob/main/docs/content/docs/getting-started/run-provider-tests.md) relevant acceptance tests using my own Google Cloud project and credentials (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
- [x] Read the [Release Notes Guide](https://github.com/GoogleCloudPlatform/magic-modules/blob/main/.ci/RELEASE_NOTES_GUIDE.md) before writing my release note below.

<!-- AUTOCHANGELOG for Downstream PRs.

Please select one of the following "release-note:" headings:
    - release-note:enhancement
    - release-note:bug
    - release-note:note
    - release-note:new-resource
    - release-note:new-datasource
    - release-note:deprecation
    - release-note:breaking-change
    - release-note:none

Unless you choose release-note:none, please add a release note.

See .ci/RELEASE_NOTES_GUIDE.md for writing good release notes.

You can add more release note blocks if you want more than one CHANGELOG
entry for this PR.
-->
**Release Note Template for Downstream PRs (will be copied)**

```release-note:bug
bigquery: fixed a permadiff when `friendly_name` is removed from `google_bigquery_dataset`
```

Derived from https://github.com/GoogleCloudPlatform/magic-modules/pull/7433


Patch:
diff --git a/converters/google/resources/bigquery_dataset.go b/converters/google/resources/bigquery_dataset.go
index d08019f1..aeb1b5b2 100644
--- a/converters/google/resources/bigquery_dataset.go
+++ b/converters/google/resources/bigquery_dataset.go
@@ -119,7 +119,7 @@ func GetBigQueryDatasetApiObject(d TerraformResourceData, config *Config) (map[s
 	friendlyNameProp, err := expandBigQueryDatasetFriendlyName(d.Get("friendly_name"), d, config)
 	if err != nil {
 		return nil, err
-	} else if v, ok := d.GetOkExists("friendly_name"); !isEmptyValue(reflect.ValueOf(friendlyNameProp)) && (ok || !reflect.DeepEqual(v, friendlyNameProp)) {
+	} else if v, ok := d.GetOkExists("friendly_name"); ok || !reflect.DeepEqual(v, friendlyNameProp) {
 		obj["friendlyName"] = friendlyNameProp
 	}
 	labelsProp, err := expandBigQueryDatasetLabels(d.Get("labels"), d, config)
diff --git a/go.mod b/go.mod
index 7e48dfba..dc9b8ea9 100644
--- a/go.mod
+++ b/go.mod
@@ -26,7 +26,7 @@ require (
 	github.com/hashicorp/go-cleanhttp v0.5.2
 	github.com/hashicorp/terraform-json v0.14.0
 	github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0
-	github.com/hashicorp/terraform-provider-google v1.20.1-0.20230310215058-7f8a5aa87cc0
+	github.com/hashicorp/terraform-provider-google v1.20.1-0.20230311000500-91bcded350e0
 	github.com/mitchellh/go-homedir v1.1.0
 	github.com/pkg/errors v0.9.1
 	github.com/sirupsen/logrus v1.9.0
diff --git a/go.sum b/go.sum
index 1d541bc4..38929067 100644
--- a/go.sum
+++ b/go.sum
@@ -514,8 +514,8 @@ github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R
 github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0 h1:FtCLTiTcykdsURXPt/ku7fYXm3y19nbzbZcUxHx9RbI=
 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0/go.mod h1:80wf5oad1tW+oLnbXS4UTYmDCrl7BuN1Q+IA91X1a4Y=
-github.com/hashicorp/terraform-provider-google v1.20.1-0.20230310215058-7f8a5aa87cc0 h1:14sguYoQ9MnCkLszWVqqOSF8p7qS4LTPCFVi4mX8EEg=
-github.com/hashicorp/terraform-provider-google v1.20.1-0.20230310215058-7f8a5aa87cc0/go.mod h1:Me09EooskxD1HNA2k+14YdLghnF8lt2HOda03gBkNpc=
+github.com/hashicorp/terraform-provider-google v1.20.1-0.20230311000500-91bcded350e0 h1:VVzPZHhQz4KYlTpuWLtYTLzFg+jwXf8vUjLhodU7nzM=
+github.com/hashicorp/terraform-provider-google v1.20.1-0.20230311000500-91bcded350e0/go.mod h1:Me09EooskxD1HNA2k+14YdLghnF8lt2HOda03gBkNpc=
 github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U=
 github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A=
 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=


Test patch:
diff --git a/testdata/templates/example_bigquery_dataset.json b/testdata/templates/example_bigquery_dataset.json
index c753c5f5..c55d9a2c 100644
--- a/testdata/templates/example_bigquery_dataset.json
+++ b/testdata/templates/example_bigquery_dataset.json
@@ -9,6 +9,7 @@
       "discovery_name": "Dataset",
       "parent": "//cloudresourcemanager.googleapis.com/projects/{{.Provider.project}}",
       "data": {
+        "friendlyName": "",
         "datasetReference": {
           "datasetId": "test-dataset"
         },
diff --git a/testdata/templates/example_bigquery_dataset_iam_binding.json b/testdata/templates/example_bigquery_dataset_iam_binding.json
index a3f5bacc..77014924 100644
--- a/testdata/templates/example_bigquery_dataset_iam_binding.json
+++ b/testdata/templates/example_bigquery_dataset_iam_binding.json
@@ -16,7 +16,8 @@
         "labels": {
           "env": "dev"
         },
-        "location": "EU"
+        "location": "EU",
+        "friendlyName": ""
       }
     },
     "iam_policy": {
diff --git a/testdata/templates/example_bigquery_dataset_iam_member.json b/testdata/templates/example_bigquery_dataset_iam_member.json
index dbda7165..7aed9ac6 100644
--- a/testdata/templates/example_bigquery_dataset_iam_member.json
+++ b/testdata/templates/example_bigquery_dataset_iam_member.json
@@ -16,7 +16,8 @@
         "labels": {
           "env": "dev"
         },
-        "location": "EU"
+        "location": "EU",
+        "friendlyName": ""
       }
     },
     "iam_policy": {
diff --git a/testdata/templates/example_bigquery_dataset_iam_policy.json b/testdata/templates/example_bigquery_dataset_iam_policy.json
index adbde0c0..5908f8d7 100644
--- a/testdata/templates/example_bigquery_dataset_iam_policy.json
+++ b/testdata/templates/example_bigquery_dataset_iam_policy.json
@@ -16,7 +16,8 @@
         "labels": {
           "env": "dev"
         },
-        "location": "EU"
+        "location": "EU",
+        "friendlyName": ""
       }
     },
     "iam_policy": {
diff --git a/testdata/templates/example_bigquery_dataset_iam_policy_empty_policy_data.json b/testdata/templates/example_bigquery_dataset_iam_policy_empty_policy_data.json
index 4431d596..f1a5ec56 100644
--- a/testdata/templates/example_bigquery_dataset_iam_policy_empty_policy_data.json
+++ b/testdata/templates/example_bigquery_dataset_iam_policy_empty_policy_data.json
@@ -12,7 +12,8 @@
         "datasetReference": {
           "datasetId": "example_dataset"
         },
-        "location": "US"
+        "location": "US",
+        "friendlyName": ""
       }
     },
     "iam_policy": {