Skip to content

Commit

Permalink
Revert "Monitors: Pass on Stack tags (#229)"
Browse files Browse the repository at this point in the history
This reverts commit 4cda276.
  • Loading branch information
skarimo committed Dec 8, 2022
1 parent 4cda276 commit 749b7a7
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
"properties": {
"DatadogCredentials": {
"$ref": "#/definitions/DatadogCredentials"
},
"TagResourceWithStackTags": {
"description": "Copy the Cloudformation Stack tags to the datadog monitor. It defaults to false to stay backwards compatible.",
"type": "boolean"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -87,6 +83,7 @@
"IncludeTags": {
"description": "Whether or not to include triggering tags into notification title",
"type": "boolean",
"insertionOrder": false,
"default": true
},
"Locked": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"properties": {
"DatadogCredentials": {
"$ref": "#/definitions/DatadogCredentials"
},
"TagResourceWithStackTags": {
"description": "Copy the Cloudformation Stack tags to the datadog monitor. It defaults to false to stay backwards compatible.",
"type": "boolean"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -91,6 +87,7 @@
"IncludeTags": {
"description": "Whether or not to include triggering tags into notification title",
"type": "boolean",
"insertionOrder": false,
"default": true
},
"Locked": {
Expand Down Expand Up @@ -215,7 +212,6 @@
"Tags": {
"description": "Tags associated with the monitor",
"type": "array",
"insertionOrder": false,
"items": {
"type": "string"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ def read_handler(
errorCode=http_to_handler_error_code(e.status),
)

_copy_stack_tags(monitor, request)

model.Created = monitor.created.isoformat()
model.Modified = monitor.modified.isoformat()
model.Message = monitor.message
Expand Down Expand Up @@ -169,7 +167,6 @@ def update_handler(
monitor.name = model.Name
if model.Tags is not None:
monitor.tags = model.Tags
_copy_stack_tags(monitor, request)
if model.Priority is not None:
monitor.priority = model.Priority
if model.RestrictedRoles is not None:
Expand Down Expand Up @@ -252,7 +249,6 @@ def create_handler(
monitor.name = model.Name
if model.Tags is not None:
monitor.tags = model.Tags
_copy_stack_tags(monitor, request)
if model.Priority is not None:
monitor.priority = model.Priority
if model.RestrictedRoles is not None:
Expand Down Expand Up @@ -337,17 +333,3 @@ def build_monitor_options_from_model(model: ResourceModel) -> ApiMonitorOptions:
options.threshold_windows.recovery_window = model.Options.ThresholdWindows.RecoveryWindow

return options


def _copy_stack_tags(monitor: ApiMonitor, request: ResourceHandlerRequest):
if request.typeConfiguration.TagResourceWithStackTags:
tags_to_copy = dict(**request.systemTags)
if request.desiredResourceTags:
tags_to_copy.update(**request.desiredResourceTags)

monitor.tags = monitor.get("tags", [])
for k, v in tags_to_copy.items():
corrected_k = k.replace(':', '_')
if any(tag.startswith(f"{corrected_k}:") for tag in monitor.tags):
continue
monitor.tags.append(f"{corrected_k}:{v}")
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def _deserialize(
@dataclass
class TypeConfigurationModel(BaseModel):
DatadogCredentials: Optional["_DatadogCredentials"]
TagResourceWithStackTags: Optional[bool]

@classmethod
def _deserialize(
Expand All @@ -232,7 +231,6 @@ def _deserialize(
return None
return cls(
DatadogCredentials=DatadogCredentials._deserialize(json_data.get("DatadogCredentials")),
TagResourceWithStackTags=json_data.get("TagResourceWithStackTags"),
)


Expand Down

0 comments on commit 749b7a7

Please sign in to comment.