Skip to content

Commit

Permalink
Daily patchdeployment (GoogleCloudPlatform#5569)
Browse files Browse the repository at this point in the history
  • Loading branch information
trodge authored and xuchenma committed Jan 7, 2022
1 parent 0e1b5b5 commit edf9bb1
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 13 deletions.
6 changes: 0 additions & 6 deletions mmv1/products/osconfig/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,6 @@ objects:
A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
- !ruby/object:Api::Type::NestedObject
name: 'weekly'
exactly_one_of:
- recurring_schedule.0.weekly
- recurring_schedule.0.monthly
description: |
Schedule with weekly executions.
properties:
Expand All @@ -803,9 +800,6 @@ objects:
- :SUNDAY
- !ruby/object:Api::Type::NestedObject
name: 'monthly'
exactly_one_of:
- recurring_schedule.0.weekly
- recurring_schedule.0.monthly
description: |
Schedule with monthly executions.
properties:
Expand Down
9 changes: 6 additions & 3 deletions mmv1/products/osconfig/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides
name: "os_config_patch_deployment_basic"
primary_resource_id: "patch"
vars:
instance_name: "patch-deploy-inst"
patch_deployment_id: "patch-deploy"
- !ruby/object:Provider::Terraform::Examples
name: "os_config_patch_deployment_daily"
primary_resource_id: "patch"
vars:
patch_deployment_id: "patch-deploy"
- !ruby/object:Provider::Terraform::Examples
name: "os_config_patch_deployment_instance"
Expand All @@ -32,7 +36,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
name: "os_config_patch_deployment_full"
primary_resource_id: "patch"
vars:
instance_name: "patch-deploy-inst"
patch_deployment_id: "patch-deploy"
properties:
patchDeploymentId: !ruby/object:Overrides::Terraform::PropertyOverride
Expand Down Expand Up @@ -127,4 +130,4 @@ files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
<%= lines(indent(compile('provider/terraform/product~compile.yaml'), 4)) -%>
<%= lines(indent(compile('provider/terraform/product~compile.yaml'), 4)) -%>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ if obj["recurringSchedule"] != nil {
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "google_os_config_patch_deployment" "<%= ctx[:primary_resource_id] %>" {
patch_deployment_id = "<%= ctx[:vars]['instance_name'] %>"
patch_deployment_id = "<%= ctx[:vars]['patch_deployment_id'] %>"

instance_filter {
all = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "google_os_config_patch_deployment" "<%= ctx[:primary_resource_id] %>" {
patch_deployment_id = "<%= ctx[:vars]['patch_deployment_id'] %>"

instance_filter {
all = true
}

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

time_of_day {
hours = 0
minutes = 30
seconds = 30
nanos = 20
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "google_os_config_patch_deployment" "<%= ctx[:primary_resource_id] %>" {
patch_deployment_id = "<%= ctx[:vars]['instance_name'] %>"
patch_deployment_id = "<%= ctx[:vars]['patch_deployment_id'] %>"

instance_filter {
group_labels {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "google_compute_instance" "foobar" {
}

resource "google_os_config_patch_deployment" "<%= ctx[:primary_resource_id] %>" {
patch_deployment_id = "<%= ctx[:vars]['instance_name'] %>"
patch_deployment_id = "<%= ctx[:vars]['patch_deployment_id'] %>"

instance_filter {
instances = [google_compute_instance.foobar.id]
Expand Down Expand Up @@ -56,4 +56,4 @@ resource "google_os_config_patch_deployment" "<%= ctx[:primary_resource_id] %>"
month_day = 1
}
}
}
}

0 comments on commit edf9bb1

Please sign in to comment.