fix use of x-* attribute in go templates (#22403)

## Description

fix
https://docs.docker.com/compose/bridge/customize/#add-your-own-templates
as attributes with a `-` can't be accessed directly using dot-notation
in a go template. See
https://stackoverflow.com/questions/48146448/range-through-values-within-variable-containing-dashes-in-golang-templates

## Related issues or tickets

## Reviews

- [ ] Technical review
- [ ] Editorial review
- [ ] Product review

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De loof 2025-04-10 10:30:57 +02:00 committed by GitHub
parent b720d48b04
commit 6057a7b51f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -133,8 +133,8 @@ metadata:
spec:
rules:
{{ range $name, $service := .services }}
{{ if $service.x-virtual-host }}
- host: ${{ $service.x-virtual-host }}
{{ range index $service "x-virtual-host" }}
- host: ${{ . }}
http:
paths:
- path: "/"