Skip to content

fix: use godotenv.Read for per-location credential isolation - #68

Open
AlbeeSo wants to merge 1 commit into
AliyunContainerService:masterfrom
AlbeeSo:feat/support-different-auth-for-bslvsl
Open

fix: use godotenv.Read for per-location credential isolation#68
AlbeeSo wants to merge 1 commit into
AliyunContainerService:masterfrom
AlbeeSo:feat/support-different-auth-for-bslvsl

Conversation

@AlbeeSo

@AlbeeSo AlbeeSo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Replace godotenv.Overload with godotenv.Read in getCredentials to avoid polluting process-wide environment variables. This enables proper per-location credential isolation when BSL and VSL reference different Kubernetes Secrets via spec.credential.

Previously, loading a credentials file via godotenv.Overload would call os.Setenv, permanently mutating the process environment. This caused a bug where BSL credentials leaked into VSL when VSL had no credentials file configured (it would pick up BSL's stale env vars instead of falling through to RAM Role).

Changes:

  • Replace loadCredentialFileFromEnv (godotenv.Overload) with getCredFilePath + readCredentialFile (godotenv.Read)
  • When credentialsFile is present, read into a local map only
  • When no credentialsFile, fall back to process env vars as before
  • Extract env var names into constants (envAccessKeyID, etc.)
  • Fix typo in error message (credientials -> credentials)

Behavior changes:

  • credentialsFile no longer leaks into other plugin instances
  • Partial credentials in file (e.g. AK without SK) no longer combine with process env vars; the file is authoritative for that location

Tested on ACK cluster with:

  • BSL using spec.credential -> oss-secret (static AK)
  • VSL using ECS instance RAM Role (no spec.credential)
  • Both paths work independently without interference

Replace godotenv.Overload with godotenv.Read in getCredentials to avoid
polluting process-wide environment variables. This enables proper
per-location credential isolation when BSL and VSL reference different
Kubernetes Secrets via spec.credential.

Previously, loading a credentials file via godotenv.Overload would call
os.Setenv, permanently mutating the process environment. This caused a
bug where BSL credentials leaked into VSL when VSL had no credentials
file configured (it would pick up BSL's stale env vars instead of
falling through to RAM Role).

Changes:
- Replace loadCredentialFileFromEnv (godotenv.Overload) with
  getCredFilePath + readCredentialFile (godotenv.Read)
- When credentialsFile is present, read into a local map only
- When no credentialsFile, fall back to process env vars as before
- Extract env var names into constants (envAccessKeyID, etc.)
- Fix typo in error message (credientials -> credentials)

Behavior changes:
- credentialsFile no longer leaks into other plugin instances
- Partial credentials in file (e.g. AK without SK) no longer combine
  with process env vars; the file is authoritative for that location

Tested on ACK cluster with:
- BSL using spec.credential -> oss-secret (static AK)
- VSL using ECS instance RAM Role (no spec.credential)
- Both paths work independently without interference
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