From 2dbc3a8b683425a01895bfa4ae334071b0f40ced Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Mon, 3 Jul 2023 10:02:35 +0300 Subject: [PATCH] chore: inline Cloudwatch.filter --- api/v1/checks.go | 16 ++++++++-------- api/v1/zz_generated.deepcopy.go | 2 +- checks/cloudwatch.go | 8 ++++---- config/schemas/canary.schema.json | 18 ++++-------------- config/schemas/component.schema.json | 18 ++++-------------- config/schemas/health_cloudwatch.schema.json | 18 ++++-------------- config/schemas/topology.schema.json | 18 ++++-------------- 7 files changed, 29 insertions(+), 69 deletions(-) diff --git a/api/v1/checks.go b/api/v1/checks.go index 83f08d338..206a10dc6 100644 --- a/api/v1/checks.go +++ b/api/v1/checks.go @@ -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 { @@ -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 } diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index e8724addd..838328380 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -741,7 +741,7 @@ func (in *CloudWatchCheck) DeepCopyInto(out *CloudWatchCheck) { in.Description.DeepCopyInto(&out.Description) in.AWSConnection.DeepCopyInto(&out.AWSConnection) out.Templatable = in.Templatable - in.Filter.DeepCopyInto(&out.Filter) + in.CloudWatchFilter.DeepCopyInto(&out.CloudWatchFilter) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudWatchCheck. diff --git a/checks/cloudwatch.go b/checks/cloudwatch.go index 2b4a85d45..aeb745aae 100644 --- a/checks/cloudwatch.go +++ b/checks/cloudwatch.go @@ -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 { diff --git a/config/schemas/canary.schema.json b/config/schemas/canary.schema.json index 953269aa0..225d7af56 100644 --- a/config/schemas/canary.schema.json +++ b/config/schemas/canary.schema.json @@ -704,19 +704,6 @@ "transform": { "$ref": "#/$defs/Template" }, - "Filter": { - "$ref": "#/$defs/CloudWatchFilter" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "Filter" - ] - }, - "CloudWatchFilter": { - "properties": { "actionPrefix": { "type": "string" }, @@ -734,7 +721,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "required": [ + "name" + ] }, "ConfigDBCheck": { "properties": { diff --git a/config/schemas/component.schema.json b/config/schemas/component.schema.json index 82b2ca9cd..bb155fe66 100644 --- a/config/schemas/component.schema.json +++ b/config/schemas/component.schema.json @@ -610,19 +610,6 @@ "transform": { "$ref": "#/$defs/Template" }, - "Filter": { - "$ref": "#/$defs/CloudWatchFilter" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "Filter" - ] - }, - "CloudWatchFilter": { - "properties": { "actionPrefix": { "type": "string" }, @@ -640,7 +627,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "required": [ + "name" + ] }, "Component": { "properties": { diff --git a/config/schemas/health_cloudwatch.schema.json b/config/schemas/health_cloudwatch.schema.json index 821187ca1..dac455c88 100644 --- a/config/schemas/health_cloudwatch.schema.json +++ b/config/schemas/health_cloudwatch.schema.json @@ -50,19 +50,6 @@ "transform": { "$ref": "#/$defs/Template" }, - "Filter": { - "$ref": "#/$defs/CloudWatchFilter" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "Filter" - ] - }, - "CloudWatchFilter": { - "properties": { "actionPrefix": { "type": "string" }, @@ -80,7 +67,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "required": [ + "name" + ] }, "ConfigMapKeySelector": { "properties": { diff --git a/config/schemas/topology.schema.json b/config/schemas/topology.schema.json index 480460cd2..2db544f6b 100644 --- a/config/schemas/topology.schema.json +++ b/config/schemas/topology.schema.json @@ -610,19 +610,6 @@ "transform": { "$ref": "#/$defs/Template" }, - "Filter": { - "$ref": "#/$defs/CloudWatchFilter" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "Filter" - ] - }, - "CloudWatchFilter": { - "properties": { "actionPrefix": { "type": "string" }, @@ -640,7 +627,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "required": [ + "name" + ] }, "ComponentCheck": { "properties": {