fix: use godotenv.Read for per-location credential isolation - #68
Open
AlbeeSo wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Behavior changes:
Tested on ACK cluster with: