Skip to content

parse quotes from env-file - fixes #3630 #6046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brian316
Copy link

@brian316 brian316 commented May 1, 2025

- What I did

Enhanced CLI support for .env files by enabling automatic parsing and trimming of surrounding quotes when using --env-file.

Reference: #3630

- How I did it

Modified the pkg/kvfile package to trim matching beginning and ending quotes from values during parsing.

- How to verify it

Added a new test case: TestParseFromReaderWithQuotes.

Manual Verification (Windows 11)

create a .env test file

SECRET="mysecret"
SECRET2="'secret2'"

Build the CLI:

docker buildx bake
docker buildx bake --set binary.platform=windows/amd64

Run a container using the env file and compare behavior:

Before:

docker run --rm -it --name test --env-file .env alpine:latest env
# SECRET="mysecret"
# SECRET2="'secret2'"

After:

.\build\docker-windows-amd64.exe run --rm -it --name test --env-file .env alpine:latest env
# SECRET=mysecret
# SECRET2='secret2'

- Human readable description for the release notes

Fix: CLI now trims matching quotes in values from `.env` files when using `--env-file`.

- A picture of a cute animal (not mandatory but encouraged)

image

Signed-off-by: Brian Duenas <[email protected]>
@brian316 brian316 force-pushed the fix_env_file_parse branch from dd0d02e to dadf0f7 Compare May 1, 2025 18:06
@brian316 brian316 changed the title parse quotes from file - fixes #3630 parse quotes from env-file - fixes #3630 May 1, 2025
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