diff --git a/internal/manifest/objects_test.go b/internal/manifest/objects_test.go index 35cd5cef..fdc6545e 100644 --- a/internal/manifest/objects_test.go +++ b/internal/manifest/objects_test.go @@ -5,6 +5,7 @@ import ( "path/filepath" "testing" + "github.com/goccy/go-yaml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -21,9 +22,23 @@ func TestMain(m *testing.M) { func TestObjectExamples(t *testing.T) { moduleRoot := pathutils.FindModuleRoot() - objects, err := sdk.ReadObjects(context.Background(), filepath.Join(moduleRoot, "manifest/**/example*.yaml")) + objects, err := sdk.ReadObjects(context.Background(), + filepath.Join(moduleRoot, "manifest/**/example*.yaml"), + filepath.Join(moduleRoot, "manifest/**/examples/*.yaml"), + ) require.NoError(t, err) - assert.Greater(t, len(objects), 0, "no object examples found") - errs := manifest.Validate(objects) - assert.Empty(t, errs) + assert.NotEmpty(t, objects, "no object examples found") + for i := range objects { + err = objects[i].Validate() + require.NoError(t, err) + // Make sure YAML and JSON are interoperable. + yamlData, err := yaml.Marshal(objects[i]) + require.NoError(t, err) + jsonData, err := yaml.YAMLToJSON(yamlData) + assert.NoError(t, err) + object, err := sdk.DecodeObject[manifest.Object](jsonData) + assert.NoError(t, err) + err = object.Validate() + require.NoError(t, err) + } } diff --git a/internal/manifest/v1alpha/examples/agent.go b/internal/manifest/v1alpha/examples/agent.go index 040fa172..cc654dc6 100644 --- a/internal/manifest/v1alpha/examples/agent.go +++ b/internal/manifest/v1alpha/examples/agent.go @@ -2,6 +2,7 @@ package v1alphaExamples import ( "fmt" + "slices" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha" @@ -14,6 +15,10 @@ type agentExample struct { typ v1alpha.DataSourceType } +func (a agentExample) GetDataSourceType() v1alpha.DataSourceType { + return a.typ +} + func Agent() []Example { types := v1alpha.DataSourceTypeValues() examples := make([]Example, 0, len(types)) @@ -30,6 +35,14 @@ func Agent() []Example { return examples } +var betaChannelAgents = []v1alpha.DataSourceType{ + v1alpha.AzureMonitor, + v1alpha.Honeycomb, + v1alpha.LogicMonitor, + v1alpha.AzurePrometheus, + v1alpha.GCM, +} + func (a agentExample) Generate() v1alphaAgent.Agent { titleName := dataSourceTypePrettyName(a.typ) agent := v1alphaAgent.New( @@ -39,8 +52,7 @@ func (a agentExample) Generate() v1alphaAgent.Agent { Project: sdk.DefaultProject, }, v1alphaAgent.Spec{ - Description: fmt.Sprintf("Example %s Agent", titleName), - ReleaseChannel: v1alpha.ReleaseChannelStable, + Description: fmt.Sprintf("Example %s Agent", titleName), }, ) agent = a.generateVariant(agent) @@ -61,6 +73,11 @@ func (a agentExample) Generate() v1alphaAgent.Agent { Unit: defaultQueryDelay.Unit, }, } + if slices.Contains(betaChannelAgents, typ) { + agent.Spec.ReleaseChannel = v1alpha.ReleaseChannelBeta + } else { + agent.Spec.ReleaseChannel = v1alpha.ReleaseChannelStable + } return agent } diff --git a/internal/manifest/v1alpha/examples/alert_method.go b/internal/manifest/v1alpha/examples/alert_method.go index 37faaca9..51208618 100644 --- a/internal/manifest/v1alpha/examples/alert_method.go +++ b/internal/manifest/v1alpha/examples/alert_method.go @@ -36,7 +36,11 @@ var customAlertMethodsSubVariants = map[v1alpha.AlertMethodType][]alertMethodSpe type alertMethodExample struct { standardExample - methodType v1alpha.AlertMethodType + typ v1alpha.AlertMethodType +} + +func (a alertMethodExample) GetAlertMethodType() v1alpha.AlertMethodType { + return a.typ } func (a alertMethodExample) GetYAMLComments() []string { @@ -54,7 +58,7 @@ func AlertMethod() []Example { standardExample: standardExample{ Variant: typ.String(), }, - methodType: typ, + typ: typ, }) } for typ, subVariants := range customAlertMethodsSubVariants { @@ -64,7 +68,7 @@ func AlertMethod() []Example { Variant: typ.String(), SubVariant: subVariant, }, - methodType: typ, + typ: typ, }) } } @@ -89,7 +93,7 @@ func (a alertMethodExample) Generate() v1alphaAlertMethod.AlertMethod { } func (a alertMethodExample) generateVariant(am v1alphaAlertMethod.AlertMethod) v1alphaAlertMethod.AlertMethod { - switch a.methodType { + switch a.typ { case v1alpha.AlertMethodTypeEmail: am.Spec.Email = &v1alphaAlertMethod.EmailAlertMethod{ To: []string{"alerts-tests@nobl9.com"}, diff --git a/internal/manifest/v1alpha/examples/alert_method_test.go b/internal/manifest/v1alpha/examples/alert_method_test.go index f823b354..45276ac6 100644 --- a/internal/manifest/v1alpha/examples/alert_method_test.go +++ b/internal/manifest/v1alpha/examples/alert_method_test.go @@ -11,7 +11,7 @@ func TestAlertMethod_SupportsAllAlertMethodTypes(t *testing.T) { variants := AlertMethod() for _, methodType := range v1alpha.AlertMethodTypeValues() { if !slices.ContainsFunc(variants, func(e Example) bool { - return e.(alertMethodExample).methodType == methodType + return e.(alertMethodExample).typ == methodType }) { t.Errorf("%T '%s' is not listed in the examples", methodType, methodType) } diff --git a/internal/manifest/v1alpha/examples/direct.go b/internal/manifest/v1alpha/examples/direct.go index e20e7b5f..a3becabb 100644 --- a/internal/manifest/v1alpha/examples/direct.go +++ b/internal/manifest/v1alpha/examples/direct.go @@ -2,6 +2,7 @@ package v1alphaExamples import ( "fmt" + "slices" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha" @@ -14,6 +15,10 @@ type directExample struct { typ v1alpha.DataSourceType } +func (d directExample) GetDataSourceType() v1alpha.DataSourceType { + return d.typ +} + func Direct() []Example { types := v1alpha.DataSourceTypeValues() examples := make([]Example, 0, len(types)) @@ -33,6 +38,13 @@ func Direct() []Example { return examples } +var betaChannelDirects = []v1alpha.DataSourceType{ + v1alpha.AzureMonitor, + v1alpha.Honeycomb, + v1alpha.LogicMonitor, + v1alpha.GoogleCloudMonitoring, +} + func (d directExample) Generate() v1alphaDirect.Direct { titleName := dataSourceTypePrettyName(d.typ) direct := v1alphaDirect.New( @@ -64,6 +76,11 @@ func (d directExample) Generate() v1alphaDirect.Direct { Unit: defaultQueryDelay.Unit, }, } + if slices.Contains(betaChannelDirects, typ) { + direct.Spec.ReleaseChannel = v1alpha.ReleaseChannelBeta + } else { + direct.Spec.ReleaseChannel = v1alpha.ReleaseChannelStable + } return direct } @@ -77,6 +94,7 @@ func (d directExample) generateVariant(direct v1alphaDirect.Direct) v1alphaDirec ClientSecret: "[secret]", } case v1alpha.AzureMonitor: + direct.Spec.ReleaseChannel = v1alpha.ReleaseChannelBeta direct.Spec.AzureMonitor = &v1alphaDirect.AzureMonitorConfig{ TenantID: "5cdecca3-c2c5-4072-89dd-5555faf05202", ClientID: "70747025-9367-41a5-98f1-59b18b5793c3", @@ -106,6 +124,7 @@ func (d directExample) generateVariant(direct v1alphaDirect.Direct) v1alphaDirec ServiceAccountKey: gcloudServiceAccountKey, } case v1alpha.Honeycomb: + direct.Spec.ReleaseChannel = v1alpha.ReleaseChannelBeta direct.Spec.Honeycomb = &v1alphaDirect.HoneycombConfig{ APIKey: "[secret]", } @@ -144,10 +163,8 @@ func (d directExample) generateVariant(direct v1alphaDirect.Direct) v1alphaDirec } case v1alpha.Redshift: direct.Spec.Redshift = &v1alphaDirect.RedshiftConfig{ - AccessKeyID: "AKIA4NPYKXO34R341XUX", - SecretAccessKey: "[secret]", - SecretARN: "arn:aws:secretsmanager:eu-central-1:123456578901:secret:prod-redshift-db-user", - RoleARN: "arn:aws:iam::123456578901:role/awsCrossAccountProdRedshift-prod-app", + SecretARN: "arn:aws:secretsmanager:eu-central-1:123456578901:secret:prod-redshift-db-user", + RoleARN: "arn:aws:iam::123456578901:role/awsCrossAccountProdRedshift-prod-app", } case v1alpha.Splunk: direct.Spec.Splunk = &v1alphaDirect.SplunkConfig{ diff --git a/manifest/v1alpha/agent/examples/amazon-prometheus.yaml b/manifest/v1alpha/agent/examples/amazon-prometheus.yaml index eb854699..b313726c 100644 --- a/manifest/v1alpha/agent/examples/amazon-prometheus.yaml +++ b/manifest/v1alpha/agent/examples/amazon-prometheus.yaml @@ -18,6 +18,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 1 - unit: Second + value: 1 + unit: Second diff --git a/manifest/v1alpha/agent/examples/app-dynamics.yaml b/manifest/v1alpha/agent/examples/app-dynamics.yaml index b969abfc..fe739fa3 100644 --- a/manifest/v1alpha/agent/examples/app-dynamics.yaml +++ b/manifest/v1alpha/agent/examples/app-dynamics.yaml @@ -17,6 +17,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/azure-monitor.yaml b/manifest/v1alpha/agent/examples/azure-monitor.yaml index ba9ce9c0..a1a8ec66 100644 --- a/manifest/v1alpha/agent/examples/azure-monitor.yaml +++ b/manifest/v1alpha/agent/examples/azure-monitor.yaml @@ -6,7 +6,7 @@ metadata: project: default spec: description: Example Azure Monitor Agent - releaseChannel: stable + releaseChannel: beta azureMonitor: tenantId: 5cdecca3-c2c5-4072-89dd-5555faf05202 historicalDataRetrieval: @@ -17,6 +17,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 6 - unit: Minute + value: 6 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/azure-prometheus.yaml b/manifest/v1alpha/agent/examples/azure-prometheus.yaml index 0c79fe94..171431ef 100644 --- a/manifest/v1alpha/agent/examples/azure-prometheus.yaml +++ b/manifest/v1alpha/agent/examples/azure-prometheus.yaml @@ -6,7 +6,7 @@ metadata: project: default spec: description: Example Azure Prometheus Agent - releaseChannel: stable + releaseChannel: beta azurePrometheus: url: https://defaultazuremonitorworkspace-westus2-szxw.westus2.prometheus.monitor.azure.com tenantId: 41372654-f4b6-4bd1-a3fe-75629c024df1 @@ -18,6 +18,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 1 - unit: Second + value: 1 + unit: Second diff --git a/manifest/v1alpha/agent/examples/big-query.yaml b/manifest/v1alpha/agent/examples/big-query.yaml index 78753170..21e3d1ff 100644 --- a/manifest/v1alpha/agent/examples/big-query.yaml +++ b/manifest/v1alpha/agent/examples/big-query.yaml @@ -9,6 +9,5 @@ spec: releaseChannel: stable bigQuery: {} queryDelay: - duration: - value: 1 - unit: Second + value: 1 + unit: Second diff --git a/manifest/v1alpha/agent/examples/cloud-watch.yaml b/manifest/v1alpha/agent/examples/cloud-watch.yaml index b7b23155..ecf74252 100644 --- a/manifest/v1alpha/agent/examples/cloud-watch.yaml +++ b/manifest/v1alpha/agent/examples/cloud-watch.yaml @@ -16,6 +16,5 @@ spec: value: 7 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/datadog.yaml b/manifest/v1alpha/agent/examples/datadog.yaml index 53a8e63e..88862514 100644 --- a/manifest/v1alpha/agent/examples/datadog.yaml +++ b/manifest/v1alpha/agent/examples/datadog.yaml @@ -17,6 +17,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/dynatrace.yaml b/manifest/v1alpha/agent/examples/dynatrace.yaml index 2c44f84f..7eab1e5d 100644 --- a/manifest/v1alpha/agent/examples/dynatrace.yaml +++ b/manifest/v1alpha/agent/examples/dynatrace.yaml @@ -17,6 +17,5 @@ spec: value: 14 unit: Day queryDelay: - duration: - value: 3 - unit: Minute + value: 3 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/elasticsearch.yaml b/manifest/v1alpha/agent/examples/elasticsearch.yaml index 05727e1f..29814f4b 100644 --- a/manifest/v1alpha/agent/examples/elasticsearch.yaml +++ b/manifest/v1alpha/agent/examples/elasticsearch.yaml @@ -10,6 +10,5 @@ spec: elasticsearch: url: http://elasticsearch-main.elasticsearch:9200 queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/generic.yaml b/manifest/v1alpha/agent/examples/generic.yaml index a96c604e..631e08c5 100644 --- a/manifest/v1alpha/agent/examples/generic.yaml +++ b/manifest/v1alpha/agent/examples/generic.yaml @@ -9,6 +9,5 @@ spec: releaseChannel: stable generic: {} queryDelay: - duration: - value: 1 - unit: Second + value: 1 + unit: Second diff --git a/manifest/v1alpha/agent/examples/google-cloud-monitoring.yaml b/manifest/v1alpha/agent/examples/google-cloud-monitoring.yaml index cca450a0..54fc77bd 100644 --- a/manifest/v1alpha/agent/examples/google-cloud-monitoring.yaml +++ b/manifest/v1alpha/agent/examples/google-cloud-monitoring.yaml @@ -16,6 +16,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 3 - unit: Minute + value: 3 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/grafana-loki.yaml b/manifest/v1alpha/agent/examples/grafana-loki.yaml index dfa57297..f2023318 100644 --- a/manifest/v1alpha/agent/examples/grafana-loki.yaml +++ b/manifest/v1alpha/agent/examples/grafana-loki.yaml @@ -10,6 +10,5 @@ spec: grafanaLoki: url: http://grafana-loki.loki:3100 queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/graphite.yaml b/manifest/v1alpha/agent/examples/graphite.yaml index fe920467..89e94087 100644 --- a/manifest/v1alpha/agent/examples/graphite.yaml +++ b/manifest/v1alpha/agent/examples/graphite.yaml @@ -17,6 +17,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/honeycomb.yaml b/manifest/v1alpha/agent/examples/honeycomb.yaml index 8f3aba32..dd3f2e7f 100644 --- a/manifest/v1alpha/agent/examples/honeycomb.yaml +++ b/manifest/v1alpha/agent/examples/honeycomb.yaml @@ -6,7 +6,7 @@ metadata: project: default spec: description: Example Honeycomb Agent - releaseChannel: stable + releaseChannel: beta honeycomb: {} historicalDataRetrieval: maxDuration: @@ -16,6 +16,5 @@ spec: value: 3 unit: Day queryDelay: - duration: - value: 6 - unit: Minute + value: 6 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/influx-d-b.yaml b/manifest/v1alpha/agent/examples/influx-d-b.yaml index 6d3ecc26..02369cca 100644 --- a/manifest/v1alpha/agent/examples/influx-d-b.yaml +++ b/manifest/v1alpha/agent/examples/influx-d-b.yaml @@ -10,6 +10,5 @@ spec: influxdb: url: https://us-west-2-2.aws.cloud2.influxdata.com queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/instana.yaml b/manifest/v1alpha/agent/examples/instana.yaml index a6437549..06239f81 100644 --- a/manifest/v1alpha/agent/examples/instana.yaml +++ b/manifest/v1alpha/agent/examples/instana.yaml @@ -10,6 +10,5 @@ spec: instana: url: https://orange-my-org12.instana.io queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/lightstep.yaml b/manifest/v1alpha/agent/examples/lightstep.yaml index 9e8040a3..7e5718e0 100644 --- a/manifest/v1alpha/agent/examples/lightstep.yaml +++ b/manifest/v1alpha/agent/examples/lightstep.yaml @@ -19,6 +19,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 3 - unit: Minute + value: 3 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/logic-monitor.yaml b/manifest/v1alpha/agent/examples/logic-monitor.yaml index a3790738..fd5efe02 100644 --- a/manifest/v1alpha/agent/examples/logic-monitor.yaml +++ b/manifest/v1alpha/agent/examples/logic-monitor.yaml @@ -6,10 +6,9 @@ metadata: project: default spec: description: Example LogicMonitor Agent - releaseChannel: stable + releaseChannel: beta logicMonitor: account: my-account-name queryDelay: - duration: - value: 3 - unit: Minute + value: 3 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/new-relic.yaml b/manifest/v1alpha/agent/examples/new-relic.yaml index 02d94f2c..a0362d60 100644 --- a/manifest/v1alpha/agent/examples/new-relic.yaml +++ b/manifest/v1alpha/agent/examples/new-relic.yaml @@ -17,6 +17,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/open-t-s-d-b.yaml b/manifest/v1alpha/agent/examples/open-t-s-d-b.yaml index 374c0290..9fe731cf 100644 --- a/manifest/v1alpha/agent/examples/open-t-s-d-b.yaml +++ b/manifest/v1alpha/agent/examples/open-t-s-d-b.yaml @@ -10,6 +10,5 @@ spec: opentsdb: url: http://opentsdb.opentsdb:4242 queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/pingdom.yaml b/manifest/v1alpha/agent/examples/pingdom.yaml index d3f01652..2e45632c 100644 --- a/manifest/v1alpha/agent/examples/pingdom.yaml +++ b/manifest/v1alpha/agent/examples/pingdom.yaml @@ -9,6 +9,5 @@ spec: releaseChannel: stable pingdom: {} queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/prometheus.yaml b/manifest/v1alpha/agent/examples/prometheus.yaml index 0082c3f3..e2b5645a 100644 --- a/manifest/v1alpha/agent/examples/prometheus.yaml +++ b/manifest/v1alpha/agent/examples/prometheus.yaml @@ -17,6 +17,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 1 - unit: Second + value: 1 + unit: Second diff --git a/manifest/v1alpha/agent/examples/redshift.yaml b/manifest/v1alpha/agent/examples/redshift.yaml index bb30b821..aefec5fb 100644 --- a/manifest/v1alpha/agent/examples/redshift.yaml +++ b/manifest/v1alpha/agent/examples/redshift.yaml @@ -9,6 +9,5 @@ spec: releaseChannel: stable redshift: {} queryDelay: - duration: - value: 31 - unit: Second + value: 31 + unit: Second diff --git a/manifest/v1alpha/agent/examples/splunk-observability.yaml b/manifest/v1alpha/agent/examples/splunk-observability.yaml index 4af30261..21c93cd4 100644 --- a/manifest/v1alpha/agent/examples/splunk-observability.yaml +++ b/manifest/v1alpha/agent/examples/splunk-observability.yaml @@ -10,6 +10,5 @@ spec: splunkObservability: realm: us1 queryDelay: - duration: - value: 6 - unit: Minute + value: 6 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/splunk.yaml b/manifest/v1alpha/agent/examples/splunk.yaml index db4196cf..36ccff33 100644 --- a/manifest/v1alpha/agent/examples/splunk.yaml +++ b/manifest/v1alpha/agent/examples/splunk.yaml @@ -17,6 +17,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 6 - unit: Minute + value: 6 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/sumo-logic.yaml b/manifest/v1alpha/agent/examples/sumo-logic.yaml index 4b8bfe86..419e2f76 100644 --- a/manifest/v1alpha/agent/examples/sumo-logic.yaml +++ b/manifest/v1alpha/agent/examples/sumo-logic.yaml @@ -10,6 +10,5 @@ spec: sumoLogic: url: https://service.sumologic.com queryDelay: - duration: - value: 5 - unit: Minute + value: 5 + unit: Minute diff --git a/manifest/v1alpha/agent/examples/thousand-eyes.yaml b/manifest/v1alpha/agent/examples/thousand-eyes.yaml index 6cd163d9..06fcf1f1 100644 --- a/manifest/v1alpha/agent/examples/thousand-eyes.yaml +++ b/manifest/v1alpha/agent/examples/thousand-eyes.yaml @@ -9,6 +9,5 @@ spec: releaseChannel: stable thousandEyes: {} queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/data_sources.go b/manifest/v1alpha/data_sources.go index 517f4cd7..c96cf478 100644 --- a/manifest/v1alpha/data_sources.go +++ b/manifest/v1alpha/data_sources.go @@ -107,20 +107,20 @@ var defaultDataRetrievalDurationValidation = validation.NewSingleRule( }) type Interval struct { - Duration + Duration `yaml:",inline"` } type Jitter struct { - Duration + Duration `yaml:",inline"` } type Timeout struct { - Duration + Duration `yaml:",inline"` } type QueryDelay struct { MinimumAgentVersion string `json:"minimumAgentVersion,omitempty"` - Duration + Duration `yaml:",inline"` } var maxQueryDelay = Duration{ diff --git a/manifest/v1alpha/direct/examples/app-dynamics.yaml b/manifest/v1alpha/direct/examples/app-dynamics.yaml index 62a6b329..c1b963f4 100644 --- a/manifest/v1alpha/direct/examples/app-dynamics.yaml +++ b/manifest/v1alpha/direct/examples/app-dynamics.yaml @@ -21,6 +21,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/azure-monitor.yaml b/manifest/v1alpha/direct/examples/azure-monitor.yaml index 81a70f6b..fa40fd6f 100644 --- a/manifest/v1alpha/direct/examples/azure-monitor.yaml +++ b/manifest/v1alpha/direct/examples/azure-monitor.yaml @@ -6,7 +6,7 @@ metadata: project: default spec: description: Example Azure Monitor Direct - releaseChannel: stable + releaseChannel: beta azureMonitor: tenantId: 5cdecca3-c2c5-4072-89dd-5555faf05202 clientId: 70747025-9367-41a5-98f1-59b18b5793c3 @@ -19,6 +19,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 6 - unit: Minute + value: 6 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/big-query.yaml b/manifest/v1alpha/direct/examples/big-query.yaml index 27d69a70..6c8abfa5 100644 --- a/manifest/v1alpha/direct/examples/big-query.yaml +++ b/manifest/v1alpha/direct/examples/big-query.yaml @@ -10,6 +10,5 @@ spec: bigQuery: serviceAccountKey: "{\n \"type\": \"service_account\",\n \"project_id\": \"prod-app\",\n \"private_key_id\": \"669180ba44964eddba9e2f6623721381\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nSECRET_KEY_GOES_HERE\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"nobl9@nobl9.iam.gserviceaccount.com\",\n \"client_id\": \"eddba9e2f66237213812\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://oauth2.googleapis.com/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/nobl9%40nobl9.iam.gserviceaccount.com\"\n}" queryDelay: - duration: - value: 1 - unit: Second + value: 1 + unit: Second diff --git a/manifest/v1alpha/direct/examples/cloud-watch.yaml b/manifest/v1alpha/direct/examples/cloud-watch.yaml index ccf7589f..a84b018c 100644 --- a/manifest/v1alpha/direct/examples/cloud-watch.yaml +++ b/manifest/v1alpha/direct/examples/cloud-watch.yaml @@ -17,6 +17,5 @@ spec: value: 7 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/datadog.yaml b/manifest/v1alpha/direct/examples/datadog.yaml index d5d8d647..71de31ca 100644 --- a/manifest/v1alpha/direct/examples/datadog.yaml +++ b/manifest/v1alpha/direct/examples/datadog.yaml @@ -19,6 +19,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/dynatrace.yaml b/manifest/v1alpha/direct/examples/dynatrace.yaml index 52e225b2..52e0235d 100644 --- a/manifest/v1alpha/direct/examples/dynatrace.yaml +++ b/manifest/v1alpha/direct/examples/dynatrace.yaml @@ -18,6 +18,5 @@ spec: value: 14 unit: Day queryDelay: - duration: - value: 3 - unit: Minute + value: 3 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/google-cloud-monitoring.yaml b/manifest/v1alpha/direct/examples/google-cloud-monitoring.yaml index 80bb9ef6..1d5dac2c 100644 --- a/manifest/v1alpha/direct/examples/google-cloud-monitoring.yaml +++ b/manifest/v1alpha/direct/examples/google-cloud-monitoring.yaml @@ -17,6 +17,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 3 - unit: Minute + value: 3 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/honeycomb.yaml b/manifest/v1alpha/direct/examples/honeycomb.yaml index 8b771c2a..d2d32289 100644 --- a/manifest/v1alpha/direct/examples/honeycomb.yaml +++ b/manifest/v1alpha/direct/examples/honeycomb.yaml @@ -6,7 +6,7 @@ metadata: project: default spec: description: Example Honeycomb Direct - releaseChannel: stable + releaseChannel: beta honeycomb: apiKey: "[secret]" historicalDataRetrieval: @@ -17,6 +17,5 @@ spec: value: 3 unit: Day queryDelay: - duration: - value: 6 - unit: Minute + value: 6 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/influx-d-b.yaml b/manifest/v1alpha/direct/examples/influx-d-b.yaml index 932adc5a..75b7ee5f 100644 --- a/manifest/v1alpha/direct/examples/influx-d-b.yaml +++ b/manifest/v1alpha/direct/examples/influx-d-b.yaml @@ -12,6 +12,5 @@ spec: apiToken: "[secret]" organizationID: my-org queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/instana.yaml b/manifest/v1alpha/direct/examples/instana.yaml index e0c388ee..04d7ca5c 100644 --- a/manifest/v1alpha/direct/examples/instana.yaml +++ b/manifest/v1alpha/direct/examples/instana.yaml @@ -11,6 +11,5 @@ spec: apiToken: "[secret]" url: https://orange-my-org12.instana.io queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/lightstep.yaml b/manifest/v1alpha/direct/examples/lightstep.yaml index 1d2a3908..14491c33 100644 --- a/manifest/v1alpha/direct/examples/lightstep.yaml +++ b/manifest/v1alpha/direct/examples/lightstep.yaml @@ -20,6 +20,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 3 - unit: Minute + value: 3 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/logic-monitor.yaml b/manifest/v1alpha/direct/examples/logic-monitor.yaml index 5d1d7d90..d2fd1d7f 100644 --- a/manifest/v1alpha/direct/examples/logic-monitor.yaml +++ b/manifest/v1alpha/direct/examples/logic-monitor.yaml @@ -6,12 +6,11 @@ metadata: project: default spec: description: Example LogicMonitor Direct - releaseChannel: stable + releaseChannel: beta logicMonitor: account: my-account-name accessId: 9xA2BssShK21ld9LoOYu accessKey: "[secret]" queryDelay: - duration: - value: 3 - unit: Minute + value: 3 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/new-relic.yaml b/manifest/v1alpha/direct/examples/new-relic.yaml index 259de8ca..5c143b11 100644 --- a/manifest/v1alpha/direct/examples/new-relic.yaml +++ b/manifest/v1alpha/direct/examples/new-relic.yaml @@ -18,6 +18,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/pingdom.yaml b/manifest/v1alpha/direct/examples/pingdom.yaml index 99c464e4..f8cd7a68 100644 --- a/manifest/v1alpha/direct/examples/pingdom.yaml +++ b/manifest/v1alpha/direct/examples/pingdom.yaml @@ -10,6 +10,5 @@ spec: pingdom: apiToken: "[secret]" queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/redshift.yaml b/manifest/v1alpha/direct/examples/redshift.yaml index c1371e60..946d0e18 100644 --- a/manifest/v1alpha/direct/examples/redshift.yaml +++ b/manifest/v1alpha/direct/examples/redshift.yaml @@ -8,11 +8,8 @@ spec: description: Example Redshift Direct releaseChannel: stable redshift: - accessKeyID: AKIA4NPYKXO34R341XUX - secretAccessKey: "[secret]" secretARN: arn:aws:secretsmanager:eu-central-1:123456578901:secret:prod-redshift-db-user roleARN: arn:aws:iam::123456578901:role/awsCrossAccountProdRedshift-prod-app queryDelay: - duration: - value: 31 - unit: Second + value: 31 + unit: Second diff --git a/manifest/v1alpha/direct/examples/splunk-observability.yaml b/manifest/v1alpha/direct/examples/splunk-observability.yaml index 198ecf3d..78a5d5a6 100644 --- a/manifest/v1alpha/direct/examples/splunk-observability.yaml +++ b/manifest/v1alpha/direct/examples/splunk-observability.yaml @@ -11,6 +11,5 @@ spec: realm: us1 accessToken: "[secret]" queryDelay: - duration: - value: 6 - unit: Minute + value: 6 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/splunk.yaml b/manifest/v1alpha/direct/examples/splunk.yaml index dbf8deee..3edd492e 100644 --- a/manifest/v1alpha/direct/examples/splunk.yaml +++ b/manifest/v1alpha/direct/examples/splunk.yaml @@ -18,6 +18,5 @@ spec: value: 15 unit: Day queryDelay: - duration: - value: 6 - unit: Minute + value: 6 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/sumo-logic.yaml b/manifest/v1alpha/direct/examples/sumo-logic.yaml index a3ea20f7..2c8a8e6f 100644 --- a/manifest/v1alpha/direct/examples/sumo-logic.yaml +++ b/manifest/v1alpha/direct/examples/sumo-logic.yaml @@ -12,6 +12,5 @@ spec: accessKey: "[secret]" url: https://service.sumologic.com queryDelay: - duration: - value: 5 - unit: Minute + value: 5 + unit: Minute diff --git a/manifest/v1alpha/direct/examples/thousand-eyes.yaml b/manifest/v1alpha/direct/examples/thousand-eyes.yaml index b9b5177b..40ab54a0 100644 --- a/manifest/v1alpha/direct/examples/thousand-eyes.yaml +++ b/manifest/v1alpha/direct/examples/thousand-eyes.yaml @@ -10,6 +10,5 @@ spec: thousandEyes: oauthBearerToken: "[secret]" queryDelay: - duration: - value: 2 - unit: Minute + value: 2 + unit: Minute diff --git a/tests/examples_test.go b/tests/examples_test.go index afd01793..fb121691 100644 --- a/tests/examples_test.go +++ b/tests/examples_test.go @@ -51,7 +51,9 @@ var examplesRegistry = func() map[manifest.Kind][]exampleWrapper { return wrapped }() -func getExample[T any](t *testing.T, kind manifest.Kind, variant, subVariant string) *T { +type examplesFilter = func(example v1alphaExamples.Example) bool + +func getExample[T any](t *testing.T, kind manifest.Kind, filter examplesFilter) *T { t.Helper() examples, ok := examplesRegistry[kind] if !ok { @@ -64,13 +66,14 @@ func getExample[T any](t *testing.T, kind manifest.Kind, variant, subVariant str } return &object } - if variant == "" && subVariant == "" { + if filter == nil { return decode(examples[0].rawObject) } for _, example := range examples { - if example.GetVariant() == variant && (subVariant == "" || example.GetSubVariant() == subVariant) { + if filter(example.Example) { return decode(example.rawObject) } } + t.Fatalf("example not found for kind %s", kind) return nil } diff --git a/tests/v1alpha_agent_test.go b/tests/v1alpha_agent_test.go new file mode 100644 index 00000000..aad4c428 --- /dev/null +++ b/tests/v1alpha_agent_test.go @@ -0,0 +1,138 @@ +//go:build e2e_test + +package tests + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + v1alphaExamples "github.com/nobl9/nobl9-go/internal/manifest/v1alpha/examples" + "github.com/nobl9/nobl9-go/manifest" + "github.com/nobl9/nobl9-go/manifest/v1alpha" + v1alphaAgent "github.com/nobl9/nobl9-go/manifest/v1alpha/agent" + "github.com/nobl9/nobl9-go/sdk" + objectsV1 "github.com/nobl9/nobl9-go/sdk/endpoints/objects/v1" +) + +func Test_Objects_V1_V1alpha_Agent(t *testing.T) { + t.Parallel() + ctx := context.Background() + project := generateV1alphaProject(t) + agentTypes := v1alpha.DataSourceTypeValues() + allObjects := make([]manifest.Object, 0, len(agentTypes)+1) + allObjects = append(allObjects, project) + + for i, typ := range agentTypes { + agent := newV1alphaAgent(t, + typ, + v1alphaAgent.Metadata{ + Name: generateName(), + DisplayName: fmt.Sprintf("Agent %d", i), + Project: project.GetName(), + }, + ) + if i == 0 { + agent.Metadata.Project = defaultProject + } + allObjects = append(allObjects, agent) + } + + v1Apply(t, ctx, allObjects[:2]) + // Since we can only apply a single Agent per request, we need to split the applies. + for _, obj := range allObjects[2:] { + v1Apply(t, ctx, []manifest.Object{obj}) + } + t.Cleanup(func() { + // Since we can only apply a single Agent per request, we need to split the applies. + for _, obj := range allObjects[2:] { + v1Delete(t, ctx, []manifest.Object{obj}) + } + v1Delete(t, ctx, allObjects[:2]) + }) + inputs := manifest.FilterByKind[v1alphaAgent.Agent](allObjects) + + filterTests := map[string]struct { + request objectsV1.GetAgentsRequest + expected []v1alphaAgent.Agent + returnsAll bool + }{ + "all": { + request: objectsV1.GetAgentsRequest{Project: sdk.ProjectsWildcard}, + expected: inputs, + returnsAll: true, + }, + "default project": { + request: objectsV1.GetAgentsRequest{}, + expected: []v1alphaAgent.Agent{inputs[0]}, + returnsAll: true, + }, + "filter by project": { + request: objectsV1.GetAgentsRequest{ + Project: project.GetName(), + }, + expected: inputs[1:], + }, + "filter by name": { + request: objectsV1.GetAgentsRequest{ + Project: project.GetName(), + Names: []string{inputs[3].Metadata.Name}, + }, + expected: []v1alphaAgent.Agent{inputs[3]}, + }, + } + for name, test := range filterTests { + t.Run(name, func(t *testing.T) { + t.Parallel() + actual, err := client.Objects().V1().GetV1alphaAgents(ctx, test.request) + require.NoError(t, err) + if !test.returnsAll { + require.Len(t, actual, len(test.expected)) + } + assertSubset(t, actual, test.expected, assertV1alphaAgentsAreEqual) + }) + } +} + +type dataSourceTypeGetter interface { + GetDataSourceType() v1alpha.DataSourceType +} + +func newV1alphaAgent( + t *testing.T, + typ v1alpha.DataSourceType, + metadata v1alphaAgent.Metadata, +) v1alphaAgent.Agent { + t.Helper() + variant := getExample[v1alphaAgent.Agent](t, + manifest.KindAgent, + func(example v1alphaExamples.Example) bool { + return example.(dataSourceTypeGetter).GetDataSourceType() == typ + }, + ) + variant.Spec.Description = objectDescription + return v1alphaAgent.New(metadata, variant.Spec) +} + +func assertV1alphaAgentsAreEqual(t *testing.T, expected, actual v1alphaAgent.Agent) { + t.Helper() + assert.NotNil(t, actual.Status) + typ, _ := expected.Spec.GetType() + assert.Equal(t, typ.String(), actual.Status.AgentType) + actual.Status = nil + actual.Spec.Interval = nil + actual.Spec.Timeout = nil + actual.Spec.Jitter = nil + if expected.Spec.HistoricalDataRetrieval != nil { + assert.NotEmpty(t, actual.Spec.HistoricalDataRetrieval.MinimumAgentVersion) + actual.Spec.HistoricalDataRetrieval.MinimumAgentVersion = "" + } + assert.NotEmpty(t, actual.Spec.QueryDelay.MinimumAgentVersion) + actual.Spec.QueryDelay.MinimumAgentVersion = "" + assert.NotEmpty(t, actual.OktaClientID) + actual.OktaClientID = "" + assert.Equal(t, expected, actual) +} diff --git a/tests/v1alpha_alertmethod_test.go b/tests/v1alpha_alertmethod_test.go index 8126ea4b..26182ff2 100644 --- a/tests/v1alpha_alertmethod_test.go +++ b/tests/v1alpha_alertmethod_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + v1alphaExamples "github.com/nobl9/nobl9-go/internal/manifest/v1alpha/examples" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha" v1alphaAlertMethod "github.com/nobl9/nobl9-go/manifest/v1alpha/alertmethod" @@ -25,7 +26,7 @@ func Test_Objects_V1_V1alpha_AlertMethod(t *testing.T) { allObjects := make([]manifest.Object, 0, len(alertMethodTypes)+1) allObjects = append(allObjects, project) - for i, typ := range v1alpha.AlertMethodTypeValues() { + for i, typ := range alertMethodTypes { method := newV1alphaAlertMethod(t, typ, v1alphaAlertMethod.Metadata{ @@ -92,7 +93,14 @@ func newV1alphaAlertMethod( metadata v1alphaAlertMethod.Metadata, ) v1alphaAlertMethod.AlertMethod { t.Helper() - variant := getExample[v1alphaAlertMethod.AlertMethod](t, manifest.KindAlertMethod, typ.String(), "") + variant := getExample[v1alphaAlertMethod.AlertMethod](t, + manifest.KindAlertMethod, + func(example v1alphaExamples.Example) bool { + return example.(interface { + GetAlertMethodType() v1alpha.AlertMethodType + }).GetAlertMethodType() == typ + }, + ) variant.Spec.Description = objectDescription return v1alphaAlertMethod.New(metadata, variant.Spec) } diff --git a/tests/v1alpha_alertpolicy_test.go b/tests/v1alpha_alertpolicy_test.go index 3c5c7146..dc8a3597 100644 --- a/tests/v1alpha_alertpolicy_test.go +++ b/tests/v1alpha_alertpolicy_test.go @@ -139,7 +139,12 @@ func newV1alphaAlertPolicy( t.Helper() metadata.Labels = annotateLabels(t, metadata.Labels) metadata.Annotations = commonAnnotations - ap := getExample[v1alphaAlertPolicy.AlertPolicy](t, manifest.KindAlertPolicy, variant, subVariant) + ap := getExample[v1alphaAlertPolicy.AlertPolicy](t, + manifest.KindAlertPolicy, + func(example v1alphaExamples.Example) bool { + return example.GetVariant() == variant && example.GetSubVariant() == subVariant + }, + ) ap.Spec.Description = objectDescription return v1alphaAlertPolicy.New(metadata, ap.Spec) } diff --git a/tests/v1alpha_direct_test.go b/tests/v1alpha_direct_test.go new file mode 100644 index 00000000..1e5ab144 --- /dev/null +++ b/tests/v1alpha_direct_test.go @@ -0,0 +1,169 @@ +//go:build e2e_test + +package tests + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + v1alphaExamples "github.com/nobl9/nobl9-go/internal/manifest/v1alpha/examples" + "github.com/nobl9/nobl9-go/manifest" + "github.com/nobl9/nobl9-go/manifest/v1alpha" + v1alphaDirect "github.com/nobl9/nobl9-go/manifest/v1alpha/direct" + "github.com/nobl9/nobl9-go/sdk" + objectsV1 "github.com/nobl9/nobl9-go/sdk/endpoints/objects/v1" +) + +func Test_Objects_V1_V1alpha_Direct(t *testing.T) { + t.Parallel() + ctx := context.Background() + project := generateV1alphaProject(t) + directTypes := filterSlice(v1alpha.DataSourceTypeValues(), func(typ v1alpha.DataSourceType) bool { + return v1alphaDirect.IsValidDirectType(typ) + }) + allObjects := make([]manifest.Object, 0, len(directTypes)+1) + allObjects = append(allObjects, project) + + for i, typ := range directTypes { + direct := newV1alphaDirect(t, + typ, + v1alphaDirect.Metadata{ + Name: generateName(), + DisplayName: fmt.Sprintf("Direct %d", i), + Project: project.GetName(), + }, + ) + if i == 0 { + direct.Metadata.Project = defaultProject + } + allObjects = append(allObjects, direct) + } + + v1Apply(t, ctx, allObjects) + t.Cleanup(func() { v1Delete(t, ctx, allObjects) }) + inputs := manifest.FilterByKind[v1alphaDirect.Direct](allObjects) + + filterTests := map[string]struct { + request objectsV1.GetDirectsRequest + expected []v1alphaDirect.Direct + returnsAll bool + }{ + "all": { + request: objectsV1.GetDirectsRequest{Project: sdk.ProjectsWildcard}, + expected: inputs, + returnsAll: true, + }, + "default project": { + request: objectsV1.GetDirectsRequest{}, + expected: []v1alphaDirect.Direct{inputs[0]}, + returnsAll: true, + }, + "filter by project": { + request: objectsV1.GetDirectsRequest{ + Project: project.GetName(), + }, + expected: inputs[1:], + }, + "filter by name": { + request: objectsV1.GetDirectsRequest{ + Project: project.GetName(), + Names: []string{inputs[3].Metadata.Name}, + }, + expected: []v1alphaDirect.Direct{inputs[3]}, + }, + } + for name, test := range filterTests { + t.Run(name, func(t *testing.T) { + t.Parallel() + actual, err := client.Objects().V1().GetV1alphaDirects(ctx, test.request) + require.NoError(t, err) + if !test.returnsAll { + require.Len(t, actual, len(test.expected)) + } + assertSubset(t, actual, test.expected, assertV1alphaDirectsAreEqual) + }) + } +} + +func newV1alphaDirect( + t *testing.T, + typ v1alpha.DataSourceType, + metadata v1alphaDirect.Metadata, +) v1alphaDirect.Direct { + t.Helper() + variant := getExample[v1alphaDirect.Direct](t, + manifest.KindDirect, + func(example v1alphaExamples.Example) bool { + return example.(dataSourceTypeGetter).GetDataSourceType() == typ + }, + ) + variant.Spec.Description = objectDescription + return v1alphaDirect.New(metadata, variant.Spec) +} + +func assertV1alphaDirectsAreEqual(t *testing.T, expected, actual v1alphaDirect.Direct) { + t.Helper() + assert.NotNil(t, actual.Status) + typ, _ := expected.Spec.GetType() + assert.Equal(t, typ.String(), actual.Status.DirectType) + actual.Status = nil + actual.Spec.Interval = nil + actual.Spec.Timeout = nil + actual.Spec.Jitter = nil + + expected = deepCopyObject(t, expected) + switch typ { + case v1alpha.AppDynamics: + apd := expected.Spec.AppDynamics + expected.Spec.AppDynamics.ClientID = fmt.Sprintf("%s@%s", apd.ClientName, apd.AccountName) + expected.Spec.AppDynamics.ClientSecret = "[hidden]" + case v1alpha.AzureMonitor: + expected.Spec.AzureMonitor.ClientSecret = "[hidden]" + expected.Spec.AzureMonitor.ClientID = "[hidden]" + case v1alpha.BigQuery: + expected.Spec.BigQuery.ServiceAccountKey = "[hidden]" + case v1alpha.CloudWatch: + expected.Spec.CloudWatch.RoleARN = "[hidden]" + case v1alpha.Datadog: + expected.Spec.Datadog.APIKey = "[hidden]" + expected.Spec.Datadog.ApplicationKey = "[hidden]" + case v1alpha.Dynatrace: + expected.Spec.Dynatrace.DynatraceToken = "[hidden]" + case v1alpha.GCM: + expected.Spec.GCM.ServiceAccountKey = "[hidden]" + case v1alpha.Honeycomb: + expected.Spec.Honeycomb.APIKey = "[hidden]" + case v1alpha.InfluxDB: + expected.Spec.InfluxDB.APIToken = "[hidden]" + expected.Spec.InfluxDB.OrganizationID = "[hidden]" + case v1alpha.Instana: + expected.Spec.Instana.APIToken = "[hidden]" + case v1alpha.Lightstep: + expected.Spec.Lightstep.AppToken = "[hidden]" + case v1alpha.LogicMonitor: + expected.Spec.LogicMonitor.AccessID = "[hidden]" + expected.Spec.LogicMonitor.AccessKey = "[hidden]" + case v1alpha.NewRelic: + expected.Spec.NewRelic.InsightsQueryKey = "[hidden]" + case v1alpha.Pingdom: + expected.Spec.Pingdom.APIToken = "[hidden]" + case v1alpha.Redshift: + expected.Spec.Redshift.RoleARN = "[hidden]" + case v1alpha.Splunk: + expected.Spec.Splunk.AccessToken = "[hidden]" + case v1alpha.SplunkObservability: + expected.Spec.SplunkObservability.AccessToken = "[hidden]" + case v1alpha.SumoLogic: + expected.Spec.SumoLogic.AccessID = "[hidden]" + expected.Spec.SumoLogic.AccessKey = "[hidden]" + case v1alpha.ThousandEyes: + expected.Spec.ThousandEyes.OauthBearerToken = "[hidden]" + default: + panic(fmt.Sprintf("unexpected v1alpha.DataSourceType: %#v", typ)) + } + assert.Equal(t, expected, actual) +} diff --git a/tests/v1alpha_project_test.go b/tests/v1alpha_project_test.go index 1004c50d..9f61cca5 100644 --- a/tests/v1alpha_project_test.go +++ b/tests/v1alpha_project_test.go @@ -104,7 +104,6 @@ func generateV1alphaProject(t *testing.T) v1alphaProject.Project { func assertV1alphaProjectsAreEqual(t *testing.T, expected, actual v1alphaProject.Project) { t.Helper() - expected = deepCopyObject(t, expected) assert.Regexp(t, timeRFC3339Regexp, actual.Spec.CreatedAt) assert.Regexp(t, userIDRegexp, actual.Spec.CreatedBy) actual.Spec.CreatedAt = "" diff --git a/tests/v1alpha_service_test.go b/tests/v1alpha_service_test.go index 048b763d..d61da245 100644 --- a/tests/v1alpha_service_test.go +++ b/tests/v1alpha_service_test.go @@ -137,7 +137,6 @@ func generateV1alphaService(t *testing.T) v1alphaService.Service { func assertV1alphaServicesAreEqual(t *testing.T, expected, actual v1alphaService.Service) { t.Helper() - expected = deepCopyObject(t, expected) assert.NotNil(t, actual.Status) actual.Status = nil assert.Equal(t, expected, actual)