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

Improve handling of environment variables in the pipe transformer #480

Closed
Hoeze opened this issue Jan 31, 2022 · 5 comments
Closed

Improve handling of environment variables in the pipe transformer #480

Hoeze opened this issue Jan 31, 2022 · 5 comments

Comments

@Hoeze
Copy link

Hoeze commented Jan 31, 2022

From https://github.com/projectglow/glow/blob/master/docs/source/tertiary/pipe-transformer.rst:

Options beginning with env_ are interpreted as environment variables. Like other options, the environment variable name is converted to lower snake case. For example, providing the option env_aniMal=MONKEY results in an environment variable with key ani_mal and value MONKEY being provided to the piped program.

Would it be possible to have some argument jsonEnv that can decode json-encoded environment variables?
E.g.:

jsonEnv='{"PATH": "/usr/bin"}'

This would make it significantly easier to adjust environment variables IMHO.

@Hoeze
Copy link
Author

Hoeze commented Jan 31, 2022

The snake-case parsing of arguments makes it impossible to pass uppercase environment variables, right?
E.g. env_TEST would get translated to t_e_s_t.

Interestingly, passing env_test_path='asdf' results in an environment variable test_path="asdf".
So actually there is no need to parse them as snake-case.

@williambrandler
Copy link
Contributor

williambrandler commented Feb 1, 2022

An alternative approach is to define environment variables via JSON and put those variables into your script, which is then run through the pipe transformer.

Here's an example,

Screen Shot 2022-02-01 at 1 28 27 PM

Screen Shot 2022-02-01 at 1 28 36 PM

I have never used the environment variable feature in glow. Probably because I hit the same limitations you describe above!

@Hoeze
Copy link
Author

Hoeze commented Feb 1, 2022

Ah, OK, I did not think of that solution 😁

@williambrandler
Copy link
Contributor

will keep the issue open for now until this is properly documented

should delete those environment variable options from the docs, they are somewhat confusing

@williambrandler
Copy link
Contributor

updating the example in the docs to avoid this issue in future:

#490

@a0x8o a0x8o closed this as completed Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants