Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmd/opampsupervisor] Support environment variable expansion in supervisor config #36269

Open
mrsillydog opened this issue Nov 7, 2024 · 3 comments
Assignees
Labels

Comments

@mrsillydog
Copy link
Contributor

Component(s)

cmd/opampsupervisor

Is your feature request related to a problem? Please describe.

Currently, environment variable expansion is not supported in the supervisor configuration. For example, given the following configuration:

server:
  endpoint: ${OPAMP_SERVER_ENDPOINT}
agent:
  executable: /bin/otelcontribcol

and the following environment variable set:

echo $OPAMP_SERVER_ENDPOINT
ws://localhost/v1/opamp

the final configuration does not expand the referenced environment variable to result in a final configuration of:

server:
  endpoint: ws://localhost/v1/opamp
agent:
  executable: /bin/otelcontribcol

Describe the solution you'd like

I'd like to utilize the go.opentelemetry.io/collector/confmap Resolver along with the go.opentelemetry.io/collector/confmap/provider/envprovider and go.opentelemetry.io/collector/confmap/provider/fileprovider Providers to allow for the expansion of environment variables when the supervisor config is read in from file.

Describe alternatives you've considered

No response

Additional context

I'm happy to implement this enhancement if accepted.

@mrsillydog mrsillydog added enhancement New feature or request needs triage New item requiring triage labels Nov 7, 2024
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@mrsillydog mrsillydog changed the title Support environment variable expansion in [cmd/opampsupervisor] Support environment variable expansion in Nov 7, 2024
@mrsillydog mrsillydog changed the title [cmd/opampsupervisor] Support environment variable expansion in [cmd/opampsupervisor] Support environment variable expansion in supervisor config Nov 7, 2024
@VihasMakwana
Copy link
Contributor

Hi!

Just so you know, envprovider will only work if following config is supplied:

server:
  endpoint: ${env:OPAMP_SERVER_ENDPOINT}
agent:
  executable: /bin/otelcontribcol

notice the env prefix.

@mrsillydog
Copy link
Contributor Author

mrsillydog commented Nov 8, 2024

Hi!

Just so you know, envprovider will only work if following config is supplied:

server:
  endpoint: ${env:OPAMP_SERVER_ENDPOINT}
agent:
  executable: /bin/otelcontribcol

notice the env prefix.

Appreciate the call out! I plan to specify env as the default scheme in the resolver settings, so that specifying the prefix is unnecessary:

resolverSettings := confmap.ResolverSettings{
	URIs: []string{configFile},
	ProviderFactories: []confmap.ProviderFactory{
		fileprovider.NewFactory(),
		envprovider.NewFactory(),
	},
	ConverterFactories: []confmap.ConverterFactory{},
	DefaultScheme:      "env",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants