Skip to content

fix(config/clouds): find the clouds config file independently of each… - #3983

Open
AntoninRuan wants to merge 1 commit into
gophercloud:mainfrom
AntoninRuan:indepedent_find
Open

fix(config/clouds): find the clouds config file independently of each…#3983
AntoninRuan wants to merge 1 commit into
gophercloud:mainfrom
AntoninRuan:indepedent_find

Conversation

@AntoninRuan

@AntoninRuan AntoninRuan commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Opening the PR as a follow up of this comment: #3949 (comment). (@stephenfin)

Change should make config files loading independent of each others as openstacksdk does

@github-actions github-actions Bot added edit:config This PR updates config code semver:minor Backwards-compatible change backport-v2 This PR will be backported to v2 labels Aug 21, 2026
@coveralls

coveralls commented Aug 21, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 63.585% (-0.003%) from 63.588% — AntoninRuan:indepedent_find into gophercloud:main

@Sharpz7 Sharpz7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I found two issues with the new independent file lookup behavior.

Assisted-By: Codex


if options.secureyamlReader != nil {
var secureClouds Clouds
if err := yaml.NewDecoder(options.secureyamlReader).Decode(&secureClouds); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WithCloudsYAML only sets the default reader, so this call falls through to filesystem discovery for secure.yaml. That means an in-memory config can unexpectedly pick up a same-named entry from the current directory or XDG config. Can we avoid filesystem lookup unless a secure reader/location was explicitly provided?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am adding a test to detect it and I'll see if I have time to change it in the week

if options.cloudsPublicyamlReader == nil {
if len(options.publicLocations) < 1 {
func readClouds(options *cloudOpts, ctype CloudsType) (map[string]Cloud, error) {
// Set the defaults and open the files for reading. This code only runs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WithLocations only sets locations[Default], so the secure lookup does not check beside the selected clouds.yaml. Existing callers using /custom/clouds.yaml and /custom/secure.yaml will silently lose the secure values. Can we preserve the companion lookup, or add a separate secure-file location option and update the docs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe we could make WithLocation also update the secure.yaml location file to keep old behavior. And have independent find only when no WithLocation is set.

That would mean we match openstack-cli when no options are passed. When only WithLocation is given we preserve old behavior and when both WithLocation and WithSecureLocation are given WithSecureLocation overrides the secure location.

Would you be ok with that?

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:config This PR updates config code semver:minor Backwards-compatible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants