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

[data/values] support reading values from environment variables or passed-in flags #2

Closed
nimakaviani opened this issue Mar 5, 2019 · 9 comments
Labels
enhancement This issue is a feature request

Comments

@nimakaviani
Copy link
Contributor

the ytt user may wish to provide data values in the form of environment variables or by passing values through the command line. this is particularly beneficial when providing secrets.

As a user of ytt I expect it to provide me with either of the options above to provide or override values.

@cppforlife
Copy link
Contributor

cppforlife commented Mar 5, 2019

per our previous discussions, potential UX may look like this:

  • multiple values are read from env vars
    • ytt tpl ... --data-values-env BAR_
    • BAR_FOO_KEY1_KEY2 -> Foo.Key1.Key2
  • single value is read from command arg
    • ytt tpl ... --data-value-arg Foo.Key1.Key2=myval (where myval is YAML unmarshable value)
  • single value is read from file
    • ytt tpl ... --data-value-file Foo.Key1.Key2=path (where path is some file whose contents will be loaded as a string)

@cppforlife
Copy link
Contributor

as a side note, i was thinking one can "override" default values by specifying it in a dedicated overlay file, which brings an interesting question of how strict should --data-value-arg Foo.Key1.Key2=myval be? for example what if Foo.Key1.Key2 does not exist in the original values file?

@nimakaviani
Copy link
Contributor Author

I feel like the behavior should be merge here if the key does not exist but the values are supplied to the command line explicitly

@cppforlife
Copy link
Contributor

if the key does not exist but the values are supplied to the command line explicitly

only concern i have here is catching typos. that's why overlay functionality is conservative until it's marked as ok to be missing.

@cppforlife cppforlife added the enhancement This issue is a feature request label Mar 19, 2019
@emayssat
Copy link

I want this feature ;-)
I would like to read values passed on the command line or in the environment.
Any ETA for this feature?

@cppforlife
Copy link
Contributor

@emayssat thanks for bumping this up. ill think more about what this feature should look like this week.

@cppforlife
Copy link
Contributor

cppforlife commented May 2, 2019

@emayssat @afcastano ive added b076047 as a first cut for this feature. try it out. examples:

export YTT_key__env=123
ytt template -R -f . \
  --data-value key.subkey="value" \
  --data-value key.boolean=true \
  --data-values-env YTT \
  --data-value-file key.file=/path

values are yaml encoded.

above keys should be specified in configuration data values, otherwise overlaying will fail, eg

#@data/values
---
key:
  subkey:
  boolean:
  env:
  file:

@cppforlife
Copy link
Contributor

@emayssat @afcastano let me know if this works out for yall. have a good weekend.

@cppforlife cppforlife changed the title support reading values from environment variables or passed-in flags [data/values] support reading values from environment variables or passed-in flags May 3, 2019
@cppforlife
Copy link
Contributor

included in v0.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a feature request
Projects
None yet
Development

No branches or pull requests

3 participants