Skip to content

Commit

Permalink
updated downtime_schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
humoflife committed Feb 28, 2024
1 parent 1bec80b commit b8d051e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
18 changes: 17 additions & 1 deletion config/external_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var ExternalNameConfigs = map[string]config.ExternalName{
"datadog_dashboard_json": config.IdentifierFromProvider,
"datadog_dashboard_list": datadogExternalNameWithInjectedID(),
"datadog_downtime": config.IdentifierFromProvider,
"datadog_downtime_schedule": config.IdentifierFromProvider,
"datadog_downtime_schedule": datadogExternalNameWithInjectedUUID(),
"datadog_integration_aws": config.IdentifierFromProvider,
"datadog_integration_aws_event_bridge": config.IdentifierFromProvider,
"datadog_integration_aws_lambda_arn": config.IdentifierFromProvider,
Expand Down Expand Up @@ -106,6 +106,22 @@ func datadogExternalNameWithInjectedID() config.ExternalName {
return e
}

// datadogExternalNameWithInjectedUUID injects an id when there is none.
// It is a slight modification of IdentifierFromProvider.
func datadogExternalNameWithInjectedUUID() config.ExternalName {
// Terraform does not allow team id to be empty.
// Using a stub value to pass validation.
e := config.IdentifierFromProvider
e.GetIDFn = func(_ context.Context, externalName string, _ map[string]any, _ map[string]any) (string, error) {
if len(externalName) == 0 {
// Some temporary id's need to be numeric
return "00000000-0000-0000-0000-000000000000", nil
}
return externalName, nil
}
return e
}

// ExternalNameConfigurations applies all external name configs listed in the
// table ExternalNameConfigs and sets the version of those resources to v1beta1
// assuming they will be tested.
Expand Down
23 changes: 13 additions & 10 deletions examples/datadog/v1alpha1/downtimeschedule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ spec:
displayTimezone: America/New_York
message: Message about the downtime
monitorIdentifier:
- monitor_tags: ["test:123", "data:test"]
#monitorId: "140479090"
monitorTags:
- "test:123"
- "data:test"
muteFirstRecoveryNotification: true
notifyEndStates:
- alert
- warn
- alert
- warn
notifyEndTypes:
- canceled
- expired
- canceled
- expired
recurringSchedule:
- recurrence:
- duration: 1h
rrule: "FREQ=DAILY;INTERVAL=1"
start: "2050-01-02T03:04:05"
timezone: "America/New_York"
recurrence:
- duration: 1h
rrule: "FREQ=DAILY;INTERVAL=1"
start: "2050-01-02T03:04:05"
timezone: "America/New_York"
scope: env:us9-prod7 AND team:test123

0 comments on commit b8d051e

Please sign in to comment.