compose/pkg/e2e/testdata/TestUnsupportedAttributesWarning/compose.yaml
Nicolas De Loof 228bb9738c fix(config): warn about ignored uid/gid/mode at creation, not at load
uid, gid and mode on a service-level configs:/secrets: reference are applied
when the object is copied into the container (content: and environment:
sources) and dropped when it is bind-mounted (file: sources). That is a
property of how the container is created, not of the compose file, and an
engine able to set ownership on bind mounts would change the answer.

Report them from create(), next to the other creation-time warnings, once
per requested service, instead of from the load-time unsupported-attribute
check. The false positive on inline and environment sources goes away
without post-filtering findings against the loaded project.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2026-11-05 09:47:51 +01:00

77 lines
1.8 KiB
YAML

services:
# Baseline: deploy.resources/replicas/restart_policy ARE honored outside
# Swarm, a port without an explicit mode defaults to mode: ingress, and
# label_file is resolved into real labels by compose-go's loader by
# default — none of these must ever produce a warning.
clean:
image: alpine
deploy:
replicas: 2
resources:
limits:
cpus: "0.50"
memory: 128M
restart_policy:
condition: on-failure
ports:
- "9090:90"
label_file:
- ./labels.env
# Every deploy.* sub-attribute that's silently ignored outside Swarm.
swarm-attrs:
image: alpine
credential_spec:
file: ./creds.json
deploy:
mode: replicated
labels:
team: backend
update_config:
parallelism: 1
failure_action: rollback
rollback_config:
parallelism: 1
placement:
constraints:
- node.role==manager
endpoint_mode: vip
# ports[].mode: host is Swarm-only.
ports-demo:
image: alpine
ports:
- target: 80
published: "8080"
mode: host
# volumes[].type: cluster (CSI) has no effect outside Swarm.
cluster-vol:
image: alpine
volumes:
- type: cluster
source: my-csi-volume
target: /data
# references the configs/secrets below. Their uid/gid/mode are not a
# load-time matter — see TestFileReferenceOverridesWarning.
file-refs:
image: alpine
configs:
- source: myconfig
secrets:
- source: mysecret
configs:
myconfig:
file: ./myconfig.txt
labels:
team: backend # configs[].labels: reachable and flagged
secrets:
mysecret:
file: ./mysecret.txt
driver_opts: # secrets[].driver_opts: reachable and flagged (unlike configs)
region: eu-west
labels:
team: backend