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

Add option to configure fly by env #3789

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

fliepeltje
Copy link
Contributor

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 :)

@fliepeltje fliepeltje requested a review from rubys July 27, 2024 11:47
@rubys rubys requested a review from benbjohnson July 27, 2024 13:16
Copy link
Contributor

@rubys rubys left a 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.

@rubys rubys requested a review from michaeldwan July 27, 2024 13:19
if strings.ToUpper(parent.Name()) == "FLY" {
return *cmd
func EnvNameFromCmd(cmd *cobra.Command) string {
if cmd.Parent() != nil {
Copy link
Contributor

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?

Copy link
Contributor Author

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

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

Successfully merging this pull request may close these issues.

2 participants