Skip to content

Commit d2f87bb

Browse files
Daily patchdeployment (#5569) (#10807)
Signed-off-by: Modular Magician <[email protected]>
1 parent 5a109ff commit d2f87bb

5 files changed

+109
-26
lines changed

.changelog/5569.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
Added daily os config patch deployments
3+
```

google/resource_os_config_patch_deployment.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,6 @@ will not run in February, April, June, etc.`,
809809
},
810810
},
811811
},
812-
ExactlyOneOf: []string{"recurring_schedule.0.weekly", "recurring_schedule.0.monthly"},
813812
},
814813
"start_time": {
815814
Type: schema.TypeString,
@@ -835,7 +834,6 @@ A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "201
835834
},
836835
},
837836
},
838-
ExactlyOneOf: []string{"recurring_schedule.0.weekly", "recurring_schedule.0.monthly"},
839837
},
840838
"last_execute_time": {
841839
Type: schema.TypeString,
@@ -3264,6 +3262,8 @@ func resourceOSConfigPatchDeploymentEncoder(d *schema.ResourceData, meta interfa
32643262
obj["recurringSchedule"].(map[string]interface{})["frequency"] = "MONTHLY"
32653263
} else if schedule["weekly"] != nil {
32663264
obj["recurringSchedule"].(map[string]interface{})["frequency"] = "WEEKLY"
3265+
} else {
3266+
obj["recurringSchedule"].(map[string]interface{})["frequency"] = "DAILY"
32673267
}
32683268
}
32693269

google/resource_os_config_patch_deployment_generated_test.go

+53-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestAccOSConfigPatchDeployment_osConfigPatchDeploymentBasicExample(t *testi
5151
func testAccOSConfigPatchDeployment_osConfigPatchDeploymentBasicExample(context map[string]interface{}) string {
5252
return Nprintf(`
5353
resource "google_os_config_patch_deployment" "patch" {
54-
patch_deployment_id = "tf-test-patch-deploy-inst%{random_suffix}"
54+
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"
5555
5656
instance_filter {
5757
all = true
@@ -64,6 +64,56 @@ resource "google_os_config_patch_deployment" "patch" {
6464
`, context)
6565
}
6666

67+
func TestAccOSConfigPatchDeployment_osConfigPatchDeploymentDailyExample(t *testing.T) {
68+
t.Parallel()
69+
70+
context := map[string]interface{}{
71+
"random_suffix": randString(t, 10),
72+
}
73+
74+
vcrTest(t, resource.TestCase{
75+
PreCheck: func() { testAccPreCheck(t) },
76+
Providers: testAccProviders,
77+
CheckDestroy: testAccCheckOSConfigPatchDeploymentDestroyProducer(t),
78+
Steps: []resource.TestStep{
79+
{
80+
Config: testAccOSConfigPatchDeployment_osConfigPatchDeploymentDailyExample(context),
81+
},
82+
{
83+
ResourceName: "google_os_config_patch_deployment.patch",
84+
ImportState: true,
85+
ImportStateVerify: true,
86+
ImportStateVerifyIgnore: []string{"patch_deployment_id"},
87+
},
88+
},
89+
})
90+
}
91+
92+
func testAccOSConfigPatchDeployment_osConfigPatchDeploymentDailyExample(context map[string]interface{}) string {
93+
return Nprintf(`
94+
resource "google_os_config_patch_deployment" "patch" {
95+
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"
96+
97+
instance_filter {
98+
all = true
99+
}
100+
101+
recurring_schedule {
102+
time_zone {
103+
id = "America/New_York"
104+
}
105+
106+
time_of_day {
107+
hours = 0
108+
minutes = 30
109+
seconds = 30
110+
nanos = 20
111+
}
112+
}
113+
}
114+
`, context)
115+
}
116+
67117
func TestAccOSConfigPatchDeployment_osConfigPatchDeploymentInstanceExample(t *testing.T) {
68118
t.Parallel()
69119

@@ -119,7 +169,7 @@ resource "google_compute_instance" "foobar" {
119169
}
120170
121171
resource "google_os_config_patch_deployment" "patch" {
122-
patch_deployment_id = "tf-test-patch-deploy-inst%{random_suffix}"
172+
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"
123173
124174
instance_filter {
125175
instances = [google_compute_instance.foobar.id]
@@ -181,7 +231,7 @@ func TestAccOSConfigPatchDeployment_osConfigPatchDeploymentFullExample(t *testin
181231
func testAccOSConfigPatchDeployment_osConfigPatchDeploymentFullExample(context map[string]interface{}) string {
182232
return Nprintf(`
183233
resource "google_os_config_patch_deployment" "patch" {
184-
patch_deployment_id = "tf-test-patch-deploy-inst%{random_suffix}"
234+
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"
185235
186236
instance_filter {
187237
group_labels {

website/docs/r/os_config_os_policy_assignment.html.markdown

+18-18
Original file line numberDiff line numberDiff line change
@@ -703,24 +703,6 @@ The `disruption_budget` block supports:
703703
(Optional)
704704
Specifies the relative value defined as a percentage, which will be multiplied by a reference value.
705705

706-
The `source` block supports:
707-
708-
* `allow_insecure` -
709-
(Optional)
710-
Defaults to false. When false, files are subject to validations based on the file type: Remote: A checksum must be specified. Cloud Storage: An object generation number must be specified.
711-
712-
* `gcs` -
713-
(Optional)
714-
A Cloud Storage object.
715-
716-
* `local_path` -
717-
(Optional)
718-
A local path within the VM to use.
719-
720-
* `remote` -
721-
(Optional)
722-
A generic remote file.
723-
724706
- - -
725707

726708
* `description` -
@@ -970,6 +952,24 @@ The `zypper` block supports:
970952
(Required)
971953
Required. A one word, unique name for this repository. This is the `repo id` in the zypper config file and also the `display_name` if `display_name` is omitted. This id is also used as the unique identifier when checking for GuestPolicy conflicts.
972954

955+
The `file` block supports:
956+
957+
* `allow_insecure` -
958+
(Optional)
959+
Defaults to false. When false, files are subject to validations based on the file type: Remote: A checksum must be specified. Cloud Storage: An object generation number must be specified.
960+
961+
* `gcs` -
962+
(Optional)
963+
A Cloud Storage object.
964+
965+
* `local_path` -
966+
(Optional)
967+
A local path within the VM to use.
968+
969+
* `remote` -
970+
(Optional)
971+
A generic remote file.
972+
973973
The `gcs` block supports:
974974

975975
* `bucket` -

website/docs/r/os_config_patch_deployment.html.markdown

+33-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To get more information about PatchDeployment, see:
4242

4343
```hcl
4444
resource "google_os_config_patch_deployment" "patch" {
45-
patch_deployment_id = "patch-deploy-inst"
45+
patch_deployment_id = "patch-deploy"
4646
4747
instance_filter {
4848
all = true
@@ -53,6 +53,36 @@ resource "google_os_config_patch_deployment" "patch" {
5353
}
5454
}
5555
```
56+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
57+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.jpy.wang%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=os_config_patch_deployment_daily&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
58+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
59+
</a>
60+
</div>
61+
## Example Usage - Os Config Patch Deployment Daily
62+
63+
64+
```hcl
65+
resource "google_os_config_patch_deployment" "patch" {
66+
patch_deployment_id = "patch-deploy"
67+
68+
instance_filter {
69+
all = true
70+
}
71+
72+
recurring_schedule {
73+
time_zone {
74+
id = "America/New_York"
75+
}
76+
77+
time_of_day {
78+
hours = 0
79+
minutes = 30
80+
seconds = 30
81+
nanos = 20
82+
}
83+
}
84+
}
85+
```
5686
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
5787
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.jpy.wang%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=os_config_patch_deployment_instance&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
5888
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
@@ -90,7 +120,7 @@ resource "google_compute_instance" "foobar" {
90120
}
91121
92122
resource "google_os_config_patch_deployment" "patch" {
93-
patch_deployment_id = "patch-deploy-inst"
123+
patch_deployment_id = "patch-deploy"
94124
95125
instance_filter {
96126
instances = [google_compute_instance.foobar.id]
@@ -132,7 +162,7 @@ resource "google_os_config_patch_deployment" "patch" {
132162

133163
```hcl
134164
resource "google_os_config_patch_deployment" "patch" {
135-
patch_deployment_id = "patch-deploy-inst"
165+
patch_deployment_id = "patch-deploy"
136166
137167
instance_filter {
138168
group_labels {

0 commit comments

Comments
 (0)