Skip to content

Expand list of accepted ENV vars for openstack.AuthOptionsFromEnv#3657

Open
danchild wants to merge 2 commits intogophercloud:mainfrom
danchild:patch-issue-3440
Open

Expand list of accepted ENV vars for openstack.AuthOptionsFromEnv#3657
danchild wants to merge 2 commits intogophercloud:mainfrom
danchild:patch-issue-3440

Conversation

@danchild
Copy link
Copy Markdown

@danchild danchild commented Mar 23, 2026

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

@github-actions github-actions bot added edit:openstack This PR updates common OpenStack code edit:gophercloud This PR updates common Gophercloud code semver:minor Backwards-compatible change backport-v2 This PR will be backported to v2 labels Mar 23, 2026
@winiciusallan
Copy link
Copy Markdown
Contributor

Hi @danchild, thanks for the PR.

Didn't take a look at the changes, but for reference, I would take a look at this issue, there may be useful discussions to take forward.

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 27, 2026

Coverage Status

coverage: 64.209% (+0.2%) from 64.022% — danchild:patch-issue-3440 into gophercloud:main

@danchild
Copy link
Copy Markdown
Author

danchild commented Apr 8, 2026

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v2 This PR will be backported to v2 edit:gophercloud This PR updates common Gophercloud code edit:openstack This PR updates common OpenStack code semver:minor Backwards-compatible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V3 Auth not properly implemented

3 participants