Skip to content

Commit

Permalink
extending a service, dependencies must be excluded
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Dec 9, 2024
1 parent 9a9cc5d commit 346c80c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion loader/extends.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
"github.com/compose-spec/compose-go/v2/types"
)

// as we use another service definition by `extends`, we must exclude attributes which creates dependency to another service
// see https://github.com/compose-spec/compose-spec/blob/main/05-services.md#restrictions
var exclusions = []string{"extends", "depends_on", "volumes_from"}

func ApplyExtends(ctx context.Context, dict map[string]any, opts *Options, tracker *cycleTracker, post ...PostProcessor) error {
a, ok := dict["services"]
if !ok {
Expand Down Expand Up @@ -123,7 +127,9 @@ func applyServiceExtends(ctx context.Context, name string, services map[string]a
if err != nil {
return nil, err
}
delete(merged, "extends")
for _, exclusion := range exclusions {
delete(merged, exclusion)
}
services[name] = merged
return merged, nil
}
Expand Down

0 comments on commit 346c80c

Please sign in to comment.