Skip to content

Commit

Permalink
Improve error message about missing bundles
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <[email protected]>
  • Loading branch information
m1kola committed Nov 3, 2023
1 parent aca6451 commit b83d5ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions internal/resolution/variablesources/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package variablesources

import (
"context"
"errors"
"fmt"
"sort"

Expand Down Expand Up @@ -94,7 +95,7 @@ func MakeBundleVariables(
// get bundle dependencies
dependencies, err := filterBundleDependencies(allBundles, head)
if err != nil {
return nil, fmt.Errorf("could not determine dependencies for bundle with id %q: %w", id, err)
return nil, fmt.Errorf("could not determine dependencies for bundle %q from package %q from catalog %q: %s", head.Name, head.Package, head.CatalogName, err)
}

// add bundle dependencies to queue for processing
Expand All @@ -119,7 +120,7 @@ func filterBundleDependencies(allBundles []*catalogmetadata.Bundle, bundle *cata
catalogfilter.InBlangSemverRange(requiredPackage.SemverRange),
))
if len(packageDependencyBundles) == 0 {
return nil, fmt.Errorf("could not find package dependencies for bundle %q", bundle.Name)
return nil, errors.New("could not find package dependencies for bundle")
}
for i := 0; i < len(packageDependencyBundles); i++ {
bundle := packageDependencyBundles[i]
Expand Down
4 changes: 2 additions & 2 deletions internal/resolution/variablesources/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestMakeBundleVariables_NonExistentDepedencies(t *testing.T) {
installedPackages := []*olmvariables.InstalledPackageVariable{}

bundles, err := variablesources.MakeBundleVariables(allBundles, requiredPackages, installedPackages)
assert.ErrorContains(t, err, `could not determine dependencies for bundle with id "fake-catalog-test-package-test-package.v1.0.0"`)
assert.ErrorContains(t, err, `could not determine dependencies for bundle "test-package.v1.0.0" from package "test-package" from catalog "fake-catalog"`)
assert.Nil(t, bundles)
}

Expand Down Expand Up @@ -550,7 +550,7 @@ var _ = Describe("BundlesAndDepsVariableSource", func() {
)
_, err := bdvs.GetVariables(context.TODO())
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(`could not determine dependencies for bundle with id "fake-catalog-test-package-bundle-2": could not find package dependencies for bundle "bundle-2"`))
Expect(err.Error()).To(ContainSubstring(`could not determine dependencies for bundle "bundle-2" from package "test-package" from catalog "fake-catalog": could not find package dependencies for bundle`))
})

It("should return error if an inner variable source returns an error", func() {
Expand Down

0 comments on commit b83d5ab

Please sign in to comment.