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

Allow for shell vars set to an empty value #624

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

marckhouzam
Copy link
Contributor

What this PR does / why we need it

If an shell variable is set it takes precedence over the same variable set in the tanzu config. However, if a shell variable was set to an empty value it was ignored.

With this commit, an empty value is no longer ignored as it is a valid value for a shell variable.

See #623 for an example.

Which issue(s) this PR fixes

Fixes #623

Describe testing done for PR

# Clean the plugin DB
$ rm ~/.cache/tanzu/plugin_inventory/default/

# Set a signature skip value for a test repo
$ tz config set env.TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST localhost:9876/tanzu-cli/plugins/central:small

# Set a shell variable that should take precedence that says "do not SKIP anything" in this shell
$ export TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST=''

# Confirm that the signature verification is performed, which means the shell variable is read
# and takes precedence over the one in the tanzu config 
$ tz plugin source update default -u localhost:9876/tanzu-cli/plugins/central:small
[i] Reading plugin inventory for "localhost:9876/tanzu-cli/plugins/central:small", this will take a few seconds.
[!] Unable to verify the plugins discovery image signature: failed validating the signature of the image localhost:9876/tanzu-cli/plugins/central:small :no matching signatures:
invalid signature when validating ASN.1 encoded signature
[x] Fatal, plugins discovery image signature verification failed. The `tanzu` CLI can not ensure the integrity of the plugins to be installed. To ignore this validation please append "localhost:9876/tanzu-cli/plugins/central:small" to the comma-separated list in the environment variable "TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST".  This is NOT RECOMMENDED and could put your environment at risk!

# Unset the shell variable and see that the one from the tanzu config is then read and that a skip is done
$ unset TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST
$ tz plugin source update default -u localhost:9876/tanzu-cli/plugins/central:small
[i] Reading plugin inventory for "localhost:9876/tanzu-cli/plugins/central:small", this will take a few seconds.
[!] Skipping the plugins discovery image signature verification for "localhost:9876/tanzu-cli/plugins/central:small"

[ok] updated discovery source default

Release note

A shell variable set to an empty value is no longer ignored by the CLI and takes precedence over a similar variable present in the tanzu config, as expected.

Additional information

Special notes for your reviewer

If an shell variable is set it takes precedence over the same variable
set in the tanzu config.  However, if a shell variable was set to an
empty value it was ignored.

With this commit, an empty value is no longer ignored as it is a valid
value for a shell variable.

Signed-off-by: Marc Khouzam <[email protected]>
@marckhouzam marckhouzam requested a review from a team as a code owner December 21, 2023 02:44
@marckhouzam marckhouzam added the kind/bug PR/issue related to a bug label Dec 21, 2023
@marckhouzam marckhouzam added this to the v1.2.0 milestone Dec 21, 2023
Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

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

LGTM

@marckhouzam marckhouzam merged commit ce43487 into vmware-tanzu:main Dec 21, 2023
7 checks passed
@marckhouzam marckhouzam deleted the fix/emptyVar branch December 21, 2023 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required kind/bug PR/issue related to a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shell variable set to an empty value is ignored
3 participants