Skip to content

Commit

Permalink
chore: inline Cloudwatch.filter
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Jul 3, 2023
1 parent 4ae4cdf commit 2dbc3a8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 69 deletions.
16 changes: 8 additions & 8 deletions api/v1/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func (c S3Check) GetType() string {
}

type CloudWatchCheck struct {
Description `yaml:",inline" json:",inline"`
AWSConnection `yaml:",inline" json:",inline"`
Templatable `yaml:",inline" json:",inline"`
Filter CloudWatchFilter `yaml:",inline" json:",inline"`
Description `yaml:",inline" json:",inline"`
AWSConnection `yaml:",inline" json:",inline"`
Templatable `yaml:",inline" json:",inline"`
CloudWatchFilter `yaml:",inline" json:",inline"`
}

type CloudWatchFilter struct {
Expand All @@ -159,11 +159,11 @@ type CloudWatchFilter struct {

func (c CloudWatchCheck) GetEndpoint() string {
endpoint := c.Region
if c.Filter.ActionPrefix != nil {
endpoint += "-" + *c.Filter.ActionPrefix
if c.CloudWatchFilter.ActionPrefix != nil {
endpoint += "-" + *c.CloudWatchFilter.ActionPrefix
}
if c.Filter.AlarmPrefix != nil {
endpoint += "-" + *c.Filter.AlarmPrefix
if c.CloudWatchFilter.AlarmPrefix != nil {
endpoint += "-" + *c.CloudWatchFilter.AlarmPrefix
}
return endpoint
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions checks/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func (c *CloudWatchChecker) Check(ctx *context.Context, extConfig external.Check
client := cloudwatch.NewFromConfig(*cfg)
maxRecords := int32(100)
alarms, err := client.DescribeAlarms(ctx, &cloudwatch.DescribeAlarmsInput{
AlarmNames: check.Filter.Alarms,
AlarmNamePrefix: check.Filter.AlarmPrefix,
ActionPrefix: check.Filter.ActionPrefix,
StateValue: types.StateValue(check.Filter.State),
AlarmNames: check.CloudWatchFilter.Alarms,
AlarmNamePrefix: check.CloudWatchFilter.AlarmPrefix,
ActionPrefix: check.CloudWatchFilter.ActionPrefix,
StateValue: types.StateValue(check.CloudWatchFilter.State),
MaxRecords: &maxRecords,
})
if err != nil {
Expand Down
18 changes: 4 additions & 14 deletions config/schemas/canary.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -704,19 +704,6 @@
"transform": {
"$ref": "#/$defs/Template"
},
"Filter": {
"$ref": "#/$defs/CloudWatchFilter"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"Filter"
]
},
"CloudWatchFilter": {
"properties": {
"actionPrefix": {
"type": "string"
},
Expand All @@ -734,7 +721,10 @@
}
},
"additionalProperties": false,
"type": "object"
"type": "object",
"required": [
"name"
]
},
"ConfigDBCheck": {
"properties": {
Expand Down
18 changes: 4 additions & 14 deletions config/schemas/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,19 +610,6 @@
"transform": {
"$ref": "#/$defs/Template"
},
"Filter": {
"$ref": "#/$defs/CloudWatchFilter"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"Filter"
]
},
"CloudWatchFilter": {
"properties": {
"actionPrefix": {
"type": "string"
},
Expand All @@ -640,7 +627,10 @@
}
},
"additionalProperties": false,
"type": "object"
"type": "object",
"required": [
"name"
]
},
"Component": {
"properties": {
Expand Down
18 changes: 4 additions & 14 deletions config/schemas/health_cloudwatch.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@
"transform": {
"$ref": "#/$defs/Template"
},
"Filter": {
"$ref": "#/$defs/CloudWatchFilter"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"Filter"
]
},
"CloudWatchFilter": {
"properties": {
"actionPrefix": {
"type": "string"
},
Expand All @@ -80,7 +67,10 @@
}
},
"additionalProperties": false,
"type": "object"
"type": "object",
"required": [
"name"
]
},
"ConfigMapKeySelector": {
"properties": {
Expand Down
18 changes: 4 additions & 14 deletions config/schemas/topology.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,19 +610,6 @@
"transform": {
"$ref": "#/$defs/Template"
},
"Filter": {
"$ref": "#/$defs/CloudWatchFilter"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"Filter"
]
},
"CloudWatchFilter": {
"properties": {
"actionPrefix": {
"type": "string"
},
Expand All @@ -640,7 +627,10 @@
}
},
"additionalProperties": false,
"type": "object"
"type": "object",
"required": [
"name"
]
},
"ComponentCheck": {
"properties": {
Expand Down

0 comments on commit 2dbc3a8

Please sign in to comment.