-
Notifications
You must be signed in to change notification settings - Fork 154
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
[9.0](backport #6602) Add support for variables in outputs and default provider #6754
Conversation
Adds support for context variables (ONLY) in outputs. Adds support for a default provide prefix to be defined for variables (default is env). This provides support for the original ${ES_PASSWORD} when used in outputs to still work as it will automatically map that to ${env.ES_PASSWORD} and it will get resolved for the context variables the same as it was being done by go-ucfg. This includes an improvement to how variables are observed in the composable controller and how it is used by the coordinator. Now when a set of observable's are passed to the composable controller it will return the current set of variables after the debounce time, this ensures that before the variables are substituted that it is using the latest set of variables. Without this change running would always show an error at first with ${env.ES_PASSWORD} is an unknown variable and then less than a few milliseconds it would find it. This change removes that behavior and is able to find the variable on initial render. (cherry picked from commit b59d51a)
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
buildkite test this |
@pierrehilbert I think I might have broken buildkite because the commit message for the change includes |
This pull request has not been merged yet. Could you please review and merge it @blakerouse? 🙏 |
buildkite test this |
|
What does this PR do?
Adds support for context variables (ONLY) in
outputs
. Adds support for a default provide prefix to be defined for variables (default isenv
). This provides support for the original${ES_PASSWORD}
when used inoutputs
to still work as it will automatically map that to${env.ES_PASSWORD}
and it will get resolved for the context variables the same as it was being done bygo-ucfg
.This includes an improvement to how variables are observed in the composable controller and how it is used by the coordinator. Now when a set of observable's are passed to the composable controller it will return the current set of variables after the debounce time, this ensures that before the variables are substituted that it is using the latest set of variables. Without this change running would always show an error at first with
${env.ES_PASSWORD}
is an unknown variable and then less than a few milliseconds it would find it. This change removes that behavior and is able to find the variable on initial render.Why is it important?
This allows the ability for all context provides to be able used in the outputs configuration. This is useful for using say the
kubernetes_secrets
provider in the policy for credentials or the newfilesource
provider to get a value from a file into the outputs. This is done in a way to not break compatibility with${ES_PASSWORD}
that could be used in outputs when it was rendered by go-ucfg, by the addition of a default provider setting (which defaults toenv
).Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files./changelog/fragments
using the changelog tool[ ] I have added an integration test or an E2E test(great coverage in unit tests)Disruptive User Impact
None.
How to test this PR locally
Replace a field in the
elastic-agent.yml
with a variable like from the environment provider.Run with the variables.
ES_USER=elastic ES_PASSWORD=password ./elastic-agent run -e
Observe that the ES_USER and ES_PASSWORD are substituted.
Related issues
This is an automatic backport of pull request #6602 done by [Mergify](https://mergify.com).