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

[JUJU-2271] PatchEnvironment now correctly unsets env vars #169

Merged

Conversation

jack-w-shaw
Copy link
Member

@jack-w-shaw jack-w-shaw commented Nov 28, 2022

os.GetEnv doesn't distinguish between unset vars and vars set to the empty string. However, LookupEnv does. This means PatchEnvironment would leave behind env vars set to the empty string when they were previously unset

These env var would then be picked up by LookupEnv, which can cause unexpected errors.

Update dependencies as a drive-by

QA Steps

  • Verify unit tests pass

  • Verify juju unit testing suite passes as usual using this in place of juju/testing

  • Also, write a test for some code which uses os.LookupEnv, branching based it's second return var, and performs some validation on the env var value. Perhaps you are wish to parse a boolean config option from your environment.
    Verify these tests fail when you PatchEnvironment with upstream. Then verify the pass with this iteration

@jack-w-shaw jack-w-shaw force-pushed the JUJU-2271_fix_bug_unsetting_envvars branch from 9050411 to 5278ee0 Compare November 28, 2022 14:00
Copy link
Member

@manadart manadart left a comment

Choose a reason for hiding this comment

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

Might as well do a go mod tidy to pick up all the latest versions of the dependencies.

@jack-w-shaw jack-w-shaw force-pushed the JUJU-2271_fix_bug_unsetting_envvars branch from 5278ee0 to 1e9c1e3 Compare November 28, 2022 15:00
os.GetEnv doesn't distinguish between unset vars and vars set to the
empty string. However, LookupEnv does. This means PatchEnvironment would
leave behind env vars set to the empty string when they were previously
unset

These env var would then be picked up by LookupEnv, which can cause
unexpected errors.
@jack-w-shaw jack-w-shaw force-pushed the JUJU-2271_fix_bug_unsetting_envvars branch from 1e9c1e3 to 80ad743 Compare November 28, 2022 15:02
@jack-w-shaw jack-w-shaw merged commit 0e4da91 into juju:master Nov 28, 2022
@jack-w-shaw jack-w-shaw deleted the JUJU-2271_fix_bug_unsetting_envvars branch November 28, 2022 17:11
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