Skip to content

Commit

Permalink
Add support for providers
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 ced38e8 commit 86ecb23
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .chloggen/components_cmd_add_providers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: otelcol

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Adds support for listing config providers in components command's output

# One or more tracking issues or pull requests related to the change
issues: [11570]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
6 changes: 5 additions & 1 deletion cmd/builder/internal/builder/templates/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ func main() {
{{- range .ConfmapProviders}}
{{.Name}}.NewFactory(),
{{- end}}
},
}, ProviderModules: map[string]string{
{{- range .ConfmapProviders}}
"{{.Name}}": "{{.GoMod}}",
{{- end}}
},
{{- if .ConfmapConverters }}
ConverterFactories: []confmap.ConverterFactory{
{{- range .ConfmapConverters}}
Expand Down
6 changes: 6 additions & 0 deletions cmd/otelcorecol/main.go

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

3 changes: 3 additions & 0 deletions confmap/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ 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
18 changes: 18 additions & 0 deletions otelcol/command_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ type componentWithStability struct {
Stability map[string]string
}

type componentWithoutStability struct {
Name string
Module string
}

type componentsOutput struct {
BuildInfo component.BuildInfo
Receivers []componentWithStability
Processors []componentWithStability
Exporters []componentWithStability
Connectors []componentWithStability
Extensions []componentWithStability
Providers []componentWithoutStability
}

// newComponentsCommand constructs a new components command using the given CollectorSettings.
Expand Down Expand Up @@ -109,6 +115,18 @@ 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.ConfigProviderSettings.ResolverSettings.ProviderModules[scheme+"provider"]
components.Providers = append(components.Providers, componentWithoutStability{
Name: scheme,
Module: module,
})
}

yamlData, err := yaml.Marshal(components)
if err != nil {
return err
Expand Down

0 comments on commit 86ecb23

Please sign in to comment.