Skip to content

Commit

Permalink
move provider modules to collector settings
Browse files Browse the repository at this point in the history
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
  • Loading branch information
ChrsMark committed Jan 7, 2025
1 parent 8df43e7 commit 337dadd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
12 changes: 6 additions & 6 deletions cmd/builder/internal/builder/templates/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ func main() {
{{- range .ConfmapProviders}}
{{.Name}}.NewFactory(),
{{- end}}
}, ProviderModules: map[string]string{
{{- range .ConfmapProviders}}
"{{.Name}}": "{{.GoMod}}",
{{- end}}
},
},
{{- if .ConfmapConverters }}
ConverterFactories: []confmap.ConverterFactory{
{{- range .ConfmapConverters}}
Expand All @@ -49,7 +45,11 @@ func main() {
DefaultScheme: "{{ .ConfResolver.DefaultURIScheme }}",
{{- end }}
},
},
}, ProviderModules: map[string]string{
{{- range .ConfmapProviders}}
"{{.Name}}": "{{.GoMod}}",
{{- end}}
},
}

if err := run(set); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions cmd/otelcorecol/main.go

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

3 changes: 0 additions & 3 deletions confmap/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ type ResolverSettings struct {
// It is required to have at least one factory.
ProviderFactories []ProviderFactory

// ProviderModules maps provider types to their respective go modules.
ProviderModules map[string]string

// DefaultScheme is the scheme that is used if ${} syntax is used but no schema is provided.
// If no DefaultScheme is set, ${} with no schema will not be expanded.
// It is strongly recommended to set "env" as the default scheme to align with the
Expand Down
3 changes: 3 additions & 0 deletions otelcol/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ type CollectorSettings struct {
// confmap.Providers watch for configuration changes.
ConfigProviderSettings ConfigProviderSettings

// ProviderModules maps provider types to their respective go modules.
ProviderModules map[string]string

// LoggingOptions provides a way to change behavior of zap logging.
LoggingOptions []zap.Option

Expand Down
9 changes: 5 additions & 4 deletions otelcol/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,13 +576,14 @@ func newDefaultConfigProviderSettings(tb testing.TB, uris []string) ConfigProvid
return ConfigProviderSettings{
ResolverSettings: confmap.ResolverSettings{
URIs: uris,
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",
},
ProviderFactories: []confmap.ProviderFactory{
fileProvider,
newEnvProvider(),
}, ProviderSettings: confmap.ProviderSettings{
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",
},
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion otelcol/command_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func newComponentsCommand(set CollectorSettings) *cobra.Command {
for _, confmapProvider := range confmapProviderFactories {
provider := confmapProvider.Create(set.ConfigProviderSettings.ResolverSettings.ProviderSettings)
scheme := provider.Scheme()
module := set.ConfigProviderSettings.ResolverSettings.ProviderModules[scheme+"provider"]
module := set.ProviderModules[scheme+"provider"]
components.Providers = append(components.Providers, componentWithoutStability{
Name: scheme,
Module: module,
Expand Down

0 comments on commit 337dadd

Please sign in to comment.