Skip to content

Commit 9acb503

Browse files
committed
switch tactics
Signed-off-by: grokspawn <jordan@nimblewidget.com>
1 parent 69881b6 commit 9acb503

File tree

4 files changed

+13
-26
lines changed

4 files changed

+13
-26
lines changed

alpha/declcfg/declcfg_to_model.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package declcfg
22

33
import (
44
"fmt"
5-
"slices"
65

76
"github.com/blang/semver/v4"
87
"k8s.io/apimachinery/pkg/util/sets"
@@ -67,14 +66,6 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) {
6766
// This API is in alpha stage and it is subject to change.
6867
Properties: c.Properties,
6968
}
70-
for _, entry := range c.Entries {
71-
// invalid if there is a skips edge which matches a replacement edge
72-
if entry.Replaces != "" && len(entry.Skips) > 0 {
73-
if slices.Contains(entry.Skips, entry.Replaces) {
74-
return nil, fmt.Errorf("invalid package %q, channel %q: entry %q has identical replaces and skips: %q", c.Package, c.Name, entry.Name, entry.Replaces)
75-
}
76-
}
77-
}
7869

7970
cde := sets.Set[string]{}
8071
for _, entry := range c.Entries {

alpha/declcfg/declcfg_to_model_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -442,22 +442,6 @@ func TestConvertToModel(t *testing.T) {
442442
},
443443
},
444444
},
445-
{
446-
name: "Error/DuplicateSkipsReplaces",
447-
assertion: hasError(`invalid package "foo", channel "alpha": entry "foo.v0.1.0" has identical replaces and skips: "foo.v0.0.1"`),
448-
cfg: DeclarativeConfig{
449-
Packages: []Package{
450-
addPackageProperties(
451-
newTestPackage("foo", "alpha", svgSmallCircle),
452-
[]property.Property{
453-
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")},
454-
},
455-
),
456-
},
457-
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0", Replaces: "foo.v0.0.1", Skips: []string{"foo.v0.0.1"}})},
458-
Bundles: []Bundle{newTestBundle("foo", "0.1.0")},
459-
},
460-
},
461445
}
462446

463447
for _, s := range specs {

alpha/model/model.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ func (c *Channel) validateReplacesChain() error {
288288
if _, ok := chainFrom[cur.Name]; !ok {
289289
chainFrom[cur.Name] = []string{cur.Name}
290290
}
291+
// if the replaces edge is known to be skipped, disregard it
292+
if skippedBundles.Has(cur.Replaces) {
293+
break
294+
}
291295
for k := range chainFrom {
292296
chainFrom[k] = append(chainFrom[k], cur.Replaces)
293297
}

alpha/model/model_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,15 @@ func TestValidReplacesChain(t *testing.T) {
164164
}},
165165
assertion: hasError(`channel contains one or more stranded bundles: anakin.v0.0.1`),
166166
},
167-
}
167+
{
168+
name: "Error/SkippedReplacesStranded",
169+
ch: Channel{Bundles: map[string]*Bundle{
170+
"anakin.v0.0.1": {Name: "anakin.v0.0.1"},
171+
"anakin.v0.0.2": {Name: "anakin.v0.0.2", Replaces: "anakin.v0.0.1"},
172+
"anakin.v0.0.3": {Name: "anakin.v0.0.3", Replaces: "anakin.v0.0.2", Skips: []string{"anakin.v0.0.2"}},
173+
}},
174+
assertion: hasError(`channel contains one or more stranded bundles: anakin.v0.0.1`),
175+
}}
168176
for _, s := range specs {
169177
t.Run(s.name, func(t *testing.T) {
170178
err := s.ch.validateReplacesChain()

0 commit comments

Comments
 (0)