From ab2e1c6a1de61b1c1703ee17c5cbf8df79076841 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 --- .vscode/launch.json | 18 +++++++++++ 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 +++---- test/e2e/e2e_suite_test.go | 6 ++-- .../extension_developer_test.go | 4 +-- 11 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..fa20e7e9d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Process", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "cmd/manager/main.go", + "args": [ + + ] + } + ] +} \ No newline at end of file diff --git a/go.mod b/go.mod index d6d23f6e6..d8b9e8ed0 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-logr/logr v1.4.2 github.com/google/go-cmp v0.6.0 github.com/operator-framework/api v0.23.0 - github.com/operator-framework/catalogd v0.12.0 + github.com/operator-framework/catalogd v0.13.0 github.com/operator-framework/helm-operator-plugins v0.2.1 github.com/operator-framework/operator-registry v1.40.0 github.com/operator-framework/rukpak v0.20.1-0.20240510194410-99faf1c1763f diff --git a/go.sum b/go.sum index 40f69580d..4e014ece8 100644 --- a/go.sum +++ b/go.sum @@ -393,8 +393,8 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= 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/helm-operator-plugins v0.2.1 h1:xPD05rYpIYKlI9VXfQBQ3XG7LFF2fALqg72lqAyFF44= github.com/operator-framework/helm-operator-plugins v0.2.1/go.mod h1:SJyyAVYkl3tqiTJl16mz0KbGv89NhPOOGRBeQb8S4Nw= github.com/operator-framework/operator-lib v0.12.0 h1:OzpMU5N7mvFgg/uje8FUUeD24Ahq64R6TdN25uswCYA= 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 66c7f29f0..b867f2201 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -591,12 +591,12 @@ func (r *ClusterExtensionReconciler) generateBundleDeploymentForUnpack(bundlePat func (r *ClusterExtensionReconciler) SetupWithManager(mgr ctrl.Manager) error { controller, err := ctrl.NewControllerManagedBy(mgr). For(&ocv1alpha1.ClusterExtension{}). - Watches(&catalogd.Catalog{}, + Watches(&catalogd.ClusterCatalog{}, crhandler.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 721a0f716..da1b93bc1 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, *catalogd.Catalog) { +func testInit(t *testing.T) (*ocv1alpha1.ClusterExtension, *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, *catalogd.Catalog) { return clusterExtension, 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)) @@ -137,7 +137,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) @@ -366,7 +366,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/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{