Skip to content

Commit 91d048d

Browse files
add day_offset field to google_os_config_patch_deployment.recurring_schedule.monthly.week_day_of_month (#9016) (#15997)
Signed-off-by: Modular Magician <[email protected]>
1 parent 959c825 commit 91d048d

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

.changelog/9016.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
osconfig: added `week_day_of_month.day_offset` field to the `google_os_config_patch_deployment` resource
3+
```

google/services/osconfig/resource_os_config_patch_deployment.go

+37
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,13 @@ will not run in February, April, June, etc.`,
818818
ValidateFunc: validation.IntBetween(-1, 4),
819819
Description: `Week number in a month. 1-4 indicates the 1st to 4th week of the month. -1 indicates the last week of the month.`,
820820
},
821+
"day_offset": {
822+
Type: schema.TypeInt,
823+
Optional: true,
824+
ForceNew: true,
825+
ValidateFunc: validation.IntBetween(-30, 30),
826+
Description: `Represents the number of days before or after the given week day of month that the patch deployment is scheduled for.`,
827+
},
821828
},
822829
},
823830
ExactlyOneOf: []string{"recurring_schedule.0.monthly.0.week_day_of_month", "recurring_schedule.0.monthly.0.month_day"},
@@ -1977,6 +1984,8 @@ func flattenOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonth(v inte
19771984
flattenOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthWeekOrdinal(original["weekOrdinal"], d, config)
19781985
transformed["day_of_week"] =
19791986
flattenOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthDayOfWeek(original["dayOfWeek"], d, config)
1987+
transformed["day_offset"] =
1988+
flattenOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthDayOffset(original["dayOffset"], d, config)
19801989
return []interface{}{transformed}
19811990
}
19821991
func flattenOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthWeekOrdinal(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -2000,6 +2009,23 @@ func flattenOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthDayOfWe
20002009
return v
20012010
}
20022011

2012+
func flattenOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthDayOffset(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2013+
// Handles the string fixed64 format
2014+
if strVal, ok := v.(string); ok {
2015+
if intVal, err := tpgresource.StringToFixed64(strVal); err == nil {
2016+
return intVal
2017+
}
2018+
}
2019+
2020+
// number values are represented as float64
2021+
if floatVal, ok := v.(float64); ok {
2022+
intVal := int(floatVal)
2023+
return intVal
2024+
}
2025+
2026+
return v // let terraform core handle it otherwise
2027+
}
2028+
20032029
func flattenOSConfigPatchDeploymentRecurringScheduleMonthlyMonthDay(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
20042030
// Handles the string fixed64 format
20052031
if strVal, ok := v.(string); ok {
@@ -3228,6 +3254,13 @@ func expandOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonth(v inter
32283254
transformed["dayOfWeek"] = transformedDayOfWeek
32293255
}
32303256

3257+
transformedDayOffset, err := expandOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthDayOffset(original["day_offset"], d, config)
3258+
if err != nil {
3259+
return nil, err
3260+
} else if val := reflect.ValueOf(transformedDayOffset); val.IsValid() && !tpgresource.IsEmptyValue(val) {
3261+
transformed["dayOffset"] = transformedDayOffset
3262+
}
3263+
32313264
return transformed, nil
32323265
}
32333266

@@ -3239,6 +3272,10 @@ func expandOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthDayOfWee
32393272
return v, nil
32403273
}
32413274

3275+
func expandOSConfigPatchDeploymentRecurringScheduleMonthlyWeekDayOfMonthDayOffset(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
3276+
return v, nil
3277+
}
3278+
32423279
func expandOSConfigPatchDeploymentRecurringScheduleMonthlyMonthDay(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
32433280
return v, nil
32443281
}

google/services/osconfig/resource_os_config_patch_deployment_generated_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ resource "google_os_config_patch_deployment" "patch" {
383383
week_day_of_month {
384384
week_ordinal = -1
385385
day_of_week = "TUESDAY"
386+
day_offset = 3
386387
}
387388
}
388389
}

website/docs/r/os_config_patch_deployment.html.markdown

+5
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ resource "google_os_config_patch_deployment" "patch" {
284284
week_day_of_month {
285285
week_ordinal = -1
286286
day_of_week = "TUESDAY"
287+
day_offset = 3
287288
}
288289
}
289290
}
@@ -801,6 +802,10 @@ The following arguments are supported:
801802
A day of the week.
802803
Possible values are: `MONDAY`, `TUESDAY`, `WEDNESDAY`, `THURSDAY`, `FRIDAY`, `SATURDAY`, `SUNDAY`.
803804

805+
* `day_offset` -
806+
(Optional)
807+
Represents the number of days before or after the given week day of month that the patch deployment is scheduled for.
808+
804809
<a name="nested_rollout"></a>The `rollout` block supports:
805810

806811
* `mode` -

0 commit comments

Comments
 (0)