From d2f87bbc8ded5faf351e04d42c3a884b8589e4e9 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 28 Dec 2021 09:18:42 -0800 Subject: [PATCH] Daily patchdeployment (#5569) (#10807) Signed-off-by: Modular Magician --- .changelog/5569.txt | 3 + google/resource_os_config_patch_deployment.go | 4 +- ..._config_patch_deployment_generated_test.go | 56 ++++++++++++++++++- ..._config_os_policy_assignment.html.markdown | 36 ++++++------ .../os_config_patch_deployment.html.markdown | 36 +++++++++++- 5 files changed, 109 insertions(+), 26 deletions(-) create mode 100644 .changelog/5569.txt diff --git a/.changelog/5569.txt b/.changelog/5569.txt new file mode 100644 index 00000000000..f9fade39f56 --- /dev/null +++ b/.changelog/5569.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +Added daily os config patch deployments +``` diff --git a/google/resource_os_config_patch_deployment.go b/google/resource_os_config_patch_deployment.go index 353d3970a4c..88f97cf571c 100644 --- a/google/resource_os_config_patch_deployment.go +++ b/google/resource_os_config_patch_deployment.go @@ -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, @@ -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, @@ -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" } } diff --git a/google/resource_os_config_patch_deployment_generated_test.go b/google/resource_os_config_patch_deployment_generated_test.go index 1d6817dcaf7..9947b8e54d4 100644 --- a/google/resource_os_config_patch_deployment_generated_test.go +++ b/google/resource_os_config_patch_deployment_generated_test.go @@ -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 @@ -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() @@ -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] @@ -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 { diff --git a/website/docs/r/os_config_os_policy_assignment.html.markdown b/website/docs/r/os_config_os_policy_assignment.html.markdown index 54379f23429..7ecb8a64c23 100644 --- a/website/docs/r/os_config_os_policy_assignment.html.markdown +++ b/website/docs/r/os_config_os_policy_assignment.html.markdown @@ -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` - @@ -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` - diff --git a/website/docs/r/os_config_patch_deployment.html.markdown b/website/docs/r/os_config_patch_deployment.html.markdown index eb4a0799a92..4e099712433 100644 --- a/website/docs/r/os_config_patch_deployment.html.markdown +++ b/website/docs/r/os_config_patch_deployment.html.markdown @@ -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 @@ -53,6 +53,36 @@ resource "google_os_config_patch_deployment" "patch" { } } ``` + +## 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 + } + } +} +```