From a91c1883d82136288d95eb320f2d77b8d6f30239 Mon Sep 17 00:00:00 2001 From: Tayler Geiger Date: Mon, 20 May 2024 09:25:57 -0500 Subject: [PATCH] Update catalogd dep to v0.13.0 Fix references to Catalog and CatalogSpec --- go.mod | 2 +- go.sum | 4 +-- internal/catalogmetadata/cache/cache.go | 2 +- internal/catalogmetadata/cache/cache_test.go | 30 +++++++++---------- internal/catalogmetadata/client/client.go | 4 +-- .../catalogmetadata/client/client_test.go | 12 ++++---- .../clusterextension_controller.go | 6 ++-- test/e2e/cluster_extension_install_test.go | 10 +++---- ...r_extension_registryV1_limitations_test.go | 4 +-- test/e2e/e2e_suite_test.go | 6 ++-- .../extension_developer_test.go | 4 +-- 11 files changed, 42 insertions(+), 42 deletions(-) diff --git a/go.mod b/go.mod index 38770c70b..a43c8c125 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/blang/semver/v4 v4.0.0 github.com/go-logr/logr v1.4.1 github.com/google/go-cmp v0.6.0 - github.com/operator-framework/catalogd v0.12.0 + github.com/operator-framework/catalogd v0.13.0 github.com/operator-framework/operator-registry v1.40.0 github.com/operator-framework/rukpak v0.20.0 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index a6d81cff6..b147160b6 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,8 @@ github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/operator-framework/api v0.23.0 h1:kHymOwcHBpBVujT49SKOCd4EVG7Odwj4wl3NbOR2LLA= github.com/operator-framework/api v0.23.0/go.mod h1:oKcFOz+Xc1UhMi2Pzcp6qsO7wjS4r+yP7EQprQBXrfM= -github.com/operator-framework/catalogd v0.12.0 h1:Cww+CyowkfTFugB9ZjUDpKvumh2vPe/TjCUpMHDmVBM= -github.com/operator-framework/catalogd v0.12.0/go.mod h1:4lryGtBTVOdqlKR0MaVYnlsSOc7HiagVRVo3J4uIo7E= +github.com/operator-framework/catalogd v0.13.0 h1:yOhEb0LpvGbZymippotpau5gFMyUnq8zMnrEYrTaJIQ= +github.com/operator-framework/catalogd v0.13.0/go.mod h1:v405w8d89Lr7K8IVE/x/Q37JtxvgdzLXGpgJxJ2Nweg= github.com/operator-framework/operator-registry v1.40.0 h1:CaYNE4F/jzahpC7UCILItaIHmB5/oE0sS066nK+5Glw= github.com/operator-framework/operator-registry v1.40.0/go.mod h1:D2YxapkfRDgjqNTO9d3h3v0DeREbV+8utCLG52zrOy4= github.com/operator-framework/rukpak v0.20.0 h1:BqF1nIlocyYLMmv6CvlbtB9QTwSMrEfTzhA+H3+do3c= diff --git a/internal/catalogmetadata/cache/cache.go b/internal/catalogmetadata/cache/cache.go index d1471601d..85c1a81ac 100644 --- a/internal/catalogmetadata/cache/cache.go +++ b/internal/catalogmetadata/cache/cache.go @@ -66,7 +66,7 @@ type filesystemCache struct { // resources that have been successfully reconciled, unpacked, and are being served. // These requirements help ensure that we can rely on status conditions to determine // when to issue a request to update the cached Catalog contents. -func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *catalogd.Catalog) (io.ReadCloser, error) { +func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *catalogd.ClusterCatalog) (io.ReadCloser, error) { if catalog == nil { return nil, fmt.Errorf("error: provided catalog must be non-nil") } diff --git a/internal/catalogmetadata/cache/cache_test.go b/internal/catalogmetadata/cache/cache_test.go index bf6bd2f56..f6719522c 100644 --- a/internal/catalogmetadata/cache/cache_test.go +++ b/internal/catalogmetadata/cache/cache_test.go @@ -54,7 +54,7 @@ func TestCache(t *testing.T) { t.Run("FetchCatalogContents", func(t *testing.T) { type test struct { name string - catalog *catalogd.Catalog + catalog *catalogd.ClusterCatalog contents []byte wantErr bool tripper *MockTripper @@ -64,11 +64,11 @@ func TestCache(t *testing.T) { for _, tt := range []test{ { name: "valid non-cached fetch", - catalog: &catalogd.Catalog{ + catalog: &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ ResolvedSource: &catalogd.ResolvedCatalogSource{ Type: catalogd.SourceTypeImage, Image: &catalogd.ResolvedImageSource{ @@ -82,11 +82,11 @@ func TestCache(t *testing.T) { }, { name: "valid cached fetch", - catalog: &catalogd.Catalog{ + catalog: &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ ResolvedSource: &catalogd.ResolvedCatalogSource{ Type: catalogd.SourceTypeImage, Image: &catalogd.ResolvedImageSource{ @@ -102,11 +102,11 @@ func TestCache(t *testing.T) { }, { name: "cached update fetch with changes", - catalog: &catalogd.Catalog{ + catalog: &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ ResolvedSource: &catalogd.ResolvedCatalogSource{ Type: catalogd.SourceTypeImage, Image: &catalogd.ResolvedImageSource{ @@ -122,11 +122,11 @@ func TestCache(t *testing.T) { }, { name: "fetch error", - catalog: &catalogd.Catalog{ + catalog: &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ ResolvedSource: &catalogd.ResolvedCatalogSource{ Type: catalogd.SourceTypeImage, Image: &catalogd.ResolvedImageSource{ @@ -141,11 +141,11 @@ func TestCache(t *testing.T) { }, { name: "fetch internal server error response", - catalog: &catalogd.Catalog{ + catalog: &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ ResolvedSource: &catalogd.ResolvedCatalogSource{ Type: catalogd.SourceTypeImage, Image: &catalogd.ResolvedImageSource{ @@ -167,11 +167,11 @@ func TestCache(t *testing.T) { }, { name: "nil catalog.status.resolvedSource", - catalog: &catalogd.Catalog{ + catalog: &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ ResolvedSource: nil, }, }, @@ -181,11 +181,11 @@ func TestCache(t *testing.T) { }, { name: "nil catalog.status.resolvedSource.image", - catalog: &catalogd.Catalog{ + catalog: &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ ResolvedSource: &catalogd.ResolvedCatalogSource{ Image: nil, }, diff --git a/internal/catalogmetadata/client/client.go b/internal/catalogmetadata/client/client.go index 172f686c6..147a50842 100644 --- a/internal/catalogmetadata/client/client.go +++ b/internal/catalogmetadata/client/client.go @@ -23,7 +23,7 @@ type Fetcher interface { // server for the catalog provided. It returns an io.ReadCloser // containing the FBC contents that the caller is expected to close. // returns an error if any occur. - FetchCatalogContents(ctx context.Context, catalog *catalogd.Catalog) (io.ReadCloser, error) + FetchCatalogContents(ctx context.Context, catalog *catalogd.ClusterCatalog) (io.ReadCloser, error) } func New(cl client.Client, fetcher Fetcher) *Client { @@ -46,7 +46,7 @@ type Client struct { func (c *Client) Bundles(ctx context.Context) ([]*catalogmetadata.Bundle, error) { var allBundles []*catalogmetadata.Bundle - var catalogList catalogd.CatalogList + var catalogList catalogd.ClusterCatalogList if err := c.cl.List(ctx, &catalogList); err != nil { return nil, err } diff --git a/internal/catalogmetadata/client/client_test.go b/internal/catalogmetadata/client/client_test.go index 047861871..7d75f4f6e 100644 --- a/internal/catalogmetadata/client/client_test.go +++ b/internal/catalogmetadata/client/client_test.go @@ -105,7 +105,7 @@ func TestClient(t *testing.T) { name: "skip catalog missing Unpacked status condition", fakeCatalog: func() ([]client.Object, []*catalogmetadata.Bundle, map[string][]byte) { objs, bundles, catalogContentMap := defaultFakeCatalog() - objs = append(objs, &catalogd.Catalog{ + objs = append(objs, &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "foobar", }, @@ -220,11 +220,11 @@ func defaultFakeCatalog() ([]client.Object, []*catalogmetadata.Bundle, map[strin }` objs := []client.Object{ - &catalogd.Catalog{ + &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog-1", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { Type: catalogd.TypeUnpacked, @@ -234,11 +234,11 @@ func defaultFakeCatalog() ([]client.Object, []*catalogmetadata.Bundle, map[strin }, }, }, - &catalogd.Catalog{ + &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog-2", }, - Status: catalogd.CatalogStatus{ + Status: catalogd.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { Type: catalogd.TypeUnpacked, @@ -338,7 +338,7 @@ type MockFetcher struct { shouldError bool } -func (mc *MockFetcher) FetchCatalogContents(_ context.Context, catalog *catalogd.Catalog) (io.ReadCloser, error) { +func (mc *MockFetcher) FetchCatalogContents(_ context.Context, catalog *catalogd.ClusterCatalog) (io.ReadCloser, error) { if mc.shouldError { return nil, errors.New("mock cache error") } diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index d0d663b25..9fc30b286 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -470,12 +470,12 @@ func (r *ClusterExtensionReconciler) GenerateExpectedBundleDeployment(o ocv1alph func (r *ClusterExtensionReconciler) SetupWithManager(mgr ctrl.Manager) error { err := ctrl.NewControllerManagedBy(mgr). For(&ocv1alpha1.ClusterExtension{}). - Watches(&catalogd.Catalog{}, + Watches(&catalogd.ClusterCatalog{}, handler.EnqueueRequestsFromMapFunc(clusterExtensionRequestsForCatalog(mgr.GetClient(), mgr.GetLogger()))). WithEventFilter(predicate.Funcs{ UpdateFunc: func(ue event.UpdateEvent) bool { - oldObject, isOldCatalog := ue.ObjectOld.(*catalogd.Catalog) - newObject, isNewCatalog := ue.ObjectNew.(*catalogd.Catalog) + oldObject, isOldCatalog := ue.ObjectOld.(*catalogd.ClusterCatalog) + newObject, isNewCatalog := ue.ObjectNew.(*catalogd.ClusterCatalog) if !isOldCatalog || !isNewCatalog { return true diff --git a/test/e2e/cluster_extension_install_test.go b/test/e2e/cluster_extension_install_test.go index d7fc3c300..20284d9d7 100644 --- a/test/e2e/cluster_extension_install_test.go +++ b/test/e2e/cluster_extension_install_test.go @@ -37,7 +37,7 @@ const ( var pollDuration = time.Minute var pollInterval = time.Second -func testInit(t *testing.T) (*ocv1alpha1.ClusterExtension, string, *catalogd.Catalog) { +func testInit(t *testing.T) (*ocv1alpha1.ClusterExtension, string, *catalogd.ClusterCatalog) { var err error extensionCatalog, err := createTestCatalog(context.Background(), testCatalogName, os.Getenv(testCatalogRefEnvVar)) require.NoError(t, err) @@ -51,10 +51,10 @@ func testInit(t *testing.T) (*ocv1alpha1.ClusterExtension, string, *catalogd.Cat return clusterExtension, clusterExtensionName, extensionCatalog } -func testCleanup(t *testing.T, cat *catalogd.Catalog, clusterExtension *ocv1alpha1.ClusterExtension) { +func testCleanup(t *testing.T, cat *catalogd.ClusterCatalog, clusterExtension *ocv1alpha1.ClusterExtension) { require.NoError(t, c.Delete(context.Background(), cat)) require.Eventually(t, func() bool { - err := c.Get(context.Background(), types.NamespacedName{Name: cat.Name}, &catalogd.Catalog{}) + err := c.Get(context.Background(), types.NamespacedName{Name: cat.Name}, &catalogd.ClusterCatalog{}) return errors.IsNotFound(err) }, pollDuration, pollInterval) require.NoError(t, c.Delete(context.Background(), clusterExtension)) @@ -138,7 +138,7 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) { t.Log("By deleting the catalog first") require.NoError(t, c.Delete(context.Background(), extensionCatalog)) require.EventuallyWithT(t, func(ct *assert.CollectT) { - err := c.Get(context.Background(), types.NamespacedName{Name: extensionCatalog.Name}, &catalogd.Catalog{}) + err := c.Get(context.Background(), types.NamespacedName{Name: extensionCatalog.Name}, &catalogd.ClusterCatalog{}) assert.True(ct, errors.IsNotFound(err)) }, pollDuration, pollInterval) @@ -367,7 +367,7 @@ func getArtifactsOutput(t *testing.T) { } // get all catalogsources save them to the artifact path. - catalogsources := catalogd.CatalogList{} + catalogsources := catalogd.ClusterCatalogList{} if err := c.List(context.Background(), &catalogsources, client.InNamespace("")); err != nil { fmt.Printf("Failed to list catalogsources: %v", err) } diff --git a/test/e2e/cluster_extension_registryV1_limitations_test.go b/test/e2e/cluster_extension_registryV1_limitations_test.go index 90705748a..016148398 100644 --- a/test/e2e/cluster_extension_registryV1_limitations_test.go +++ b/test/e2e/cluster_extension_registryV1_limitations_test.go @@ -20,10 +20,10 @@ import ( func TestClusterExtensionPackagesWithWebhooksAreNotAllowed(t *testing.T) { ctx := context.Background() catalog, err := createTestCatalog(ctx, testCatalogName, os.Getenv(testCatalogRefEnvVar)) - defer func(cat *catalogd.Catalog) { + defer func(cat *catalogd.ClusterCatalog) { require.NoError(t, c.Delete(context.Background(), cat)) require.Eventually(t, func() bool { - err := c.Get(context.Background(), types.NamespacedName{Name: cat.Name}, &catalogd.Catalog{}) + err := c.Get(context.Background(), types.NamespacedName{Name: cat.Name}, &catalogd.ClusterCatalog{}) return errors.IsNotFound(err) }, pollDuration, pollInterval) }(catalog) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 5f9e4f0ca..8c32390bd 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -39,12 +39,12 @@ func TestMain(m *testing.M) { // createTestCatalog will create a new catalog on the test cluster, provided // the context, catalog name, and the image reference. It returns the created catalog // or an error if any errors occurred while creating the catalog. -func createTestCatalog(ctx context.Context, name string, imageRef string) (*catalogd.Catalog, error) { - catalog := &catalogd.Catalog{ +func createTestCatalog(ctx context.Context, name string, imageRef string) (*catalogd.ClusterCatalog, error) { + catalog := &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Spec: catalogd.CatalogSpec{ + Spec: catalogd.ClusterCatalogSpec{ Source: catalogd.CatalogSource{ Type: catalogd.SourceTypeImage, Image: &catalogd.ImageSource{ diff --git a/test/extension-developer-e2e/extension_developer_test.go b/test/extension-developer-e2e/extension_developer_test.go index 4b4bbe219..7de5f3fd7 100644 --- a/test/extension-developer-e2e/extension_developer_test.go +++ b/test/extension-developer-e2e/extension_developer_test.go @@ -47,11 +47,11 @@ func TestExtensionDeveloper(t *testing.T) { clusterExtension := ce t.Run(clusterExtension.ObjectMeta.Name, func(t *testing.T) { t.Parallel() - catalog := &catalogd.Catalog{ + catalog := &catalogd.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "catalog", }, - Spec: catalogd.CatalogSpec{ + Spec: catalogd.ClusterCatalogSpec{ Source: catalogd.CatalogSource{ Type: catalogd.SourceTypeImage, Image: &catalogd.ImageSource{