score-spec / score-compose

Reference implementation for docker-compose target platform support
https://score.dev/
Apache License 2.0
445 stars 40 forks source link

Build context parsing does not follow compose docs #130

Closed astromechza closed 4 months ago

astromechza commented 4 months ago

Describe the bug

The extend form of the --build arg to generate only supports a strict json structure and doesn't follow the compose spec.

To Reproduce

With the sample score file:

score-compose init
score-compose generate --build `'hello-world={"context":".","args":["thing"]}'` score.yaml

json: cannot unmarshal array into Go struct field BuildConfig.args of type types.MappingWithEquals

But it should succeed since the compose docs indicate that an array is allowed here (https://docs.docker.com/compose/compose-file/build/#args).

The work around is to use 'hello-world={"context":".","args":{"thing":null}}'.

Expected behavior

No error.

Additional context

The fix should be to replace the json unmarshal call with a call to the compose or mapstructure loaders instead.