[chore] Small refactoring in builder config functions (#11617)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
parent
17d5d8f259
commit
52848cca99
|
|
@ -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 == "" {
|
||||
|
|
|
|||
|
|
@ -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{}
|
||||
|
|
|
|||
Loading…
Reference in New Issue