compose-go
compose-go copied to clipboard
Services broken that start with x-
I hit something strange today that seems to be caused by:
https://github.com/compose-spec/compose-go/blob/b5ef325e9175ca7eb38290cc4ce1b5073c9c7b75/loader/loader.go#L209
I have a simple compose file:
version: "3"
services:
x-kiosk:
image: busybox:latest
command: "sleep 10m"
When I call proj.WithServices
, I get 2 two services. "x-kiosk" and one named "extensions". I'm not sure I fully understand this portion of the spec. However, I think that groupXFieldsIntoExtensions needs to skip service keys while recursing through the dict.
groupXFieldsIntoExtensions
indeed applies the x-*
reserved prefix logic everywhere, while docker-compose is not that strict.
According to the spec https://github.com/compose-spec/compose-spec/blob/master/spec.md#extension
Special extension fields can be of any format as long as their name starts with the x- character sequence. They can be used within any structure in a Compose file.
so, this is valid for an extension to be set within services
and MUST NOT be considered a service definition. That's a slight difference between the legacy implementation in docker-compose and the spec. I don't know any use of a services-level extension, but there might be use-cases for it and it would not be relevant to prevent this.
Better not use x-*
as your service naming scheme