Skip to content

Commit cc70cc8

Browse files
osconfig: fix permadiff where patch_config.yum.minimal doesn't send false for empty values (#15046)
1 parent 9fd482b commit cc70cc8

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

mmv1/products/osconfig/PatchDeployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ properties:
254254
- 'patch_config.0.yum.0.excludes'
255255
- 'patch_config.0.yum.0.exclusive_packages'
256256
- name: 'minimal'
257+
send_empty_value: true
257258
type: Boolean
258259
description: |
259260
Will cause patch to run yum update-minimal instead.

mmv1/templates/terraform/decoders/os_config_patch_deployment.go.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ if res["patchConfig"] != nil {
44
patchConfig["goo"].(map[string]interface{})["enabled"] = true
55
res["patchConfig"] = patchConfig
66
}
7+
8+
if patchConfig["yum"] != nil {
9+
patchConfigYum := patchConfig["yum"].(map[string]interface{})
10+
if _, ok := patchConfigYum["minimal"]; !ok {
11+
patchConfigYum["minimal"] = false
12+
}
13+
patchConfig["yum"] = patchConfigYum
14+
}
715
}
816

917
return res, nil
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package osconfig_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
"github.com/hashicorp/terraform-provider-google/google/acctest"
8+
)
9+
10+
func TestAccOSConfigPatchDeployment_osConfigPatchDeployment_yum_basic(t *testing.T) {
11+
t.Parallel()
12+
13+
context := map[string]interface{}{
14+
"random_suffix": acctest.RandString(t, 10),
15+
}
16+
17+
acctest.VcrTest(t, resource.TestCase{
18+
PreCheck: func() { acctest.AccTestPreCheck(t) },
19+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
20+
CheckDestroy: testAccCheckOSConfigPatchDeploymentDestroyProducer(t),
21+
Steps: []resource.TestStep{
22+
{
23+
Config: testAccOSConfigPatchDeployment_osConfigPatchDeployment_yum_basic(context),
24+
Check: resource.ComposeTestCheckFunc(
25+
resource.TestCheckResourceAttr("google_os_config_patch_deployment.patch", "patch_config.0.yum.0.minimal", "false"),
26+
),
27+
},
28+
{
29+
ResourceName: "google_os_config_patch_deployment.patch",
30+
ImportState: true,
31+
ImportStateVerify: true,
32+
ImportStateVerifyIgnore: []string{"patch_deployment_id"},
33+
},
34+
},
35+
})
36+
}
37+
38+
func testAccOSConfigPatchDeployment_osConfigPatchDeployment_yum_basic(context map[string]interface{}) string {
39+
return acctest.Nprintf(`
40+
resource "google_os_config_patch_deployment" "patch" {
41+
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"
42+
43+
instance_filter {
44+
all = true
45+
}
46+
47+
patch_config {
48+
yum {
49+
minimal = false
50+
}
51+
}
52+
53+
one_time_schedule {
54+
execute_time = "2999-10-10T10:10:10.045123456Z"
55+
}
56+
}
57+
`, context)
58+
}

0 commit comments

Comments
 (0)