cli icon indicating copy to clipboard operation
cli copied to clipboard

parse quotes from env-file - fixes #3630

Open brian316 opened this issue 8 months ago • 0 comments

- 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

brian316 avatar May 01 '25 18:05 brian316