score-spec / score-compose

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

feat: pass through workload metadata.annotations onto services #134

Closed astromechza closed 5 months ago

astromechza commented 5 months ago

This allows annotations to be used during post processing, and this also follows the general behavior of other score implementations.

For example injecting dapr sidecars:

yq '(.services) += (.services | 
  with_entries(select((.value | has("hostname")) and (.value.annotations | has("dapr.io/enabled")))) | 
  with_entries(. as $e | .key |= . + "-sidecar"| .value |= {"image": "daprio/daprd:latest", "command": ["./daprd","--app-id", ($e.value.annotations."dapr.io/app-id" | "unknown")], "network_mode": "service:" + $e.key}))' examples/01-hello/compose.yaml

This would support score workloads with the dapr enabled annotation.

apiVersion: score.dev/v1b1
metadata:
  name: foo
  annotations:
    dapr.io/enabled: "true"
    dapr.io/app-id: "foo-app"
...

🎸