Skip to content

Commit e022af7

Browse files
committed
Add support for providers
Signed-off-by: ChrsMark <[email protected]>
1 parent ced38e8 commit e022af7

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: otelcol
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Adds support for listing config providers in components command's output
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11570]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user]

cmd/builder/internal/builder/templates/main.go.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ func main() {
3333
{{- range .ConfmapProviders}}
3434
{{.Name}}.NewFactory(),
3535
{{- end}}
36-
},
36+
}, ProviderModules: map[string]string{
37+
{{- range .ConfmapProviders}}
38+
"{{.Name}}": "{{.GoMod}}",
39+
{{- end}}
40+
},
3741
{{- if .ConfmapConverters }}
3842
ConverterFactories: []confmap.ConverterFactory{
3943
{{- range .ConfmapConverters}}

cmd/otelcorecol/main.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

confmap/resolver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ type ResolverSettings struct {
3939
// It is required to have at least one factory.
4040
ProviderFactories []ProviderFactory
4141

42+
// ProviderModules maps provider types to their respective go modules.
43+
ProviderModules map[string]string
44+
4245
// DefaultScheme is the scheme that is used if ${} syntax is used but no schema is provided.
4346
// If no DefaultScheme is set, ${} with no schema will not be expanded.
4447
// It is strongly recommended to set "env" as the default scheme to align with the

otelcol/command_components.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ type componentWithStability struct {
2424
Stability map[string]string
2525
}
2626

27+
type componentWithoutStability struct {
28+
Name string
29+
Module string
30+
}
31+
2732
type componentsOutput struct {
2833
BuildInfo component.BuildInfo
2934
Receivers []componentWithStability
3035
Processors []componentWithStability
3136
Exporters []componentWithStability
3237
Connectors []componentWithStability
3338
Extensions []componentWithStability
39+
Providers []componentWithoutStability
3440
}
3541

3642
// newComponentsCommand constructs a new components command using the given CollectorSettings.
@@ -109,6 +115,18 @@ func newComponentsCommand(set CollectorSettings) *cobra.Command {
109115
})
110116
}
111117
components.BuildInfo = set.BuildInfo
118+
119+
confmapProviderFactories := set.ConfigProviderSettings.ResolverSettings.ProviderFactories
120+
for _, confmapProvider := range confmapProviderFactories {
121+
provider := confmapProvider.Create(set.ConfigProviderSettings.ResolverSettings.ProviderSettings)
122+
scheme := provider.Scheme()
123+
module := set.ConfigProviderSettings.ResolverSettings.ProviderModules[scheme+"provider"]
124+
components.Providers = append(components.Providers, componentWithoutStability{
125+
Name: scheme,
126+
Module: module,
127+
})
128+
}
129+
112130
yamlData, err := yaml.Marshal(components)
113131
if err != nil {
114132
return err

0 commit comments

Comments
 (0)