Skip to content

Commit b834fdc

Browse files
authored
workbench: Fix issue with apply failing with labels was null (#15055)
1 parent 6f1f501 commit b834fdc

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

mmv1/products/workbench/Instance.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ properties:
615615
description: |
616616
Optional. Labels to apply to this instance. These can be later modified
617617
by the UpdateInstance method.
618-
diff_suppress_func: 'WorkbenchInstanceLabelsDiffSuppress'
619618
- name: 'enableThirdPartyIdentity'
620619
type: Boolean
621620
description: |

mmv1/templates/terraform/constants/workbench_instance.go.tmpl

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
var WorkbenchInstanceProvidedLabels = []string{
2-
"consumer-project-id",
3-
"consumer-project-number",
4-
"notebooks-product",
5-
"resource-name",
6-
}
7-
8-
func WorkbenchInstanceLabelsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
9-
// Suppress diffs for the labels
10-
for _, label := range WorkbenchInstanceProvidedLabels {
11-
if strings.Contains(k, label) && new == "" {
12-
return true
13-
}
14-
}
15-
16-
// Let diff be determined by labels (above)
17-
if strings.Contains(k, "labels.%") {
18-
return true
19-
}
20-
21-
// For other keys, don't suppress diff.
22-
return false
23-
}
24-
25-
261
var WorkbenchInstanceSettableUnmodifiableDefaultMetadata = []string{
272
"install-monitoring-agent",
283
"serial-port-logging-enable",

mmv1/third_party/terraform/services/workbench/resource_workbench_instance_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,9 @@ resource "google_workbench_instance" "instance" {
732732
}
733733

734734
func TestAccWorkbenchInstance_updatelabels(t *testing.T) {
735+
// Skip it in VCR test because of the randomness of uuid in "labels" field
736+
// which causes the replaying mode after recording mode failing in VCR test
737+
acctest.SkipIfVcr(t)
735738
t.Parallel()
736739

737740
context := map[string]interface{}{
@@ -741,6 +744,9 @@ func TestAccWorkbenchInstance_updatelabels(t *testing.T) {
741744
acctest.VcrTest(t, resource.TestCase{
742745
PreCheck: func() { acctest.AccTestPreCheck(t) },
743746
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
747+
ExternalProviders: map[string]resource.ExternalProvider{
748+
"random": {},
749+
},
744750
Steps: []resource.TestStep{
745751
{
746752
Config: testAccWorkbenchInstance_label(context),
@@ -787,11 +793,15 @@ func TestAccWorkbenchInstance_updatelabels(t *testing.T) {
787793

788794
func testAccWorkbenchInstance_label(context map[string]interface{}) string {
789795
return acctest.Nprintf(`
796+
resource "random_uuid" "test" {
797+
}
798+
790799
resource "google_workbench_instance" "instance" {
791800
name = "tf-test-workbench-instance%{random_suffix}"
792801
location = "us-central1-a"
793802
labels = {
794803
k = "val"
804+
computed_label = "${random_uuid.test.result}"
795805
}
796806
}
797807
`, context)

0 commit comments

Comments
 (0)