diff --git a/cmd/builder/internal/builder/config.go b/cmd/builder/internal/builder/config.go index 427920c84e..7c2af3ffe1 100644 --- a/cmd/builder/internal/builder/config.go +++ b/cmd/builder/internal/builder/config.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "slices" "strings" "time" @@ -203,6 +204,10 @@ func (c *Config) ParseModules() error { return nil } +func (c *Config) allComponents() []Module { + return slices.Concat[[]Module](c.Exporters, c.Receivers, c.Processors, c.Extensions, c.Connectors, c.Providers, c.Converters) +} + func validateModules(name string, mods []Module) error { for i, mod := range mods { if mod.GoMod == "" { diff --git a/cmd/builder/internal/builder/main.go b/cmd/builder/internal/builder/main.go index 3bd8285cb4..8b564532d6 100644 --- a/cmd/builder/internal/builder/main.go +++ b/cmd/builder/internal/builder/main.go @@ -10,7 +10,6 @@ import ( "os" "os/exec" "path/filepath" - "slices" "strings" "text/template" "time" @@ -149,7 +148,7 @@ func GetModules(cfg *Config) error { // 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() + modulePath, dependencyVersions, err := readGoModFile(cfg) if err != nil { return err } @@ -212,13 +211,9 @@ func processAndWrite(cfg *Config, tmpl *template.Template, outFile string, tmplP return tmpl.Execute(out, tmplParams) } -func (c *Config) allComponents() []Module { - return slices.Concat[[]Module](c.Exporters, c.Receivers, c.Processors, c.Extensions, c.Connectors, c.Providers, c.Converters) -} - -func (c *Config) readGoModFile() (string, map[string]string, error) { +func readGoModFile(cfg *Config) (string, map[string]string, error) { var modPath string - stdout, err := runGoCommand(c, "mod", "edit", "-print") + stdout, err := runGoCommand(cfg, "mod", "edit", "-print") if err != nil { return modPath, nil, err } @@ -226,7 +221,7 @@ func (c *Config) readGoModFile() (string, map[string]string, error) { if err != nil { return modPath, nil, err } - if parsedFile != nil && parsedFile.Module != nil { + if parsedFile.Module != nil { modPath = parsedFile.Module.Mod.Path } dependencies := map[string]string{}