diff --git a/PROJECT b/PROJECT index 50ac542dc..a307347a4 100644 --- a/PROJECT +++ b/PROJECT @@ -11,8 +11,8 @@ resources: domain: operatorframework.io group: olm kind: ClusterExtension - path: github.com/operator-framework/operator-controller/api/v1alpha1 - version: v1alpha1 + path: github.com/operator-framework/operator-controller/api/v1 + version: v1 - api: crdVersion: v1 namespaced: true @@ -20,6 +20,6 @@ resources: domain: operatorframework.io group: olm kind: Extension - path: github.com/operator-framework/operator-controller/api/v1alpha1 - version: v1alpha1 + path: github.com/operator-framework/operator-controller/api/v1 + version: v1 version: "3" diff --git a/README.md b/README.md index 822bab9b2..7380dfc7c 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ kubectl wait --for=condition=Unpacked=True clustercatalog/operatorhubio --timeou ```bash # Apply the sample ClusterExtension. Manifest already includes # namespace and adequately privileged service account -kubectl apply -f config/samples/olm_v1alpha1_clusterextension.yaml +kubectl apply -f config/samples/olm_v1_clusterextension.yaml ``` #### Upgrade/Downgrade @@ -87,7 +87,7 @@ kubectl delete clusterextension/argocd && kubectl delete namespace argocd ```bash # Delete cluster-scoped resources -kubectl delete --ignore-not-found=true -f config/samples/olm_v1alpha1_clusterextension.yaml +kubectl delete --ignore-not-found=true -f config/samples/olm_v1_clusterextension.yaml ``` ### Advanced Usage @@ -133,7 +133,7 @@ kubectl create clusterrolebinding "argocd-operator-installer-cluster-admin" \ ```bash # Apply ClusterExtension cat < Annotations: - API Version: olm.operatorframework.io/v1alpha1 + API Version: olm.operatorframework.io/v1 Kind: ClusterCatalog Metadata: Creation Timestamp: 2024-03-12T19:34:50Z diff --git a/docs/Tasks/installing-an-extension.md b/docs/Tasks/installing-an-extension.md index 680b8ca80..29f134055 100644 --- a/docs/Tasks/installing-an-extension.md +++ b/docs/Tasks/installing-an-extension.md @@ -19,7 +19,7 @@ After you add a catalog to your cluster, you can install an extension by creatin 1. Create a CR for the Kubernetes extension you want to install: ``` yaml title="Example CR" - apiVersion: olm.operatorframework.io/v1alpha1 + apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: @@ -92,7 +92,7 @@ After you add a catalog to your cluster, you can install an extension by creatin Namespace: Labels: Annotations: - API Version: olm.operatorframework.io/v1alpha1 + API Version: olm.operatorframework.io/v1 Kind: ClusterExtension Metadata: Creation Timestamp: 2024-03-15T15:03:47Z diff --git a/docs/drafts/how-to-pin-version.md b/docs/drafts/how-to-pin-version.md index 17bd7e1c6..d71f5ec28 100644 --- a/docs/drafts/how-to-pin-version.md +++ b/docs/drafts/how-to-pin-version.md @@ -5,7 +5,7 @@ To disable automatic updates, and pin the version of an extension, set `version` Example: ```yaml -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: argocd diff --git a/docs/drafts/how-to-version-range-upgrades.md b/docs/drafts/how-to-version-range-upgrades.md index 5622a5ae6..a47040af5 100644 --- a/docs/drafts/how-to-version-range-upgrades.md +++ b/docs/drafts/how-to-version-range-upgrades.md @@ -5,7 +5,7 @@ Set the version for the desired package in the Catalog source to a comparison st Example: ```yaml -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: argocd diff --git a/docs/drafts/how-to-z-stream-upgrades.md b/docs/drafts/how-to-z-stream-upgrades.md index 835abc2b5..8f28b22c4 100644 --- a/docs/drafts/how-to-z-stream-upgrades.md +++ b/docs/drafts/how-to-z-stream-upgrades.md @@ -5,7 +5,7 @@ To restrict automatic updates to only z-stream patches and avoid breaking change Example: ```yaml -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: argocd diff --git a/docs/drafts/upgrade-support.md b/docs/drafts/upgrade-support.md index 418fbb44b..6be55dfd3 100644 --- a/docs/drafts/upgrade-support.md +++ b/docs/drafts/upgrade-support.md @@ -33,7 +33,7 @@ If `1.0.0` is installed, OLM v1 behavior differs in the following ways: You can change the default behavior of the upgrade constraints by setting the `upgradeConstraintPolicy` parameter in your cluster extension's custom resource (CR). ``` yaml hl_lines="10" -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: @@ -81,7 +81,7 @@ If you set the field to `Ignore`, no upgrade constraints are set on the package. Example `ClusterExtension` with `.spec.upgradeConstraintPolicy` field set to `Ignore`: ```yaml -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: extension-sample diff --git a/docs/refs/crd-upgrade-safety.md b/docs/refs/crd-upgrade-safety.md index 47ad18d7b..7b10099fa 100644 --- a/docs/refs/crd-upgrade-safety.md +++ b/docs/refs/crd-upgrade-safety.md @@ -56,7 +56,7 @@ The CRD Upgrade Safety preflight check can be entirely disabled by adding the `preflight.crdUpgradeSafety.disabled` field with a value of "true" to the ClusterExtension of the CRD. ```yaml -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: clusterextension-sample @@ -103,7 +103,7 @@ spec: singular: sample scope: Namespaced versions: - - name: v1alpha1 + - name: v1 schema: openAPIV3Schema: properties: diff --git a/hack/test/pre-upgrade-setup.sh b/hack/test/pre-upgrade-setup.sh index 8eed4c81d..c19824054 100755 --- a/hack/test/pre-upgrade-setup.sh +++ b/hack/test/pre-upgrade-setup.sh @@ -20,7 +20,7 @@ TEST_CLUSTER_CATALOG_NAME=$2 TEST_CLUSTER_EXTENSION_NAME=$3 kubectl apply -f - << EOF -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterCatalog metadata: name: ${TEST_CLUSTER_CATALOG_NAME} @@ -128,7 +128,7 @@ roleRef: EOF kubectl apply -f - << EOF -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: ${TEST_CLUSTER_EXTENSION_NAME} diff --git a/internal/action/restconfig.go b/internal/action/restconfig.go index a034ebb21..013203afb 100644 --- a/internal/action/restconfig.go +++ b/internal/action/restconfig.go @@ -8,13 +8,13 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/authentication" ) func ServiceAccountRestConfigMapper(tokenGetter *authentication.TokenGetter) func(ctx context.Context, o client.Object, c *rest.Config) (*rest.Config, error) { return func(ctx context.Context, o client.Object, c *rest.Config) (*rest.Config, error) { - cExt := o.(*ocv1alpha1.ClusterExtension) + cExt := o.(*ocv1.ClusterExtension) saKey := types.NamespacedName{ Name: cExt.Spec.Install.ServiceAccount.Name, Namespace: cExt.Spec.Install.Namespace, diff --git a/internal/applier/helm.go b/internal/applier/helm.go index ac43726f1..a46e912ff 100644 --- a/internal/applier/helm.go +++ b/internal/applier/helm.go @@ -22,7 +22,7 @@ import ( helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/rukpak/convert" "github.com/operator-framework/operator-controller/internal/rukpak/preflights/crdupgradesafety" "github.com/operator-framework/operator-controller/internal/rukpak/util" @@ -56,7 +56,7 @@ type Helm struct { Preflights []Preflight } -func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.ClusterExtension, objectLabels map[string]string, storageLabels map[string]string) ([]client.Object, string, error) { +func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1.ClusterExtension, objectLabels map[string]string, storageLabels map[string]string) ([]client.Object, string, error) { chrt, err := convert.RegistryV1ToHelmChart(ctx, contentFS, ext.Spec.Install.Namespace, []string{corev1.NamespaceAll}) if err != nil { return nil, "", err @@ -79,7 +79,7 @@ func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.Clust for _, preflight := range h.Preflights { if ext.Spec.Install.Preflight != nil && ext.Spec.Install.Preflight.CRDUpgradeSafety != nil { - if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Install.Preflight.CRDUpgradeSafety.Policy == ocv1alpha1.CRDUpgradeSafetyPolicyDisabled { + if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Install.Preflight.CRDUpgradeSafety.Policy == ocv1.CRDUpgradeSafetyPolicyDisabled { // Skip this preflight check because it is of type *crdupgradesafety.Preflight and the CRD Upgrade Safety // preflight check has been disabled continue @@ -134,7 +134,7 @@ func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.Clust return relObjects, state, nil } -func (h *Helm) getReleaseState(cl helmclient.ActionInterface, ext *ocv1alpha1.ClusterExtension, chrt *chart.Chart, values chartutil.Values, post postrender.PostRenderer) (*release.Release, *release.Release, string, error) { +func (h *Helm) getReleaseState(cl helmclient.ActionInterface, ext *ocv1.ClusterExtension, chrt *chart.Chart, values chartutil.Values, post postrender.PostRenderer) (*release.Release, *release.Release, string, error) { currentRelease, err := cl.Get(ext.GetName()) if err != nil && !errors.Is(err, driver.ErrReleaseNotFound) { return nil, nil, StateError, err diff --git a/internal/bundleutil/bundle.go b/internal/bundleutil/bundle.go index 1bfd0c063..c7bd4b998 100644 --- a/internal/bundleutil/bundle.go +++ b/internal/bundleutil/bundle.go @@ -9,7 +9,7 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" "github.com/operator-framework/operator-registry/alpha/property" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) func GetVersion(b declcfg.Bundle) (*bsemver.Version, error) { @@ -30,8 +30,8 @@ func GetVersion(b declcfg.Bundle) (*bsemver.Version, error) { } // MetadataFor returns a BundleMetadata for the given bundle name and version. -func MetadataFor(bundleName string, bundleVersion bsemver.Version) *ocv1alpha1.BundleMetadata { - return &ocv1alpha1.BundleMetadata{ +func MetadataFor(bundleName string, bundleVersion bsemver.Version) *ocv1.BundleMetadata { + return &ocv1.BundleMetadata{ Name: bundleName, Version: bundleVersion.String(), } diff --git a/internal/catalogmetadata/filter/successors.go b/internal/catalogmetadata/filter/successors.go index 54e2083b1..479d3e96b 100644 --- a/internal/catalogmetadata/filter/successors.go +++ b/internal/catalogmetadata/filter/successors.go @@ -8,11 +8,11 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/features" ) -func SuccessorsOf(installedBundle *ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) { +func SuccessorsOf(installedBundle *ocv1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) { var successors successorsPredicateFunc = legacySuccessor if features.OperatorControllerFeatureGate.Enabled(features.ForceSemverUpgradeConstraints) { successors = semverSuccessor @@ -42,9 +42,9 @@ func SuccessorsOf(installedBundle *ocv1alpha1.BundleMetadata, channels ...declcf // successorsPredicateFunc returns a predicate to find successors // for a bundle. Predicate must not include the current version. -type successorsPredicateFunc func(installedBundle *ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) +type successorsPredicateFunc func(installedBundle *ocv1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) -func legacySuccessor(installedBundle *ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) { +func legacySuccessor(installedBundle *ocv1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) { installedBundleVersion, err := bsemver.Parse(installedBundle.Version) if err != nil { return nil, fmt.Errorf("error parsing installed bundle version: %w", err) @@ -88,7 +88,7 @@ func legacySuccessor(installedBundle *ocv1alpha1.BundleMetadata, channels ...dec // in a channel entry that is necessary to determine if a bundle is a successor. // A semver range check is the only necessary element. If filtering by channel // membership is necessary, an additional filter for that purpose should be applied. -func semverSuccessor(installedBundle *ocv1alpha1.BundleMetadata, _ ...declcfg.Channel) (Predicate[declcfg.Bundle], error) { +func semverSuccessor(installedBundle *ocv1.BundleMetadata, _ ...declcfg.Channel) (Predicate[declcfg.Bundle], error) { currentVersion, err := mmsemver.NewVersion(installedBundle.Version) if err != nil { return nil, err diff --git a/internal/catalogmetadata/filter/successors_test.go b/internal/catalogmetadata/filter/successors_test.go index d70110bcd..f0cf05ac2 100644 --- a/internal/catalogmetadata/filter/successors_test.go +++ b/internal/catalogmetadata/filter/successors_test.go @@ -14,7 +14,7 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" "github.com/operator-framework/operator-registry/alpha/property" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/bundleutil" "github.com/operator-framework/operator-controller/internal/catalogmetadata/compare" "github.com/operator-framework/operator-controller/internal/features" @@ -129,7 +129,7 @@ func TestSuccessorsPredicateWithForceSemverUpgradeConstraintsEnabled(t *testing. for _, tt := range []struct { name string - installedBundle *ocv1alpha1.BundleMetadata + installedBundle *ocv1.BundleMetadata expectedResult []declcfg.Bundle }{ { @@ -162,7 +162,7 @@ func TestSuccessorsPredicateWithForceSemverUpgradeConstraintsEnabled(t *testing. }, { name: "installed bundle not found", - installedBundle: &ocv1alpha1.BundleMetadata{ + installedBundle: &ocv1.BundleMetadata{ Name: "test-package.v9.0.0", Version: "9.0.0", }, @@ -281,7 +281,7 @@ func TestSuccessorsPredicateWithForceSemverUpgradeConstraintsDisabled(t *testing for _, tt := range []struct { name string - installedBundle *ocv1alpha1.BundleMetadata + installedBundle *ocv1.BundleMetadata expectedResult []declcfg.Bundle }{ { @@ -319,7 +319,7 @@ func TestSuccessorsPredicateWithForceSemverUpgradeConstraintsDisabled(t *testing }, { name: "installed bundle not found", - installedBundle: &ocv1alpha1.BundleMetadata{ + installedBundle: &ocv1.BundleMetadata{ Name: "test-package.v9.0.0", Version: "9.0.0", }, @@ -368,7 +368,7 @@ func TestLegacySuccessor(t *testing.T) { }, }, } - installedBundle := &ocv1alpha1.BundleMetadata{ + installedBundle := &ocv1.BundleMetadata{ Name: "package1.v0.0.1", Version: "0.0.1", } diff --git a/internal/contentmanager/cache/cache_test.go b/internal/contentmanager/cache/cache_test.go index edf5c0e7a..da4455168 100644 --- a/internal/contentmanager/cache/cache_test.go +++ b/internal/contentmanager/cache/cache_test.go @@ -14,7 +14,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) type mockWatcher struct { @@ -64,7 +64,7 @@ func TestCacheWatch(t *testing.T) { &mockSourcerer{ source: &mockSource{}, }, - &ocv1alpha1.ClusterExtension{}, + &ocv1.ClusterExtension{}, time.Second, ) @@ -81,7 +81,7 @@ func TestCacheWatchInvalidGVK(t *testing.T) { &mockSourcerer{ source: &mockSource{}, }, - &ocv1alpha1.ClusterExtension{}, + &ocv1.ClusterExtension{}, time.Second, ) @@ -94,7 +94,7 @@ func TestCacheWatchSourcererError(t *testing.T) { &mockSourcerer{ err: errors.New("error"), }, - &ocv1alpha1.ClusterExtension{}, + &ocv1.ClusterExtension{}, time.Second, ) @@ -109,7 +109,7 @@ func TestCacheWatchWatcherError(t *testing.T) { &mockSourcerer{ source: &mockSource{}, }, - &ocv1alpha1.ClusterExtension{}, + &ocv1.ClusterExtension{}, time.Second, ) @@ -126,7 +126,7 @@ func TestCacheWatchSourceWaitForSyncError(t *testing.T) { err: errors.New("error"), }, }, - &ocv1alpha1.ClusterExtension{}, + &ocv1.ClusterExtension{}, time.Second, ) @@ -142,7 +142,7 @@ func TestCacheWatchExistingSourceNotPanic(t *testing.T) { &mockSourcerer{ source: &mockSource{}, }, - &ocv1alpha1.ClusterExtension{}, + &ocv1.ClusterExtension{}, time.Second, ) @@ -162,7 +162,7 @@ func TestCacheWatchRemovesStaleSources(t *testing.T) { &mockSourcerer{ source: &mockSource{}, }, - &ocv1alpha1.ClusterExtension{}, + &ocv1.ClusterExtension{}, time.Second, ) @@ -186,7 +186,7 @@ func TestCacheWatchRemovingStaleSourcesError(t *testing.T) { &mockSourcerer{ source: &mockSource{}, }, - &ocv1alpha1.ClusterExtension{}, + &ocv1.ClusterExtension{}, time.Second, ) diff --git a/internal/contentmanager/contentmanager.go b/internal/contentmanager/contentmanager.go index 13fc92f9b..4324ba0c4 100644 --- a/internal/contentmanager/contentmanager.go +++ b/internal/contentmanager/contentmanager.go @@ -14,7 +14,7 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/operator-framework/operator-controller/api/v1alpha1" + "github.com/operator-framework/operator-controller/api/v1" cmcache "github.com/operator-framework/operator-controller/internal/contentmanager/cache" oclabels "github.com/operator-framework/operator-controller/internal/labels" ) @@ -25,10 +25,10 @@ type Manager interface { // Get returns a managed content cache for the provided // ClusterExtension if one exists. If one does not exist, // a new Cache is created and returned - Get(context.Context, *v1alpha1.ClusterExtension) (cmcache.Cache, error) + Get(context.Context, *v1.ClusterExtension) (cmcache.Cache, error) // Delete will stop and remove a managed content cache // for the provided ClusterExtension if one exists. - Delete(*v1alpha1.ClusterExtension) error + Delete(*v1.ClusterExtension) error } type RestConfigMapper func(context.Context, client.Object, *rest.Config) (*rest.Config, error) @@ -84,7 +84,7 @@ func NewManager(rcm RestConfigMapper, cfg *rest.Config, mapper meta.RESTMapper, // Get returns a Cache for the provided ClusterExtension. // If a cache does not already exist, a new one will be created. // If a nil ClusterExtension is provided this function will panic. -func (i *managerImpl) Get(ctx context.Context, ce *v1alpha1.ClusterExtension) (cmcache.Cache, error) { +func (i *managerImpl) Get(ctx context.Context, ce *v1.ClusterExtension) (cmcache.Cache, error) { if ce == nil { panic("nil ClusterExtension provided") } @@ -107,7 +107,7 @@ func (i *managerImpl) Get(ctx context.Context, ce *v1alpha1.ClusterExtension) (c } tgtLabels := labels.Set{ - oclabels.OwnerKindKey: v1alpha1.ClusterExtensionKind, + oclabels.OwnerKindKey: v1.ClusterExtensionKind, oclabels.OwnerNameKey: ce.GetName(), } @@ -129,7 +129,7 @@ func (i *managerImpl) Get(ctx context.Context, ce *v1alpha1.ClusterExtension) (c } // Delete stops and removes the Cache for the provided ClusterExtension -func (i *managerImpl) Delete(ce *v1alpha1.ClusterExtension) error { +func (i *managerImpl) Delete(ce *v1.ClusterExtension) error { if ce == nil { panic("nil ClusterExtension provided") } diff --git a/internal/contentmanager/source/dynamicsource_test.go b/internal/contentmanager/source/dynamicsource_test.go index 61cbab8ca..bbcd3f9bc 100644 --- a/internal/contentmanager/source/dynamicsource_test.go +++ b/internal/contentmanager/source/dynamicsource_test.go @@ -14,7 +14,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" - "github.com/operator-framework/operator-controller/api/v1alpha1" + "github.com/operator-framework/operator-controller/api/v1" ) func TestDynamicInformerSourceCloseBeforeStartErrors(t *testing.T) { @@ -101,7 +101,7 @@ func TestDynamicInformerSourceStart(t *testing.T) { Version: "v1", Resource: "pods", }, - Owner: &v1alpha1.ClusterExtension{}, + Owner: &v1.ClusterExtension{}, Handler: handler.Funcs{}, Predicates: []predicate.Predicate{}, OnPostSyncError: func(ctx context.Context) {}, diff --git a/internal/contentmanager/sourcerer.go b/internal/contentmanager/sourcerer.go index a946cb7ba..4f6c82468 100644 --- a/internal/contentmanager/sourcerer.go +++ b/internal/contentmanager/sourcerer.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" - "github.com/operator-framework/operator-controller/api/v1alpha1" + "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/contentmanager/cache" "github.com/operator-framework/operator-controller/internal/contentmanager/source" ) @@ -68,7 +68,7 @@ func buildScheme(gvks ...schema.GroupVersionKind) (*runtime.Scheme, error) { // The ClusterExtension types must be added to the scheme since its // going to be used to establish watches that trigger reconciliation // of the owning ClusterExtension - if err := v1alpha1.AddToScheme(scheme); err != nil { + if err := v1.AddToScheme(scheme); err != nil { return nil, fmt.Errorf("adding operator controller APIs to scheme: %w", err) } diff --git a/internal/controllers/clusterextension_admission_test.go b/internal/controllers/clusterextension_admission_test.go index c7bc3ae1a..a571e54ca 100644 --- a/internal/controllers/clusterextension_admission_test.go +++ b/internal/controllers/clusterextension_admission_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) func TestClusterExtensionSourceConfig(t *testing.T) { @@ -36,29 +36,29 @@ func TestClusterExtensionSourceConfig(t *testing.T) { cl := newClient(t) var err error if tc.unionField == "Catalog" { - err = cl.Create(context.Background(), buildClusterExtension(ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + err = cl.Create(context.Background(), buildClusterExtension(ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: tc.sourceType, - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "test-package", }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: "default", }, }, })) } if tc.unionField == "" { - err = cl.Create(context.Background(), buildClusterExtension(ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + err = cl.Create(context.Background(), buildClusterExtension(ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: tc.sourceType, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: "default", }, }, @@ -110,16 +110,16 @@ func TestClusterExtensionAdmissionPackageName(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() cl := newClient(t) - err := cl.Create(context.Background(), buildClusterExtension(ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + err := cl.Create(context.Background(), buildClusterExtension(ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: tc.pkgName, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: "default", }, }, @@ -209,17 +209,17 @@ func TestClusterExtensionAdmissionVersion(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() cl := newClient(t) - err := cl.Create(context.Background(), buildClusterExtension(ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + err := cl.Create(context.Background(), buildClusterExtension(ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "package", Version: tc.version, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: "default", }, }, @@ -266,17 +266,17 @@ func TestClusterExtensionAdmissionChannel(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() cl := newClient(t) - err := cl.Create(context.Background(), buildClusterExtension(ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + err := cl.Create(context.Background(), buildClusterExtension(ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "package", Channels: tc.channels, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: "default", }, }, @@ -322,16 +322,16 @@ func TestClusterExtensionAdmissionInstallNamespace(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() cl := newClient(t) - err := cl.Create(context.Background(), buildClusterExtension(ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + err := cl.Create(context.Background(), buildClusterExtension(ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "package", }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: tc.namespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: "default", }, }, @@ -378,16 +378,16 @@ func TestClusterExtensionAdmissionServiceAccount(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() cl := newClient(t) - err := cl.Create(context.Background(), buildClusterExtension(ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + err := cl.Create(context.Background(), buildClusterExtension(ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "package", }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: tc.serviceAccount, }, }, @@ -402,8 +402,8 @@ func TestClusterExtensionAdmissionServiceAccount(t *testing.T) { } } -func buildClusterExtension(spec ocv1alpha1.ClusterExtensionSpec) *ocv1alpha1.ClusterExtension { - return &ocv1alpha1.ClusterExtension{ +func buildClusterExtension(spec ocv1.ClusterExtensionSpec) *ocv1.ClusterExtension { + return &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-extension-", }, diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index 4213a5687..46b147a94 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -43,12 +43,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/operator-framework/api/pkg/operators/v1alpha1" + operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client" "github.com/operator-framework/operator-registry/alpha/declcfg" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/bundleutil" "github.com/operator-framework/operator-controller/internal/conditionsets" "github.com/operator-framework/operator-controller/internal/contentmanager" @@ -79,11 +79,11 @@ type Applier interface { // Apply applies the content in the provided fs.FS using the configuration of the provided ClusterExtension. // It also takes in a map[string]string to be applied to all applied resources as labels and another // map[string]string used to create a unique identifier for a stored reference to the resources created. - Apply(context.Context, fs.FS, *ocv1alpha1.ClusterExtension, map[string]string, map[string]string) ([]client.Object, string, error) + Apply(context.Context, fs.FS, *ocv1.ClusterExtension, map[string]string, map[string]string) ([]client.Object, string, error) } type InstalledBundleGetter interface { - GetInstalledBundle(ctx context.Context, ext *ocv1alpha1.ClusterExtension) (*ocv1alpha1.BundleMetadata, error) + GetInstalledBundle(ctx context.Context, ext *ocv1.ClusterExtension) (*ocv1.BundleMetadata, error) } //+kubebuilder:rbac:groups=olm.operatorframework.io,resources=clusterextensions,verbs=get;list;watch;update;patch @@ -104,7 +104,7 @@ func (r *ClusterExtensionReconciler) Reconcile(ctx context.Context, req ctrl.Req l.V(1).Info("reconcile starting") defer l.V(1).Info("reconcile ending") - existingExt := &ocv1alpha1.ClusterExtension{} + existingExt := &ocv1.ClusterExtension{} if err := r.Client.Get(ctx, req.NamespacedName, existingExt); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } @@ -139,7 +139,7 @@ func (r *ClusterExtensionReconciler) Reconcile(ctx context.Context, req ctrl.Req // ensureAllConditionsWithReason checks that all defined condition types exist in the given ClusterExtension, // and assigns a specified reason and custom message to any missing condition. -func ensureAllConditionsWithReason(ext *ocv1alpha1.ClusterExtension, reason v1alpha1.ConditionReason, message string) { +func ensureAllConditionsWithReason(ext *ocv1.ClusterExtension, reason operatorsv1alpha1.ConditionReason, message string) { for _, condType := range conditionsets.ConditionTypes { cond := apimeta.FindStatusCondition(ext.Status.Conditions, condType) if cond == nil { @@ -158,8 +158,8 @@ func ensureAllConditionsWithReason(ext *ocv1alpha1.ClusterExtension, reason v1al } // Compare resources - ignoring status & metadata.finalizers -func checkForUnexpectedFieldChange(a, b ocv1alpha1.ClusterExtension) bool { - a.Status, b.Status = ocv1alpha1.ClusterExtensionStatus{}, ocv1alpha1.ClusterExtensionStatus{} +func checkForUnexpectedFieldChange(a, b ocv1.ClusterExtension) bool { + a.Status, b.Status = ocv1.ClusterExtensionStatus{}, ocv1.ClusterExtensionStatus{} a.Finalizers, b.Finalizers = []string{}, []string{} return !equality.Semantic.DeepEqual(a, b) } @@ -180,7 +180,7 @@ func checkForUnexpectedFieldChange(a, b ocv1alpha1.ClusterExtension) bool { 4.3 Apply the release on cluster. */ //nolint:unparam -func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.ClusterExtension) (ctrl.Result, error) { +func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1.ClusterExtension) (ctrl.Result, error) { l := log.FromContext(ctx) l.V(1).Info("handling finalizers") @@ -194,7 +194,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp setInstallStatus(ext, nil) setResolutionStatus(ext, nil) setResolvedStatusConditionFailed(ext, err.Error()) - ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonResolutionFailed, err.Error()) + ensureAllConditionsWithReason(ext, ocv1.ReasonResolutionFailed, err.Error()) return ctrl.Result{}, err } if finalizeResult.Updated || finalizeResult.StatusUpdated { @@ -220,7 +220,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp setInstallStatus(ext, nil) setResolutionStatus(ext, nil) setResolvedStatusConditionFailed(ext, err.Error()) - ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonResolutionFailed, err.Error()) + ensureAllConditionsWithReason(ext, ocv1.ReasonResolutionFailed, err.Error()) return ctrl.Result{}, err } @@ -240,7 +240,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp // all catalogs? SetDeprecationStatus(ext, resolvedBundle.Name, resolvedDeprecation) - resStatus := &ocv1alpha1.ClusterExtensionResolutionStatus{ + resStatus := &ocv1.ClusterExtensionResolutionStatus{ Bundle: bundleutil.MetadataFor(resolvedBundle.Name, *resolvedBundleVersion), } setResolutionStatus(ext, resStatus) @@ -262,7 +262,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp switch unpackResult.State { case rukpaksource.StatePending: setStatusUnpackFailed(ext, unpackResult.Message) - ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonUnpackFailed, "unpack pending") + ensureAllConditionsWithReason(ext, ocv1.ReasonUnpackFailed, "unpack pending") return ctrl.Result{}, nil case rukpaksource.StateUnpacked: setStatusUnpacked(ext, fmt.Sprintf("unpack successful: %v", unpackResult.Message)) @@ -273,7 +273,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp } objLbls := map[string]string{ - labels.OwnerKindKey: ocv1alpha1.ClusterExtensionKind, + labels.OwnerKindKey: ocv1.ClusterExtensionKind, labels.OwnerNameKey: ext.GetName(), } @@ -299,7 +299,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp return ctrl.Result{}, err } - installStatus := &ocv1alpha1.ClusterExtensionInstallStatus{ + installStatus := &ocv1.ClusterExtensionInstallStatus{ Bundle: bundleutil.MetadataFor(resolvedBundle.Name, *resolvedBundleVersion), } setInstallStatus(ext, installStatus) @@ -311,8 +311,8 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp // If we fail to get the cache, set the Healthy condition to // "Unknown". We can't know the health of resources we can't monitor apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeHealthy, - Reason: ocv1alpha1.ReasonUnverifiable, + Type: ocv1.TypeHealthy, + Reason: ocv1.ReasonUnverifiable, Status: metav1.ConditionUnknown, Message: err.Error(), ObservedGeneration: ext.Generation, @@ -324,8 +324,8 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp // If we fail to establish watches, set the Healthy condition to // "Unknown". We can't know the health of resources we can't monitor apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeHealthy, - Reason: ocv1alpha1.ReasonUnverifiable, + Type: ocv1.TypeHealthy, + Reason: ocv1.ReasonUnverifiable, Status: metav1.ConditionUnknown, Message: err.Error(), ObservedGeneration: ext.Generation, @@ -335,14 +335,14 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp // If we have successfully established the watches, remove the "Healthy" condition. // It should be interpreted as "Unknown" when not present. - apimeta.RemoveStatusCondition(&ext.Status.Conditions, ocv1alpha1.TypeHealthy) + apimeta.RemoveStatusCondition(&ext.Status.Conditions, ocv1.TypeHealthy) return ctrl.Result{}, nil } // SetDeprecationStatus will set the appropriate deprecation statuses for a ClusterExtension // based on the provided bundle -func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundleName string, deprecation *declcfg.Deprecation) { +func SetDeprecationStatus(ext *ocv1.ClusterExtension, bundleName string, deprecation *declcfg.Deprecation) { deprecations := map[string][]declcfg.DeprecationEntry{} channelSet := sets.New[string]() if ext.Spec.Source.Catalog != nil { @@ -354,16 +354,16 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundleName string, d for _, entry := range deprecation.Entries { switch entry.Reference.Schema { case declcfg.SchemaPackage: - deprecations[ocv1alpha1.TypePackageDeprecated] = []declcfg.DeprecationEntry{entry} + deprecations[ocv1.TypePackageDeprecated] = []declcfg.DeprecationEntry{entry} case declcfg.SchemaChannel: if channelSet.Has(entry.Reference.Name) { - deprecations[ocv1alpha1.TypeChannelDeprecated] = append(deprecations[ocv1alpha1.TypeChannelDeprecated], entry) + deprecations[ocv1.TypeChannelDeprecated] = append(deprecations[ocv1.TypeChannelDeprecated], entry) } case declcfg.SchemaBundle: if bundleName != entry.Reference.Name { continue } - deprecations[ocv1alpha1.TypeBundleDeprecated] = []declcfg.DeprecationEntry{entry} + deprecations[ocv1.TypeBundleDeprecated] = []declcfg.DeprecationEntry{entry} } } } @@ -371,9 +371,9 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundleName string, d // first get ordered deprecation messages that we'll join in the Deprecated condition message var deprecationMessages []string for _, conditionType := range []string{ - ocv1alpha1.TypePackageDeprecated, - ocv1alpha1.TypeChannelDeprecated, - ocv1alpha1.TypeBundleDeprecated, + ocv1.TypePackageDeprecated, + ocv1.TypeChannelDeprecated, + ocv1.TypeBundleDeprecated, } { if entries, ok := deprecations[conditionType]; ok { for _, entry := range entries { @@ -383,12 +383,12 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundleName string, d } // next, set the Deprecated condition - status, reason, message := metav1.ConditionFalse, ocv1alpha1.ReasonDeprecated, "" + status, reason, message := metav1.ConditionFalse, ocv1.ReasonDeprecated, "" if len(deprecationMessages) > 0 { - status, reason, message = metav1.ConditionTrue, ocv1alpha1.ReasonDeprecated, strings.Join(deprecationMessages, ";") + status, reason, message = metav1.ConditionTrue, ocv1.ReasonDeprecated, strings.Join(deprecationMessages, ";") } apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeDeprecated, + Type: ocv1.TypeDeprecated, Reason: reason, Status: status, Message: message, @@ -397,14 +397,14 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundleName string, d // finally, set the individual deprecation conditions for package, channel, and bundle for _, conditionType := range []string{ - ocv1alpha1.TypePackageDeprecated, - ocv1alpha1.TypeChannelDeprecated, - ocv1alpha1.TypeBundleDeprecated, + ocv1.TypePackageDeprecated, + ocv1.TypeChannelDeprecated, + ocv1.TypeBundleDeprecated, } { entries, ok := deprecations[conditionType] - status, reason, message := metav1.ConditionFalse, ocv1alpha1.ReasonDeprecated, "" + status, reason, message := metav1.ConditionFalse, ocv1.ReasonDeprecated, "" if ok { - status, reason = metav1.ConditionTrue, ocv1alpha1.ReasonDeprecated + status, reason = metav1.ConditionTrue, ocv1.ReasonDeprecated for _, entry := range entries { message = fmt.Sprintf("%s\n%s", message, entry.Message) } @@ -422,7 +422,7 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundleName string, d // SetupWithManager sets up the controller with the Manager. func (r *ClusterExtensionReconciler) SetupWithManager(mgr ctrl.Manager) error { controller, err := ctrl.NewControllerManagedBy(mgr). - For(&ocv1alpha1.ClusterExtension{}). + For(&ocv1.ClusterExtension{}). Watches(&catalogd.ClusterCatalog{}, crhandler.EnqueueRequestsFromMapFunc(clusterExtensionRequestsForCatalog(mgr.GetClient(), mgr.GetLogger())), builder.WithPredicates(predicate.Funcs{ @@ -457,7 +457,7 @@ func clusterExtensionRequestsForCatalog(c client.Reader, logger logr.Logger) crh return func(ctx context.Context, _ client.Object) []reconcile.Request { // no way of associating an extension to a catalog so create reconcile requests for everything clusterExtensions := metav1.PartialObjectMetadataList{} - clusterExtensions.SetGroupVersionKind(ocv1alpha1.GroupVersion.WithKind("ClusterExtensionList")) + clusterExtensions.SetGroupVersionKind(ocv1.GroupVersion.WithKind("ClusterExtensionList")) err := c.List(ctx, &clusterExtensions) if err != nil { logger.Error(err, "unable to enqueue cluster extensions for catalog reconcile") @@ -480,7 +480,7 @@ type DefaultInstalledBundleGetter struct { helmclient.ActionClientGetter } -func (d *DefaultInstalledBundleGetter) GetInstalledBundle(ctx context.Context, ext *ocv1alpha1.ClusterExtension) (*ocv1alpha1.BundleMetadata, error) { +func (d *DefaultInstalledBundleGetter) GetInstalledBundle(ctx context.Context, ext *ocv1.ClusterExtension) (*ocv1.BundleMetadata, error) { cl, err := d.ActionClientFor(ctx, ext) if err != nil { return nil, err @@ -494,7 +494,7 @@ func (d *DefaultInstalledBundleGetter) GetInstalledBundle(ctx context.Context, e return nil, nil } - return &ocv1alpha1.BundleMetadata{ + return &ocv1.BundleMetadata{ Name: release.Labels[labels.BundleNameKey], Version: release.Labels[labels.BundleVersionKey], }, nil diff --git a/internal/controllers/clusterextension_controller_test.go b/internal/controllers/clusterextension_controller_test.go index 81dcf3686..0fb2d4987 100644 --- a/internal/controllers/clusterextension_controller_test.go +++ b/internal/controllers/clusterextension_controller_test.go @@ -21,7 +21,7 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/conditionsets" "github.com/operator-framework/operator-controller/internal/controllers" "github.com/operator-framework/operator-controller/internal/resolve" @@ -42,7 +42,7 @@ func TestClusterExtensionDoesNotExist(t *testing.T) { func TestClusterExtensionResolutionFails(t *testing.T) { pkgName := fmt.Sprintf("non-existent-%s", rand.String(6)) cl, reconciler := newClientAndReconciler(t) - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { return nil, nil, nil, fmt.Errorf("no package %q found", pkgName) }) ctx := context.Background() @@ -50,18 +50,18 @@ func TestClusterExtensionResolutionFails(t *testing.T) { t.Log("When the cluster extension specifies a non-existent package") t.Log("By initializing cluster state") - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: "default", }, }, @@ -83,14 +83,14 @@ func TestClusterExtensionResolutionFails(t *testing.T) { require.Empty(t, clusterExtension.Status.Install) t.Log("By checking the expected conditions") - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, cond) require.Equal(t, metav1.ConditionFalse, cond.Status) - require.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason) + require.Equal(t, ocv1.ReasonResolutionFailed, cond.Reason) require.Equal(t, fmt.Sprintf("no package %q found", pkgName), cond.Message) verifyInvariants(ctx, t, reconciler.Client, clusterExtension) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } func TestClusterExtensionResolutionSucceeds(t *testing.T) { @@ -112,20 +112,20 @@ func TestClusterExtensionResolutionSucceeds(t *testing.T) { namespace := fmt.Sprintf("test-ns-%s", rand.String(8)) serviceAccount := fmt.Sprintf("test-sa-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, Version: pkgVer, Channels: []string{pkgChan}, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: namespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: serviceAccount, }, }, @@ -136,7 +136,7 @@ func TestClusterExtensionResolutionSucceeds(t *testing.T) { t.Log("It sets resolution success status") t.Log("By running reconcile") - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { v := bsemver.MustParse("1.0.0") return &declcfg.Bundle{ Name: "prometheus.v1.0.0", @@ -152,23 +152,23 @@ func TestClusterExtensionResolutionSucceeds(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) require.Empty(t, clusterExtension.Status.Install) t.Log("By checking the expected conditions") - resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, resolvedCond) require.Equal(t, metav1.ConditionTrue, resolvedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) require.NotNil(t, unpackedCond) require.Equal(t, metav1.ConditionFalse, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnpackFailed, unpackedCond.Reason) + require.Equal(t, ocv1.ReasonUnpackFailed, unpackedCond.Reason) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } func TestClusterExtensionUnpackFails(t *testing.T) { @@ -188,20 +188,20 @@ func TestClusterExtensionUnpackFails(t *testing.T) { namespace := fmt.Sprintf("test-ns-%s", rand.String(8)) serviceAccount := fmt.Sprintf("test-sa-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, Version: pkgVer, Channels: []string{pkgChan}, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: namespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: serviceAccount, }, }, @@ -212,7 +212,7 @@ func TestClusterExtensionUnpackFails(t *testing.T) { t.Log("It sets resolution success status") t.Log("By running reconcile") - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { v := bsemver.MustParse("1.0.0") return &declcfg.Bundle{ Name: "prometheus.v1.0.0", @@ -228,23 +228,23 @@ func TestClusterExtensionUnpackFails(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) require.Empty(t, clusterExtension.Status.Install) t.Log("By checking the expected conditions") - resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, resolvedCond) require.Equal(t, metav1.ConditionTrue, resolvedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) require.NotNil(t, unpackedCond) require.Equal(t, metav1.ConditionFalse, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnpackFailed, unpackedCond.Reason) + require.Equal(t, ocv1.ReasonUnpackFailed, unpackedCond.Reason) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } func TestClusterExtensionUnpackUnexpectedState(t *testing.T) { @@ -266,20 +266,20 @@ func TestClusterExtensionUnpackUnexpectedState(t *testing.T) { namespace := fmt.Sprintf("test-ns-%s", rand.String(8)) serviceAccount := fmt.Sprintf("test-sa-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, Version: pkgVer, Channels: []string{pkgChan}, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: namespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: serviceAccount, }, }, @@ -290,7 +290,7 @@ func TestClusterExtensionUnpackUnexpectedState(t *testing.T) { t.Log("It sets resolution success status") t.Log("By running reconcile") - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { v := bsemver.MustParse("1.0.0") return &declcfg.Bundle{ Name: "prometheus.v1.0.0", @@ -306,23 +306,23 @@ func TestClusterExtensionUnpackUnexpectedState(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) require.Empty(t, clusterExtension.Status.Install) t.Log("By checking the expected conditions") - resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, resolvedCond) require.Equal(t, metav1.ConditionTrue, resolvedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) require.NotNil(t, unpackedCond) require.Equal(t, metav1.ConditionFalse, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnpackFailed, unpackedCond.Reason) + require.Equal(t, ocv1.ReasonUnpackFailed, unpackedCond.Reason) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } func TestClusterExtensionUnpackSucceeds(t *testing.T) { @@ -345,20 +345,20 @@ func TestClusterExtensionUnpackSucceeds(t *testing.T) { namespace := fmt.Sprintf("test-ns-%s", rand.String(8)) serviceAccount := fmt.Sprintf("test-sa-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, Version: pkgVer, Channels: []string{pkgChan}, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: namespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: serviceAccount, }, }, @@ -369,7 +369,7 @@ func TestClusterExtensionUnpackSucceeds(t *testing.T) { t.Log("It sets resolution success status") t.Log("By running reconcile") - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { v := bsemver.MustParse("1.0.0") return &declcfg.Bundle{ Name: "prometheus.v1.0.0", @@ -388,23 +388,23 @@ func TestClusterExtensionUnpackSucceeds(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) require.Empty(t, clusterExtension.Status.Install) t.Log("By checking the expected resolution conditions") - resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, resolvedCond) require.Equal(t, metav1.ConditionTrue, resolvedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) require.NotNil(t, unpackedCond) require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason) + require.Equal(t, ocv1.ReasonUnpackSuccess, unpackedCond.Reason) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } func TestClusterExtensionInstallationFailedApplierFails(t *testing.T) { @@ -427,20 +427,20 @@ func TestClusterExtensionInstallationFailedApplierFails(t *testing.T) { namespace := fmt.Sprintf("test-ns-%s", rand.String(8)) serviceAccount := fmt.Sprintf("test-sa-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, Version: pkgVer, Channels: []string{pkgChan}, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: namespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: serviceAccount, }, }, @@ -451,7 +451,7 @@ func TestClusterExtensionInstallationFailedApplierFails(t *testing.T) { t.Log("It sets resolution success status") t.Log("By running reconcile") - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { v := bsemver.MustParse("1.0.0") return &declcfg.Bundle{ Name: "prometheus.v1.0.0", @@ -470,29 +470,29 @@ func TestClusterExtensionInstallationFailedApplierFails(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) require.Empty(t, clusterExtension.Status.Install) t.Log("By checking the expected resolution conditions") - resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, resolvedCond) require.Equal(t, metav1.ConditionTrue, resolvedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) require.NotNil(t, unpackedCond) require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason) + require.Equal(t, ocv1.ReasonUnpackSuccess, unpackedCond.Reason) t.Log("By checking the expected installed conditions") - installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) require.NotNil(t, installedCond) require.Equal(t, metav1.ConditionFalse, installedCond.Status) - require.Equal(t, ocv1alpha1.ReasonInstallationFailed, installedCond.Reason) + require.Equal(t, ocv1.ReasonInstallationFailed, installedCond.Reason) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } func TestClusterExtensionManagerFailed(t *testing.T) { @@ -515,20 +515,20 @@ func TestClusterExtensionManagerFailed(t *testing.T) { namespace := fmt.Sprintf("test-ns-%s", rand.String(8)) serviceAccount := fmt.Sprintf("test-sa-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, Version: pkgVer, Channels: []string{pkgChan}, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: namespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: serviceAccount, }, }, @@ -539,7 +539,7 @@ func TestClusterExtensionManagerFailed(t *testing.T) { t.Log("It sets resolution success status") t.Log("By running reconcile") - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { v := bsemver.MustParse("1.0.0") return &declcfg.Bundle{ Name: "prometheus.v1.0.0", @@ -561,35 +561,35 @@ func TestClusterExtensionManagerFailed(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Install.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Install.Bundle) t.Log("By checking the expected resolution conditions") - resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, resolvedCond) require.Equal(t, metav1.ConditionTrue, resolvedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) require.NotNil(t, unpackedCond) require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason) + require.Equal(t, ocv1.ReasonUnpackSuccess, unpackedCond.Reason) t.Log("By checking the expected installed conditions") - installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) require.NotNil(t, installedCond) require.Equal(t, metav1.ConditionTrue, installedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, installedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, installedCond.Reason) t.Log("By checking the expected healthy conditions") - managedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeHealthy) + managedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeHealthy) require.NotNil(t, managedCond) require.Equal(t, metav1.ConditionUnknown, managedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnverifiable, managedCond.Reason) + require.Equal(t, ocv1.ReasonUnverifiable, managedCond.Reason) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } func TestClusterExtensionManagedContentCacheWatchFail(t *testing.T) { @@ -612,21 +612,21 @@ func TestClusterExtensionManagedContentCacheWatchFail(t *testing.T) { installNamespace := fmt.Sprintf("test-ns-%s", rand.String(8)) serviceAccount := fmt.Sprintf("test-sa-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ - SourceType: ocv1alpha1.SourceTypeCatalog, + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ + SourceType: ocv1.SourceTypeCatalog, - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, Version: pkgVer, Channels: []string{pkgChan}, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: installNamespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: serviceAccount, }, }, @@ -637,7 +637,7 @@ func TestClusterExtensionManagedContentCacheWatchFail(t *testing.T) { t.Log("It sets resolution success status") t.Log("By running reconcile") - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { v := bsemver.MustParse("1.0.0") return &declcfg.Bundle{ Name: "prometheus.v1.0.0", @@ -661,35 +661,35 @@ func TestClusterExtensionManagedContentCacheWatchFail(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Install.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Install.Bundle) t.Log("By checking the expected resolution conditions") - resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, resolvedCond) require.Equal(t, metav1.ConditionTrue, resolvedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) require.NotNil(t, unpackedCond) require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason) + require.Equal(t, ocv1.ReasonUnpackSuccess, unpackedCond.Reason) t.Log("By checking the expected installed conditions") - installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) require.NotNil(t, installedCond) require.Equal(t, metav1.ConditionTrue, installedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, installedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, installedCond.Reason) t.Log("By checking the expected healthy conditions") - managedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeHealthy) + managedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeHealthy) require.NotNil(t, managedCond) require.Equal(t, metav1.ConditionUnknown, managedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnverifiable, managedCond.Reason) + require.Equal(t, ocv1.ReasonUnverifiable, managedCond.Reason) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } func TestClusterExtensionInstallationSucceeds(t *testing.T) { @@ -712,20 +712,20 @@ func TestClusterExtensionInstallationSucceeds(t *testing.T) { namespace := fmt.Sprintf("test-ns-%s", rand.String(8)) serviceAccount := fmt.Sprintf("test-sa-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkgName, Version: pkgVer, Channels: []string{pkgChan}, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: namespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: serviceAccount, }, }, @@ -736,7 +736,7 @@ func TestClusterExtensionInstallationSucceeds(t *testing.T) { t.Log("It sets resolution success status") t.Log("By running reconcile") - reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1alpha1.ClusterExtension, _ *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { + reconciler.Resolver = resolve.Func(func(_ context.Context, _ *ocv1.ClusterExtension, _ *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { v := bsemver.MustParse("1.0.0") return &declcfg.Bundle{ Name: "prometheus.v1.0.0", @@ -758,39 +758,39 @@ func TestClusterExtensionInstallationSucceeds(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Install.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle) + require.Equal(t, &ocv1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Install.Bundle) t.Log("By checking the expected resolution conditions") - resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + resolvedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) require.NotNil(t, resolvedCond) require.Equal(t, metav1.ConditionTrue, resolvedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) require.NotNil(t, unpackedCond) require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason) + require.Equal(t, ocv1.ReasonUnpackSuccess, unpackedCond.Reason) t.Log("By checking the expected installed conditions") - installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) require.NotNil(t, installedCond) require.Equal(t, metav1.ConditionTrue, installedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, installedCond.Reason) + require.Equal(t, ocv1.ReasonSuccess, installedCond.Reason) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1.ClusterExtension{})) } -func verifyInvariants(ctx context.Context, t *testing.T, c client.Client, ext *ocv1alpha1.ClusterExtension) { +func verifyInvariants(ctx context.Context, t *testing.T, c client.Client, ext *ocv1.ClusterExtension) { key := client.ObjectKeyFromObject(ext) require.NoError(t, c.Get(ctx, key, ext)) verifyConditionsInvariants(t, ext) } -func verifyConditionsInvariants(t *testing.T, ext *ocv1alpha1.ClusterExtension) { +func verifyConditionsInvariants(t *testing.T, ext *ocv1.ClusterExtension) { // Expect that the cluster extension's set of conditions contains all defined // condition types for the ClusterExtension API. Every reconcile should always // ensure every condition type's status/reason/message reflects the state @@ -808,48 +808,48 @@ func verifyConditionsInvariants(t *testing.T, ext *ocv1alpha1.ClusterExtension) func TestSetDeprecationStatus(t *testing.T) { for _, tc := range []struct { name string - clusterExtension *ocv1alpha1.ClusterExtension - expectedClusterExtension *ocv1alpha1.ClusterExtension + clusterExtension *ocv1.ClusterExtension + expectedClusterExtension *ocv1.ClusterExtension bundle *declcfg.Bundle deprecation *declcfg.Deprecation }{ { name: "no deprecations, all deprecation statuses set to False", - clusterExtension: &ocv1alpha1.ClusterExtension{ + clusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{}, }, }, - expectedClusterExtension: &ocv1alpha1.ClusterExtension{ + expectedClusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{ { - Type: ocv1alpha1.TypeDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypePackageDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypePackageDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeChannelDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeChannelDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeBundleDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeBundleDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, @@ -861,53 +861,53 @@ func TestSetDeprecationStatus(t *testing.T) { }, { name: "deprecated channel, but no channel specified, all deprecation statuses set to False", - clusterExtension: &ocv1alpha1.ClusterExtension{ + clusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{}, + Catalog: &ocv1.CatalogSource{}, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{}, }, }, - expectedClusterExtension: &ocv1alpha1.ClusterExtension{ + expectedClusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{}, + Catalog: &ocv1.CatalogSource{}, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{ { - Type: ocv1alpha1.TypeDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypePackageDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypePackageDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeChannelDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeChannelDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeBundleDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeBundleDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, @@ -926,57 +926,57 @@ func TestSetDeprecationStatus(t *testing.T) { }, { name: "deprecated channel, but a non-deprecated channel specified, all deprecation statuses set to False", - clusterExtension: &ocv1alpha1.ClusterExtension{ + clusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"nondeprecated"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{}, }, }, - expectedClusterExtension: &ocv1alpha1.ClusterExtension{ + expectedClusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"nondeprecated"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{ { - Type: ocv1alpha1.TypeDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypePackageDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypePackageDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeChannelDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeChannelDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeBundleDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeBundleDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, @@ -997,57 +997,57 @@ func TestSetDeprecationStatus(t *testing.T) { }, { name: "deprecated channel specified, ChannelDeprecated and Deprecated status set to true, others set to false", - clusterExtension: &ocv1alpha1.ClusterExtension{ + clusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{}, }, }, - expectedClusterExtension: &ocv1alpha1.ClusterExtension{ + expectedClusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{ { - Type: ocv1alpha1.TypeDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypePackageDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypePackageDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeChannelDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeChannelDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeBundleDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeBundleDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, @@ -1069,57 +1069,57 @@ func TestSetDeprecationStatus(t *testing.T) { }, { name: "deprecated package and channel specified, deprecated bundle, all deprecation statuses set to true", - clusterExtension: &ocv1alpha1.ClusterExtension{ + clusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{}, }, }, - expectedClusterExtension: &ocv1alpha1.ClusterExtension{ + expectedClusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{ { - Type: ocv1alpha1.TypeDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypePackageDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypePackageDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeChannelDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeChannelDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeBundleDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeBundleDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, @@ -1154,57 +1154,57 @@ func TestSetDeprecationStatus(t *testing.T) { }, { name: "deprecated channel specified, deprecated bundle, all deprecation statuses set to true, all deprecation statuses set to true except PackageDeprecated", - clusterExtension: &ocv1alpha1.ClusterExtension{ + clusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{}, }, }, - expectedClusterExtension: &ocv1alpha1.ClusterExtension{ + expectedClusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{ { - Type: ocv1alpha1.TypeDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypePackageDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypePackageDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeChannelDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeChannelDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeBundleDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeBundleDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, @@ -1233,57 +1233,57 @@ func TestSetDeprecationStatus(t *testing.T) { }, { name: "deprecated package and channel specified, all deprecation statuses set to true except BundleDeprecated", - clusterExtension: &ocv1alpha1.ClusterExtension{ + clusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{}, }, }, - expectedClusterExtension: &ocv1alpha1.ClusterExtension{ + expectedClusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{ { - Type: ocv1alpha1.TypeDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypePackageDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypePackageDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeChannelDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeChannelDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeBundleDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeBundleDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, @@ -1311,57 +1311,57 @@ func TestSetDeprecationStatus(t *testing.T) { }, { name: "deprecated channels specified, ChannelDeprecated and Deprecated status set to true, others set to false", - clusterExtension: &ocv1alpha1.ClusterExtension{ + clusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel", "anotherbadchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{}, }, }, - expectedClusterExtension: &ocv1alpha1.ClusterExtension{ + expectedClusterExtension: &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ Channels: []string{"badchannel", "anotherbadchannel"}, }, }, }, - Status: ocv1alpha1.ClusterExtensionStatus{ + Status: ocv1.ClusterExtensionStatus{ Conditions: []metav1.Condition{ { - Type: ocv1alpha1.TypeDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypePackageDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypePackageDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeChannelDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeChannelDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionTrue, ObservedGeneration: 1, }, { - Type: ocv1alpha1.TypeBundleDeprecated, - Reason: ocv1alpha1.ReasonDeprecated, + Type: ocv1.TypeBundleDeprecated, + Reason: ocv1.ReasonDeprecated, Status: metav1.ConditionFalse, ObservedGeneration: 1, }, diff --git a/internal/controllers/common_controller.go b/internal/controllers/common_controller.go index 05fb7bcd2..e94db2946 100644 --- a/internal/controllers/common_controller.go +++ b/internal/controllers/common_controller.go @@ -20,78 +20,78 @@ import ( apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) // setResolvedStatusConditionSuccess sets the resolved status condition to success. -func setResolvedStatusConditionSuccess(ext *ocv1alpha1.ClusterExtension, message string) { +func setResolvedStatusConditionSuccess(ext *ocv1.ClusterExtension, message string) { apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeResolved, + Type: ocv1.TypeResolved, Status: metav1.ConditionTrue, - Reason: ocv1alpha1.ReasonSuccess, + Reason: ocv1.ReasonSuccess, Message: message, ObservedGeneration: ext.GetGeneration(), }) } // setResolvedStatusConditionFailed sets the resolved status condition to failed. -func setResolvedStatusConditionFailed(ext *ocv1alpha1.ClusterExtension, message string) { +func setResolvedStatusConditionFailed(ext *ocv1.ClusterExtension, message string) { apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeResolved, + Type: ocv1.TypeResolved, Status: metav1.ConditionFalse, - Reason: ocv1alpha1.ReasonResolutionFailed, + Reason: ocv1.ReasonResolutionFailed, Message: message, ObservedGeneration: ext.GetGeneration(), }) } // setInstalledStatusConditionSuccess sets the installed status condition to success. -func setInstalledStatusConditionSuccess(ext *ocv1alpha1.ClusterExtension, message string) { +func setInstalledStatusConditionSuccess(ext *ocv1.ClusterExtension, message string) { apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeInstalled, + Type: ocv1.TypeInstalled, Status: metav1.ConditionTrue, - Reason: ocv1alpha1.ReasonSuccess, + Reason: ocv1.ReasonSuccess, Message: message, ObservedGeneration: ext.GetGeneration(), }) } // setInstalledStatusConditionFailed sets the installed status condition to failed. -func setInstalledStatusConditionFailed(ext *ocv1alpha1.ClusterExtension, message string) { +func setInstalledStatusConditionFailed(ext *ocv1.ClusterExtension, message string) { apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeInstalled, + Type: ocv1.TypeInstalled, Status: metav1.ConditionFalse, - Reason: ocv1alpha1.ReasonInstallationFailed, + Reason: ocv1.ReasonInstallationFailed, Message: message, ObservedGeneration: ext.GetGeneration(), }) } -func setStatusUnpackFailed(ext *ocv1alpha1.ClusterExtension, message string) { +func setStatusUnpackFailed(ext *ocv1.ClusterExtension, message string) { setInstallStatus(ext, nil) apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeUnpacked, + Type: ocv1.TypeUnpacked, Status: metav1.ConditionFalse, - Reason: ocv1alpha1.ReasonUnpackFailed, + Reason: ocv1.ReasonUnpackFailed, Message: message, ObservedGeneration: ext.GetGeneration(), }) } -func setStatusUnpacked(ext *ocv1alpha1.ClusterExtension, message string) { +func setStatusUnpacked(ext *ocv1.ClusterExtension, message string) { apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeUnpacked, + Type: ocv1.TypeUnpacked, Status: metav1.ConditionTrue, - Reason: ocv1alpha1.ReasonUnpackSuccess, + Reason: ocv1.ReasonUnpackSuccess, Message: message, ObservedGeneration: ext.GetGeneration(), }) } -func setResolutionStatus(ext *ocv1alpha1.ClusterExtension, resStatus *ocv1alpha1.ClusterExtensionResolutionStatus) { +func setResolutionStatus(ext *ocv1.ClusterExtension, resStatus *ocv1.ClusterExtensionResolutionStatus) { ext.Status.Resolution = resStatus } -func setInstallStatus(ext *ocv1alpha1.ClusterExtension, installStatus *ocv1alpha1.ClusterExtensionInstallStatus) { +func setInstallStatus(ext *ocv1.ClusterExtension, installStatus *ocv1.ClusterExtensionInstallStatus) { ext.Status.Install = installStatus } diff --git a/internal/controllers/suite_test.go b/internal/controllers/suite_test.go index 9fa70e457..b33017fbf 100644 --- a/internal/controllers/suite_test.go +++ b/internal/controllers/suite_test.go @@ -35,7 +35,7 @@ import ( helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/contentmanager" cmcache "github.com/operator-framework/operator-controller/internal/contentmanager/cache" "github.com/operator-framework/operator-controller/internal/controllers" @@ -65,7 +65,7 @@ func newClient(t *testing.T) client.Client { // TODO: this is a live client, which behaves differently than a cache client. // We may want to use a caching client instead to get closer to real behavior. sch := runtime.NewScheme() - require.NoError(t, ocv1alpha1.AddToScheme(sch)) + require.NoError(t, ocv1.AddToScheme(sch)) cl, err := client.New(config, client.Options{Scheme: sch}) require.NoError(t, err) require.NotNil(t, cl) @@ -73,14 +73,14 @@ func newClient(t *testing.T) client.Client { } type MockInstalledBundleGetter struct { - bundle *ocv1alpha1.BundleMetadata + bundle *ocv1.BundleMetadata } -func (m *MockInstalledBundleGetter) SetBundle(bundle *ocv1alpha1.BundleMetadata) { +func (m *MockInstalledBundleGetter) SetBundle(bundle *ocv1.BundleMetadata) { m.bundle = bundle } -func (m *MockInstalledBundleGetter) GetInstalledBundle(ctx context.Context, ext *ocv1alpha1.ClusterExtension) (*ocv1alpha1.BundleMetadata, error) { +func (m *MockInstalledBundleGetter) GetInstalledBundle(ctx context.Context, ext *ocv1.ClusterExtension) (*ocv1.BundleMetadata, error) { return m.bundle, nil } @@ -92,7 +92,7 @@ type MockApplier struct { state string } -func (m *MockApplier) Apply(_ context.Context, _ fs.FS, _ *ocv1alpha1.ClusterExtension, _ map[string]string, _ map[string]string) ([]client.Object, string, error) { +func (m *MockApplier) Apply(_ context.Context, _ fs.FS, _ *ocv1.ClusterExtension, _ map[string]string, _ map[string]string) ([]client.Object, string, error) { if m.err != nil { return nil, m.state, m.err } @@ -107,14 +107,14 @@ type MockManagedContentCacheManager struct { cache cmcache.Cache } -func (m *MockManagedContentCacheManager) Get(_ context.Context, _ *ocv1alpha1.ClusterExtension) (cmcache.Cache, error) { +func (m *MockManagedContentCacheManager) Get(_ context.Context, _ *ocv1.ClusterExtension) (cmcache.Cache, error) { if m.err != nil { return nil, m.err } return m.cache, nil } -func (m *MockManagedContentCacheManager) Delete(_ *ocv1alpha1.ClusterExtension) error { +func (m *MockManagedContentCacheManager) Delete(_ *ocv1.ClusterExtension) error { return m.err } diff --git a/internal/resolve/catalog.go b/internal/resolve/catalog.go index 83857a8fe..7292e2db3 100644 --- a/internal/resolve/catalog.go +++ b/internal/resolve/catalog.go @@ -17,7 +17,7 @@ import ( catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" "github.com/operator-framework/operator-registry/alpha/declcfg" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/bundleutil" "github.com/operator-framework/operator-controller/internal/catalogmetadata/compare" "github.com/operator-framework/operator-controller/internal/catalogmetadata/filter" @@ -37,7 +37,7 @@ type foundBundle struct { } // Resolve returns a Bundle from a catalog that needs to get installed on the cluster. -func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterExtension, installedBundle *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { +func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1.ClusterExtension, installedBundle *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { packageName := ext.Spec.Source.Catalog.PackageName versionRange := ext.Spec.Source.Catalog.Version channels := ext.Spec.Source.Catalog.Channels @@ -83,7 +83,7 @@ func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterEx predicates = append(predicates, filter.InMastermindsSemverRange(versionRangeConstraints)) } - if ext.Spec.Source.Catalog.UpgradeConstraintPolicy != ocv1alpha1.UpgradeConstraintPolicyIgnore && installedBundle != nil { + if ext.Spec.Source.Catalog.UpgradeConstraintPolicy != ocv1.UpgradeConstraintPolicyIgnore && installedBundle != nil { successorPredicate, err := filter.SuccessorsOf(installedBundle, packageFBC.Channels...) if err != nil { return fmt.Errorf("error finding upgrade edges: %w", err) @@ -181,7 +181,7 @@ type resolutionError struct { PackageName string Version string Channels []string - InstalledBundle *ocv1alpha1.BundleMetadata + InstalledBundle *ocv1.BundleMetadata ResolvedBundles []foundBundle } diff --git a/internal/resolve/catalog_test.go b/internal/resolve/catalog_test.go index 89ea7e3f2..0a9ac1244 100644 --- a/internal/resolve/catalog_test.go +++ b/internal/resolve/catalog_test.go @@ -20,14 +20,14 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" "github.com/operator-framework/operator-registry/alpha/property" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/features" ) func TestInvalidClusterExtensionVersionRange(t *testing.T) { r := CatalogResolver{} pkgName := randPkg() - ce := buildFooClusterExtension(pkgName, []string{}, "foobar", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "foobar", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, `desired version range "foobar" is invalid: improper constraint: foobar`) } @@ -37,7 +37,7 @@ func TestErrorWalkingCatalogs(t *testing.T) { return fmt.Errorf("fake error") }} pkgName := randPkg() - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, "error walking catalogs: fake error") } @@ -50,7 +50,7 @@ func TestErrorGettingPackage(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} pkgName := randPkg() - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`error walking catalogs: error getting package %q from catalog "a": fake error`, pkgName)) } @@ -69,7 +69,7 @@ func TestPackageDoesNotExist(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} pkgName := randPkg() - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q`, pkgName)) } @@ -88,7 +88,7 @@ func TestPackageExists(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "3.0.0"), *gotBundle) @@ -117,7 +117,7 @@ func TestValidationFailed(t *testing.T) { }, }, } - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) } @@ -136,7 +136,7 @@ func TestVersionDoesNotExist(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "4.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "4.0.0", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q matching version "4.0.0"`, pkgName)) } @@ -155,7 +155,7 @@ func TestVersionExists(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <2.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <2.0.0", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "1.0.2"), *gotBundle) @@ -177,7 +177,7 @@ func TestChannelDoesNotExist(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"stable"}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"stable"}, "", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q in channels [stable]`, pkgName)) } @@ -196,7 +196,7 @@ func TestChannelExists(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"beta"}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"beta"}, "", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "1.0.2"), *gotBundle) @@ -218,7 +218,7 @@ func TestChannelExistsButNotVersion(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"beta"}, "3.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"beta"}, "3.0.0", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q matching version "3.0.0" in channels [beta]`, pkgName)) } @@ -237,7 +237,7 @@ func TestVersionExistsButNotChannel(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"stable"}, "1.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"stable"}, "1.0.0", ocv1.UpgradeConstraintPolicyEnforce) _, _, _, err := r.Resolve(context.Background(), ce, nil) assert.EqualError(t, err, fmt.Sprintf(`no bundles found for package %q matching version "1.0.0" in channels [stable]`, pkgName)) } @@ -256,7 +256,7 @@ func TestChannelAndVersionExist(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"alpha"}, "0.1.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"alpha"}, "0.1.0", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "0.1.0"), *gotBundle) @@ -278,7 +278,7 @@ func TestPreferNonDeprecated(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">=0.1.0 <=1.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=0.1.0 <=1.0.0", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "0.1.0"), *gotBundle) @@ -300,7 +300,7 @@ func TestAcceptDeprecated(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "1.0.1"), *gotBundle) @@ -383,7 +383,7 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) { r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} t.Run("when bundle candidates for a package are deprecated in all but one catalog", func(t *testing.T) { - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.3", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.3", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) // We choose the only non-deprecated package @@ -393,7 +393,7 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) { }) t.Run("when bundle candidates are found and deprecated in multiple catalogs", func(t *testing.T) { - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) // We will not make a decision on which catalog to use @@ -404,7 +404,7 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) { }) t.Run("when bundle candidates are found and not deprecated in multiple catalogs", func(t *testing.T) { - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.4", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.4", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) // We will not make a decision on which catalog to use @@ -415,7 +415,7 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) { }) t.Run("highest semver bundle is chosen when candidates are all from the same catalog", func(t *testing.T) { - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.4 <=1.0.5", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.4 <=1.0.5", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) // Bundles within one catalog for a package will be sorted by semver and deprecation and the best is returned @@ -440,8 +440,8 @@ func TestUpgradeFoundLegacy(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) - installedBundle := &ocv1alpha1.BundleMetadata{ + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) + installedBundle := &ocv1.BundleMetadata{ Name: bundleName(pkgName, "0.1.0"), Version: "0.1.0", } @@ -468,8 +468,8 @@ func TestUpgradeNotFoundLegacy(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "<1.0.0 >=2.0.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) - installedBundle := &ocv1alpha1.BundleMetadata{ + ce := buildFooClusterExtension(pkgName, []string{}, "<1.0.0 >=2.0.0", ocv1.UpgradeConstraintPolicyEnforce) + installedBundle := &ocv1.BundleMetadata{ Name: bundleName(pkgName, "0.1.0"), Version: "0.1.0", } @@ -493,8 +493,8 @@ func TestUpgradeFoundSemver(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) - installedBundle := &ocv1alpha1.BundleMetadata{ + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) + installedBundle := &ocv1.BundleMetadata{ Name: bundleName(pkgName, "1.0.0"), Version: "1.0.0", } @@ -523,8 +523,8 @@ func TestUpgradeNotFoundSemver(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "!=0.1.0", ocv1alpha1.UpgradeConstraintPolicyEnforce) - installedBundle := &ocv1alpha1.BundleMetadata{ + ce := buildFooClusterExtension(pkgName, []string{}, "!=0.1.0", ocv1.UpgradeConstraintPolicyEnforce) + installedBundle := &ocv1.BundleMetadata{ Name: bundleName(pkgName, "0.1.0"), Version: "0.1.0", } @@ -548,8 +548,8 @@ func TestDowngradeFound(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "<1.0.2", ocv1alpha1.UpgradeConstraintPolicyIgnore) - installedBundle := &ocv1alpha1.BundleMetadata{ + ce := buildFooClusterExtension(pkgName, []string{}, "<1.0.2", ocv1.UpgradeConstraintPolicyIgnore) + installedBundle := &ocv1.BundleMetadata{ Name: bundleName(pkgName, "1.0.2"), Version: "1.0.2", } @@ -576,8 +576,8 @@ func TestDowngradeNotFound(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">0.1.0 <1.0.0", ocv1alpha1.UpgradeConstraintPolicyIgnore) - installedBundle := &ocv1alpha1.BundleMetadata{ + ce := buildFooClusterExtension(pkgName, []string{}, ">0.1.0 <1.0.0", ocv1.UpgradeConstraintPolicyIgnore) + installedBundle := &ocv1.BundleMetadata{ Name: bundleName(pkgName, "1.0.2"), Version: "1.0.2", } @@ -640,19 +640,19 @@ func TestCatalogWalker(t *testing.T) { }) } -func buildFooClusterExtension(pkg string, channels []string, version string, upgradeConstraintPolicy ocv1alpha1.UpgradeConstraintPolicy) *ocv1alpha1.ClusterExtension { - return &ocv1alpha1.ClusterExtension{ +func buildFooClusterExtension(pkg string, channels []string, version string, upgradeConstraintPolicy ocv1.UpgradeConstraintPolicy) *ocv1.ClusterExtension { + return &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Name: pkg, }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{Name: "default"}, + ServiceAccount: ocv1.ServiceAccountReference{Name: "default"}, }, - Source: ocv1alpha1.SourceConfig{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: pkg, Version: version, Channels: channels, @@ -762,13 +762,13 @@ func genPackage(pkg string) *declcfg.DeclarativeConfig { func TestInvalidClusterExtensionCatalogMatchExpressions(t *testing.T) { r := CatalogResolver{} - ce := &ocv1alpha1.ClusterExtension{ + ce := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ - Catalog: &ocv1alpha1.CatalogSource{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ + Catalog: &ocv1.CatalogSource{ PackageName: "foo", Selector: metav1.LabelSelector{ MatchExpressions: []metav1.LabelSelectorRequirement{ @@ -794,13 +794,13 @@ func TestInvalidClusterExtensionCatalogMatchLabelsName(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := &ocv1alpha1.ClusterExtension{ + ce := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ - Catalog: &ocv1alpha1.CatalogSource{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ + Catalog: &ocv1.CatalogSource{ PackageName: "foo", Selector: metav1.LabelSelector{ MatchLabels: map[string]string{"": "value"}, @@ -820,13 +820,13 @@ func TestInvalidClusterExtensionCatalogMatchLabelsValue(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := &ocv1alpha1.ClusterExtension{ + ce := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ - Catalog: &ocv1alpha1.CatalogSource{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ + Catalog: &ocv1.CatalogSource{ PackageName: "foo", Selector: metav1.LabelSelector{ MatchLabels: map[string]string{"name": "&value"}, @@ -851,7 +851,7 @@ func TestClusterExtensionMatchLabel(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/name": "b"} _, _, _, err := r.Resolve(context.Background(), ce, nil) @@ -870,7 +870,7 @@ func TestClusterExtensionNoMatchLabel(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) ce.Spec.Source.Catalog.Selector.MatchLabels = map[string]string{"olm.operatorframework.io/name": "a"} _, _, _, err := r.Resolve(context.Background(), ce, nil) @@ -912,7 +912,7 @@ func TestUnequalPriority(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, "", ocv1.UpgradeConstraintPolicyEnforce) _, gotVersion, _, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) require.Equal(t, bsemver.MustParse("1.0.0"), *gotVersion) @@ -933,7 +933,7 @@ func TestMultiplePriority(t *testing.T) { } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0 <=1.0.1", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.Error(t, err) assert.ErrorContains(t, err, "in multiple catalogs with the same priority [a b c]") @@ -956,7 +956,7 @@ func TestMultipleChannels(t *testing.T) { }, } r := CatalogResolver{WalkCatalogsFunc: w.WalkCatalogs} - ce := buildFooClusterExtension(pkgName, []string{"beta", "alpha"}, "", ocv1alpha1.UpgradeConstraintPolicyEnforce) + ce := buildFooClusterExtension(pkgName, []string{"beta", "alpha"}, "", ocv1.UpgradeConstraintPolicyEnforce) gotBundle, gotVersion, gotDeprecation, err := r.Resolve(context.Background(), ce, nil) require.NoError(t, err) assert.Equal(t, genBundle(pkgName, "2.0.0"), *gotBundle) diff --git a/internal/resolve/resolver.go b/internal/resolve/resolver.go index de9b952b0..625111d63 100644 --- a/internal/resolve/resolver.go +++ b/internal/resolve/resolver.go @@ -7,15 +7,15 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) type Resolver interface { - Resolve(ctx context.Context, ext *ocv1alpha1.ClusterExtension, installedBundle *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) + Resolve(ctx context.Context, ext *ocv1.ClusterExtension, installedBundle *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) } -type Func func(ctx context.Context, ext *ocv1alpha1.ClusterExtension, installedBundle *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) +type Func func(ctx context.Context, ext *ocv1.ClusterExtension, installedBundle *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) -func (f Func) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterExtension, installedBundle *ocv1alpha1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { +func (f Func) Resolve(ctx context.Context, ext *ocv1.ClusterExtension, installedBundle *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { return f(ctx, ext, installedBundle) } diff --git a/internal/rukpak/convert/registryv1.go b/internal/rukpak/convert/registryv1.go index 0acdd0d6d..db2130d67 100644 --- a/internal/rukpak/convert/registryv1.go +++ b/internal/rukpak/convert/registryv1.go @@ -22,7 +22,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/yaml" - "github.com/operator-framework/api/pkg/operators/v1alpha1" + operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" registrybundle "github.com/operator-framework/operator-registry/pkg/lib/bundle" registry "github.com/operator-framework/operator-controller/internal/rukpak/operator-registry" @@ -31,7 +31,7 @@ import ( type RegistryV1 struct { PackageName string - CSV v1alpha1.ClusterServiceVersion + CSV operatorsv1alpha1.ClusterServiceVersion Others []unstructured.Unstructured } @@ -84,7 +84,7 @@ func RegistryV1ToHelmChart(ctx context.Context, rv1 fs.FS, installNamespace stri } switch info.Object.GetObjectKind().GroupVersionKind().Kind { case "ClusterServiceVersion": - csv := v1alpha1.ClusterServiceVersion{} + csv := operatorsv1alpha1.ClusterServiceVersion{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(info.Object.(*unstructured.Unstructured).Object, &csv); err != nil { return err } @@ -131,19 +131,19 @@ func validateTargetNamespaces(supportedInstallModes sets.Set[string], installNam set := sets.New[string](targetNamespaces...) switch { case set.Len() == 0 || (set.Len() == 1 && set.Has("")): - if supportedInstallModes.Has(string(v1alpha1.InstallModeTypeAllNamespaces)) { + if supportedInstallModes.Has(string(operatorsv1alpha1.InstallModeTypeAllNamespaces)) { return nil } return fmt.Errorf("supported install modes %v do not support targeting all namespaces", sets.List(supportedInstallModes)) case set.Len() == 1 && !set.Has(""): - if supportedInstallModes.Has(string(v1alpha1.InstallModeTypeSingleNamespace)) { + if supportedInstallModes.Has(string(operatorsv1alpha1.InstallModeTypeSingleNamespace)) { return nil } - if supportedInstallModes.Has(string(v1alpha1.InstallModeTypeOwnNamespace)) && targetNamespaces[0] == installNamespace { + if supportedInstallModes.Has(string(operatorsv1alpha1.InstallModeTypeOwnNamespace)) && targetNamespaces[0] == installNamespace { return nil } default: - if supportedInstallModes.Has(string(v1alpha1.InstallModeTypeMultiNamespace)) && !set.Has("") { + if supportedInstallModes.Has(string(operatorsv1alpha1.InstallModeTypeMultiNamespace)) && !set.Has("") { return nil } } @@ -171,9 +171,9 @@ func Convert(in RegistryV1, installNamespace string, targetNamespaces []string) } } if len(targetNamespaces) == 0 { - if supportedInstallModes.Has(string(v1alpha1.InstallModeTypeAllNamespaces)) { + if supportedInstallModes.Has(string(operatorsv1alpha1.InstallModeTypeAllNamespaces)) { targetNamespaces = []string{""} - } else if supportedInstallModes.Has(string(v1alpha1.InstallModeTypeOwnNamespace)) { + } else if supportedInstallModes.Has(string(operatorsv1alpha1.InstallModeTypeOwnNamespace)) { targetNamespaces = []string{installNamespace} } } diff --git a/internal/rukpak/convert/registryv1_test.go b/internal/rukpak/convert/registryv1_test.go index 991d5dbdd..682c5d61a 100644 --- a/internal/rukpak/convert/registryv1_test.go +++ b/internal/rukpak/convert/registryv1_test.go @@ -16,7 +16,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/operator-framework/api/pkg/operators/v1alpha1" + operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" "github.com/operator-framework/operator-registry/alpha/property" ) @@ -35,15 +35,15 @@ var _ = Describe("RegistryV1 Suite", func() { Context("Should set the namespaces of object correctly", func() { var ( svc corev1.Service - csv v1alpha1.ClusterServiceVersion + csv operatorsv1alpha1.ClusterServiceVersion ) BeforeEach(func() { - csv = v1alpha1.ClusterServiceVersion{ + csv = operatorsv1alpha1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "testCSV", }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeAllNamespaces, Supported: true}}, + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ + InstallModes: []operatorsv1alpha1.InstallMode{{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: true}}, }, } svc = corev1.Service{ @@ -167,23 +167,23 @@ var _ = Describe("RegistryV1 Suite", func() { Context("Should generate objects successfully based on target namespaces", func() { var ( svc corev1.Service - csv v1alpha1.ClusterServiceVersion + csv operatorsv1alpha1.ClusterServiceVersion watchNamespaces []string ) BeforeEach(func() { - csv = v1alpha1.ClusterServiceVersion{ + csv = operatorsv1alpha1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "testCSV", Annotations: map[string]string{ "olm.properties": fmt.Sprintf("[{\"type\": %s, \"value\": \"%s\"}]", property.TypeConstraint, "value"), }, }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeMultiNamespace, Supported: true}}, - InstallStrategy: v1alpha1.NamedInstallStrategy{ - StrategySpec: v1alpha1.StrategyDetailsDeployment{ - Permissions: []v1alpha1.StrategyDeploymentPermissions{ + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ + InstallModes: []operatorsv1alpha1.InstallMode{{Type: operatorsv1alpha1.InstallModeTypeMultiNamespace, Supported: true}}, + InstallStrategy: operatorsv1alpha1.NamedInstallStrategy{ + StrategySpec: operatorsv1alpha1.StrategyDetailsDeployment{ + Permissions: []operatorsv1alpha1.StrategyDeploymentPermissions{ { ServiceAccountName: "testServiceAccount", Rules: []rbacv1.PolicyRule{ @@ -228,15 +228,15 @@ var _ = Describe("RegistryV1 Suite", func() { }) It("should convert into plain manifests successfully with single namespace", func() { - csv = v1alpha1.ClusterServiceVersion{ + csv = operatorsv1alpha1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "testCSV", }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeSingleNamespace, Supported: true}}, - InstallStrategy: v1alpha1.NamedInstallStrategy{ - StrategySpec: v1alpha1.StrategyDetailsDeployment{ - Permissions: []v1alpha1.StrategyDeploymentPermissions{ + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ + InstallModes: []operatorsv1alpha1.InstallMode{{Type: operatorsv1alpha1.InstallModeTypeSingleNamespace, Supported: true}}, + InstallStrategy: operatorsv1alpha1.NamedInstallStrategy{ + StrategySpec: operatorsv1alpha1.StrategyDetailsDeployment{ + Permissions: []operatorsv1alpha1.StrategyDeploymentPermissions{ { ServiceAccountName: "testServiceAccount", Rules: []rbacv1.PolicyRule{ @@ -272,15 +272,15 @@ var _ = Describe("RegistryV1 Suite", func() { }) It("should convert into plain manifests successfully with own namespace", func() { - csv = v1alpha1.ClusterServiceVersion{ + csv = operatorsv1alpha1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "testCSV", }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeOwnNamespace, Supported: true}}, - InstallStrategy: v1alpha1.NamedInstallStrategy{ - StrategySpec: v1alpha1.StrategyDetailsDeployment{ - Permissions: []v1alpha1.StrategyDeploymentPermissions{ + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ + InstallModes: []operatorsv1alpha1.InstallMode{{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: true}}, + InstallStrategy: operatorsv1alpha1.NamedInstallStrategy{ + StrategySpec: operatorsv1alpha1.StrategyDetailsDeployment{ + Permissions: []operatorsv1alpha1.StrategyDeploymentPermissions{ { ServiceAccountName: "testServiceAccount", Rules: []rbacv1.PolicyRule{ @@ -332,12 +332,12 @@ var _ = Describe("RegistryV1 Suite", func() { }) It("should error when single namespace mode is disabled with more than one target namespaces", func() { - csv = v1alpha1.ClusterServiceVersion{ + csv = operatorsv1alpha1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "testCSV", }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeSingleNamespace, Supported: false}}, + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ + InstallModes: []operatorsv1alpha1.InstallMode{{Type: operatorsv1alpha1.InstallModeTypeSingleNamespace, Supported: false}}, }, } @@ -357,16 +357,16 @@ var _ = Describe("RegistryV1 Suite", func() { }) It("should error when all namespace mode is disabled with target namespace containing an empty string", func() { - csv = v1alpha1.ClusterServiceVersion{ + csv = operatorsv1alpha1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "testCSV", }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - InstallModes: []v1alpha1.InstallMode{ - {Type: v1alpha1.InstallModeTypeAllNamespaces, Supported: false}, - {Type: v1alpha1.InstallModeTypeOwnNamespace, Supported: true}, - {Type: v1alpha1.InstallModeTypeSingleNamespace, Supported: true}, - {Type: v1alpha1.InstallModeTypeMultiNamespace, Supported: true}, + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ + InstallModes: []operatorsv1alpha1.InstallMode{ + {Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: false}, + {Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: true}, + {Type: operatorsv1alpha1.InstallModeTypeSingleNamespace, Supported: true}, + {Type: operatorsv1alpha1.InstallModeTypeMultiNamespace, Supported: true}, }, }, } @@ -406,13 +406,13 @@ var _ = Describe("RegistryV1 Suite", func() { Context("Should enforce limitations", func() { It("should not allow bundles with webhooks", func() { By("creating a registry v1 bundle") - csv := v1alpha1.ClusterServiceVersion{ + csv := operatorsv1alpha1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "testCSV", }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeAllNamespaces, Supported: true}}, - WebhookDefinitions: []v1alpha1.WebhookDescription{{ConversionCRDs: []string{"fake-webhook.package-with-webhooks.io"}}}, + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ + InstallModes: []operatorsv1alpha1.InstallMode{{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: true}}, + WebhookDefinitions: []operatorsv1alpha1.WebhookDescription{{ConversionCRDs: []string{"fake-webhook.package-with-webhooks.io"}}}, }, } watchNamespaces := []string{metav1.NamespaceAll} @@ -429,14 +429,14 @@ var _ = Describe("RegistryV1 Suite", func() { It("should not allow bundles with API service definitions", func() { By("creating a registry v1 bundle") - csv := v1alpha1.ClusterServiceVersion{ + csv := operatorsv1alpha1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "testCSV", }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeAllNamespaces, Supported: true}}, - APIServiceDefinitions: v1alpha1.APIServiceDefinitions{ - Owned: []v1alpha1.APIServiceDescription{{Name: "fake-owned-api-definition"}}, + Spec: operatorsv1alpha1.ClusterServiceVersionSpec{ + InstallModes: []operatorsv1alpha1.InstallMode{{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: true}}, + APIServiceDefinitions: operatorsv1alpha1.APIServiceDefinitions{ + Owned: []operatorsv1alpha1.APIServiceDescription{{Name: "fake-owned-api-definition"}}, }, }, } diff --git a/internal/scheme/scheme.go b/internal/scheme/scheme.go index 933d89b05..f247d9e7e 100644 --- a/internal/scheme/scheme.go +++ b/internal/scheme/scheme.go @@ -9,14 +9,14 @@ import ( catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) var Scheme = runtime.NewScheme() func init() { utilruntime.Must(clientgoscheme.AddToScheme(Scheme)) - utilruntime.Must(ocv1alpha1.AddToScheme(Scheme)) + utilruntime.Must(ocv1.AddToScheme(Scheme)) utilruntime.Must(catalogd.AddToScheme(Scheme)) utilruntime.Must(appsv1.AddToScheme(Scheme)) utilruntime.Must(corev1.AddToScheme(Scheme)) diff --git a/test/e2e/cluster_extension_install_test.go b/test/e2e/cluster_extension_install_test.go index d18cb21c2..af334944a 100644 --- a/test/e2e/cluster_extension_install_test.go +++ b/test/e2e/cluster_extension_install_test.go @@ -28,7 +28,7 @@ import ( catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) const ( @@ -177,13 +177,13 @@ func createClusterRoleAndBindingForSA(ctx context.Context, name string, sa *core return nil } -func testInit(t *testing.T) (*ocv1alpha1.ClusterExtension, *catalogd.ClusterCatalog, *corev1.ServiceAccount) { +func testInit(t *testing.T) (*ocv1.ClusterExtension, *catalogd.ClusterCatalog, *corev1.ServiceAccount) { var err error extensionCatalog, err := createTestCatalog(context.Background(), testCatalogName, os.Getenv(testCatalogRefEnvVar)) require.NoError(t, err) clusterExtensionName := fmt.Sprintf("clusterextension-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Name: clusterExtensionName, }, @@ -199,7 +199,7 @@ func testInit(t *testing.T) (*ocv1alpha1.ClusterExtension, *catalogd.ClusterCata return clusterExtension, extensionCatalog, sa } -func testCleanup(t *testing.T, cat *catalogd.ClusterCatalog, clusterExtension *ocv1alpha1.ClusterExtension, sa *corev1.ServiceAccount) { +func testCleanup(t *testing.T, cat *catalogd.ClusterCatalog, clusterExtension *ocv1.ClusterExtension, sa *corev1.ServiceAccount) { require.NoError(t, c.Delete(context.Background(), cat)) require.Eventually(t, func() bool { err := c.Get(context.Background(), types.NamespacedName{Name: cat.Name}, &catalogd.ClusterCatalog{}) @@ -207,7 +207,7 @@ func testCleanup(t *testing.T, cat *catalogd.ClusterCatalog, clusterExtension *o }, pollDuration, pollInterval) require.NoError(t, c.Delete(context.Background(), clusterExtension)) require.Eventually(t, func() bool { - err := c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, &ocv1alpha1.ClusterExtension{}) + err := c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, &ocv1.ClusterExtension{}) return errors.IsNotFound(err) }, pollDuration, pollInterval) require.NoError(t, c.Delete(context.Background(), sa)) @@ -225,19 +225,19 @@ func TestClusterExtensionInstallRegistry(t *testing.T) { defer testCleanup(t, extensionCatalog, clusterExtension, sa) defer getArtifactsOutput(t) - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", Selector: metav1.LabelSelector{ MatchLabels: map[string]string{"olm.operatorframework.io/name": extensionCatalog.Name}, }, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -249,15 +249,15 @@ func TestClusterExtensionInstallRegistry(t *testing.T) { t.Log("By eventually reporting a successful resolution and bundle path") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.2.0", Version: "1.2.0", }}, @@ -268,24 +268,24 @@ func TestClusterExtensionInstallRegistry(t *testing.T) { t.Log("By eventually reporting a successful unpacked") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonUnpackSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonUnpackSuccess, cond.Reason) assert.Contains(ct, cond.Message, "unpack successful") }, pollDuration, pollInterval) t.Log("By eventually installing the package successfully") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "Installed bundle") assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle) }, pollDuration, pollInterval) @@ -298,16 +298,16 @@ func TestClusterExtensionInstallRegistryMultipleBundles(t *testing.T) { defer testCleanup(t, extensionCatalog, clusterExtension, sa) defer getArtifactsOutput(t) - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -319,12 +319,12 @@ func TestClusterExtensionInstallRegistryMultipleBundles(t *testing.T) { t.Log("By eventually reporting a failed resolution with multiple bundles") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionFalse, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonResolutionFailed, cond.Reason) + assert.Equal(ct, ocv1.ReasonResolutionFailed, cond.Reason) assert.Contains(ct, cond.Message, "in multiple catalogs with the same priority [operatorhubio test-catalog]") assert.Nil(ct, clusterExtension.Status.Resolution) }, pollDuration, pollInterval) @@ -339,18 +339,18 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) { defer getArtifactsOutput(t) t.Log("By creating an ClusterExtension at a specified version") - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", Version: "1.0.0", // No Selector since this is an exact version match }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -359,21 +359,21 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) { t.Log("By eventually reporting a successful installation") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.0.0", Version: "1.0.0", }}, clusterExtension.Status.Resolution, ) assert.Equal(ct, - &ocv1alpha1.ClusterExtensionInstallStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionInstallStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.0.0", Version: "1.0.0", }}, @@ -389,11 +389,11 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) { t.Log("By eventually reporting an unsatisfiable resolution") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } - assert.Equal(ct, ocv1alpha1.ReasonResolutionFailed, cond.Reason) + assert.Equal(ct, ocv1.ReasonResolutionFailed, cond.Reason) assert.Equal(ct, "error upgrading from currently installed version \"1.0.0\": no bundles found for package \"prometheus\" matching version \"1.2.0\"", cond.Message) assert.Empty(ct, clusterExtension.Status.Resolution) }, pollDuration, pollInterval) @@ -408,17 +408,17 @@ func TestClusterExtensionForceInstallNonSuccessorVersion(t *testing.T) { defer getArtifactsOutput(t) t.Log("By creating an ClusterExtension at a specified version") - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", Version: "1.0.0", }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -427,14 +427,14 @@ func TestClusterExtensionForceInstallNonSuccessorVersion(t *testing.T) { t.Log("By eventually reporting a successful resolution") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.0.0", Version: "1.0.0", }}, @@ -446,19 +446,19 @@ func TestClusterExtensionForceInstallNonSuccessorVersion(t *testing.T) { t.Log("By updating the ClusterExtension resource to a non-successor version") // 1.2.0 does not replace/skip/skipRange 1.0.0. clusterExtension.Spec.Source.Catalog.Version = "1.2.0" - clusterExtension.Spec.Source.Catalog.UpgradeConstraintPolicy = ocv1alpha1.UpgradeConstraintPolicyIgnore + clusterExtension.Spec.Source.Catalog.UpgradeConstraintPolicy = ocv1.UpgradeConstraintPolicyIgnore require.NoError(t, c.Update(context.Background(), clusterExtension)) t.Log("By eventually reporting a satisfiable resolution") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.2.0", Version: "1.2.0", }}, @@ -475,17 +475,17 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) { defer getArtifactsOutput(t) t.Log("By creating an ClusterExtension at a specified version") - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", Version: "1.0.0", }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -494,14 +494,14 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) { t.Log("By eventually reporting a successful resolution") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.0.0", Version: "1.0.0", }}, @@ -517,14 +517,14 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) { t.Log("By eventually reporting a successful resolution and bundle path") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.0.1", Version: "1.0.1", }}, @@ -540,10 +540,10 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) { defer testCleanup(t, extensionCatalog, clusterExtension, sa) defer getArtifactsOutput(t) - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", Selector: metav1.LabelSelector{ MatchExpressions: []metav1.LabelSelectorRequirement{ @@ -556,9 +556,9 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) { }, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -570,15 +570,15 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) { t.Log("By reporting a successful resolution and bundle path") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.2.0", Version: "1.2.0", }}, @@ -604,15 +604,15 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) { t.Log("By eventually reporting a successful resolution and bundle path") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.2.0.0", Version: "2.0.0", }}, @@ -636,7 +636,7 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) { extensionCatalog, err := createTestCatalog(context.Background(), testCatalogName, latestCatalogImage) require.NoError(t, err) clusterExtensionName := fmt.Sprintf("clusterextension-%s", rand.String(8)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Name: clusterExtensionName, }, @@ -646,19 +646,19 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) { defer testCleanup(t, extensionCatalog, clusterExtension, sa) defer getArtifactsOutput(t) - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", Selector: metav1.LabelSelector{ MatchLabels: map[string]string{"olm.operatorframework.io/name": extensionCatalog.Name}, }, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -670,15 +670,15 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) { t.Log("By reporting a successful resolution and bundle path") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.2.0", Version: "1.2.0", }}, @@ -704,15 +704,15 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) { t.Log("By eventually reporting a successful resolution and bundle path") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.2.0", Version: "1.2.0", }}, @@ -728,19 +728,19 @@ func TestClusterExtensionInstallReResolvesWhenManagedContentChanged(t *testing.T defer testCleanup(t, extensionCatalog, clusterExtension, sa) defer getArtifactsOutput(t) - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", Selector: metav1.LabelSelector{ MatchLabels: map[string]string{"olm.operatorframework.io/name": extensionCatalog.Name}, }, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -752,14 +752,14 @@ func TestClusterExtensionInstallReResolvesWhenManagedContentChanged(t *testing.T t.Log("By reporting a successful installation") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.2.0", Version: "1.2.0", }}, @@ -800,19 +800,19 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes defer testCleanup(t, extensionCatalog, clusterExtension, sa) defer getArtifactsOutput(t) - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + clusterExtension.Spec = ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: "prometheus", Selector: metav1.LabelSelector{ MatchLabels: map[string]string{"olm.operatorframework.io/name": extensionCatalog.Name}, }, }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: "default", - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -824,15 +824,15 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes t.Log("By eventually reporting a successful resolution and bundle path") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeResolved) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") assert.Equal(ct, - &ocv1alpha1.ClusterExtensionResolutionStatus{Bundle: &ocv1alpha1.BundleMetadata{ + &ocv1.ClusterExtensionResolutionStatus{Bundle: &ocv1.BundleMetadata{ Name: "prometheus-operator.1.2.0", Version: "1.2.0", }}, @@ -843,24 +843,24 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes t.Log("By eventually reporting a successful unpacked") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeUnpacked) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonUnpackSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonUnpackSuccess, cond.Reason) assert.Contains(ct, cond.Message, "unpack successful") }, pollDuration, pollInterval) t.Log("By eventually failing to install the package successfully due to insufficient ServiceAccount permissions") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionFalse, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonInstallationFailed, cond.Reason) + assert.Equal(ct, ocv1.ReasonInstallationFailed, cond.Reason) assert.Contains(ct, cond.Message, "forbidden") }, pollDuration, pollInterval) @@ -874,12 +874,12 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes t.Log("By eventually installing the package successfully") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "Installed bundle") assert.NotEmpty(ct, clusterExtension.Status.Install) }, pollDuration, pollInterval) @@ -916,7 +916,7 @@ func getArtifactsOutput(t *testing.T) { } // get all cluster extensions save them to the artifact path. - clusterExtensions := ocv1alpha1.ClusterExtensionList{} + clusterExtensions := ocv1.ClusterExtensionList{} if err := c.List(context.Background(), &clusterExtensions, client.InNamespace("")); err != nil { fmt.Printf("Failed to list cluster extensions: %v", err) } diff --git a/test/extension-developer-e2e/extension_developer_test.go b/test/extension-developer-e2e/extension_developer_test.go index 91e7391a9..7a47cc2fd 100644 --- a/test/extension-developer-e2e/extension_developer_test.go +++ b/test/extension-developer-e2e/extension_developer_test.go @@ -20,7 +20,7 @@ import ( catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) func TestExtensionDeveloper(t *testing.T) { @@ -30,7 +30,7 @@ func TestExtensionDeveloper(t *testing.T) { scheme := runtime.NewScheme() require.NoError(t, catalogd.AddToScheme(scheme)) - require.NoError(t, ocv1alpha1.AddToScheme(scheme)) + require.NoError(t, ocv1.AddToScheme(scheme)) require.NoError(t, corev1.AddToScheme(scheme)) require.NoError(t, rbacv1.AddToScheme(scheme)) @@ -65,20 +65,20 @@ func TestExtensionDeveloper(t *testing.T) { } require.NoError(t, c.Create(ctx, sa)) - clusterExtension := &ocv1alpha1.ClusterExtension{ + clusterExtension := &ocv1.ClusterExtension{ ObjectMeta: metav1.ObjectMeta{ Name: "registryv1", }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - Source: ocv1alpha1.SourceConfig{ + Spec: ocv1.ClusterExtensionSpec{ + Source: ocv1.SourceConfig{ SourceType: "Catalog", - Catalog: &ocv1alpha1.CatalogSource{ + Catalog: &ocv1.CatalogSource{ PackageName: os.Getenv("REG_PKG_NAME"), }, }, - Install: ocv1alpha1.ClusterExtensionInstallConfig{ + Install: ocv1.ClusterExtensionInstallConfig{ Namespace: installNamespace, - ServiceAccount: ocv1alpha1.ServiceAccountReference{ + ServiceAccount: ocv1.ServiceAccountReference{ Name: sa.Name, }, }, @@ -203,14 +203,14 @@ func TestExtensionDeveloper(t *testing.T) { require.NoError(t, c.Create(context.Background(), clusterExtension)) t.Log("It should have a status condition type of Installed with a status of True and a reason of Success") require.EventuallyWithT(t, func(ct *assert.CollectT) { - ext := &ocv1alpha1.ClusterExtension{} + ext := &ocv1.ClusterExtension{} assert.NoError(ct, c.Get(context.Background(), client.ObjectKeyFromObject(clusterExtension), ext)) - cond := meta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeInstalled) + cond := meta.FindStatusCondition(ext.Status.Conditions, ocv1.TypeInstalled) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) }, 2*time.Minute, time.Second) require.NoError(t, c.Delete(context.Background(), catalog)) require.NoError(t, c.Delete(context.Background(), clusterExtension)) diff --git a/test/upgrade-e2e/post_upgrade_test.go b/test/upgrade-e2e/post_upgrade_test.go index 11bbf7544..ae60b05b5 100644 --- a/test/upgrade-e2e/post_upgrade_test.go +++ b/test/upgrade-e2e/post_upgrade_test.go @@ -20,7 +20,7 @@ import ( catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" + ocv1 "github.com/operator-framework/operator-controller/api/v1" ) func TestClusterExtensionAfterOLMUpgrade(t *testing.T) { @@ -76,15 +76,15 @@ func TestClusterExtensionAfterOLMUpgrade(t *testing.T) { }, time.Minute, time.Second) t.Log("Checking that the ClusterExtension is installed") - var clusterExtension ocv1alpha1.ClusterExtension + var clusterExtension ocv1.ClusterExtension require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(ctx, types.NamespacedName{Name: testClusterExtensionName}, &clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) if !assert.NotNil(ct, cond) { return } assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "Installed bundle") if assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle) { assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle.Version) @@ -101,14 +101,14 @@ func TestClusterExtensionAfterOLMUpgrade(t *testing.T) { t.Log("Checking that the ClusterExtension installs successfully") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(ctx, types.NamespacedName{Name: testClusterExtensionName}, &clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) + cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled) if !assert.NotNil(ct, cond) { return } - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) + assert.Equal(ct, ocv1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "Installed bundle") - assert.Equal(ct, &ocv1alpha1.BundleMetadata{Name: "prometheus-operator.1.0.1", Version: "1.0.1"}, clusterExtension.Status.Resolution.Bundle) - assert.Equal(ct, &ocv1alpha1.BundleMetadata{Name: "prometheus-operator.1.0.1", Version: "1.0.1"}, clusterExtension.Status.Install.Bundle) + assert.Equal(ct, &ocv1.BundleMetadata{Name: "prometheus-operator.1.0.1", Version: "1.0.1"}, clusterExtension.Status.Resolution.Bundle) + assert.Equal(ct, &ocv1.BundleMetadata{Name: "prometheus-operator.1.0.1", Version: "1.0.1"}, clusterExtension.Status.Install.Bundle) assert.NotEqual(ct, previousVersion, clusterExtension.Status.Install.Bundle.Version) }, time.Minute, time.Second) } diff --git a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_alertmanagerconfigs.yaml b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_alertmanagerconfigs.yaml index 64919a78a..e84a054a9 100644 --- a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_alertmanagerconfigs.yaml +++ b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_alertmanagerconfigs.yaml @@ -18,7 +18,7 @@ spec: singular: alertmanagerconfig scope: Namespaced versions: - - name: v1alpha1 + - name: v1 schema: openAPIV3Schema: description: AlertmanagerConfig defines a namespaced AlertmanagerConfig to diff --git a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_prometheusagents.yaml b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_prometheusagents.yaml index 848b223b5..52e5d1f7f 100644 --- a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_prometheusagents.yaml +++ b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_prometheusagents.yaml @@ -45,7 +45,7 @@ spec: name: Paused priority: 1 type: boolean - name: v1alpha1 + name: v1 schema: openAPIV3Schema: description: PrometheusAgent defines a Prometheus agent deployment. diff --git a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_scrapeconfigs.yaml b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_scrapeconfigs.yaml index eef7f4e48..5d391f8f3 100644 --- a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_scrapeconfigs.yaml +++ b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/monitoring.coreos.com_scrapeconfigs.yaml @@ -18,7 +18,7 @@ spec: singular: scrapeconfig scope: Namespaced versions: - - name: v1alpha1 + - name: v1 schema: openAPIV3Schema: description: ScrapeConfig defines a namespaced Prometheus scrape_config to diff --git a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/prometheusoperator.clusterserviceversion.yaml b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/prometheusoperator.clusterserviceversion.yaml index d29ed3a82..7d1618b96 100644 --- a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/prometheusoperator.clusterserviceversion.yaml +++ b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/manifests/prometheusoperator.clusterserviceversion.yaml @@ -1,4 +1,4 @@ -apiVersion: operators.coreos.com/v1alpha1 +apiVersion: operators.coreos.com/v1 kind: ClusterServiceVersion metadata: annotations: @@ -201,7 +201,7 @@ spec: displayName: AlertmanagerConfig kind: AlertmanagerConfig name: alertmanagerconfigs.monitoring.coreos.com - version: v1alpha1 + version: v1 - description: Configures an Alertmanager for the namespace displayName: Alertmanager kind: Alertmanager @@ -261,7 +261,7 @@ spec: kind: PrometheusAgent displayName: Prometheus Agent name: prometheusagents.monitoring.coreos.com - version: v1alpha1 + version: v1 - description: A running Prometheus instance displayName: Prometheus kind: Prometheus @@ -322,7 +322,7 @@ spec: kind: ScrapeConfig displayName: Scrape Config name: scrapeconfigs.monitoring.coreos.com - version: v1alpha1 + version: v1 - description: Configures prometheus to monitor a particular k8s service displayName: Service Monitor kind: ServiceMonitor