Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions internal/resolution/variablesources/installed_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ type successorsFunc func(allBundles []*catalogmetadata.Bundle, installedBundle *
func legacySemanticsSuccessors(allBundles []*catalogmetadata.Bundle, installedBundle *catalogmetadata.Bundle) ([]*catalogmetadata.Bundle, error) {
// find the bundles that replace the bundle provided
// TODO: this algorithm does not yet consider skips and skipRange
upgradeEdges := catalogfilter.Filter(allBundles, catalogfilter.Replaces(installedBundle.Name))
upgradeEdges := catalogfilter.Filter(allBundles, catalogfilter.And(
catalogfilter.WithPackageName(installedBundle.Package),
catalogfilter.Replaces(installedBundle.Name),
))
sort.SliceStable(upgradeEdges, func(i, j int) bool {
return catalogsort.ByVersion(upgradeEdges[i], upgradeEdges[j])
})
Expand All @@ -108,7 +111,10 @@ func semverSuccessors(allBundles []*catalogmetadata.Bundle, installedBundle *cat
return nil, err
}

upgradeEdges := catalogfilter.Filter(allBundles, catalogfilter.InMastermindsSemverRange(wantedVersionRangeConstraint))
upgradeEdges := catalogfilter.Filter(allBundles, catalogfilter.And(
catalogfilter.WithPackageName(installedBundle.Package),
catalogfilter.InMastermindsSemverRange(wantedVersionRangeConstraint),
))
sort.SliceStable(upgradeEdges, func(i, j int) bool {
return catalogsort.ByVersion(upgradeEdges[i], upgradeEdges[j])
})
Expand Down
49 changes: 34 additions & 15 deletions internal/resolution/variablesources/installed_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ import (
)

func TestInstalledPackageVariableSource(t *testing.T) {
channel := catalogmetadata.Channel{Channel: declcfg.Channel{
Name: "stable",
someOtherPackageChannel := catalogmetadata.Channel{Channel: declcfg.Channel{
Name: "stable",
Package: "some-other-package",
Entries: []declcfg.ChannelEntry{
{
Name: "some-other-package.v2.3.0",
},
},
}}
testPackageChannel := catalogmetadata.Channel{Channel: declcfg.Channel{
Name: "stable",
Package: "test-package",
Entries: []declcfg.ChannelEntry{
{
Name: "test-package.v0.0.1",
Expand Down Expand Up @@ -80,7 +90,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "0.0.1"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v0.0.2",
Expand All @@ -89,7 +99,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "0.0.2"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v0.1.0",
Expand All @@ -98,7 +108,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "0.1.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v0.1.1",
Expand All @@ -107,7 +117,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "0.1.1"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v0.2.0",
Expand All @@ -116,7 +126,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "0.2.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v1.0.0",
Expand All @@ -125,7 +135,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "1.0.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v3.0.0",
Expand All @@ -134,7 +144,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "3.0.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v2.0.0",
Expand All @@ -143,7 +153,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "2.0.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v2.1.0",
Expand All @@ -152,7 +162,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "2.1.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v2.2.0",
Expand All @@ -161,7 +171,7 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "2.2.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v4.0.0",
Expand All @@ -170,16 +180,25 @@ func TestInstalledPackageVariableSource(t *testing.T) {
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "4.0.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "test-package.v5.0.0",
Package: "test-package",
Image: "registry.io/repo/[email protected]",
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "5-0.0"}`)},
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "test-package", "version": "5.0.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&testPackageChannel},
},
{Bundle: declcfg.Bundle{
Name: "some-other-package.v2.3.0",
Package: "some-other-package",
Image: "registry.io/repo/[email protected]",
Properties: []property.Property{
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName": "some-other-package", "version": "2.3.0"}`)},
}},
InChannels: []*catalogmetadata.Channel{&channel},
InChannels: []*catalogmetadata.Channel{&someOtherPackageChannel},
},
}

Expand Down