Skip to content

Commit

Permalink
use scheme directly in providerModules map keys
Browse files Browse the repository at this point in the history
Signed-off-by: ChrsMark <[email protected]>
  • Loading branch information
ChrsMark committed Jan 16, 2025
1 parent cb1e2fc commit c645175
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/builder/internal/builder/templates/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func main() {
},
}, ProviderModules: map[string]string{
{{- range .ConfmapProviders}}
"{{.Name}}": "{{.GoMod}}",
{{.Name}}.NewFactory().Create(confmap.ProviderSettings{}).Scheme(): "{{.GoMod}}",
{{- end}}
},
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/otelcorecol/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions otelcol/command_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,10 @@ func newComponentsCommand(set CollectorSettings) *cobra.Command {
}
components.BuildInfo = set.BuildInfo

confmapProviderFactories := set.ConfigProviderSettings.ResolverSettings.ProviderFactories
for _, confmapProvider := range confmapProviderFactories {
provider := confmapProvider.Create(set.ConfigProviderSettings.ResolverSettings.ProviderSettings)
scheme := provider.Scheme()
module := set.ProviderModules[scheme+"provider"]
for providerScheme, providerModuleModule := range set.ProviderModules {
components.Providers = append(components.Providers, componentWithoutStability{
Name: scheme,
Module: module,
Name: providerScheme,
Module: providerModuleModule,
})
}

Expand Down
4 changes: 2 additions & 2 deletions otelcol/command_components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func TestNewBuildSubCommand(t *testing.T) {
Factories: nopFactories,
ConfigProviderSettings: newDefaultConfigProviderSettings(t, []string{filepath.Join("testdata", "otelcol-nop.yaml")}),
ProviderModules: map[string]string{
"envprovider": "go.opentelemetry.io/collector/confmap/provider/envprovider v1.2.3",
"fileprovider": "go.opentelemetry.io/collector/confmap/provider/fileprovider v1.2.3",
"env": "go.opentelemetry.io/collector/confmap/provider/envprovider v1.2.3",
"file": "go.opentelemetry.io/collector/confmap/provider/fileprovider v1.2.3",
},
}
cmd := NewCommand(set)
Expand Down

0 comments on commit c645175

Please sign in to comment.