Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daily patchdeployment #10807

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/5569.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Added daily os config patch deployments
```
4 changes: 2 additions & 2 deletions google/resource_os_config_patch_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ will not run in February, April, June, etc.`,
},
},
},
ExactlyOneOf: []string{"recurring_schedule.0.weekly", "recurring_schedule.0.monthly"},
},
"start_time": {
Type: schema.TypeString,
Expand All @@ -835,7 +834,6 @@ A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "201
},
},
},
ExactlyOneOf: []string{"recurring_schedule.0.weekly", "recurring_schedule.0.monthly"},
},
"last_execute_time": {
Type: schema.TypeString,
Expand Down Expand Up @@ -3264,6 +3262,8 @@ func resourceOSConfigPatchDeploymentEncoder(d *schema.ResourceData, meta interfa
obj["recurringSchedule"].(map[string]interface{})["frequency"] = "MONTHLY"
} else if schedule["weekly"] != nil {
obj["recurringSchedule"].(map[string]interface{})["frequency"] = "WEEKLY"
} else {
obj["recurringSchedule"].(map[string]interface{})["frequency"] = "DAILY"
}
}

Expand Down
56 changes: 53 additions & 3 deletions google/resource_os_config_patch_deployment_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestAccOSConfigPatchDeployment_osConfigPatchDeploymentBasicExample(t *testi
func testAccOSConfigPatchDeployment_osConfigPatchDeploymentBasicExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "tf-test-patch-deploy-inst%{random_suffix}"
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"

instance_filter {
all = true
Expand All @@ -64,6 +64,56 @@ resource "google_os_config_patch_deployment" "patch" {
`, context)
}

func TestAccOSConfigPatchDeployment_osConfigPatchDeploymentDailyExample(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: testAccCheckOSConfigPatchDeploymentDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccOSConfigPatchDeployment_osConfigPatchDeploymentDailyExample(context),
},
{
ResourceName: "google_os_config_patch_deployment.patch",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"patch_deployment_id"},
},
},
})
}

func testAccOSConfigPatchDeployment_osConfigPatchDeploymentDailyExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"

instance_filter {
all = true
}

recurring_schedule {
time_zone {
id = "America/New_York"
}

time_of_day {
hours = 0
minutes = 30
seconds = 30
nanos = 20
}
}
}
`, context)
}

func TestAccOSConfigPatchDeployment_osConfigPatchDeploymentInstanceExample(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -119,7 +169,7 @@ resource "google_compute_instance" "foobar" {
}

resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "tf-test-patch-deploy-inst%{random_suffix}"
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"

instance_filter {
instances = [google_compute_instance.foobar.id]
Expand Down Expand Up @@ -181,7 +231,7 @@ func TestAccOSConfigPatchDeployment_osConfigPatchDeploymentFullExample(t *testin
func testAccOSConfigPatchDeployment_osConfigPatchDeploymentFullExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "tf-test-patch-deploy-inst%{random_suffix}"
patch_deployment_id = "tf-test-patch-deploy%{random_suffix}"

instance_filter {
group_labels {
Expand Down
36 changes: 18 additions & 18 deletions website/docs/r/os_config_os_policy_assignment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -703,24 +703,6 @@ The `disruption_budget` block supports:
(Optional)
Specifies the relative value defined as a percentage, which will be multiplied by a reference value.

The `source` block supports:

* `allow_insecure` -
(Optional)
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.

* `gcs` -
(Optional)
A Cloud Storage object.

* `local_path` -
(Optional)
A local path within the VM to use.

* `remote` -
(Optional)
A generic remote file.

- - -

* `description` -
Expand Down Expand Up @@ -970,6 +952,24 @@ The `zypper` block supports:
(Required)
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.

The `file` block supports:

* `allow_insecure` -
(Optional)
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.

* `gcs` -
(Optional)
A Cloud Storage object.

* `local_path` -
(Optional)
A local path within the VM to use.

* `remote` -
(Optional)
A generic remote file.

The `gcs` block supports:

* `bucket` -
Expand Down
36 changes: 33 additions & 3 deletions website/docs/r/os_config_patch_deployment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ To get more information about PatchDeployment, see:

```hcl
resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "patch-deploy-inst"
patch_deployment_id = "patch-deploy"

instance_filter {
all = true
Expand All @@ -53,6 +53,36 @@ resource "google_os_config_patch_deployment" "patch" {
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgit.luolix.top%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">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Os Config Patch Deployment Daily


```hcl
resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "patch-deploy"

instance_filter {
all = true
}

recurring_schedule {
time_zone {
id = "America/New_York"
}

time_of_day {
hours = 0
minutes = 30
seconds = 30
nanos = 20
}
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgit.luolix.top%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">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
Expand Down Expand Up @@ -90,7 +120,7 @@ resource "google_compute_instance" "foobar" {
}

resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "patch-deploy-inst"
patch_deployment_id = "patch-deploy"

instance_filter {
instances = [google_compute_instance.foobar.id]
Expand Down Expand Up @@ -132,7 +162,7 @@ resource "google_os_config_patch_deployment" "patch" {

```hcl
resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "patch-deploy-inst"
patch_deployment_id = "patch-deploy"

instance_filter {
group_labels {
Expand Down