compose-spec / compose-go

Reference library for parsing and loading Compose YAML files
https://compose-spec.io
Apache License 2.0
355 stars 112 forks source link

secrets & config mount merge violates compose spec #662

Open edwardpeek-crown-public opened 3 months ago

edwardpeek-crown-public commented 3 months ago

Per https://github.com/compose-spec/compose-spec/blob/master/13-merge.md#unique-resources

Applies to the ports, volumes, secrets and configs services attributes. While these types are modeled in a Compose file as a sequence, they have special uniqueness requirements:

Attribute Unique key volumes target secrets source configs source ports {ip, target, published, protocol}

But current behaviour is to merge based on target instead, as demonstrated by https://github.com/compose-spec/compose-go/blob/main/override/merge_mounts_test.go :

services:
  test:
    image: foo
    secrets:
      - foo
      - bar
      - zot

merged with

services:
  test:
    image: foo
    secrets:
      - source: zot
        target: /run/secrets/foo

results in

services:
  test:
    image: foo
    secrets:
      - source: zot
        target: /run/secrets/foo
      - bar
      - zot

Per compose spec the output should be

services:
  test:
    image: foo
    secrets:
      - foo
      - bar
      - source: zot
        target: /run/secrets/foo
ndeloof commented 5 days ago

that's indeed a mistake writing the spec, thanks for reporting