From 3ee48c4050ac270cbe898220bd46e6488157db45 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:09:56 -0600 Subject: [PATCH] [chore] Add // nolint:staticcheck to unblock release (#33599) Unblocks https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33593 Related to https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 --- connector/datadogconnector/example_test.go | 2 ++ connector/servicegraphconnector/config_test.go | 3 ++- exporter/awss3exporter/config_test.go | 10 ++++++++++ exporter/datadogexporter/examples_test.go | 5 ++++- .../integrationtest/integration_test.go | 2 ++ .../googlemanagedprometheusexporter/config_test.go | 2 ++ .../loadbalancingexporter/metrics_exporter_test.go | 3 ++- exporter/loadbalancingexporter/trace_exporter_test.go | 3 ++- processor/probabilisticsamplerprocessor/config_test.go | 3 ++- processor/sumologicprocessor/config_test.go | 2 ++ receiver/azureblobreceiver/config_test.go | 2 ++ receiver/azureeventhubreceiver/config_test.go | 2 ++ receiver/gitproviderreceiver/config_test.go | 6 ++++++ receiver/hostmetricsreceiver/config_test.go | 6 ++++++ receiver/hostmetricsreceiver/hostmetrics_linux_test.go | 4 ++++ receiver/receivercreator/config_test.go | 4 ++++ receiver/snmpreceiver/integration_test.go | 2 ++ 17 files changed, 56 insertions(+), 5 deletions(-) diff --git a/connector/datadogconnector/example_test.go b/connector/datadogconnector/example_test.go index 13ef46e716f0..444ead06b3ec 100644 --- a/connector/datadogconnector/example_test.go +++ b/connector/datadogconnector/example_test.go @@ -25,6 +25,8 @@ func TestExamples(t *testing.T) { t.Setenv("DD_API_KEY", "testvalue") factories := newTestComponents(t) const configFile = "./examples/config.yaml" + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err := otelcoltest.LoadConfigAndValidate(configFile, factories) require.NoError(t, err, "All yaml config must validate. Please ensure that all necessary component factories are added in newTestComponents()") } diff --git a/connector/servicegraphconnector/config_test.go b/connector/servicegraphconnector/config_test.go index 8357c09535f8..aa98d986c193 100644 --- a/connector/servicegraphconnector/config_test.go +++ b/connector/servicegraphconnector/config_test.go @@ -22,7 +22,8 @@ func TestLoadConfig(t *testing.T) { require.NoError(t, err) factories.Connectors[metadata.Type] = NewFactory() - + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "service-graph-connector-config.yaml"), factories) // Verify diff --git a/exporter/awss3exporter/config_test.go b/exporter/awss3exporter/config_test.go index f9c6011ea7b4..11ba3298ce2c 100644 --- a/exporter/awss3exporter/config_test.go +++ b/exporter/awss3exporter/config_test.go @@ -23,6 +23,8 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() factories.Exporters[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "default.yaml"), factories) require.NoError(t, err) @@ -50,6 +52,8 @@ func TestConfig(t *testing.T) { factory := NewFactory() factories.Exporters[factory.Type()] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate( filepath.Join("testdata", "config.yaml"), factories) @@ -78,6 +82,8 @@ func TestConfigForS3CompatibleSystems(t *testing.T) { factory := NewFactory() factories.Exporters[factory.Type()] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate( filepath.Join("testdata", "config-s3-compatible-systems.yaml"), factories) @@ -189,6 +195,8 @@ func TestMarshallerName(t *testing.T) { factory := NewFactory() factories.Exporters[factory.Type()] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate( filepath.Join("testdata", "marshaler.yaml"), factories) @@ -229,6 +237,8 @@ func TestCompressionName(t *testing.T) { factory := NewFactory() factories.Exporters[factory.Type()] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate( filepath.Join("testdata", "compression.yaml"), factories) diff --git a/exporter/datadogexporter/examples_test.go b/exporter/datadogexporter/examples_test.go index 0da3f50a693d..775d86028b6d 100644 --- a/exporter/datadogexporter/examples_test.go +++ b/exporter/datadogexporter/examples_test.go @@ -55,6 +55,8 @@ func TestExamples(t *testing.T) { t.Run(filepath.Base(f.Name()), func(t *testing.T) { t.Setenv("DD_API_KEY", "testvalue") name := filepath.Join(folder, f.Name()) + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err := otelcoltest.LoadConfigAndValidate(name, factories) require.NoError(t, err, "All yaml config must validate. Please ensure that all necessary component factories are added in newTestComponents()") }) @@ -83,7 +85,8 @@ func TestExamples(t *testing.T) { require.Equal(t, n, len(data)) require.NoError(t, f.Close()) defer os.RemoveAll(f.Name()) - + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err = otelcoltest.LoadConfigAndValidate(f.Name(), factories) require.NoError(t, err, "All yaml config must validate. Please ensure that all necessary component factories are added in newTestComponents()") }) diff --git a/exporter/datadogexporter/integrationtest/integration_test.go b/exporter/datadogexporter/integrationtest/integration_test.go index 7e7fce4b610c..ebb07b2279f4 100644 --- a/exporter/datadogexporter/integrationtest/integration_test.go +++ b/exporter/datadogexporter/integrationtest/integration_test.go @@ -268,6 +268,8 @@ func getIntegrationTestCollector(t *testing.T, cfgStr string, url string, factor require.NoError(t, err) _, err = confFile.Write([]byte(cfg)) require.NoError(t, err) + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err = otelcoltest.LoadConfigAndValidate(confFile.Name(), factories) require.NoError(t, err, "All yaml config must be valid.") diff --git a/exporter/googlemanagedprometheusexporter/config_test.go b/exporter/googlemanagedprometheusexporter/config_test.go index 8e784c25392e..a69c3427777b 100644 --- a/exporter/googlemanagedprometheusexporter/config_test.go +++ b/exporter/googlemanagedprometheusexporter/config_test.go @@ -24,6 +24,8 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() factories.Exporters[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) require.NoError(t, err) diff --git a/exporter/loadbalancingexporter/metrics_exporter_test.go b/exporter/loadbalancingexporter/metrics_exporter_test.go index d965ef7ca1f7..303d1a3a94a1 100644 --- a/exporter/loadbalancingexporter/metrics_exporter_test.go +++ b/exporter/loadbalancingexporter/metrics_exporter_test.go @@ -459,7 +459,8 @@ func TestBuildExporterConfigUnknown(t *testing.T) { require.NoError(t, err) factories.Exporters[metadata.Type] = NewFactory() - + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "test-build-exporter-config.yaml"), factories) require.NoError(t, err) require.NotNil(t, cfg) diff --git a/exporter/loadbalancingexporter/trace_exporter_test.go b/exporter/loadbalancingexporter/trace_exporter_test.go index 56c18db8b5a4..1d39c4befd52 100644 --- a/exporter/loadbalancingexporter/trace_exporter_test.go +++ b/exporter/loadbalancingexporter/trace_exporter_test.go @@ -350,7 +350,8 @@ func TestBuildExporterConfig(t *testing.T) { require.NoError(t, err) factories.Exporters[metadata.Type] = NewFactory() - + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "test-build-exporter-config.yaml"), factories) require.NoError(t, err) require.NotNil(t, cfg) diff --git a/processor/probabilisticsamplerprocessor/config_test.go b/processor/probabilisticsamplerprocessor/config_test.go index 46477ca0c52e..96c6a2005e4d 100644 --- a/processor/probabilisticsamplerprocessor/config_test.go +++ b/processor/probabilisticsamplerprocessor/config_test.go @@ -84,7 +84,8 @@ func TestLoadInvalidConfig(t *testing.T) { factory := NewFactory() factories.Processors[metadata.Type] = factory - + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", test.file), factories) require.ErrorContains(t, err, test.contains) }) diff --git a/processor/sumologicprocessor/config_test.go b/processor/sumologicprocessor/config_test.go index 12d276b0be6a..06e891ea9806 100644 --- a/processor/sumologicprocessor/config_test.go +++ b/processor/sumologicprocessor/config_test.go @@ -21,6 +21,8 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() factories.Processors[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) require.NoError(t, err) diff --git a/receiver/azureblobreceiver/config_test.go b/receiver/azureblobreceiver/config_test.go index 794570532998..b1deb0ef1319 100644 --- a/receiver/azureblobreceiver/config_test.go +++ b/receiver/azureblobreceiver/config_test.go @@ -22,6 +22,8 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) require.NoError(t, err) diff --git a/receiver/azureeventhubreceiver/config_test.go b/receiver/azureeventhubreceiver/config_test.go index 7d4dcf4c546f..4f658844f047 100644 --- a/receiver/azureeventhubreceiver/config_test.go +++ b/receiver/azureeventhubreceiver/config_test.go @@ -21,6 +21,8 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) require.NoError(t, err) diff --git a/receiver/gitproviderreceiver/config_test.go b/receiver/gitproviderreceiver/config_test.go index 748f783feb9f..925423f20924 100644 --- a/receiver/gitproviderreceiver/config_test.go +++ b/receiver/gitproviderreceiver/config_test.go @@ -26,6 +26,8 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) require.NoError(t, err) @@ -61,6 +63,8 @@ func TestLoadInvalidConfig_NoScrapers(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-noscrapers.yaml"), factories) require.Contains(t, err.Error(), "must specify at least one scraper") @@ -72,6 +76,8 @@ func TestLoadInvalidConfig_InvalidScraperKey(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-invalidscraperkey.yaml"), factories) require.Contains(t, err.Error(), "error reading configuration for \"gitprovider\": invalid scraper key: \"invalidscraperkey\"") diff --git a/receiver/hostmetricsreceiver/config_test.go b/receiver/hostmetricsreceiver/config_test.go index e5b1f969eaa4..dff0488c9cdc 100644 --- a/receiver/hostmetricsreceiver/config_test.go +++ b/receiver/hostmetricsreceiver/config_test.go @@ -35,6 +35,8 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) require.NoError(t, err) @@ -127,6 +129,8 @@ func TestLoadInvalidConfig_NoScrapers(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-noscrapers.yaml"), factories) require.Contains(t, err.Error(), "must specify at least one scraper when using hostmetrics receiver") @@ -138,6 +142,8 @@ func TestLoadInvalidConfig_InvalidScraperKey(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-invalidscraperkey.yaml"), factories) require.Contains(t, err.Error(), "error reading configuration for \"hostmetrics\": invalid scraper key: invalidscraperkey") diff --git a/receiver/hostmetricsreceiver/hostmetrics_linux_test.go b/receiver/hostmetricsreceiver/hostmetrics_linux_test.go index 38d614a44c30..3b3758c58db9 100644 --- a/receiver/hostmetricsreceiver/hostmetrics_linux_test.go +++ b/receiver/hostmetricsreceiver/hostmetrics_linux_test.go @@ -38,6 +38,8 @@ func TestLoadConfigRootPath(t *testing.T) { factories, _ := otelcoltest.NopFactories() factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-root-path.yaml"), factories) require.NoError(t, err) globalRootPath = "" @@ -63,6 +65,8 @@ func TestLoadInvalidConfig_RootPathNotExist(t *testing.T) { factories, _ := otelcoltest.NopFactories() factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck _, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-bad-root-path.yaml"), factories) assert.ErrorContains(t, err, "invalid root_path:") globalRootPath = "" diff --git a/receiver/receivercreator/config_test.go b/receiver/receivercreator/config_test.go index 0df6b23806ad..7d4dbd9d0540 100644 --- a/receiver/receivercreator/config_test.go +++ b/receiver/receivercreator/config_test.go @@ -143,6 +143,8 @@ func TestInvalidResourceAttributeEndpointType(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "invalid-resource-attributes.yaml"), factories) require.Contains(t, err.Error(), "error reading configuration for \"receiver_creator\": resource attributes for unsupported endpoint type \"not.a.real.type\"") require.Nil(t, cfg) @@ -156,6 +158,8 @@ func TestInvalidReceiverResourceAttributeValueType(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "invalid-receiver-resource-attributes.yaml"), factories) require.Contains(t, err.Error(), "error reading configuration for \"receiver_creator\": unsupported `resource_attributes` \"one\" value in examplereceiver/1") require.Nil(t, cfg) diff --git a/receiver/snmpreceiver/integration_test.go b/receiver/snmpreceiver/integration_test.go index 9b0cfcfe6b40..1c16c75369da 100644 --- a/receiver/snmpreceiver/integration_test.go +++ b/receiver/snmpreceiver/integration_test.go @@ -59,6 +59,8 @@ func TestIntegration(t *testing.T) { factory := NewFactory() factories.Receivers[metadata.Type] = factory configFile := filepath.Join("testdata", "integration", testCase.configFilename) + // https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594 + // nolint:staticcheck cfg, err := otelcoltest.LoadConfigAndValidate(configFile, factories) require.NoError(t, err) snmpConfig := cfg.Receivers[component.NewID(metadata.Type)].(*Config)