Skip to content

feat: support build.args list form and add build --build-arg flag - #143

Open
OrtegaMatias wants to merge 1 commit into
Mcrich23:mainfrom
OrtegaMatias:feat/build-args
Open

feat: support build.args list form and add build --build-arg flag#143
OrtegaMatias wants to merge 1 commit into
Mcrich23:mainfrom
OrtegaMatias:feat/build-args

Conversation

@OrtegaMatias

Copy link
Copy Markdown
Contributor

Summary

Completes build.args support end-to-end:

Details

#136 — list-form build.args

Build.args only decoded [String: String] (map form), so this valid Compose file crashed at decode time:

nginx:
  build:
    context: nginx
    args:
      - DIR=development        # ← list form

Build now accepts map or list, reusing the exact same list-parsing semantics environment: already uses. To avoid duplicating that logic, the body of Service.parseEnvironmentList is lifted into a shared parseComposeKeyValueList(_:) helper that both environment: and build.args: call — split on the first = (so values keep internal =), and a bare KEY inherits from the environment.

#69build --build-arg

container-compose build --build-arg TOKEN=$TOKEN --build-arg ENV=prod

Previously failed with Unknown option '--build-arg'. Now, per Docker parity:

  • compose-file args: values are interpolated against the environment (unchanged),
  • CLI --build-arg values are passed through as-is and win on key conflicts,
  • a bare --build-arg KEY inherits 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:

swift test --filter Container_Compose_StaticTests
✔ Test run with 243 tests in 21 suites passed

New static tests:

  • list-form build.args decode + the exact DecodingError.typeMismatch in build args #136 repro at the DockerCompose level
  • list-form value with an internal = (DSN) round-trips
  • --build-arg flag parsing (repeated + default-empty)
  • CLI-overrides-file precedence, and non-colliding CLI+file args both kept

No changes to the dynamic (daemon) tests.

Scope

--build-arg is added only to the build subcommand (parity with Docker). environment: behavior is unchanged (its existing list-form tests still pass after the shared-helper extraction).

`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
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.

DecodingError.typeMismatch in build args build command: add support for --build-arg flag

1 participant