diff --git a/README.md b/README.md index 1cc0f49c..0680bba8 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Procedure steps marked with an asterisk (`*`) are likely to change with future A ```sh $ kubectl apply -f - << EOF - apiVersion: olm.operatorframework.io/v1alpha1 + apiVersion: olm.operatorframework.io/v1 kind: ClusterCatalog metadata: name: operatorhubio @@ -42,7 +42,7 @@ Procedure steps marked with an asterisk (`*`) are likely to change with future A Namespace: Labels: olm.operatorframework.io/metadata.name=operatorhubio Annotations: - API Version: olm.operatorframework.io/v1alpha1 + API Version: olm.operatorframework.io/v1 Kind: ClusterCatalog Metadata: Creation Timestamp: 2024-10-17T13:48:46Z diff --git a/api/core/doc.go b/api/core/doc.go deleted file mode 100644 index dec65a7c..00000000 --- a/api/core/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2022. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +k8s:deepcopy-gen=package,register -// +groupName=olm.operatorframework.io - -// Package api is the internal version of the API. -package core diff --git a/api/core/v1alpha1/clustercatalog_types.go b/api/v1/clustercatalog_types.go similarity index 99% rename from api/core/v1alpha1/clustercatalog_types.go rename to api/v1/clustercatalog_types.go index f91cdce2..102c389c 100644 --- a/api/core/v1alpha1/clustercatalog_types.go +++ b/api/v1/clustercatalog_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/api/core/v1alpha1/clustercatalog_types_test.go b/api/v1/clustercatalog_types_test.go similarity index 94% rename from api/core/v1alpha1/clustercatalog_types_test.go rename to api/v1/clustercatalog_types_test.go index b0e96cd6..074acc52 100644 --- a/api/core/v1alpha1/clustercatalog_types_test.go +++ b/api/v1/clustercatalog_types_test.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1 import ( "context" @@ -20,10 +20,12 @@ import ( "sigs.k8s.io/yaml" ) +const crdFilePath = "../../config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml" + func TestImageSourceCELValidationRules(t *testing.T) { - validators := fieldValidatorsFromFile(t, "../../../config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml") + validators := fieldValidatorsFromFile(t, crdFilePath) pth := "openAPIV3Schema.properties.spec.properties.source.properties.image" - validator, found := validators["v1alpha1"][pth] + validator, found := validators[GroupVersion.Version][pth] require.True(t, found) for name, tc := range map[string]struct { @@ -157,9 +159,9 @@ func TestImageSourceCELValidationRules(t *testing.T) { } func TestResolvedImageSourceCELValidation(t *testing.T) { - validators := fieldValidatorsFromFile(t, "../../../config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml") + validators := fieldValidatorsFromFile(t, crdFilePath) pth := "openAPIV3Schema.properties.status.properties.resolvedSource.properties.image.properties.ref" - validator, found := validators["v1alpha1"][pth] + validator, found := validators[GroupVersion.Version][pth] require.True(t, found) for name, tc := range map[string]struct { @@ -250,9 +252,9 @@ func TestResolvedImageSourceCELValidation(t *testing.T) { } func TestClusterCatalogURLsCELValidation(t *testing.T) { - validators := fieldValidatorsFromFile(t, "../../../config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml") + validators := fieldValidatorsFromFile(t, crdFilePath) pth := "openAPIV3Schema.properties.status.properties.urls.properties.base" - validator, found := validators["v1alpha1"][pth] + validator, found := validators[GroupVersion.Version][pth] require.True(t, found) for name, tc := range map[string]struct { urls ClusterCatalogURLs @@ -294,9 +296,9 @@ func TestClusterCatalogURLsCELValidation(t *testing.T) { } func TestSourceCELValidation(t *testing.T) { - validators := fieldValidatorsFromFile(t, "../../../config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml") + validators := fieldValidatorsFromFile(t, crdFilePath) pth := "openAPIV3Schema.properties.spec.properties.source" - validator, found := validators["v1alpha1"][pth] + validator, found := validators[GroupVersion.Version][pth] require.True(t, found) for name, tc := range map[string]struct { source CatalogSource @@ -335,9 +337,9 @@ func TestSourceCELValidation(t *testing.T) { } func TestResolvedSourceCELValidation(t *testing.T) { - validators := fieldValidatorsFromFile(t, "../../../config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml") + validators := fieldValidatorsFromFile(t, crdFilePath) pth := "openAPIV3Schema.properties.status.properties.resolvedSource" - validator, found := validators["v1alpha1"][pth] + validator, found := validators[GroupVersion.Version][pth] require.True(t, found) for name, tc := range map[string]struct { diff --git a/api/core/v1alpha1/groupversion_info.go b/api/v1/groupversion_info.go similarity index 89% rename from api/core/v1alpha1/groupversion_info.go rename to api/v1/groupversion_info.go index cbc9b6b2..adb650eb 100644 --- a/api/core/v1alpha1/groupversion_info.go +++ b/api/v1/groupversion_info.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 contains API Schema definitions for the core v1alpha1 API group +// Package v1 contains API Schema definitions for the core v1 API group // +kubebuilder:object:generate=true // +groupName=olm.operatorframework.io -package v1alpha1 +package v1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "olm.operatorframework.io", Version: "v1alpha1"} + GroupVersion = schema.GroupVersion{Group: "olm.operatorframework.io", Version: "v1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/api/core/v1alpha1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go similarity index 98% rename from api/core/v1alpha1/zz_generated.deepcopy.go rename to api/v1/zz_generated.deepcopy.go index 202d330d..ce423751 100644 --- a/api/core/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -18,10 +18,10 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -125,7 +125,7 @@ func (in *ClusterCatalogStatus) DeepCopyInto(out *ClusterCatalogStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } diff --git a/cmd/manager/main.go b/cmd/manager/main.go index b39fd795..1ba23302 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -51,7 +51,7 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" crwebhook "sigs.k8s.io/controller-runtime/pkg/webhook" - "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" corecontrollers "github.com/operator-framework/catalogd/internal/controllers/core" "github.com/operator-framework/catalogd/internal/features" "github.com/operator-framework/catalogd/internal/garbagecollection" @@ -76,7 +76,7 @@ const ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(v1alpha1.AddToScheme(scheme)) + utilruntime.Must(catalogdv1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } diff --git a/config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml b/config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml index ecdf5bdb..46750f05 100644 --- a/config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml +++ b/config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml @@ -24,7 +24,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1alpha1 + name: v1 schema: openAPIV3Schema: description: |- diff --git a/config/base/default/clustercatalogs/default-catalogs.yaml b/config/base/default/clustercatalogs/default-catalogs.yaml index 7df6ec96..a656b350 100644 --- a/config/base/default/clustercatalogs/default-catalogs.yaml +++ b/config/base/default/clustercatalogs/default-catalogs.yaml @@ -1,4 +1,4 @@ -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterCatalog metadata: name: operatorhubio diff --git a/config/base/manager/webhook/manifests.yaml b/config/base/manager/webhook/manifests.yaml index bd133c05..a5842de4 100644 --- a/config/base/manager/webhook/manifests.yaml +++ b/config/base/manager/webhook/manifests.yaml @@ -10,14 +10,14 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-olm-operatorframework-io-v1alpha1-clustercatalog + path: /mutate-olm-operatorframework-io-v1-clustercatalog failurePolicy: Fail name: inject-metadata-name.olm.operatorframework.io rules: - apiGroups: - olm.operatorframework.io apiVersions: - - v1alpha1 + - v1 operations: - CREATE - UPDATE diff --git a/config/samples/core_v1alpha1_clustercatalog.yaml b/config/samples/core_v1_clustercatalog.yaml similarity index 80% rename from config/samples/core_v1alpha1_clustercatalog.yaml rename to config/samples/core_v1_clustercatalog.yaml index 7027c39c..661bf2a6 100644 --- a/config/samples/core_v1alpha1_clustercatalog.yaml +++ b/config/samples/core_v1_clustercatalog.yaml @@ -1,4 +1,4 @@ -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterCatalog metadata: name: operatorhubio diff --git a/docs/fetching-catalog-contents.md b/docs/fetching-catalog-contents.md index 2c577e53..ccc0ff23 100644 --- a/docs/fetching-catalog-contents.md +++ b/docs/fetching-catalog-contents.md @@ -145,7 +145,7 @@ This section outlines a way of exposing the `Catalogd` Service's endpoints outsi ```sh $ kubectl apply -f - << EOF - apiVersion: olm.operatorframework.io/v1alpha1 + apiVersion: olm.operatorframework.io/v1 kind: ClusterCatalog metadata: name: operatorhubio diff --git a/internal/controllers/core/clustercatalog_controller.go b/internal/controllers/core/clustercatalog_controller.go index 1e7fe453..2879bdfe 100644 --- a/internal/controllers/core/clustercatalog_controller.go +++ b/internal/controllers/core/clustercatalog_controller.go @@ -37,7 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" "github.com/operator-framework/catalogd/internal/source" "github.com/operator-framework/catalogd/internal/storage" ) @@ -86,7 +86,7 @@ func (r *ClusterCatalogReconciler) Reconcile(ctx context.Context, req ctrl.Reque l.Info("reconcile starting") defer l.Info("reconcile ending") - existingCatsrc := v1alpha1.ClusterCatalog{} + existingCatsrc := catalogdv1.ClusterCatalog{} if err := r.Client.Get(ctx, req.NamespacedName, &existingCatsrc); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } @@ -145,7 +145,7 @@ func (r *ClusterCatalogReconciler) SetupWithManager(mgr ctrl.Manager) error { } return ctrl.NewControllerManagedBy(mgr). - For(&v1alpha1.ClusterCatalog{}). + For(&catalogdv1.ClusterCatalog{}). Complete(r) } @@ -157,11 +157,11 @@ func (r *ClusterCatalogReconciler) SetupWithManager(mgr ctrl.Manager) error { // to add the ctrl.Result type back as a return value. Adding a comment to ignore // linting from the linter that was fussing about this. // nolint:unparam -func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *v1alpha1.ClusterCatalog) (ctrl.Result, error) { +func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *catalogdv1.ClusterCatalog) (ctrl.Result, error) { l := log.FromContext(ctx) // Check if the catalog availability is set to disabled, if true then // unset base URL, delete it from the cache and set appropriate status - if catalog.Spec.AvailabilityMode == v1alpha1.AvailabilityModeUnavailable { + if catalog.Spec.AvailabilityMode == catalogdv1.AvailabilityModeUnavailable { // Delete the catalog from local cache err := r.deleteCatalogCache(ctx, catalog) if err != nil { @@ -262,7 +262,7 @@ func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *v1alp return nextPollResult(unpackResult.LastSuccessfulPollAttempt.Time, catalog), nil } -func (r *ClusterCatalogReconciler) getCurrentState(catalog *v1alpha1.ClusterCatalog) (*v1alpha1.ClusterCatalogStatus, storedCatalogData, bool) { +func (r *ClusterCatalogReconciler) getCurrentState(catalog *catalogdv1.ClusterCatalog) (*catalogdv1.ClusterCatalogStatus, storedCatalogData, bool) { r.storedCatalogsMu.RLock() storedCatalog, hasStoredCatalog := r.storedCatalogs[catalog.Name] r.storedCatalogsMu.RUnlock() @@ -279,10 +279,10 @@ func (r *ClusterCatalogReconciler) getCurrentState(catalog *v1alpha1.ClusterCata return expectedStatus, storedCatalog, hasStoredCatalog } -func nextPollResult(lastSuccessfulPoll time.Time, catalog *v1alpha1.ClusterCatalog) ctrl.Result { +func nextPollResult(lastSuccessfulPoll time.Time, catalog *catalogdv1.ClusterCatalog) ctrl.Result { var requeueAfter time.Duration switch catalog.Spec.Source.Type { - case v1alpha1.SourceTypeImage: + case catalogdv1.SourceTypeImage: if catalog.Spec.Source.Image != nil && catalog.Spec.Source.Image.PollIntervalMinutes != nil { pollDuration := time.Duration(*catalog.Spec.Source.Image.PollIntervalMinutes) * time.Minute jitteredDuration := wait.Jitter(pollDuration, requeueJitterMaxFactor) @@ -292,64 +292,64 @@ func nextPollResult(lastSuccessfulPoll time.Time, catalog *v1alpha1.ClusterCatal return ctrl.Result{RequeueAfter: requeueAfter} } -func clearUnknownConditions(status *v1alpha1.ClusterCatalogStatus) { +func clearUnknownConditions(status *catalogdv1.ClusterCatalogStatus) { knownTypes := sets.New[string]( - v1alpha1.TypeServing, - v1alpha1.TypeProgressing, + catalogdv1.TypeServing, + catalogdv1.TypeProgressing, ) status.Conditions = slices.DeleteFunc(status.Conditions, func(cond metav1.Condition) bool { return !knownTypes.Has(cond.Type) }) } -func updateStatusProgressing(status *v1alpha1.ClusterCatalogStatus, generation int64, err error) { +func updateStatusProgressing(status *catalogdv1.ClusterCatalogStatus, generation int64, err error) { progressingCond := metav1.Condition{ - Type: v1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: v1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, Message: "Successfully unpacked and stored content from resolved source", ObservedGeneration: generation, } if err != nil { progressingCond.Status = metav1.ConditionTrue - progressingCond.Reason = v1alpha1.ReasonRetrying + progressingCond.Reason = catalogdv1.ReasonRetrying progressingCond.Message = err.Error() } if errors.Is(err, reconcile.TerminalError(nil)) { progressingCond.Status = metav1.ConditionFalse - progressingCond.Reason = v1alpha1.ReasonBlocked + progressingCond.Reason = catalogdv1.ReasonBlocked } meta.SetStatusCondition(&status.Conditions, progressingCond) } -func updateStatusServing(status *v1alpha1.ClusterCatalogStatus, result source.Result, baseURL string, generation int64) { +func updateStatusServing(status *catalogdv1.ClusterCatalogStatus, result source.Result, baseURL string, generation int64) { status.ResolvedSource = result.ResolvedSource if status.URLs == nil { - status.URLs = &v1alpha1.ClusterCatalogURLs{} + status.URLs = &catalogdv1.ClusterCatalogURLs{} } status.URLs.Base = baseURL status.LastUnpacked = ptr.To(metav1.NewTime(result.UnpackTime)) meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: v1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: v1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, Message: "Serving desired content from resolved source", ObservedGeneration: generation, }) } -func updateStatusProgressingUserSpecifiedUnavailable(status *v1alpha1.ClusterCatalogStatus, generation int64) { +func updateStatusProgressingUserSpecifiedUnavailable(status *catalogdv1.ClusterCatalogStatus, generation int64) { // Set Progressing condition to True with reason Succeeded // since we have successfully progressed to the unavailable // availability mode and are ready to progress to any future // desired state. progressingCond := metav1.Condition{ - Type: v1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: v1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, Message: "Catalog availability mode is set to Unavailable", ObservedGeneration: generation, } @@ -358,9 +358,9 @@ func updateStatusProgressingUserSpecifiedUnavailable(status *v1alpha1.ClusterCat // so that users of this condition are aware that this catalog is // intentionally not being served servingCond := metav1.Condition{ - Type: v1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionFalse, - Reason: v1alpha1.ReasonUserSpecifiedUnavailable, + Reason: catalogdv1.ReasonUserSpecifiedUnavailable, Message: "Catalog availability mode is set to Unavailable", ObservedGeneration: generation, } @@ -369,19 +369,19 @@ func updateStatusProgressingUserSpecifiedUnavailable(status *v1alpha1.ClusterCat meta.SetStatusCondition(&status.Conditions, servingCond) } -func updateStatusNotServing(status *v1alpha1.ClusterCatalogStatus, generation int64) { +func updateStatusNotServing(status *catalogdv1.ClusterCatalogStatus, generation int64) { status.ResolvedSource = nil status.URLs = nil status.LastUnpacked = nil meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: v1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionFalse, - Reason: v1alpha1.ReasonUnavailable, + Reason: catalogdv1.ReasonUnavailable, ObservedGeneration: generation, }) } -func (r *ClusterCatalogReconciler) needsPoll(lastSuccessfulPoll time.Time, catalog *v1alpha1.ClusterCatalog) bool { +func (r *ClusterCatalogReconciler) needsPoll(lastSuccessfulPoll time.Time, catalog *catalogdv1.ClusterCatalog) bool { // If polling is disabled, we don't need to poll. if catalog.Spec.Source.Image.PollIntervalMinutes == nil { return false @@ -393,8 +393,8 @@ func (r *ClusterCatalogReconciler) needsPoll(lastSuccessfulPoll time.Time, catal } // Compare resources - ignoring status & metadata.finalizers -func checkForUnexpectedFieldChange(a, b v1alpha1.ClusterCatalog) bool { - a.Status, b.Status = v1alpha1.ClusterCatalogStatus{}, v1alpha1.ClusterCatalogStatus{} +func checkForUnexpectedFieldChange(a, b catalogdv1.ClusterCatalog) bool { + a.Status, b.Status = catalogdv1.ClusterCatalogStatus{}, catalogdv1.ClusterCatalogStatus{} a.Finalizers, b.Finalizers = []string{}, []string{} return !equality.Semantic.DeepEqual(a, b) } @@ -408,7 +408,7 @@ func (f finalizerFunc) Finalize(ctx context.Context, obj client.Object) (crfinal func (r *ClusterCatalogReconciler) setupFinalizers() error { f := crfinalizer.NewFinalizers() err := f.Register(fbcDeletionFinalizer, finalizerFunc(func(ctx context.Context, obj client.Object) (crfinalizer.Result, error) { - catalog, ok := obj.(*v1alpha1.ClusterCatalog) + catalog, ok := obj.(*catalogdv1.ClusterCatalog) if !ok { panic("could not convert object to clusterCatalog") } @@ -428,7 +428,7 @@ func (r *ClusterCatalogReconciler) deleteStoredCatalog(catalogName string) { delete(r.storedCatalogs, catalogName) } -func (r *ClusterCatalogReconciler) deleteCatalogCache(ctx context.Context, catalog *v1alpha1.ClusterCatalog) error { +func (r *ClusterCatalogReconciler) deleteCatalogCache(ctx context.Context, catalog *catalogdv1.ClusterCatalog) error { if err := r.Storage.Delete(catalog.Name); err != nil { updateStatusProgressing(&catalog.Status, catalog.GetGeneration(), err) return err diff --git a/internal/controllers/core/clustercatalog_controller_test.go b/internal/controllers/core/clustercatalog_controller_test.go index 93a2cbee..c1705d87 100644 --- a/internal/controllers/core/clustercatalog_controller_test.go +++ b/internal/controllers/core/clustercatalog_controller_test.go @@ -20,7 +20,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/reconcile" - catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" "github.com/operator-framework/catalogd/internal/source" "github.com/operator-framework/catalogd/internal/storage" ) @@ -39,7 +39,7 @@ type MockSource struct { cleanupError error } -func (ms *MockSource) Unpack(_ context.Context, _ *catalogdv1alpha1.ClusterCatalog) (*source.Result, error) { +func (ms *MockSource) Unpack(_ context.Context, _ *catalogdv1.ClusterCatalog) (*source.Result, error) { if ms.unpackError != nil { return nil, ms.unpackError } @@ -47,7 +47,7 @@ func (ms *MockSource) Unpack(_ context.Context, _ *catalogdv1alpha1.ClusterCatal return ms.result, nil } -func (ms *MockSource) Cleanup(_ context.Context, _ *catalogdv1alpha1.ClusterCatalog) error { +func (ms *MockSource) Cleanup(_ context.Context, _ *catalogdv1.ClusterCatalog) error { return ms.cleanupError } @@ -86,10 +86,10 @@ func (m MockStore) ContentExists(_ string) bool { func TestCatalogdControllerReconcile(t *testing.T) { for _, tt := range []struct { name string - catalog *catalogdv1alpha1.ClusterCatalog + catalog *catalogdv1.ClusterCatalog expectedError error shouldPanic bool - expectedCatalog *catalogdv1alpha1.ClusterCatalog + expectedCatalog *catalogdv1.ClusterCatalog source source.Unpacker store storage.Instance }{ @@ -97,34 +97,34 @@ func TestCatalogdControllerReconcile(t *testing.T) { name: "invalid source type, panics", source: &MockSource{}, store: &MockStore{}, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ Type: "invalid", }, }, }, shouldPanic: true, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ Type: "invalid", }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonBlocked, + Reason: catalogdv1.ReasonBlocked, }, }, }, @@ -137,39 +137,39 @@ func TestCatalogdControllerReconcile(t *testing.T) { unpackError: errors.New("mocksource error"), }, store: &MockStore{}, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonRetrying, + Reason: catalogdv1.ReasonRetrying, }, }, }, @@ -182,39 +182,39 @@ func TestCatalogdControllerReconcile(t *testing.T) { unpackError: reconcile.TerminalError(errors.New("mocksource terminal error")), }, store: &MockStore{}, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonBlocked, + Reason: catalogdv1.ReasonBlocked, }, }, }, @@ -226,57 +226,57 @@ func TestCatalogdControllerReconcile(t *testing.T) { result: &source.Result{ State: source.StateUnpacked, FS: &fstest.MapFS{}, - ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{ - Image: &catalogdv1alpha1.ResolvedImageSource{ + ResolvedSource: &catalogdv1.ResolvedCatalogSource{ + Image: &catalogdv1.ResolvedImageSource{ Ref: "my.org/someimage@someSHA256Digest", }, }, }, }, store: &MockStore{}, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ - URLs: &catalogdv1alpha1.ClusterCatalogURLs{Base: "URL"}, + Status: catalogdv1.ClusterCatalogStatus{ + URLs: &catalogdv1.ClusterCatalogURLs{Base: "URL"}, Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, }, { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, }, - ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{ - Image: &catalogdv1alpha1.ResolvedImageSource{ + ResolvedSource: &catalogdv1.ResolvedCatalogSource{ + Image: &catalogdv1.ResolvedImageSource{ Ref: "my.org/someimage@someSHA256Digest", }, }, @@ -296,39 +296,39 @@ func TestCatalogdControllerReconcile(t *testing.T) { store: &MockStore{ shouldError: true, }, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonRetrying, + Reason: catalogdv1.ReasonRetrying, }, }, }, @@ -343,28 +343,28 @@ func TestCatalogdControllerReconcile(t *testing.T) { }, }, store: &MockStore{}, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, @@ -380,67 +380,67 @@ func TestCatalogdControllerReconcile(t *testing.T) { }, }, store: &MockStore{}, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, DeletionTimestamp: &metav1.Time{Time: time.Date(2023, time.October, 10, 4, 19, 0, 0, time.UTC)}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ LastUnpacked: &metav1.Time{}, - ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ResolvedImageSource{ + ResolvedSource: &catalogdv1.ResolvedCatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ResolvedImageSource{ Ref: "", }, }, Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, }, { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{}, DeletionTimestamp: &metav1.Time{Time: time.Date(2023, time.October, 10, 4, 19, 0, 0, time.UTC)}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonUnavailable, + Reason: catalogdv1.ReasonUnavailable, }, { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, }, }, @@ -458,62 +458,62 @@ func TestCatalogdControllerReconcile(t *testing.T) { store: &MockStore{ shouldError: true, }, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, DeletionTimestamp: &metav1.Time{Time: time.Date(2023, time.October, 10, 4, 19, 0, 0, time.UTC)}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ - URLs: &catalogdv1alpha1.ClusterCatalogURLs{Base: "URL"}, + Status: catalogdv1.ClusterCatalogStatus{ + URLs: &catalogdv1.ClusterCatalogURLs{Base: "URL"}, Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, DeletionTimestamp: &metav1.Time{Time: time.Date(2023, time.October, 10, 4, 19, 0, 0, time.UTC)}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ - URLs: &catalogdv1alpha1.ClusterCatalogURLs{Base: "URL"}, + Status: catalogdv1.ClusterCatalogStatus{ + URLs: &catalogdv1.ClusterCatalogURLs{Base: "URL"}, Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonRetrying, + Reason: catalogdv1.ReasonRetrying, }, { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, }, }, }, @@ -529,60 +529,60 @@ func TestCatalogdControllerReconcile(t *testing.T) { store: &MockStore{ shouldError: false, }, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, DeletionTimestamp: &metav1.Time{Time: time.Date(2023, time.October, 10, 4, 19, 0, 0, time.UTC)}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, DeletionTimestamp: &metav1.Time{Time: time.Date(2023, time.October, 10, 4, 19, 0, 0, time.UTC)}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonRetrying, + Reason: catalogdv1.ReasonRetrying, }, { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonUnavailable, + Reason: catalogdv1.ReasonUnavailable, }, }, }, @@ -597,66 +597,66 @@ func TestCatalogdControllerReconcile(t *testing.T) { }, }, store: &MockStore{}, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, - AvailabilityMode: catalogdv1alpha1.AvailabilityModeUnavailable, + AvailabilityMode: catalogdv1.AvailabilityModeUnavailable, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ - URLs: &catalogdv1alpha1.ClusterCatalogURLs{Base: "URL"}, + Status: catalogdv1.ClusterCatalogStatus{ + URLs: &catalogdv1.ClusterCatalogURLs{Base: "URL"}, LastUnpacked: &metav1.Time{}, - ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ResolvedImageSource{ + ResolvedSource: &catalogdv1.ResolvedCatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ResolvedImageSource{ Ref: "", }, }, Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, }, { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, - AvailabilityMode: catalogdv1alpha1.AvailabilityModeUnavailable, + AvailabilityMode: catalogdv1.AvailabilityModeUnavailable, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonUserSpecifiedUnavailable, + Reason: catalogdv1.ReasonUserSpecifiedUnavailable, }, { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, }, }, @@ -671,68 +671,68 @@ func TestCatalogdControllerReconcile(t *testing.T) { }, }, store: &MockStore{}, - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, - AvailabilityMode: catalogdv1alpha1.AvailabilityModeUnavailable, + AvailabilityMode: catalogdv1.AvailabilityModeUnavailable, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ - URLs: &catalogdv1alpha1.ClusterCatalogURLs{Base: "URL"}, + Status: catalogdv1.ClusterCatalogStatus{ + URLs: &catalogdv1.ClusterCatalogURLs{Base: "URL"}, LastUnpacked: &metav1.Time{}, - ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ResolvedImageSource{ + ResolvedSource: &catalogdv1.ResolvedCatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ResolvedImageSource{ Ref: "", }, }, Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, }, { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, }, }, }, - expectedCatalog: &catalogdv1alpha1.ClusterCatalog{ + expectedCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "catalog", Finalizers: []string{}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, - AvailabilityMode: catalogdv1alpha1.AvailabilityModeUnavailable, + AvailabilityMode: catalogdv1.AvailabilityModeUnavailable, }, - Status: catalogdv1alpha1.ClusterCatalogStatus{ + Status: catalogdv1.ClusterCatalogStatus{ Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionFalse, - Reason: catalogdv1alpha1.ReasonUserSpecifiedUnavailable, + Reason: catalogdv1.ReasonUserSpecifiedUnavailable, }, { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, }, }, }, @@ -773,20 +773,20 @@ func TestCatalogdControllerReconcile(t *testing.T) { func TestPollingRequeue(t *testing.T) { for name, tc := range map[string]struct { - catalog *catalogdv1alpha1.ClusterCatalog + catalog *catalogdv1.ClusterCatalog expectedRequeueAfter time.Duration lastPollTime metav1.Time }{ "ClusterCatalog with tag based image ref without any poll interval specified, requeueAfter set to 0, ie polling disabled": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, @@ -796,15 +796,15 @@ func TestPollingRequeue(t *testing.T) { lastPollTime: metav1.Now(), }, "ClusterCatalog with tag based image ref with poll interval specified, requeueAfter set to wait.jitter(pollInterval)": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", PollIntervalMinutes: ptr.To(5), }, @@ -821,8 +821,8 @@ func TestPollingRequeue(t *testing.T) { Unpacker: &MockSource{result: &source.Result{ State: source.StateUnpacked, FS: &fstest.MapFS{}, - ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{ - Image: &catalogdv1alpha1.ResolvedImageSource{ + ResolvedSource: &catalogdv1.ResolvedCatalogSource{ + Image: &catalogdv1.ResolvedImageSource{ Ref: "my.org/someImage@someSHA256Digest", }, }, @@ -843,28 +843,28 @@ func TestPollingReconcilerUnpack(t *testing.T) { newDigest := "f42337e7b85a46d83c94694638e2312e10ca16a03542399a65ba783c94a32b63" successfulObservedGeneration := int64(2) - successfulUnpackStatus := func(mods ...func(status *catalogdv1alpha1.ClusterCatalogStatus)) catalogdv1alpha1.ClusterCatalogStatus { - s := catalogdv1alpha1.ClusterCatalogStatus{ - URLs: &catalogdv1alpha1.ClusterCatalogURLs{Base: "URL"}, + successfulUnpackStatus := func(mods ...func(status *catalogdv1.ClusterCatalogStatus)) catalogdv1.ClusterCatalogStatus { + s := catalogdv1.ClusterCatalogStatus{ + URLs: &catalogdv1.ClusterCatalogURLs{Base: "URL"}, Conditions: []metav1.Condition{ { - Type: catalogdv1alpha1.TypeProgressing, + Type: catalogdv1.TypeProgressing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonSucceeded, + Reason: catalogdv1.ReasonSucceeded, Message: "Successfully unpacked and stored content from resolved source", ObservedGeneration: successfulObservedGeneration, }, { - Type: catalogdv1alpha1.TypeServing, + Type: catalogdv1.TypeServing, Status: metav1.ConditionTrue, - Reason: catalogdv1alpha1.ReasonAvailable, + Reason: catalogdv1.ReasonAvailable, Message: "Serving desired content from resolved source", ObservedGeneration: successfulObservedGeneration, }, }, - ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ResolvedImageSource{ + ResolvedSource: &catalogdv1.ResolvedCatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ResolvedImageSource{ Ref: "my.org/someimage@sha256:" + oldDigest, }, }, @@ -888,20 +888,20 @@ func TestPollingReconcilerUnpack(t *testing.T) { } for name, tc := range map[string]struct { - catalog *catalogdv1alpha1.ClusterCatalog + catalog *catalogdv1.ClusterCatalog storedCatalogData map[string]storedCatalogData expectedUnpackRun bool }{ "ClusterCatalog being resolved the first time, unpack should run": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", PollIntervalMinutes: ptr.To(5), }, @@ -911,16 +911,16 @@ func TestPollingReconcilerUnpack(t *testing.T) { expectedUnpackRun: true, }, "ClusterCatalog not being resolved the first time, no pollInterval mentioned, unpack should not run": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, Generation: 2, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", }, }, @@ -931,16 +931,16 @@ func TestPollingReconcilerUnpack(t *testing.T) { expectedUnpackRun: false, }, "ClusterCatalog not being resolved the first time, pollInterval mentioned, \"now\" is before next expected poll time, unpack should not run": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, Generation: 2, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", PollIntervalMinutes: ptr.To(7), }, @@ -952,16 +952,16 @@ func TestPollingReconcilerUnpack(t *testing.T) { expectedUnpackRun: false, }, "ClusterCatalog not being resolved the first time, pollInterval mentioned, \"now\" is after next expected poll time, unpack should run": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, Generation: 2, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someimage:latest", PollIntervalMinutes: ptr.To(3), }, @@ -973,16 +973,16 @@ func TestPollingReconcilerUnpack(t *testing.T) { expectedUnpackRun: true, }, "ClusterCatalog not being resolved the first time, pollInterval mentioned, \"now\" is before next expected poll time, generation changed, unpack should run": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, Generation: 3, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someotherimage@sha256:" + newDigest, PollIntervalMinutes: ptr.To(7), }, @@ -994,16 +994,16 @@ func TestPollingReconcilerUnpack(t *testing.T) { expectedUnpackRun: true, }, "ClusterCatalog not being resolved the first time, no stored catalog in cache, unpack should run": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, Generation: 3, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someotherimage@sha256:" + newDigest, PollIntervalMinutes: ptr.To(7), }, @@ -1014,23 +1014,23 @@ func TestPollingReconcilerUnpack(t *testing.T) { expectedUnpackRun: true, }, "ClusterCatalog not being resolved the first time, unexpected status, unpack should run": { - catalog: &catalogdv1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Finalizers: []string{fbcDeletionFinalizer}, Generation: 3, }, - Spec: catalogdv1alpha1.ClusterCatalogSpec{ - Source: catalogdv1alpha1.CatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "my.org/someotherimage@sha256:" + newDigest, PollIntervalMinutes: ptr.To(7), }, }, }, - Status: successfulUnpackStatus(func(status *catalogdv1alpha1.ClusterCatalogStatus) { - meta.FindStatusCondition(status.Conditions, catalogdv1alpha1.TypeProgressing).Status = metav1.ConditionTrue + Status: successfulUnpackStatus(func(status *catalogdv1.ClusterCatalogStatus) { + meta.FindStatusCondition(status.Conditions, catalogdv1.TypeProgressing).Status = metav1.ConditionTrue }), }, storedCatalogData: successfulStoredCatalogData(metav1.Now()), diff --git a/internal/garbagecollection/garbage_collector.go b/internal/garbagecollection/garbage_collector.go index b2579748..bbe6b3d7 100644 --- a/internal/garbagecollection/garbage_collector.go +++ b/internal/garbagecollection/garbage_collector.go @@ -13,7 +13,7 @@ import ( "k8s.io/client-go/metadata" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) var _ manager.Runnable = (*GarbageCollector)(nil) @@ -64,7 +64,7 @@ func (gc *GarbageCollector) Start(ctx context.Context) error { } func runGarbageCollection(ctx context.Context, cachePath string, metaClient metadata.Interface) ([]string, error) { - getter := metaClient.Resource(v1alpha1.GroupVersion.WithResource("clustercatalogs")) + getter := metaClient.Resource(catalogdv1.GroupVersion.WithResource("clustercatalogs")) metaList, err := getter.List(ctx, metav1.ListOptions{}) if err != nil { return nil, fmt.Errorf("error listing clustercatalogs: %w", err) diff --git a/internal/garbagecollection/garbage_collector_test.go b/internal/garbagecollection/garbage_collector_test.go index 59f045d9..43f4661e 100644 --- a/internal/garbagecollection/garbage_collector_test.go +++ b/internal/garbagecollection/garbage_collector_test.go @@ -12,7 +12,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/metadata/fake" - "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) func TestRunGarbageCollection(t *testing.T) { @@ -28,7 +28,7 @@ func TestRunGarbageCollection(t *testing.T) { { TypeMeta: metav1.TypeMeta{ Kind: "ClusterCatalog", - APIVersion: v1alpha1.GroupVersion.String(), + APIVersion: catalogdv1.GroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ Name: "one", @@ -37,7 +37,7 @@ func TestRunGarbageCollection(t *testing.T) { { TypeMeta: metav1.TypeMeta{ Kind: "ClusterCatalog", - APIVersion: v1alpha1.GroupVersion.String(), + APIVersion: catalogdv1.GroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ Name: "two", @@ -48,7 +48,7 @@ func TestRunGarbageCollection(t *testing.T) { { TypeMeta: metav1.TypeMeta{ Kind: "ClusterCatalog", - APIVersion: v1alpha1.GroupVersion.String(), + APIVersion: catalogdv1.GroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ Name: "three", diff --git a/internal/source/containers_image.go b/internal/source/containers_image.go index 7f3035f5..d6ddfd58 100644 --- a/internal/source/containers_image.go +++ b/internal/source/containers_image.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" - catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) const ConfigDirLabel = "operators.operatorframework.io.index.configs.v1" @@ -38,11 +38,11 @@ type ContainersImageRegistry struct { SourceContextFunc func(logger logr.Logger) (*types.SystemContext, error) } -func (i *ContainersImageRegistry) Unpack(ctx context.Context, catalog *catalogdv1alpha1.ClusterCatalog) (*Result, error) { +func (i *ContainersImageRegistry) Unpack(ctx context.Context, catalog *catalogdv1.ClusterCatalog) (*Result, error) { l := log.FromContext(ctx) - if catalog.Spec.Source.Type != catalogdv1alpha1.SourceTypeImage { - panic(fmt.Sprintf("programmer error: source type %q is unable to handle specified catalog source type %q", catalogdv1alpha1.SourceTypeImage, catalog.Spec.Source.Type)) + if catalog.Spec.Source.Type != catalogdv1.SourceTypeImage { + panic(fmt.Sprintf("programmer error: source type %q is unable to handle specified catalog source type %q", catalogdv1.SourceTypeImage, catalog.Spec.Source.Type)) } if catalog.Spec.Source.Image == nil { @@ -169,9 +169,9 @@ func (i *ContainersImageRegistry) Unpack(ctx context.Context, catalog *catalogdv func successResult(unpackPath string, canonicalRef reference.Canonical, lastUnpacked time.Time) *Result { return &Result{ FS: os.DirFS(unpackPath), - ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{ - Type: catalogdv1alpha1.SourceTypeImage, - Image: &catalogdv1alpha1.ResolvedImageSource{ + ResolvedSource: &catalogdv1.ResolvedCatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ResolvedImageSource{ Ref: canonicalRef.String(), }, }, @@ -188,7 +188,7 @@ func successResult(unpackPath string, canonicalRef reference.Canonical, lastUnpa } } -func (i *ContainersImageRegistry) Cleanup(_ context.Context, catalog *catalogdv1alpha1.ClusterCatalog) error { +func (i *ContainersImageRegistry) Cleanup(_ context.Context, catalog *catalogdv1.ClusterCatalog) error { if err := deleteRecursive(i.catalogPath(catalog.Name)); err != nil { return fmt.Errorf("error deleting catalog cache: %w", err) } diff --git a/internal/source/containers_image_test.go b/internal/source/containers_image_test.go index 16bb9932..10efa750 100644 --- a/internal/source/containers_image_test.go +++ b/internal/source/containers_image_test.go @@ -17,7 +17,7 @@ import ( "github.com/go-logr/logr/funcr" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/registry" - v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/mutate" "github.com/google/go-containerregistry/pkg/v1/random" "github.com/google/go-containerregistry/pkg/v1/remote" @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" "github.com/operator-framework/catalogd/internal/source" ) @@ -38,7 +38,7 @@ func TestImageRegistry(t *testing.T) { // if the Catalog.Spec.Source.Image.Ref field is empty, // one is injected during test runtime to ensure it // points to the registry created for the test - catalog *v1alpha1.ClusterCatalog + catalog *catalogdv1.ClusterCatalog wantErr bool terminal bool image v1.Image @@ -50,13 +50,13 @@ func TestImageRegistry(t *testing.T) { }{ { name: ".spec.source.image is nil", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, Image: nil, }, }, @@ -67,14 +67,14 @@ func TestImageRegistry(t *testing.T) { }, { name: ".spec.source.image.ref is unparsable", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "::)12-as^&8asd789A(::", }, }, @@ -86,14 +86,14 @@ func TestImageRegistry(t *testing.T) { }, { name: "tag based, image is missing required label", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "", }, }, @@ -111,14 +111,14 @@ func TestImageRegistry(t *testing.T) { }, { name: "digest based, image is missing required label", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "", }, }, @@ -137,14 +137,14 @@ func TestImageRegistry(t *testing.T) { }, { name: "image doesn't exist", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "", }, }, @@ -155,14 +155,14 @@ func TestImageRegistry(t *testing.T) { }, { name: "tag based image, digest already exists in cache", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "", }, }, @@ -181,14 +181,14 @@ func TestImageRegistry(t *testing.T) { }, { name: "digest based image, digest already exists in cache", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "", }, }, @@ -207,14 +207,14 @@ func TestImageRegistry(t *testing.T) { }, { name: "old ref is cached", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "", }, }, @@ -241,14 +241,14 @@ func TestImageRegistry(t *testing.T) { }, { name: "tag ref, happy path", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "", }, }, @@ -274,14 +274,14 @@ func TestImageRegistry(t *testing.T) { }, { name: "digest ref, happy path", - catalog: &v1alpha1.ClusterCatalog{ + catalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: "", }, }, @@ -456,14 +456,14 @@ func TestImageRegistryMissingLabelConsistentFailure(t *testing.T) { err = remote.Write(imgName, image) require.NoError(t, err) - catalog := &v1alpha1.ClusterCatalog{ + catalog := &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: v1alpha1.ClusterCatalogSpec{ - Source: v1alpha1.CatalogSource{ - Type: v1alpha1.SourceTypeImage, - Image: &v1alpha1.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: imgName.Name(), }, }, diff --git a/internal/source/unpacker.go b/internal/source/unpacker.go index 7b0f878a..bedaa211 100644 --- a/internal/source/unpacker.go +++ b/internal/source/unpacker.go @@ -7,7 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) // TODO: This package is almost entirely copy/pasted from rukpak. We should look @@ -31,8 +31,8 @@ import ( // specifications. A source should treat a catalog root directory as an opaque // file tree and delegate catalog format concerns to catalog parsers. type Unpacker interface { - Unpack(context.Context, *catalogdv1alpha1.ClusterCatalog) (*Result, error) - Cleanup(context.Context, *catalogdv1alpha1.ClusterCatalog) error + Unpack(context.Context, *catalogdv1.ClusterCatalog) (*Result, error) + Cleanup(context.Context, *catalogdv1.ClusterCatalog) error } // Result conveys progress information about unpacking catalog content. @@ -49,7 +49,7 @@ type Result struct { // For example, resolved image sources should reference a container image // digest rather than an image tag, and git sources should reference a // commit hash rather than a branch or tag. - ResolvedSource *catalogdv1alpha1.ResolvedCatalogSource + ResolvedSource *catalogdv1.ResolvedCatalogSource LastSuccessfulPollAttempt metav1.Time diff --git a/internal/webhook/cluster_catalog_webhook.go b/internal/webhook/cluster_catalog_webhook.go index a938673a..d330c5b8 100644 --- a/internal/webhook/cluster_catalog_webhook.go +++ b/internal/webhook/cluster_catalog_webhook.go @@ -8,21 +8,21 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) -// +kubebuilder:webhook:admissionReviewVersions={v1},failurePolicy=Fail,groups=olm.operatorframework.io,mutating=true,name=inject-metadata-name.olm.operatorframework.io,path=/mutate-olm-operatorframework-io-v1alpha1-clustercatalog,resources=clustercatalogs,verbs=create;update,versions=v1alpha1,sideEffects=None,timeoutSeconds=10 +// +kubebuilder:webhook:admissionReviewVersions={v1},failurePolicy=Fail,groups=olm.operatorframework.io,mutating=true,name=inject-metadata-name.olm.operatorframework.io,path=/mutate-olm-operatorframework-io-v1-clustercatalog,resources=clustercatalogs,verbs=create;update,versions=v1,sideEffects=None,timeoutSeconds=10 // +kubebuilder:rbac:groups=olm.operatorframework.io,resources=clustercatalogs,verbs=get;list;watch;patch;update -// ClusterCatalog wraps the external v1alpha1.ClusterCatalog type and implements admission.Defaulter +// ClusterCatalog wraps the external v1.ClusterCatalog type and implements admission.Defaulter type ClusterCatalog struct{} // Default is the method that will be called by the webhook to apply defaults. func (r *ClusterCatalog) Default(ctx context.Context, obj runtime.Object) error { log := log.FromContext(ctx) log.Info("Invoking Default method for ClusterCatalog", "object", obj) - catalog, ok := obj.(*v1alpha1.ClusterCatalog) + catalog, ok := obj.(*catalogdv1.ClusterCatalog) if !ok { return fmt.Errorf("expected a ClusterCatalog but got a %T", obj) } @@ -31,8 +31,8 @@ func (r *ClusterCatalog) Default(ctx context.Context, obj runtime.Object) error if catalog.Labels == nil { catalog.Labels = map[string]string{} } - catalog.Labels[v1alpha1.MetadataNameLabel] = catalog.GetName() - log.Info("default", v1alpha1.MetadataNameLabel, catalog.Name, "labels", catalog.Labels) + catalog.Labels[catalogdv1.MetadataNameLabel] = catalog.GetName() + log.Info("default", catalogdv1.MetadataNameLabel, catalog.Name, "labels", catalog.Labels) return nil } @@ -40,7 +40,7 @@ func (r *ClusterCatalog) Default(ctx context.Context, obj runtime.Object) error // SetupWebhookWithManager sets up the webhook with the manager func (r *ClusterCatalog) SetupWebhookWithManager(mgr ctrl.Manager) error { return ctrl.NewWebhookManagedBy(mgr). - For(&v1alpha1.ClusterCatalog{}). + For(&catalogdv1.ClusterCatalog{}). WithDefaulter(r). Complete() } diff --git a/internal/webhook/cluster_catalog_webhook_test.go b/internal/webhook/cluster_catalog_webhook_test.go index 50aeb9bb..8a0d33a3 100644 --- a/internal/webhook/cluster_catalog_webhook_test.go +++ b/internal/webhook/cluster_catalog_webhook_test.go @@ -8,7 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) // Define a dummy struct that implements runtime.Object but isn't a ClusterCatalog @@ -29,7 +29,7 @@ func TestClusterCatalogDefaulting(t *testing.T) { errorMessage string }{ "no labels provided, name label added": { - clusterCatalog: &v1alpha1.ClusterCatalog{ + clusterCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", }, @@ -40,7 +40,7 @@ func TestClusterCatalogDefaulting(t *testing.T) { expectError: false, }, "labels already present, name label added": { - clusterCatalog: &v1alpha1.ClusterCatalog{ + clusterCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Labels: map[string]string{ @@ -55,7 +55,7 @@ func TestClusterCatalogDefaulting(t *testing.T) { expectError: false, }, "name label already present, no changes": { - clusterCatalog: &v1alpha1.ClusterCatalog{ + clusterCatalog: &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: "test-catalog", Labels: map[string]string{ @@ -96,7 +96,7 @@ func TestClusterCatalogDefaulting(t *testing.T) { } else { assert.NoError(t, err) if tc.expectedLabels != nil { - labels := tc.clusterCatalog.(*v1alpha1.ClusterCatalog).Labels + labels := tc.clusterCatalog.(*catalogdv1.ClusterCatalog).Labels assert.Equal(t, tc.expectedLabels, labels) } } diff --git a/pprof/README.md b/pprof/README.md index 9e8b7db5..e782ac60 100644 --- a/pprof/README.md +++ b/pprof/README.md @@ -4,7 +4,7 @@ > This pprof data is based on early versions of catalogd and has not been updated since. The data is likely not accurate anymore. > A decision about removing or updating this data will be made in the future. -This folder contains some profiles that can be read using [pprof](https://github.com/google/pprof) to show how the core kubernetes apiserver and the custom catalogd apiserver CPU & Memory utilization is affected by the creation and reconciliation of the sample `Catalog` CR found at `../config/samples/core_v1alpha1_catalog.yaml`. +This folder contains some profiles that can be read using [pprof](https://github.com/google/pprof) to show how the core kubernetes apiserver and the custom catalogd apiserver CPU & Memory utilization is affected by the creation and reconciliation of the sample `Catalog` CR found at `../config/samples/core_v1_clustercatalog.yaml`. Instead of providing static screenshots and losing the interactivity associated with these `pprof` profiles, each of the files with the extension `.pb` can be used to view the profiles that were the result of running `pprof` against the live processes. @@ -85,7 +85,7 @@ This section is being added as the pprof metrics don't necessarily show the whol This image shows the spike in CPU utilization and the increase in Memory consumption. In this scenario, the command: ``` -kubectl apply -f config/samples/core_v1alpha1_catalog.yaml +kubectl apply -f config/samples/core_v1_clustercatalog.yaml ``` was run right at 1:44 PM. @@ -112,7 +112,7 @@ With this, we can see that without the catalogd apiserver the core kube-apiserve This image shows the spike in CPU utilization and the increase in Memory consumption. In this scenario, the command: ``` -kubectl apply -f config/samples/core_v1alpha1_catalog.yaml +kubectl apply -f config/samples/core_v1_clustercatalog.yaml ``` was run right at 3:06 PM @@ -139,7 +139,7 @@ With this, we can see that with the catalogd apiserver the core kube-apiserver h This image shows the spike in CPU utilization and the increase in Memory consumption. In this scenario, the command: ``` -kubectl apply -f config/samples/core_v1alpha1_catalog.yaml +kubectl apply -f config/samples/core_v1_clustercatalog.yaml ``` was run right at 3:06 PM @@ -174,7 +174,7 @@ Overall, when running both the kube-apiserver and the catalogd apiserver the tot This image shows the spike in CPU utilization and the increase in Memory consumption. In this scenario, the command: ``` -kubectl apply -f config/samples/core_v1alpha1_catalog.yaml +kubectl apply -f config/samples/core_v1_clustercatalog.yaml ``` was run right at 3:06 PM diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 4f2e10f9..165fcb1f 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -13,7 +13,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) var ( @@ -34,7 +34,7 @@ var _ = BeforeSuite(func() { cfg = ctrl.GetConfigOrDie() sch := scheme.Scheme - Expect(catalogd.AddToScheme(sch)).To(Succeed()) + Expect(catalogdv1.AddToScheme(sch)).To(Succeed()) c, err = client.New(cfg, client.Options{Scheme: sch}) Expect(err).To(Not(HaveOccurred())) kubeClient, err = kubernetes.NewForConfig(cfg) diff --git a/test/e2e/unpack_test.go b/test/e2e/unpack_test.go index ad0b0b06..36661a65 100644 --- a/test/e2e/unpack_test.go +++ b/test/e2e/unpack_test.go @@ -13,7 +13,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) const ( @@ -39,21 +39,21 @@ func catalogImageRef() string { var _ = Describe("ClusterCatalog Unpacking", func() { var ( ctx context.Context - catalog *catalogd.ClusterCatalog + catalog *catalogdv1.ClusterCatalog ) When("A ClusterCatalog is created", func() { BeforeEach(func() { ctx = context.Background() var err error - catalog = &catalogd.ClusterCatalog{ + catalog = &catalogdv1.ClusterCatalog{ ObjectMeta: metav1.ObjectMeta{ Name: catalogName, }, - Spec: catalogd.ClusterCatalogSpec{ - Source: catalogd.CatalogSource{ - Type: catalogd.SourceTypeImage, - Image: &catalogd.ImageSource{ + Spec: catalogdv1.ClusterCatalogSpec{ + Source: catalogdv1.CatalogSource{ + Type: catalogdv1.SourceTypeImage, + Image: &catalogdv1.ImageSource{ Ref: catalogImageRef(), }, }, @@ -69,10 +69,10 @@ var _ = Describe("ClusterCatalog Unpacking", func() { Eventually(func(g Gomega) { err := c.Get(ctx, types.NamespacedName{Name: catalog.Name}, catalog) g.Expect(err).ToNot(HaveOccurred()) - cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogd.TypeProgressing) + cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogdv1.TypeProgressing) g.Expect(cond).ToNot(BeNil()) g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) - g.Expect(cond.Reason).To(Equal(catalogd.ReasonSucceeded)) + g.Expect(cond.Reason).To(Equal(catalogdv1.ReasonSucceeded)) }).Should(Succeed()) By("Checking that it has an appropriate name label") @@ -92,16 +92,16 @@ var _ = Describe("ClusterCatalog Unpacking", func() { Eventually(func(g Gomega) { err := c.Get(ctx, types.NamespacedName{Name: catalog.Name}, catalog) g.Expect(err).ToNot(HaveOccurred()) - cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogd.TypeServing) + cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogdv1.TypeServing) g.Expect(cond).ToNot(BeNil()) g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) - g.Expect(cond.Reason).To(Equal(catalogd.ReasonAvailable)) + g.Expect(cond.Reason).To(Equal(catalogdv1.ReasonAvailable)) }).Should(Succeed()) }) AfterEach(func() { Expect(c.Delete(ctx, catalog)).To(Succeed()) Eventually(func(g Gomega) { - err = c.Get(ctx, types.NamespacedName{Name: catalog.Name}, &catalogd.ClusterCatalog{}) + err = c.Get(ctx, types.NamespacedName{Name: catalog.Name}, &catalogdv1.ClusterCatalog{}) g.Expect(errors.IsNotFound(err)).To(BeTrue()) }).Should(Succeed()) }) diff --git a/test/e2e/util.go b/test/e2e/util.go index e5784fb0..416d8c3a 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -10,10 +10,10 @@ import ( "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/client" - catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) -func ReadTestCatalogServerContents(ctx context.Context, catalog *catalogd.ClusterCatalog, c client.Client, kubeClient kubernetes.Interface) ([]byte, error) { +func ReadTestCatalogServerContents(ctx context.Context, catalog *catalogdv1.ClusterCatalog, c client.Client, kubeClient kubernetes.Interface) ([]byte, error) { if catalog == nil { return nil, fmt.Errorf("cannot read nil catalog") } diff --git a/test/tools/imageregistry/pre-upgrade-setup.sh b/test/tools/imageregistry/pre-upgrade-setup.sh index 5c2b4ed5..707e2c9e 100755 --- a/test/tools/imageregistry/pre-upgrade-setup.sh +++ b/test/tools/imageregistry/pre-upgrade-setup.sh @@ -20,7 +20,7 @@ export TEST_CLUSTER_CATALOG_IMAGE=$1 export TEST_CLUSTER_CATALOG_NAME=$2 kubectl apply -f - << EOF -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterCatalog metadata: name: ${TEST_CLUSTER_CATALOG_NAME} diff --git a/test/upgrade/unpack_test.go b/test/upgrade/unpack_test.go index 2cc368d3..39f37df2 100644 --- a/test/upgrade/unpack_test.go +++ b/test/upgrade/unpack_test.go @@ -20,7 +20,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" "github.com/operator-framework/catalogd/test/e2e" ) @@ -30,7 +30,7 @@ var _ = Describe("ClusterCatalog Unpacking", func() { ctx := context.Background() var managerDeployment appsv1.Deployment - managerLabelSelector := labels.Set{"control-plane": "catalogd-controller-manager"} + managerLabelSelector := labels.Set{"control-plane": "catalogdv1-controller-manager"} By("Checking that the controller-manager deployment is updated") Eventually(func(g Gomega) { var managerDeployments appsv1.DeploymentList @@ -54,7 +54,7 @@ var _ = Describe("ClusterCatalog Unpacking", func() { managerPod = managerPods.Items[0] }).Should(Succeed()) - By("Reading logs to make sure that ClusterCatalog was reconciled by catalogd") + By("Reading logs to make sure that ClusterCatalog was reconciled by catalogdv1") logCtx, cancel := context.WithTimeout(ctx, time.Minute) defer cancel() substrings := []string{ @@ -65,15 +65,15 @@ var _ = Describe("ClusterCatalog Unpacking", func() { Expect(err).ToNot(HaveOccurred()) Expect(found).To(BeTrue()) - catalog := &catalogd.ClusterCatalog{} + catalog := &catalogdv1.ClusterCatalog{} By("Ensuring ClusterCatalog has Status.Condition of Progressing with a status == False, reason == Succeeded") Eventually(func(g Gomega) { err := c.Get(ctx, types.NamespacedName{Name: testClusterCatalogName}, catalog) g.Expect(err).ToNot(HaveOccurred()) - cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogd.TypeProgressing) + cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogdv1.TypeProgressing) g.Expect(cond).ToNot(BeNil()) g.Expect(cond.Status).To(Equal(metav1.ConditionFalse)) - g.Expect(cond.Reason).To(Equal(catalogd.ReasonSucceeded)) + g.Expect(cond.Reason).To(Equal(catalogdv1.ReasonSucceeded)) }).Should(Succeed()) expectedFBC, err := os.ReadFile("../../testdata/catalogs/test-catalog/expected_all.json") @@ -90,10 +90,10 @@ var _ = Describe("ClusterCatalog Unpacking", func() { Eventually(func(g Gomega) { err := c.Get(ctx, types.NamespacedName{Name: testClusterCatalogName}, catalog) g.Expect(err).ToNot(HaveOccurred()) - cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogd.TypeServing) + cond := meta.FindStatusCondition(catalog.Status.Conditions, catalogdv1.TypeServing) g.Expect(cond).ToNot(BeNil()) g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) - g.Expect(cond.Reason).To(Equal(catalogd.ReasonAvailable)) + g.Expect(cond.Reason).To(Equal(catalogdv1.ReasonAvailable)) }).Should(Succeed()) }) }) diff --git a/test/upgrade/upgrade_suite_test.go b/test/upgrade/upgrade_suite_test.go index a7d332ae..77c38598 100644 --- a/test/upgrade/upgrade_suite_test.go +++ b/test/upgrade/upgrade_suite_test.go @@ -14,7 +14,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" + catalogdv1 "github.com/operator-framework/catalogd/api/v1" ) const ( @@ -41,7 +41,7 @@ var _ = BeforeSuite(func() { cfg = ctrl.GetConfigOrDie() sch := scheme.Scheme - Expect(catalogd.AddToScheme(sch)).To(Succeed()) + Expect(catalogdv1.AddToScheme(sch)).To(Succeed()) c, err = client.New(cfg, client.Options{Scheme: sch}) Expect(err).To(Not(HaveOccurred())) kubeClient, err = kubernetes.NewForConfig(cfg)