bump compose-go to v2.1.4

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours
2024-07-17 16:57:39 +02:00
parent 3005743f7c
commit ca452c47d8
18 changed files with 625 additions and 220 deletions

View File

@ -25,6 +25,7 @@ var defaultValues = map[tree.Path]transformFunc{}
func init() {
defaultValues["services.*.build"] = defaultBuildContext
defaultValues["services.*.secrets.*"] = defaultSecretMount
defaultValues["services.*.ports.*"] = portDefaults
}
// SetDefaultValues transforms a compose model to set default values to missing attributes

View File

@ -87,3 +87,18 @@ func encode(v any) (map[string]any, error) {
err = decoder.Decode(v)
return m, err
}
func portDefaults(data any, _ tree.Path, _ bool) (any, error) {
switch v := data.(type) {
case map[string]any:
if _, ok := v["protocol"]; !ok {
v["protocol"] = "tcp"
}
if _, ok := v["mode"]; !ok {
v["mode"] = "ingress"
}
return v, nil
default:
return data, nil
}
}