Skip to content

Commit a88a5cc

Browse files
committed
opm validate: make sure skipped bundles are not included in replaces chain
Signed-off-by: Joe Lanford <[email protected]>
1 parent 2629279 commit a88a5cc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

alpha/model/model.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,18 @@ func (c *Channel) validateReplacesChain() error {
283283

284284
chainFrom := map[string][]string{}
285285
replacesChainFromHead := sets.NewString(head.Name)
286+
skippedInChain := sets.NewString()
286287
cur := head
287288
for cur != nil {
288289
if _, ok := chainFrom[cur.Name]; !ok {
289290
chainFrom[cur.Name] = []string{cur.Name}
290291
}
292+
if skippedBundles.Has(cur.Replaces) {
293+
break
294+
}
295+
for _, skip := range cur.Skips {
296+
skippedInChain = skippedInChain.Insert(skip)
297+
}
291298
for k := range chainFrom {
292299
chainFrom[k] = append(chainFrom[k], cur.Replaces)
293300
}
@@ -298,7 +305,7 @@ func (c *Channel) validateReplacesChain() error {
298305
cur = c.Bundles[cur.Replaces]
299306
}
300307

301-
strandedBundles := allBundles.Difference(replacesChainFromHead).Difference(skippedBundles).List()
308+
strandedBundles := allBundles.Difference(replacesChainFromHead).Difference(skippedInChain).List()
302309
if len(strandedBundles) > 0 {
303310
return fmt.Errorf("channel contains one or more stranded bundles: %s", strings.Join(strandedBundles, ", "))
304311
}

0 commit comments

Comments
 (0)