Skip to content

Commit

Permalink
Update with core API verison validation
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-bradley committed Apr 19, 2024
1 parent 5d428fd commit f2830f0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 54 deletions.
3 changes: 1 addition & 2 deletions cmd/builder/internal/builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -101,7 +101,6 @@ func (c *Config) Validate() error {
validateModules(c.Processors),
validateModules(c.Connectors),
providersError,
convertersError,
)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/builder/internal/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
29 changes: 11 additions & 18 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
},
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
},
Expand All @@ -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
Expand All @@ -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
},
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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{
{
Expand All @@ -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{
Expand All @@ -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{
{
Expand Down
10 changes: 5 additions & 5 deletions cmd/otelcorecol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ../../
Expand Down
14 changes: 7 additions & 7 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 0 additions & 21 deletions cmd/otelcorecol/main.go

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

0 comments on commit f2830f0

Please sign in to comment.