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

Log env vars which override the env file #483

Merged
merged 2 commits into from
Feb 28, 2024

Conversation

Sushisource
Copy link
Member

What was changed

Log any time an env var overrides an env file setting

Why?

It can be a bit confusing if you've forgotten you've set an env var. Helpful reminder.

Checklist

  1. Closes [Feature Request] Log notice when --env is getting overrode by env var #293

  2. How was this tested:
    Added unit test

  3. Any docs updates needed?

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only thing I really care about before approving is to remove the value from the log

temporalcli/commands.go Outdated Show resolved Hide resolved
@@ -254,11 +257,21 @@ func (c *CommandContext) populateFlagsFromEnv(flags *pflag.FlagSet) error {
flag.Name, anns[0], envVal, err)
return
}
if flag.Changed {
logCalls = append(logCalls, func(l *slog.Logger) {
l.Info("Env var overrode --env setting", "env_var", anns[0], "flag", flag.Name, "value", envVal)
Copy link
Member

@cretz cretz Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrmm, not sure we ever clarified the format of log keys (i.e. snake_case or what), I have no strong opinion here and I don't consider log keys to have stability guarantees anyways

temporalcli/commands.go Outdated Show resolved Hide resolved
@Sushisource Sushisource merged commit 7c2cf4c into cli-rewrite Feb 28, 2024
5 checks passed
@Sushisource Sushisource deleted the env-overrides-env-var branch February 28, 2024 20:41
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