Skip to content

Commit

Permalink
Merge pull request #2701 from tonistiigi/fix-link-entitlements
Browse files Browse the repository at this point in the history
bake: fix linking to targets with entitlements
  • Loading branch information
crazy-max authored Sep 25, 2024
2 parents fdda92f + c60afbb commit 8e47387
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path"
"path/filepath"
"regexp"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -502,6 +503,14 @@ func (c Config) loadLinks(name string, t *Target, m map[string]*Target, o map[st
if err := c.loadLinks(target, t2, m, o, visited); err != nil {
return err
}

// entitlements are inherited from linked targets
for _, ent := range t2.Entitlements {
if !slices.Contains(t.Entitlements, ent) {
t.Entitlements = append(t.Entitlements, ent)
}
}

if len(t.Platforms) > 1 && len(t2.Platforms) > 1 {
if !sliceEqual(t.Platforms, t2.Platforms) {
return errors.Errorf("target %s can't be used by %s because it is defined for different platforms %v and %v", target, name, t2.Platforms, t.Platforms)
Expand Down

0 comments on commit 8e47387

Please sign in to comment.