feat: support build.args list form and add build --build-arg flag - #143
Open
OrtegaMatias wants to merge 1 commit into
Open
feat: support build.args list form and add build --build-arg flag#143OrtegaMatias wants to merge 1 commit into
build --build-arg flag#143OrtegaMatias wants to merge 1 commit into
Conversation
`build.args` in list form (`- KEY=VALUE`) previously threw `DecodingError.typeMismatch` and crashed `up` (Mcrich23#136). It now decodes both the map and list forms, reusing the same shared list parser as `environment:`. Adds a repeatable `--build-arg KEY=VALUE` flag to the `build` subcommand (Mcrich23#69), matching `docker compose build`: CLI values override compose-file args on key conflict, and a bare `KEY` inherits its value from the environment. Closes Mcrich23#136 Closes Mcrich23#69
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.
Summary
Completes
build.argssupport end-to-end:build.argsin list form (- KEY=VALUE) threwDecodingError.typeMismatch: expected Mapping ... found Nodeand crashed the entireup.Buildnow decodes both the map form and the list form.--build-arg KEY=VALUEflag to thebuildsubcommand, matchingdocker compose build.Details
#136 — list-form
build.argsBuild.argsonly decoded[String: String](map form), so this valid Compose file crashed at decode time:Buildnow accepts map or list, reusing the exact same list-parsing semanticsenvironment:already uses. To avoid duplicating that logic, the body ofService.parseEnvironmentListis lifted into a sharedparseComposeKeyValueList(_:)helper that bothenvironment:andbuild.args:call — split on the first=(so values keep internal=), and a bareKEYinherits from the environment.#69 —
build --build-argPreviously failed with
Unknown option '--build-arg'. Now, per Docker parity:args:values are interpolated against the environment (unchanged),--build-argvalues are passed through as-is and win on key conflicts,--build-arg KEYinherits its value from the environment.The merge is a small pure function
mergedBuildArgs(fileArgs:cliArgs:), unit-tested independently of the daemon.Testing (TDD)
Written test-first. Full static suite is green locally:
New static tests:
build.argsdecode + the exact DecodingError.typeMismatch in build args #136 repro at theDockerComposelevel=(DSN) round-trips--build-argflag parsing (repeated + default-empty)No changes to the dynamic (daemon) tests.
Scope
--build-argis added only to thebuildsubcommand (parity with Docker).environment:behavior is unchanged (its existing list-form tests still pass after the shared-helper extraction).