diff --git a/internal/rukpak/source/containers_image.go b/internal/rukpak/source/containers_image.go index 60841ea49..2394e5f30 100644 --- a/internal/rukpak/source/containers_image.go +++ b/internal/rukpak/source/containers_image.go @@ -21,6 +21,7 @@ import ( "github.com/containers/image/v5/types" "github.com/opencontainers/go-digest" "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/reconcile" ) type ContainersImageRegistry struct { @@ -36,7 +37,7 @@ func (i *ContainersImageRegistry) Unpack(ctx context.Context, bundle *BundleSour } if bundle.Image == nil { - return nil, NewUnrecoverable(fmt.Errorf("error parsing bundle, bundle %s has a nil image source", bundle.Name)) + return nil, reconcile.TerminalError(fmt.Errorf("error parsing bundle, bundle %s has a nil image source", bundle.Name)) } ////////////////////////////////////////////////////// @@ -46,7 +47,7 @@ func (i *ContainersImageRegistry) Unpack(ctx context.Context, bundle *BundleSour ////////////////////////////////////////////////////// imgRef, err := reference.ParseNamed(bundle.Image.Ref) if err != nil { - return nil, NewUnrecoverable(fmt.Errorf("error parsing image reference %q: %w", bundle.Image.Ref, err)) + return nil, reconcile.TerminalError(fmt.Errorf("error parsing image reference %q: %w", bundle.Image.Ref, err)) } canonicalRef, err := resolveCanonicalRef(ctx, imgRef, i.SourceContext) @@ -180,7 +181,7 @@ func resolveCanonicalRef(ctx context.Context, imgRef reference.Named, imageCtx * srcRef, err := docker.NewReference(imgRef) if err != nil { - return nil, NewUnrecoverable(fmt.Errorf("error creating reference: %w", err)) + return nil, reconcile.TerminalError(fmt.Errorf("error creating reference: %w", err)) } imgSrc, err := srcRef.NewImageSource(ctx, imageCtx) diff --git a/internal/rukpak/source/containers_image_test.go b/internal/rukpak/source/containers_image_test.go index 1d1c42dcd..32b43d2fc 100644 --- a/internal/rukpak/source/containers_image_test.go +++ b/internal/rukpak/source/containers_image_test.go @@ -20,6 +20,7 @@ import ( "github.com/opencontainers/go-digest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/operator-framework/operator-controller/internal/rukpak/source" ) @@ -143,7 +144,7 @@ func TestUnpackNameOnlyImageReference(t *testing.T) { // Attempt to pull and unpack the image _, err := unpacker.Unpack(context.Background(), bundleSource) assert.ErrorContains(t, err, "tag or digest is needed") - assert.ErrorAs(t, err, &source.Unrecoverable{}) + assert.ErrorIs(t, err, reconcile.TerminalError(nil)) } func TestUnpackUnservedTaggedImageReference(t *testing.T) { @@ -225,7 +226,7 @@ func TestUnpackInvalidNilImage(t *testing.T) { result, err := unpacker.Unpack(context.Background(), bundleSource) assert.Nil(t, result) assert.ErrorContains(t, err, "nil image source") - assert.ErrorAs(t, err, &source.Unrecoverable{}) + assert.ErrorIs(t, err, reconcile.TerminalError(nil)) assert.NoDirExists(t, filepath.Join(unpacker.BaseCachePath, bundleSource.Name)) } @@ -244,7 +245,7 @@ func TestUnpackInvalidImageRef(t *testing.T) { result, err := unpacker.Unpack(context.Background(), bundleSource) assert.Nil(t, result) assert.ErrorContains(t, err, "error parsing image reference") - assert.ErrorAs(t, err, &source.Unrecoverable{}) + assert.ErrorIs(t, err, reconcile.TerminalError(nil)) assert.NoDirExists(t, filepath.Join(unpacker.BaseCachePath, bundleSource.Name)) } diff --git a/internal/rukpak/source/unpacker.go b/internal/rukpak/source/unpacker.go index 5d2b5f633..f56de0010 100644 --- a/internal/rukpak/source/unpacker.go +++ b/internal/rukpak/source/unpacker.go @@ -13,17 +13,6 @@ type ImageSource struct { Ref string } -// Unrecoverable represents an error that can not be recovered -// from without user intervention. When this error is returned -// the request should not be requeued. -type Unrecoverable struct { - error -} - -func NewUnrecoverable(err error) Unrecoverable { - return Unrecoverable{err} -} - // Unpacker unpacks bundle content, either synchronously or asynchronously and // returns a Result, which conveys information about the progress of unpacking // the bundle content.