Skip to content

Commit

Permalink
[chore] rename confmap modules to ConfmapConverters and ConfmapProvid…
Browse files Browse the repository at this point in the history
…ers (#11678)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
change name in templates and cmd/builder to refer to Providers and
Converters as ConfmapProviders and ConfmapConverters
<!-- Issue number if applicable -->
#### Link to tracking issue
as requested here:
#11653 (comment)

<!--Describe what testing was performed and which tests were added.-->
#### Testing
existing tests should cover this
<!--Describe the documentation added.-->
#### Documentation
none, internal change and no new code/api
<!--Please delete paragraphs that you did not use before submitting.-->
  • Loading branch information
jackgopack4 authored Nov 14, 2024
1 parent 51d57f0 commit 1d87709
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
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

0 comments on commit 1d87709

Please sign in to comment.