Expand list of accepted ENV vars for openstack.AuthOptionsFromEnv#3657
Open
danchild wants to merge 2 commits intogophercloud:mainfrom
Open
Expand list of accepted ENV vars for openstack.AuthOptionsFromEnv#3657danchild wants to merge 2 commits intogophercloud:mainfrom
danchild wants to merge 2 commits intogophercloud:mainfrom
Conversation
Contributor
Author
|
Hi @mandre regarding the failed tests, I just pushed a new commit that allows for OS_DOMAIN_X to be set alongside OS_USER_DOMAIN_X and OS_PROJECT_DOMAIN_X provided that they are the same values. I also added a check to test if there is ambiguity between OS_TENANT_X and OS_PROJECT_X which hadn't been done in previous versions. |
According to the OpenStack API documentation, OS_USER_DOMAIN_ID, OS_USER_DOMAIN_NAME, OS_PROJECT_DOMAIN_ID, AND OS_PROJECT_DOMAIN_NAME are all valid inputs for identity v3. - Implement passing in vars if they exist and set OS_DOMAIN_ID and OS_DOMAIN_NAME only if they don't exist already. - Include ErrEnvironmentVarsExpectedEqual and ErrAmbiguousEnvironmentVarsClash error types to throw errors when there is unacceptable env variable ambiguity - Include unit tests to test for unacceptable ambiguity between env varibles API Reference: https://docs.openstack.org/python-openstackclient/2025.2/cli/authentication.html Signed-off-by: Dan Childers <dchilder@redhat.com>
For backwards compatibility, allow the use of OS_DOMAIN_NAME or OS_DOMAIN_ID with OS_USER_DOMAIN_X or OS_PROJECT_DOMAIN_X provided they are equal. Also, it is necessary to disambiguate OS_TENANT_X and OS_PROJECT_X if both are provided. Signed-off-by: Dan Childers <dchilder@redhat.com>
1c4055c to
84ea7ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3440 #3240
According to the OpenStack API documentation, OS_USER_DOMAIN_ID, OS_USER_DOMAIN_NAME, OS_PROJECT_DOMAIN_ID, AND OS_PROJECT_DOMAIN_NAME are all valid inputs for identity v3. The current
implementation of openstack.AuthOptionsFromEnv does not accept these environment variables as inputs.
This fix keeps the gophercloud.AuthOptions struct intact, keeping the semantics of the name domainID and domainName unchanged so we do not need refactor code that consumes the the struct. Instead a new implementation
of openstack.AuthOptionsFromEnv would check for the presence of the OS_USER_DOMAIN_X and
OS_PROJECT_DOMAIN_X environment variables and set domainID and domainName accordingly.
The difficult part is to resolve ambiguity between the env vars passed in and provide either warnings or errors
to the users depending on different combinations. Given that the approach to not changing gophercloud.AuthOptions
is the best path forward, dealing with this ambiguity needs to be iterated on, and I certainly need some help determining what users expect and what makes sense base on OpenStack identity v3 conventions.
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
API Reference: https://docs.openstack.org/python-openstackclient/2025.2/cli/authentication.html