Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] rename confmap modules to ConfmapConverters and ConfmapProviders #11678

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions cmd/builder/internal/builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ type Config struct {
LDFlags string `mapstructure:"-"`
Verbose bool `mapstructure:"-"`

Distribution Distribution `mapstructure:"dist"`
Exporters []Module `mapstructure:"exporters"`
Extensions []Module `mapstructure:"extensions"`
Receivers []Module `mapstructure:"receivers"`
Processors []Module `mapstructure:"processors"`
Connectors []Module `mapstructure:"connectors"`
Providers []Module `mapstructure:"providers"`
Converters []Module `mapstructure:"converters"`
Replaces []string `mapstructure:"replaces"`
Excludes []string `mapstructure:"excludes"`
Distribution Distribution `mapstructure:"dist"`
Exporters []Module `mapstructure:"exporters"`
Extensions []Module `mapstructure:"extensions"`
Receivers []Module `mapstructure:"receivers"`
Processors []Module `mapstructure:"processors"`
Connectors []Module `mapstructure:"connectors"`
ConfmapProviders []Module `mapstructure:"providers"`
ConfmapConverters []Module `mapstructure:"converters"`
Replaces []string `mapstructure:"replaces"`
Excludes []string `mapstructure:"excludes"`

ConfResolver ConfResolver `mapstructure:"conf_resolver"`

Expand Down Expand Up @@ -112,7 +112,7 @@ func NewDefaultConfig() (*Config, error) {
numRetries: 3,
wait: 5 * time.Second,
},
Providers: []Module{
ConfmapProviders: []Module{
{
GoMod: "go.opentelemetry.io/collector/confmap/provider/envprovider " + defaultStableOtelColVersion,
},
Expand Down Expand Up @@ -143,8 +143,8 @@ func (c *Config) Validate() error {
validateModules("exporter", c.Exporters),
validateModules("processor", c.Processors),
validateModules("connector", c.Connectors),
validateModules("provider", c.Providers),
validateModules("converter", c.Converters),
validateModules("provider", c.ConfmapProviders),
validateModules("converter", c.ConfmapConverters),
)
}

Expand Down Expand Up @@ -193,19 +193,19 @@ func (c *Config) ParseModules() error {
return err
}

c.Providers, err = parseModules(c.Providers)
c.ConfmapProviders, err = parseModules(c.ConfmapProviders)
if err != nil {
return err
}
c.Converters, err = parseModules(c.Converters)
c.ConfmapConverters, err = parseModules(c.ConfmapConverters)
if err != nil {
return err
}
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)
return slices.Concat[[]Module](c.Exporters, c.Receivers, c.Processors, c.Extensions, c.Connectors, c.ConfmapProviders, c.ConfmapConverters)
}

func validateModules(name string, mods []Module) error {
Expand Down
12 changes: 6 additions & 6 deletions cmd/builder/internal/builder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestParseModules(t *testing.T) {
func TestInvalidConverter(t *testing.T) {
// Create a Config instance with invalid Converters
config := &Config{
Converters: []Module{
ConfmapConverters: []Module{
{
Path: "./invalid/module/path", // Invalid module path to trigger an error
},
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestMissingModule(t *testing.T) {
{
cfg: Config{
Logger: zap.NewNop(),
Providers: []Module{{
ConfmapProviders: []Module{{
Import: "invalid",
}},
},
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestMissingModule(t *testing.T) {
{
cfg: Config{
Logger: zap.NewNop(),
Converters: []Module{{
ConfmapConverters: []Module{{
Import: "invalid",
}},
},
Expand Down Expand Up @@ -252,14 +252,14 @@ func TestAddsDefaultProviders(t *testing.T) {
cfg, err := NewDefaultConfig()
require.NoError(t, err)
require.NoError(t, cfg.ParseModules())
assert.Len(t, cfg.Providers, 5)
assert.Len(t, cfg.ConfmapProviders, 5)
}

func TestSkipsNilFieldValidation(t *testing.T) {
cfg, err := NewDefaultConfig()
require.NoError(t, err)
cfg.Providers = nil
cfg.Converters = nil
cfg.ConfmapProviders = nil
cfg.ConfmapConverters = nil
assert.NoError(t, cfg.Validate())
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestVersioning(t *testing.T) {
GoMod: "go.opentelemetry.io/collector/exporter/otlpexporter v0.112.0",
},
}
cfg.Providers = []Module{}
cfg.ConfmapProviders = []Module{}
cfg.Replaces = append(cfg.Replaces, replaces...)
return cfg
},
Expand All @@ -194,7 +194,7 @@ func TestVersioning(t *testing.T) {
GoMod: "go.opentelemetry.io/collector/exporter/otlpexporter v0.112.0",
},
}
cfg.Providers = []Module{}
cfg.ConfmapProviders = []Module{}
cfg.Replaces = append(cfg.Replaces, replaces...)
return cfg
},
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestGenerateAndCompile(t *testing.T) {
cfg := newTestConfig(t)
cfg.Distribution.OutputPath = t.TempDir()
cfg.Replaces = append(cfg.Replaces, replaces...)
cfg.Providers = []Module{}
cfg.ConfmapProviders = []Module{}
return cfg
},
},
Expand Down
8 changes: 4 additions & 4 deletions cmd/builder/internal/builder/templates/go.mod.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module {{.Distribution.Module}}
go 1.22

require (
{{- range .Providers}}
{{- range .ConfmapConverters}}
{{if .GoMod}}{{.GoMod}}{{end}}
{{- end}}
{{- range .Converters}}
{{- range .ConfmapProviders}}
{{if .GoMod}}{{.GoMod}}{{end}}
{{- end}}
{{- range .Connectors}}
Expand All @@ -34,10 +34,10 @@ require (
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
)

{{- range .Converters}}
{{- range .ConfmapConverters}}
{{if ne .Path ""}}replace {{.GoMod}} => {{.Path}}{{end}}
{{- end}}
{{- range .Providers}}
{{- range .ConfmapProviders}}
{{if ne .Path ""}}replace {{.GoMod}} => {{.Path}}{{end}}
{{- end}}
{{- range .Connectors}}
Expand Down
10 changes: 5 additions & 5 deletions cmd/builder/internal/builder/templates/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
{{- range .Converters}}
{{- range .ConfmapConverters}}
{{.Name}} "{{.Import}}"
{{- end}}
{{- range .Providers}}
{{- range .ConfmapProviders}}
{{.Name}} "{{.Import}}"
{{- end}}
"go.opentelemetry.io/collector/otelcol"
Expand All @@ -30,13 +30,13 @@ func main() {
ConfigProviderSettings: otelcol.ConfigProviderSettings{
ResolverSettings: confmap.ResolverSettings{
ProviderFactories: []confmap.ProviderFactory{
{{- range .Providers}}
{{- range .ConfmapProviders}}
{{.Name}}.NewFactory(),
{{- end}}
},
{{- if .Converters }}
{{- if .ConfmapConverters }}
ConverterFactories: []confmap.ConverterFactory{
{{- range .Converters}}
{{- range .ConfmapConverters}}
{{.Name}}.NewFactory(),
{{- end}}
},
Expand Down
Loading