Skip to content

fix(config): improve config override behavior#817

Open
nhedger wants to merge 3 commits intoexoscale:masterfrom
nhedger:feat/improve-config-override
Open

fix(config): improve config override behavior#817
nhedger wants to merge 3 commits intoexoscale:masterfrom
nhedger:feat/improve-config-override

Conversation

@nhedger
Copy link
Copy Markdown

@nhedger nhedger commented Mar 25, 2026

Note

Disclosure:

  • AI assistance was used to implement this feature
  • Manual review and testing was done

Description

Fixes #737

This updates config resolution so environment variables override account credentials without discarding the rest of the selected profile.

Previously, when EXOSCALE_API_KEY and EXOSCALE_API_SECRET were set, the CLI returned early during config initialization and skipped loading the config file entirely. As a result, profile values such as defaultZone were ignored and commands relying on the account default zone could fall back to the built-in default instead of the zone configured in exoscale.toml.

This change now:

  • loads and selects the config profile first when a config file is available
  • applies environment overrides afterwards for credentials and related override fields
  • preserves profile settings such as defaultZone and other account defaults
  • keeps the existing env-only behavior when no config file is present
    This fixes the override precedence so env credentials replace authentication settings, not the whole profile.

Checklist

(For exoscale contributors)

  • Changelog updated (under Unreleased block, and add the Pull Request #number for each bit you add to the CHANGELOG.md)
  • Testing

Testing

  • Ran go test ./...
  • Ran targeted e2e coverage for the config/env precedence:
    • go test -run 'TestScriptsLocal/(show_with_env_credentials_keeps_config_defaults|show_with_env_credentials_without_config)$' -count=1 ./... from tests/e2e
  • Verified that:
    • env credentials still work without a config file
    • defaultZone from the config is preserved when env credentials are set
  • Confirmed that [Bug]: Default zone is not respected #737 cannot be reproduced anymore:
    export EXOSCALE_API_KEY="..."
    export EXOSCALE_API_SECRET="..."
    VOL_ID=$(./bin/exo --output-format json compute block-storage create repro-737-$(date +%s) --zone ch-gva-2 --size 10 | jq -r '.id')
    ./bin/exo compute block-storage list
    ./bin/exo compute block-storage show "$VOL_ID"
    ./bin/exo compute block-storage show "$VOL_ID" --zone ch-gva-2
    ./bin/exo compute block-storage delete "$VOL_ID" --zone ch-gva-2 -f

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.

[Bug]: Default zone is not respected

1 participant