-
Notifications
You must be signed in to change notification settings - Fork 242
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
Add option to configure fly by env #3789
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though you described what you were doing quite clearly, it took me a minute or two to figure out what this was doing. If would be a good idea for Michael and/or Ben to review this too.
We currently have FLY_ORG. This change would generalize this to pretty much any flag on any command.
if strings.ToUpper(parent.Name()) == "FLY" { | ||
return *cmd | ||
func EnvNameFromCmd(cmd *cobra.Command) string { | ||
if cmd.Parent() != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break existing users of FLY_ORG?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I broke that elsewhere; this is the "fix", but with a caveat:
FLY_ORG
by itself as an env var will do what you expect, but if you for instance do FLY_LAUNCH_ORG
, that will get precedence. Some examples:
list apps for org xxx:
FLY_ORG=xxx fly apps list
list apps for org yyy:
FLY_APPS_ORG=yyy fly apps list
list apps for org yyy:
FLY_ORG=xxx FLY_APPS_ORG=yyy fly apps list
Change Summary
What and Why:
Allow config to be set by env vars for most flags.
Let's say you're managing multiple infrastructure setups, it can be be convenient to have certain flags/options set in the environment; this is a "one-size" solution for that; the precedence is still any flags you might specify, but if no flag is specified, we check for the corresponding env var (which is all-caps,
FLY_
prefixed stuff).This is a draft/idea for now - I'd love to have a discussion about whether this makes sense or not :)