From f2830f03f9186c4c1fa24f4c38bf3c5d08e99fd4 Mon Sep 17 00:00:00 2001 From: Evan Bradley <11745660+evan-bradley@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:44:09 -0400 Subject: [PATCH] Update with core API verison validation --- cmd/builder/internal/builder/config.go | 3 +-- cmd/builder/internal/builder/main.go | 3 ++- cmd/builder/internal/builder/main_test.go | 29 +++++++++-------------- cmd/otelcorecol/builder-config.yaml | 10 ++++---- cmd/otelcorecol/go.mod | 14 +++++------ cmd/otelcorecol/main.go | 21 ---------------- 6 files changed, 26 insertions(+), 54 deletions(-) diff --git a/cmd/builder/internal/builder/config.go b/cmd/builder/internal/builder/config.go index 01a824e108e..2c754c05663 100644 --- a/cmd/builder/internal/builder/config.go +++ b/cmd/builder/internal/builder/config.go @@ -90,7 +90,7 @@ func NewDefaultConfig() Config { // Validate checks whether the current configuration is valid func (c *Config) Validate() error { - var providersError, convertersError error + var providersError error if c.Providers != nil { providersError = validateModules(*c.Providers) } @@ -101,7 +101,6 @@ func (c *Config) Validate() error { validateModules(c.Processors), validateModules(c.Connectors), providersError, - convertersError, ) } diff --git a/cmd/builder/internal/builder/main.go b/cmd/builder/internal/builder/main.go index dcf3b1f6d0d..9e5eec13021 100644 --- a/cmd/builder/internal/builder/main.go +++ b/cmd/builder/internal/builder/main.go @@ -239,7 +239,8 @@ func (c *Config) allComponents() []Module { append(c.Receivers, append(c.Processors, append(c.Extensions, - c.Connectors...)...)...)...) + append(c.Connectors, + *c.Providers...)...)...)...)...) } func (c *Config) readGoModFile() (string, map[string]string, error) { diff --git a/cmd/builder/internal/builder/main_test.go b/cmd/builder/internal/builder/main_test.go index e711fed825f..e592eafdfa6 100644 --- a/cmd/builder/internal/builder/main_test.go +++ b/cmd/builder/internal/builder/main_test.go @@ -47,13 +47,6 @@ func TestGenerateDefault(t *testing.T) { require.NoError(t, Generate(newInitializedConfig(t))) } -func TestGenerateInvalidCollectorVersion(t *testing.T) { - cfg := newInitializedConfig(t) - cfg.Distribution.OtelColVersion = "invalid" - err := Generate(cfg) - require.NoError(t, err) -} - func TestGenerateInvalidOutputPath(t *testing.T) { cfg := newInitializedConfig(t) cfg.Distribution.OutputPath = "/:invalid" @@ -71,7 +64,7 @@ func TestVersioning(t *testing.T) { { description: "defaults", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.Go = "go" return cfg }, @@ -80,7 +73,7 @@ func TestVersioning(t *testing.T) { { description: "require otelcol", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.Go = "go" cfg.Distribution.RequireOtelColModule = true return cfg @@ -90,7 +83,7 @@ func TestVersioning(t *testing.T) { { description: "only gomod file, skip generate", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) tempDir := t.TempDir() err := makeModule(tempDir, goModTestFile) require.NoError(t, err) @@ -104,7 +97,7 @@ func TestVersioning(t *testing.T) { { description: "old otel version", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.OtelColVersion = "0.90.0" return cfg }, @@ -113,7 +106,7 @@ func TestVersioning(t *testing.T) { { description: "old otel version without strict mode", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Verbose = true cfg.Distribution.Go = "go" cfg.SkipStrictVersioning = true @@ -125,7 +118,7 @@ func TestVersioning(t *testing.T) { { description: "invalid collector version", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.OtelColVersion = "invalid" return cfg }, @@ -134,7 +127,7 @@ func TestVersioning(t *testing.T) { { description: "invalid collector version without strict mode, only generate", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.OtelColVersion = "invalid" cfg.SkipGetModules = true cfg.SkipCompilation = true @@ -146,7 +139,7 @@ func TestVersioning(t *testing.T) { { description: "invalid collector version without strict mode", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.OtelColVersion = "invalid" cfg.SkipStrictVersioning = true return cfg @@ -156,7 +149,7 @@ func TestVersioning(t *testing.T) { { description: "old component version", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.Go = "go" cfg.Exporters = []Module{ { @@ -171,7 +164,7 @@ func TestVersioning(t *testing.T) { { description: "old component version without strict mode", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.Go = "go" cfg.SkipStrictVersioning = true cfg.Exporters = []Module{ @@ -187,7 +180,7 @@ func TestVersioning(t *testing.T) { { description: "invalid component version", cfgBuilder: func() Config { - cfg := NewDefaultConfig() + cfg := newInitializedConfig(t) cfg.Distribution.Go = "go" cfg.Exporters = []Module{ { diff --git a/cmd/otelcorecol/builder-config.yaml b/cmd/otelcorecol/builder-config.yaml index 44d1a1fa392..9946db772de 100644 --- a/cmd/otelcorecol/builder-config.yaml +++ b/cmd/otelcorecol/builder-config.yaml @@ -25,11 +25,11 @@ connectors: - gomod: go.opentelemetry.io/collector/connector/forwardconnector v0.98.0 providers: - - gomod: go.opentelemetry.io/collector/confmap/provider/envprovider v0.97.0 - - gomod: go.opentelemetry.io/collector/confmap/provider/fileprovider v0.97.0 - - gomod: go.opentelemetry.io/collector/confmap/provider/httpprovider v0.97.0 - - gomod: go.opentelemetry.io/collector/confmap/provider/httpsprovider v0.97.0 - - gomod: go.opentelemetry.io/collector/confmap/provider/yamlprovider v0.97.0 + - gomod: go.opentelemetry.io/collector/confmap/provider/envprovider v0.98.0 + - gomod: go.opentelemetry.io/collector/confmap/provider/fileprovider v0.98.0 + - gomod: go.opentelemetry.io/collector/confmap/provider/httpprovider v0.98.0 + - gomod: go.opentelemetry.io/collector/confmap/provider/httpsprovider v0.98.0 + - gomod: go.opentelemetry.io/collector/confmap/provider/yamlprovider v0.98.0 replaces: - go.opentelemetry.io/collector => ../../ diff --git a/cmd/otelcorecol/go.mod b/cmd/otelcorecol/go.mod index ccc0a9ad887..c8761006346 100644 --- a/cmd/otelcorecol/go.mod +++ b/cmd/otelcorecol/go.mod @@ -6,13 +6,6 @@ go 1.21 require ( go.opentelemetry.io/collector/component v0.98.0 - go.opentelemetry.io/collector/confmap v0.98.0 - go.opentelemetry.io/collector/confmap/converter/expandconverter v0.98.0 - go.opentelemetry.io/collector/confmap/provider/envprovider v0.98.0 - go.opentelemetry.io/collector/confmap/provider/fileprovider v0.98.0 - go.opentelemetry.io/collector/confmap/provider/httpprovider v0.98.0 - go.opentelemetry.io/collector/confmap/provider/httpsprovider v0.98.0 - go.opentelemetry.io/collector/confmap/provider/yamlprovider v0.98.0 go.opentelemetry.io/collector/connector v0.98.0 go.opentelemetry.io/collector/connector/forwardconnector v0.98.0 go.opentelemetry.io/collector/exporter v0.98.0 @@ -89,6 +82,13 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.98.0 // indirect go.opentelemetry.io/collector/config/configtls v0.98.0 // indirect go.opentelemetry.io/collector/config/internal v0.98.0 // indirect + go.opentelemetry.io/collector/confmap v0.98.0 // indirect + go.opentelemetry.io/collector/confmap/converter/expandconverter v0.98.0 // indirect + go.opentelemetry.io/collector/confmap/provider/envprovider v0.98.0 // indirect + go.opentelemetry.io/collector/confmap/provider/fileprovider v0.98.0 // indirect + go.opentelemetry.io/collector/confmap/provider/httpprovider v0.98.0 // indirect + go.opentelemetry.io/collector/confmap/provider/httpsprovider v0.98.0 // indirect + go.opentelemetry.io/collector/confmap/provider/yamlprovider v0.98.0 // indirect go.opentelemetry.io/collector/consumer v0.98.0 // indirect go.opentelemetry.io/collector/extension/auth v0.98.0 // indirect go.opentelemetry.io/collector/featuregate v1.5.0 // indirect diff --git a/cmd/otelcorecol/main.go b/cmd/otelcorecol/main.go index 9dcf000667e..27ebe7aaa11 100644 --- a/cmd/otelcorecol/main.go +++ b/cmd/otelcorecol/main.go @@ -7,13 +7,6 @@ import ( "log" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/confmap" - "go.opentelemetry.io/collector/confmap/converter/expandconverter" - envprovider "go.opentelemetry.io/collector/confmap/provider/envprovider" - fileprovider "go.opentelemetry.io/collector/confmap/provider/fileprovider" - httpprovider "go.opentelemetry.io/collector/confmap/provider/httpprovider" - httpsprovider "go.opentelemetry.io/collector/confmap/provider/httpsprovider" - yamlprovider "go.opentelemetry.io/collector/confmap/provider/yamlprovider" "go.opentelemetry.io/collector/otelcol" ) @@ -27,20 +20,6 @@ func main() { set := otelcol.CollectorSettings{ BuildInfo: info, Factories: components, - ConfigProviderSettings: otelcol.ConfigProviderSettings{ - ResolverSettings: confmap.ResolverSettings{ - ProviderFactories: []confmap.ProviderFactory{ - envprovider.NewFactory(), - fileprovider.NewFactory(), - httpprovider.NewFactory(), - httpsprovider.NewFactory(), - yamlprovider.NewFactory(), - }, - ConverterFactories: []confmap.ConverterFactory{ - expandconverter.NewFactory(), - }, - }, - }, } if err := run(set); err != nil {