bump compose-go to version v2.6.0

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours
2025-04-10 18:02:16 +02:00
parent f8de3c3bdc
commit 0b4e624aaa
23 changed files with 397 additions and 768 deletions

View File

@ -19,10 +19,9 @@ package override
import (
"cmp"
"fmt"
"strings"
"slices"
"github.com/compose-spec/compose-go/v2/tree"
"golang.org/x/exp/slices"
)
// Merge applies overrides to a config model
@ -62,6 +61,7 @@ func init() {
mergeSpecials["services.*.extra_hosts"] = mergeExtraHosts
mergeSpecials["services.*.healthcheck.test"] = override
mergeSpecials["services.*.labels"] = mergeToSequence
mergeSpecials["services.*.volumes.*.volume.labels"] = mergeToSequence
mergeSpecials["services.*.logging"] = mergeLogging
mergeSpecials["services.*.networks"] = mergeNetworks
mergeSpecials["services.*.sysctls"] = mergeToSequence
@ -104,7 +104,7 @@ func mergeYaml(e any, o any, p tree.Path) (any, error) {
func mergeMappings(mapping map[string]any, other map[string]any, p tree.Path) (map[string]any, error) {
for k, v := range other {
e, ok := mapping[k]
if !ok || strings.HasPrefix(k, "x-") {
if !ok {
mapping[k] = v
continue
}
@ -227,9 +227,17 @@ func mergeUlimit(_ any, o any, p tree.Path) (any, error) {
func mergeIPAMConfig(c any, o any, path tree.Path) (any, error) {
var ipamConfigs []any
for _, original := range c.([]any) {
configs, ok := c.([]any)
if !ok {
return o, fmt.Errorf("%s: unexpected type %T", path, c)
}
overrides, ok := o.([]any)
if !ok {
return o, fmt.Errorf("%s: unexpected type %T", path, c)
}
for _, original := range configs {
right := convertIntoMapping(original, nil)
for _, override := range o.([]any) {
for _, override := range overrides {
left := convertIntoMapping(override, nil)
if left["subnet"] != right["subnet"] {
// check if left is already in ipamConfigs, add it if not and continue with the next config