Skip to content

Commit

Permalink
Merge pull request #4215 from cpuguy83/v0.11_cherry_pick_policy_ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
jedevc authored Sep 8, 2023
2 parents 832fdb5 + 28012fb commit d3e6c13
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions solver/llbsolver/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,27 +977,21 @@ func loadEntitlements(b solver.Builder) (entitlements.Set, error) {
}

func loadSourcePolicy(b solver.Builder) (*spb.Policy, error) {
set := make(map[spb.Rule]struct{}, 0)
var srcPol spb.Policy
err := b.EachValue(context.TODO(), keySourcePolicy, func(v interface{}) error {
x, ok := v.(spb.Policy)
if !ok {
return errors.Errorf("invalid source policy %T", v)
}
for _, f := range x.Rules {
set[*f] = struct{}{}
r := *f
srcPol.Rules = append(srcPol.Rules, &r)
}
srcPol.Version = x.Version
return nil
})
if err != nil {
return nil, err
}
var srcPol *spb.Policy
if len(set) > 0 {
srcPol = &spb.Policy{}
for k := range set {
k := k
srcPol.Rules = append(srcPol.Rules, &k)
}
}
return srcPol, nil
return &srcPol, nil
}

0 comments on commit d3e6c13

Please sign in to comment.