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

Fix command line arguments and non-AWS profile scoped arguments when an AWS profile is not present in the config. #196

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

MatthewJohn
Copy link
Contributor

@MatthewJohn MatthewJohn commented Feb 27, 2024

viper.Get() returns an empty string when an AWS profile exists in the config, but has not been set.
viper.Get() returns nil when the AWS profile does not exist in the config or the config file does not exist. viper.
viper.IsSet() returns will return false when the config/profile does not exist, but always returns true when the profile exists (irrelevant of whether the actual key is defined).

Combining these two means that:

  • When a config file does not exist or profile is not present in the config, IsSet will return false and the original key is returned.
  • When a config file does exist and the profile exists, but the config key does not exist, Get will return an empty string and the key is returned.
  • When a config file does exist, the profile exists and the key exists, IsSet returns true, Get returns non-empty string and the '.' key is returned.

Fixes #194

Addresses issue in #192

…an AWS profile is not present in the config.

viper.Get() returns an empty string when an AWS profile exists in the config, but has not been set.
viper.Get() returns nil when the AWS profile does not exist in the config or the config file does not exist.
viper.IsSet() returns will return false when the config/profile does not exist, but always returns true when the profile exists (irelevant of whether the actual key is defined).
Combining these two means that:
 * When a config file does not exist or profile is not present in the config, IsSet will return false and the original key is returned.
 * When a config file does exist and the profile exists, but the config key does not exist, Get will return an empty string and the key is returned.
 * When a config file does exist, the profile exists and the key exists, IsSet returns true, Get returns non-empty string and the '<profile>.<config>' key is returned.

Fixes okta#194

Addresses issue in okta#192
@MatthewJohn MatthewJohn marked this pull request as ready for review February 27, 2024 07:42
@shanesmith
Copy link

This does fix my use case, thanks!

@MatthewJohn
Copy link
Contributor Author

@shanesmith Thank you for testing it out and confirming :) :)

@monde monde merged commit 0e074e6 into okta:master Feb 27, 2024
1 check passed
@monde monde mentioned this pull request Feb 27, 2024
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.

Error when using profile argument in v2.1.1
3 participants