diff --git a/internal/resolution/variablesources/installed_package.go b/internal/resolution/variablesources/installed_package.go index c3a9ff268..071afaa73 100644 --- a/internal/resolution/variablesources/installed_package.go +++ b/internal/resolution/variablesources/installed_package.go @@ -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]) }) @@ -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]) }) diff --git a/internal/resolution/variablesources/installed_package_test.go b/internal/resolution/variablesources/installed_package_test.go index 1accbb830..23b785126 100644 --- a/internal/resolution/variablesources/installed_package_test.go +++ b/internal/resolution/variablesources/installed_package_test.go @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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/test-package@v5.0.0", 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/some-other-package@v2.3.0", + 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}, }, }