Skip to content

Commit

Permalink
fixup! PoC: refactor variable sources
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
  • Loading branch information
m1kola committed Oct 20, 2023
1 parent c40d1a2 commit cd2ab54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions internal/resolution/variablesources/olm.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ func RequiredPackageVariable(allBundles []*catalogmetadata.Bundle, packageName,
// during the upstream call on the 2023-04-11 we decided to pin the version instead. But, we'll keep version range
// support under the covers in case we decide to pivot back.
if versionRange != "" && channelName != "" {
return nil, fmt.Errorf("package '%s' at version '%s' in channel '%s' not found", packageName, versionRange, channelName)
return nil, fmt.Errorf("no package '%s' matching version '%s' found in channel '%s'", packageName, versionRange, channelName)
}
if versionRange != "" {
return nil, fmt.Errorf("package '%s' at version '%s' not found", packageName, versionRange)
return nil, fmt.Errorf("no package '%s' matching version '%s' found", packageName, versionRange)
}
if channelName != "" {
return nil, fmt.Errorf("package '%s' in channel '%s' not found", packageName, channelName)
return nil, fmt.Errorf("no package '%s' found in channel '%s'", packageName, channelName)
}
return nil, fmt.Errorf("package '%s' not found", packageName)
return nil, fmt.Errorf("no package '%s' found", packageName)
}
sort.SliceStable(resultSet, func(i, j int) bool {
return catalogsort.ByVersion(resultSet[i], resultSet[j])
Expand Down Expand Up @@ -285,8 +285,6 @@ func filterBundleDependencies(allBundles []*catalogmetadata.Bundle, bundle *cata
func BundleUniquenessVariables(bundleVariables []*olmvariables.BundleVariable) ([]*olmvariables.BundleUniquenessVariable, error) {
result := []*olmvariables.BundleUniquenessVariable{}

// TODO: https://github.com/operator-framework/operator-controller/issues/459
// TODO: Get this merged: https://github.com/operator-framework/operator-controller/pull/461
bundleIDs := sets.Set[deppy.Identifier]{}
packageOrder := []string{}
bundleOrder := map[string][]deppy.Identifier{}
Expand Down
8 changes: 4 additions & 4 deletions internal/resolution/variablesources/olm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ func TestRequiredPackageVariable(t *testing.T) {
t.Run("package not found", func(t *testing.T) {
reqPackageVar, err := variablesources.RequiredPackageVariable([]*catalogmetadata.Bundle{}, "test-package", "", "")
assert.Nil(t, reqPackageVar)
assert.ErrorContains(t, err, "package 'test-package' not found")
assert.ErrorContains(t, err, "no package 'test-package' found")

reqPackageVar, err = variablesources.RequiredPackageVariable([]*catalogmetadata.Bundle{}, "test-package", "stable", "")
assert.Nil(t, reqPackageVar)
assert.ErrorContains(t, err, "package 'test-package' in channel 'stable' not found")
assert.ErrorContains(t, err, "no package 'test-package' found in channel 'stable'")

reqPackageVar, err = variablesources.RequiredPackageVariable([]*catalogmetadata.Bundle{}, "test-package", "", "1.0.0")
assert.Nil(t, reqPackageVar)
assert.ErrorContains(t, err, "package 'test-package' at version '1.0.0' not found")
assert.ErrorContains(t, err, "no package 'test-package' matching version '1.0.0' found")

reqPackageVar, err = variablesources.RequiredPackageVariable([]*catalogmetadata.Bundle{}, "test-package", "stable", "1.0.0")
assert.Nil(t, reqPackageVar)
assert.ErrorContains(t, err, "package 'test-package' at version '1.0.0' in channel 'stable' not found")
assert.ErrorContains(t, err, "no package 'test-package' matching version '1.0.0' found in channel 'stable'")
})
}

Expand Down

0 comments on commit cd2ab54

Please sign in to comment.