Skip to content

feat(provider): clouds.yaml (cloud / OS_CLOUD) support - #12

Merged
PF9-pushkar merged 2 commits into
mainfrom
feat/provider-clouds-yaml
Jul 12, 2026
Merged

feat(provider): clouds.yaml (cloud / OS_CLOUD) support#12
PF9-pushkar merged 2 commits into
mainfrom
feat/provider-clouds-yaml

Conversation

@PF9-pushkar

Copy link
Copy Markdown
Collaborator

Part of #2 (Phase 1 follow-ups). When cloud (or OS_CLOUD) is set, auth defaults are sourced from a clouds.yaml entry.

  • Search order: $OS_CLIENT_CONFIG_FILE, ./clouds.yaml, ~/.config/openstack/clouds.yaml, /etc/openstack/clouds.yaml.
  • Precedence (per field): explicit provider config > OS_* env > clouds.yaml.
  • verify: false → insecure TLS; a single auth domain_name/domain_id fans out to both user and project domain unless a specific key overrides.
  • Uses gopkg.in/yaml.v3 (already in the module graph — promoted to a direct require, no new external dependency). secure.yaml, cloud profiles, and clouds-public.yaml are not yet resolved.

Tests: unit tests for the parser (internal/clients/clouds_test.go) and for the config > env > clouds.yaml precedence including the empty-config edge case (internal/provider/config_test.go).

Adversarial review fix included: an explicitly-empty config value (e.g. a variable defaulting to "") now correctly falls through to the env var instead of skipping straight to the clouds.yaml fallback — restoring the documented precedence and matching terraform-provider-openstack's env-default behavior.

build / vet / gofmt / golangci-lint (0 issues) / unit tests all clean.

When `cloud` (or OS_CLOUD) is set, load that named entry from a clouds.yaml file
and use its auth/TLS settings as the lowest-precedence defaults. Search order:
$OS_CLIENT_CONFIG_FILE, ./clouds.yaml, ~/.config/openstack/clouds.yaml,
/etc/openstack/clouds.yaml. Per-field precedence is explicit provider config >
OS_* env > clouds.yaml. `verify: false` maps to insecure TLS; a single auth
domain_name/id fans out to both user and project domain unless overridden.

Uses gopkg.in/yaml.v3 (already in the module graph; promoted to a direct
require) — no new external dependency. secure.yaml, cloud profiles, and
clouds-public.yaml are not yet resolved. Unit-tested; build/gofmt/lint clean.
strval returned an explicitly-empty config string (e.g. a variable defaulting to
"") as-is instead of consulting the env var, so pick() coalesced it straight to
the clouds.yaml fallback — silently skipping the OS_* env layer and inverting the
documented config > env > clouds.yaml precedence. Treat an empty config value as
unset (matching terraform-provider-openstack's env-default behavior). Added unit
tests for strval/pick precedence. Found by adversarial review.
@PF9-pushkar
PF9-pushkar merged commit f0c3c53 into main Jul 12, 2026
4 checks passed
@PF9-pushkar
PF9-pushkar deleted the feat/provider-clouds-yaml branch July 12, 2026 03:58
PF9-pushkar added a commit that referenced this pull request Jul 14, 2026
feat(provider): clouds.yaml (cloud / OS_CLOUD) support
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.

1 participant