From e9b432dcea3699dde1e0118e7a3c6df3dff36137 Mon Sep 17 00:00:00 2001 From: Kristina Pathak Date: Thu, 18 Apr 2024 03:25:05 -0700 Subject: [PATCH] [builder] Add strict versioning (#9897) **Description:** Adds strict version checking in the builder. This enables users to ensure that the versions specified in the builder config are the versions used in the go.mod when building the collector binary. This can be disabled with --skip-strict-versioning. **Link to tracking Issue:** #9896 **Testing:** Added unit tests **Documentation:** Added to builder README --------- Co-authored-by: Pablo Baeyens --- .chloggen/builder-strict-versioning.yaml | 25 +++ cmd/builder/README.md | 21 +++ cmd/builder/go.mod | 1 + cmd/builder/go.sum | 2 + cmd/builder/internal/builder/config.go | 13 +- cmd/builder/internal/builder/main.go | 140 +++++++++++++--- cmd/builder/internal/builder/main_test.go | 190 +++++++++++++++++++++- cmd/builder/internal/command.go | 5 + cmd/builder/internal/command_test.go | 43 +++-- cmd/builder/test/core.builder.yaml | 8 +- 10 files changed, 400 insertions(+), 48 deletions(-) create mode 100644 .chloggen/builder-strict-versioning.yaml diff --git a/.chloggen/builder-strict-versioning.yaml b/.chloggen/builder-strict-versioning.yaml new file mode 100644 index 00000000000..de512390e60 --- /dev/null +++ b/.chloggen/builder-strict-versioning.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: builder + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add strict version checking when using the builder. Add the temporary flag `--skip-strict-versioning `for skipping this check. + +# One or more tracking issues or pull requests related to the change +issues: [9896] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: Strict version checking will error on mismatches between the `otelcol_version` configured and the builder version or versions in the go.mod. This check can be temporarily disabled by using the `--skip-strict-versioning` flag. This flag will be removed in a future minor version. + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/cmd/builder/README.md b/cmd/builder/README.md index 7a4259d59e5..18cffa052d9 100644 --- a/cmd/builder/README.md +++ b/cmd/builder/README.md @@ -145,3 +145,24 @@ then commit the code in a git repo. A CI can sync the code and execute ocb --skip-generate --skip-get-modules --config=config.yaml ``` to only execute the compilation step. + +### Strict versioning checks + +The builder checks the relevant `go.mod` +file for the following things after `go get`ing all components and calling +`go mod tidy`: + +1. The `dist::otelcol_version` field in the build configuration must + match the core library version calculated by the Go toolchain, + considering all components. A mismatch could happen, for example, + when one of the components depends on a newer release of the core + collector library. +2. For each component in the build configuration, the version included + in the `gomod` module specifier must match the one calculated by + the Go toolchain, considering all components. A mismatch could + happen, for example, when the enclosing Go module uses a newer + release of the core collector library. + +The `--skip-strict-versioning` flag disables these versioning checks. +This flag is available temporarily and +**will be removed in a future minor version**. \ No newline at end of file diff --git a/cmd/builder/go.mod b/cmd/builder/go.mod index b6b63cb3de7..1a3fb86740c 100644 --- a/cmd/builder/go.mod +++ b/cmd/builder/go.mod @@ -18,6 +18,7 @@ require ( go.uber.org/goleak v1.3.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 + golang.org/x/mod v0.17.0 ) require ( diff --git a/cmd/builder/go.sum b/cmd/builder/go.sum index e9d2440664a..bc3b48a8fa0 100644 --- a/cmd/builder/go.sum +++ b/cmd/builder/go.sum @@ -52,6 +52,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/cmd/builder/internal/builder/config.go b/cmd/builder/internal/builder/config.go index 2260f6940c4..72f868093b5 100644 --- a/cmd/builder/internal/builder/config.go +++ b/cmd/builder/internal/builder/config.go @@ -23,12 +23,13 @@ var ErrInvalidGoMod = errors.New("invalid gomod specification for module") // Config holds the builder's configuration type Config struct { - Logger *zap.Logger - SkipGenerate bool `mapstructure:"-"` - SkipCompilation bool `mapstructure:"-"` - SkipGetModules bool `mapstructure:"-"` - LDFlags string `mapstructure:"-"` - Verbose bool `mapstructure:"-"` + Logger *zap.Logger + SkipGenerate bool `mapstructure:"-"` + SkipCompilation bool `mapstructure:"-"` + SkipGetModules bool `mapstructure:"-"` + SkipStrictVersioning bool `mapstructure:"-"` + LDFlags string `mapstructure:"-"` + Verbose bool `mapstructure:"-"` Distribution Distribution `mapstructure:"dist"` Exporters []Module `mapstructure:"exporters"` diff --git a/cmd/builder/internal/builder/main.go b/cmd/builder/internal/builder/main.go index 0a00b653208..4aecca68970 100644 --- a/cmd/builder/internal/builder/main.go +++ b/cmd/builder/internal/builder/main.go @@ -4,42 +4,52 @@ package builder // import "go.opentelemetry.io/collector/cmd/builder/internal/builder" import ( + "bytes" "errors" "fmt" "os" "os/exec" "path/filepath" + "strings" "text/template" "time" "go.uber.org/zap" - "go.uber.org/zap/zapio" + "golang.org/x/mod/modfile" ) var ( // ErrGoNotFound is returned when a Go binary hasn't been found - ErrGoNotFound = errors.New("go binary not found") + ErrGoNotFound = errors.New("go binary not found") + ErrDepNotFound = errors.New("dependency not found in go mod file") + ErrVersionMismatch = errors.New("mismatch in go.mod and builder configuration versions") + errGoGetFailed = errors.New("failed to go get") + errDownloadFailed = errors.New("failed to download go modules") + errCompileFailed = errors.New("failed to compile the OpenTelemetry Collector distribution") + skipStrictMsg = "Use --skip-strict-versioning to temporarily disable this check. This flag will be removed in a future minor version" ) -func runGoCommand(cfg Config, args ...string) error { - cfg.Logger.Info("Running go subcommand.", zap.Any("arguments", args)) +func runGoCommand(cfg Config, args ...string) ([]byte, error) { + if cfg.Verbose { + cfg.Logger.Info("Running go subcommand.", zap.Any("arguments", args)) + } + // #nosec G204 -- cfg.Distribution.Go is trusted to be a safe path and the caller is assumed to have carried out necessary input validation cmd := exec.Command(cfg.Distribution.Go, args...) cmd.Dir = cfg.Distribution.OutputPath - if cfg.Verbose { - writer := &zapio.Writer{Log: cfg.Logger} - defer func() { _ = writer.Close() }() - cmd.Stdout = writer - cmd.Stderr = writer - return cmd.Run() - } + var stdout, stderr bytes.Buffer + cmd.Stdout = &stdout + cmd.Stderr = &stderr - if out, err := cmd.CombinedOutput(); err != nil { - return fmt.Errorf("go subcommand failed with args '%v': %w. Output:\n%s", args, err, out) + if err := cmd.Run(); err != nil { + return nil, fmt.Errorf("go subcommand failed with args '%v': %w, error message: %s", args, err, stderr.String()) + } + if cfg.Verbose && stderr.Len() != 0 { + cfg.Logger.Info("go subcommand error", zap.String("message", stderr.String())) } - return nil + return stdout.Bytes(), nil } // GenerateAndCompile will generate the source files based on the given configuration, update go mod, and will compile into a binary @@ -64,6 +74,9 @@ func Generate(cfg Config) error { } // create a warning message for non-aligned builder and collector base if cfg.Distribution.OtelColVersion != defaultOtelColVersion { + if !cfg.SkipStrictVersioning { + return fmt.Errorf("builder version %q does not match build configuration version %q: %w", cfg.Distribution.OtelColVersion, defaultOtelColVersion, ErrVersionMismatch) + } cfg.Logger.Info("You're building a distribution with non-aligned version of the builder. Compilation may fail due to API changes. Please upgrade your builder or API", zap.String("builder-version", defaultOtelColVersion)) } // if the file does not exist, try to create it @@ -114,8 +127,8 @@ func Compile(cfg Config) error { if cfg.Distribution.BuildTags != "" { args = append(args, "-tags", cfg.Distribution.BuildTags) } - if err := runGoCommand(cfg, args...); err != nil { - return fmt.Errorf("failed to compile the OpenTelemetry Collector distribution: %w", err) + if _, err := runGoCommand(cfg, args...); err != nil { + return fmt.Errorf("%w: %s", errCompileFailed, err.Error()) } cfg.Logger.Info("Compiled", zap.String("binary", fmt.Sprintf("%s/%s", cfg.Distribution.OutputPath, cfg.Distribution.Name))) @@ -130,21 +143,66 @@ func GetModules(cfg Config) error { } // ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules - if err := runGoCommand(cfg, "get", "cloud.google.com/go"); err != nil { - return fmt.Errorf("failed to go get: %w", err) + if _, err := runGoCommand(cfg, "get", "cloud.google.com/go"); err != nil { + return fmt.Errorf("%w: %s", errGoGetFailed, err.Error()) } - if err := runGoCommand(cfg, "mod", "tidy", "-compat=1.21"); err != nil { + if _, err := runGoCommand(cfg, "mod", "tidy", "-compat=1.21"); err != nil { return fmt.Errorf("failed to update go.mod: %w", err) } + if cfg.SkipStrictVersioning { + return downloadModules(cfg) + } + + // Perform strict version checking. For each component listed and the + // otelcol core dependency, check that the enclosing go module matches. + modulePath, dependencyVersions, err := cfg.readGoModFile() + if err != nil { + return err + } + + corePath, coreVersion := cfg.coreModuleAndVersion() + coreDepVersion, ok := dependencyVersions[corePath] + if !ok { + return fmt.Errorf("core collector %w: '%s'. %s", ErrDepNotFound, corePath, skipStrictMsg) + } + if coreDepVersion != coreVersion { + return fmt.Errorf( + "%w: core collector version calculated by component dependencies %q does not match configured version %q. %s", + ErrVersionMismatch, coreDepVersion, coreVersion, skipStrictMsg) + } + + for _, mod := range cfg.allComponents() { + module, version, _ := strings.Cut(mod.GoMod, " ") + if module == modulePath { + // No need to check the version of components that are part of the + // module we're building from. + continue + } + + moduleDepVersion, ok := dependencyVersions[module] + if !ok { + return fmt.Errorf("component %w: '%s'. %s", ErrDepNotFound, module, skipStrictMsg) + } + if moduleDepVersion != version { + return fmt.Errorf( + "%w: component %q version calculated by dependencies %q does not match configured version %q. %s", + ErrVersionMismatch, module, moduleDepVersion, version, skipStrictMsg) + } + } + + return downloadModules(cfg) +} + +func downloadModules(cfg Config) error { cfg.Logger.Info("Getting go modules") // basic retry if error from go mod command (in case of transient network error). This could be improved // retry 3 times with 5 second spacing interval retries := 3 failReason := "unknown" for i := 1; i <= retries; i++ { - if err := runGoCommand(cfg, "mod", "download"); err != nil { + if _, err := runGoCommand(cfg, "mod", "download"); err != nil { failReason = err.Error() cfg.Logger.Info("Failed modules download", zap.String("retry", fmt.Sprintf("%d/%d", i, retries))) time.Sleep(5 * time.Second) @@ -152,7 +210,7 @@ func GetModules(cfg Config) error { } return nil } - return fmt.Errorf("failed to download go modules: %s", failReason) + return fmt.Errorf("%w: %s", errDownloadFailed, failReason) } func processAndWrite(cfg Config, tmpl *template.Template, outFile string, tmplParams any) error { @@ -164,3 +222,43 @@ func processAndWrite(cfg Config, tmpl *template.Template, outFile string, tmplPa defer out.Close() return tmpl.Execute(out, tmplParams) } + +func (c *Config) coreModuleAndVersion() (string, string) { + module := "go.opentelemetry.io/collector" + if c.Distribution.RequireOtelColModule { + module += "/otelcol" + } + return module, "v" + c.Distribution.OtelColVersion +} + +func (c *Config) allComponents() []Module { + // TODO: Use slices.Concat when we drop support for Go 1.21 + return append(c.Exporters, + append(c.Receivers, + append(c.Processors, + append(c.Extensions, + c.Connectors...)...)...)...) +} + +func (c *Config) readGoModFile() (string, map[string]string, error) { + var modPath string + stdout, err := runGoCommand(*c, "mod", "edit", "-print") + if err != nil { + return modPath, nil, err + } + parsedFile, err := modfile.Parse("go.mod", stdout, nil) + if err != nil { + return modPath, nil, err + } + if parsedFile != nil && parsedFile.Module != nil { + modPath = parsedFile.Module.Mod.Path + } + dependencies := map[string]string{} + for _, req := range parsedFile.Require { + if req == nil { + continue + } + dependencies[req.Mod.Path] = req.Mod.Version + } + return modPath, dependencies, nil +} diff --git a/cmd/builder/internal/builder/main_test.go b/cmd/builder/internal/builder/main_test.go index 8635baf41a1..f8a3f2c6643 100644 --- a/cmd/builder/internal/builder/main_test.go +++ b/cmd/builder/internal/builder/main_test.go @@ -13,19 +13,30 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/zap" +) + +var ( + goModTestFile = []byte(`// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +module go.opentelemetry.io/collector/cmd/builder/internal/tester +go 1.20 +require ( + go.opentelemetry.io/collector/component v0.96.0 + go.opentelemetry.io/collector/connector v0.94.1 + go.opentelemetry.io/collector/exporter v0.94.1 + go.opentelemetry.io/collector/extension v0.94.1 + go.opentelemetry.io/collector/otelcol v0.94.1 + go.opentelemetry.io/collector/processor v0.94.1 + go.opentelemetry.io/collector/receiver v0.94.1 + go.opentelemetry.io/collector v0.96.0 +)`) ) func TestGenerateDefault(t *testing.T) { require.NoError(t, Generate(NewDefaultConfig())) } -func TestGenerateInvalidCollectorVersion(t *testing.T) { - cfg := NewDefaultConfig() - cfg.Distribution.OtelColVersion = "invalid" - err := Generate(cfg) - require.NoError(t, err) -} - func TestGenerateInvalidOutputPath(t *testing.T) { cfg := NewDefaultConfig() cfg.Distribution.OutputPath = "/:invalid" @@ -34,6 +45,153 @@ func TestGenerateInvalidOutputPath(t *testing.T) { require.Contains(t, err.Error(), "failed to create output path") } +func TestVersioning(t *testing.T) { + tests := []struct { + description string + cfgBuilder func() Config + expectedErr error + }{ + { + description: "defaults", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.Go = "go" + return cfg + }, + expectedErr: nil, + }, + { + description: "require otelcol", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.Go = "go" + cfg.Distribution.RequireOtelColModule = true + return cfg + }, + expectedErr: nil, + }, + { + description: "only gomod file, skip generate", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + tempDir := t.TempDir() + err := makeModule(tempDir, goModTestFile) + require.NoError(t, err) + cfg.Distribution.OutputPath = tempDir + cfg.SkipGenerate = true + cfg.Distribution.Go = "go" + return cfg + }, + expectedErr: ErrDepNotFound, + }, + { + description: "old otel version", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.OtelColVersion = "0.90.0" + return cfg + }, + expectedErr: ErrVersionMismatch, + }, + { + description: "old otel version without strict mode", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Verbose = true + cfg.Distribution.Go = "go" + cfg.SkipStrictVersioning = true + cfg.Distribution.OtelColVersion = "0.90.0" + return cfg + }, + expectedErr: nil, + }, + { + description: "invalid collector version", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.OtelColVersion = "invalid" + return cfg + }, + expectedErr: ErrVersionMismatch, + }, + { + description: "invalid collector version without strict mode, only generate", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.OtelColVersion = "invalid" + cfg.SkipGetModules = true + cfg.SkipCompilation = true + cfg.SkipStrictVersioning = true + return cfg + }, + expectedErr: nil, + }, + { + description: "invalid collector version without strict mode", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.OtelColVersion = "invalid" + cfg.SkipStrictVersioning = true + return cfg + }, + expectedErr: errGoGetFailed, + }, + { + description: "old component version", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.Go = "go" + cfg.Exporters = []Module{ + { + Import: "go.opentelemetry.io/collector/receiver/otlpreceiver", + GoMod: "go.opentelemetry.io/collector v0.96.0", + }, + } + return cfg + }, + expectedErr: ErrVersionMismatch, + }, + { + description: "old component version without strict mode", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.Go = "go" + cfg.SkipStrictVersioning = true + cfg.Exporters = []Module{ + { + Import: "go.opentelemetry.io/collector/receiver/otlpreceiver", + GoMod: "go.opentelemetry.io/collector v0.96.0", + }, + } + return cfg + }, + expectedErr: errCompileFailed, + }, + { + description: "invalid component version", + cfgBuilder: func() Config { + cfg := NewDefaultConfig() + cfg.Distribution.Go = "go" + cfg.Exporters = []Module{ + { + Import: "go.opentelemetry.io/collector/receiver/otlpreceiver", + GoMod: "go.opentelemetry.io/collector invalid", + }, + } + return cfg + }, + expectedErr: errGoGetFailed, + }, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + cfg := tc.cfgBuilder() + err := GenerateAndCompile(cfg) + require.ErrorIs(t, err, tc.expectedErr) + }) + } +} + func TestSkipGenerate(t *testing.T) { cfg := NewDefaultConfig() cfg.Distribution.OutputPath = t.TempDir() @@ -119,6 +277,7 @@ func TestGenerateAndCompile(t *testing.T) { cfg := NewDefaultConfig() cfg.Distribution.OutputPath = t.TempDir() cfg.Replaces = append(cfg.Replaces, replaces...) + cfg.Logger = zap.NewNop() cfg.Distribution.DebugCompilation = true return cfg }, @@ -134,3 +293,20 @@ func TestGenerateAndCompile(t *testing.T) { }) } } + +func makeModule(dir string, fileContents []byte) error { + // if the file does not exist, try to create it + if _, err := os.Stat(dir); os.IsNotExist(err) { + if err = os.Mkdir(dir, 0750); err != nil { + return fmt.Errorf("failed to create output path: %w", err) + } + } else if err != nil { + return fmt.Errorf("failed to create output path: %w", err) + } + + err := os.WriteFile(filepath.Clean(filepath.Join(dir, "go.mod")), fileContents, 0600) + if err != nil { + return fmt.Errorf("failed to write go.mod file: %w", err) + } + return nil +} diff --git a/cmd/builder/internal/command.go b/cmd/builder/internal/command.go index 34d1b0b13b9..9ced5aa6c28 100644 --- a/cmd/builder/internal/command.go +++ b/cmd/builder/internal/command.go @@ -23,6 +23,7 @@ const ( skipGenerateFlag = "skip-generate" skipCompilationFlag = "skip-compilation" skipGetModulesFlag = "skip-get-modules" + skipStrictVersioningFlag = "skip-strict-versioning" ldflagsFlag = "ldflags" distributionNameFlag = "name" distributionDescriptionFlag = "description" @@ -83,6 +84,7 @@ configuration is provided, ocb will generate a default Collector. cmd.Flags().BoolVar(&cfg.SkipGenerate, skipGenerateFlag, false, "Whether builder should skip generating go code (default false)") cmd.Flags().BoolVar(&cfg.SkipCompilation, skipCompilationFlag, false, "Whether builder should only generate go code with no compile of the collector (default false)") cmd.Flags().BoolVar(&cfg.SkipGetModules, skipGetModulesFlag, false, "Whether builder should skip updating go.mod and retrieve Go module list (default false)") + cmd.Flags().BoolVar(&cfg.SkipStrictVersioning, skipStrictVersioningFlag, false, "Whether builder should skip strictly checking the calculated versions following dependency resolution") cmd.Flags().BoolVar(&cfg.Verbose, verboseFlag, false, "Whether builder should print verbose output (default false)") cmd.Flags().StringVar(&cfg.LDFlags, ldflagsFlag, "", `ldflags to include in the "go build" command`) cmd.Flags().StringVar(&cfg.Distribution.Name, distributionNameFlag, "otelcol-custom", "The executable name for the OpenTelemetry Collector distribution") @@ -180,6 +182,9 @@ func applyCfgFromFile(flags *flag.FlagSet, cfgFromFile builder.Config) { if !flags.Changed(skipGetModulesFlag) && cfgFromFile.SkipGetModules { cfg.SkipGetModules = cfgFromFile.SkipGetModules } + if !flags.Changed(skipStrictVersioningFlag) && cfgFromFile.SkipStrictVersioning { + cfg.SkipStrictVersioning = cfgFromFile.SkipStrictVersioning + } if !flags.Changed(distributionNameFlag) && cfgFromFile.Distribution.Name != "" { cfg.Distribution.Name = cfgFromFile.Distribution.Name } diff --git a/cmd/builder/internal/command_test.go b/cmd/builder/internal/command_test.go index 78ad0d740d2..27ae655893b 100644 --- a/cmd/builder/internal/command_test.go +++ b/cmd/builder/internal/command_test.go @@ -178,6 +178,26 @@ func Test_applyCfgFromFile(t *testing.T) { }, wantErr: false, }, + { + name: "Skip strict versioning true", + args: args{ + flags: flag.NewFlagSet("version=1.0.0", 1), + cfgFromFile: builder.Config{ + Logger: zap.NewNop(), + SkipCompilation: true, + SkipStrictVersioning: true, + Distribution: testDistribution, + }, + }, + want: builder.Config{ + Logger: zap.NewNop(), + SkipCompilation: true, + SkipGetModules: true, + SkipStrictVersioning: true, + Distribution: testDistribution, + }, + wantErr: false, + }, { name: "Skip generate false", args: args{ @@ -191,11 +211,12 @@ func Test_applyCfgFromFile(t *testing.T) { }, }, want: builder.Config{ - Logger: zap.NewNop(), - SkipGenerate: false, - SkipCompilation: true, - SkipGetModules: true, - Distribution: testDistribution, + Logger: zap.NewNop(), + SkipGenerate: false, + SkipCompilation: true, + SkipGetModules: true, + SkipStrictVersioning: true, + Distribution: testDistribution, }, wantErr: false, }, @@ -212,11 +233,12 @@ func Test_applyCfgFromFile(t *testing.T) { }, }, want: builder.Config{ - Logger: zap.NewNop(), - SkipGenerate: true, - SkipCompilation: true, - SkipGetModules: true, - Distribution: testDistribution, + Logger: zap.NewNop(), + SkipGenerate: true, + SkipCompilation: true, + SkipGetModules: true, + SkipStrictVersioning: true, + Distribution: testDistribution, }, wantErr: false, }, @@ -228,6 +250,7 @@ func Test_applyCfgFromFile(t *testing.T) { assert.Equal(t, tt.want.SkipGenerate, cfg.SkipGenerate) assert.Equal(t, tt.want.SkipCompilation, cfg.SkipCompilation) assert.Equal(t, tt.want.SkipGetModules, cfg.SkipGetModules) + assert.Equal(t, tt.want.SkipStrictVersioning, cfg.SkipStrictVersioning) assert.Equal(t, tt.want.Excludes, cfg.Excludes) assert.Equal(t, tt.want.Exporters, cfg.Exporters) assert.Equal(t, tt.want.Receivers, cfg.Receivers) diff --git a/cmd/builder/test/core.builder.yaml b/cmd/builder/test/core.builder.yaml index fb4e60c10a0..7583616770f 100644 --- a/cmd/builder/test/core.builder.yaml +++ b/cmd/builder/test/core.builder.yaml @@ -1,20 +1,20 @@ dist: module: go.opentelemetry.io/collector/builder/test/core - otelcol_version: 0.94.0 + otelcol_version: 0.98.0 extensions: - import: go.opentelemetry.io/collector/extension/zpagesextension - gomod: go.opentelemetry.io/collector v0.94.0 + gomod: go.opentelemetry.io/collector v0.98.0 path: ${WORKSPACE_DIR} receivers: - import: go.opentelemetry.io/collector/receiver/otlpreceiver - gomod: go.opentelemetry.io/collector v0.94.0 + gomod: go.opentelemetry.io/collector v0.98.0 path: ${WORKSPACE_DIR} exporters: - import: go.opentelemetry.io/collector/exporter/debugexporter - gomod: go.opentelemetry.io/collector v0.94.0 + gomod: go.opentelemetry.io/collector v0.98.0 path: ${WORKSPACE_DIR} replaces: