diff --git a/deploy/crds/operators_v1_catalogsourceconfig_crd.yaml b/deploy/crds/operators_v2_catalogsourceconfig_crd.yaml similarity index 94% rename from deploy/crds/operators_v1_catalogsourceconfig_crd.yaml rename to deploy/crds/operators_v2_catalogsourceconfig_crd.yaml index 237abc186..c2009f7dd 100644 --- a/deploy/crds/operators_v1_catalogsourceconfig_crd.yaml +++ b/deploy/crds/operators_v2_catalogsourceconfig_crd.yaml @@ -15,7 +15,14 @@ spec: shortNames: - csc scope: Namespaced - version: v1 + version: v2 + versions: + - name: v2 + served: true + storage: true + - name: v1 + served: true + storage: false additionalPrinterColumns: - name: Status type: string diff --git a/deploy/upstream/02_catalogsourceconfig.crd.yaml b/deploy/upstream/02_catalogsourceconfig.crd.yaml index bb2ed2015..321c3a607 100644 --- a/deploy/upstream/02_catalogsourceconfig.crd.yaml +++ b/deploy/upstream/02_catalogsourceconfig.crd.yaml @@ -15,7 +15,14 @@ spec: shortNames: - csc scope: Namespaced - version: v1 + version: v2 + versions: + - name: v2 + served: true + storage: true + - name: v1 + served: true + storage: false additionalPrinterColumns: - name: Status type: string diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt new file mode 100644 index 000000000..0926592d3 --- /dev/null +++ b/hack/boilerplate.go.txt @@ -0,0 +1,15 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ diff --git a/manifests/02_catalogsourceconfig.crd.yaml b/manifests/02_catalogsourceconfig.crd.yaml index 237abc186..c2009f7dd 100644 --- a/manifests/02_catalogsourceconfig.crd.yaml +++ b/manifests/02_catalogsourceconfig.crd.yaml @@ -15,7 +15,14 @@ spec: shortNames: - csc scope: Namespaced - version: v1 + version: v2 + versions: + - name: v2 + served: true + storage: true + - name: v1 + served: true + storage: false additionalPrinterColumns: - name: Status type: string diff --git a/pkg/apis/addtoscheme_operators_v1.go b/pkg/apis/addtoscheme_operators_v1.go index 0b5d4c31c..54909c768 100644 --- a/pkg/apis/addtoscheme_operators_v1.go +++ b/pkg/apis/addtoscheme_operators_v1.go @@ -1,10 +1,10 @@ package apis import ( - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" ) func init() { // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back - AddToSchemes = append(AddToSchemes, marketplace.SchemeBuilder.AddToScheme) + AddToSchemes = append(AddToSchemes, v1.SchemeBuilder.AddToScheme) } diff --git a/pkg/apis/addtoscheme_operators_v2.go b/pkg/apis/addtoscheme_operators_v2.go new file mode 100644 index 000000000..14ce8a918 --- /dev/null +++ b/pkg/apis/addtoscheme_operators_v2.go @@ -0,0 +1,10 @@ +package apis + +import ( + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" +) + +func init() { + // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back + AddToSchemes = append(AddToSchemes, v2.SchemeBuilder.AddToScheme) +} diff --git a/pkg/apis/operators/shared/doc.go b/pkg/apis/operators/shared/doc.go new file mode 100644 index 000000000..4fa38fda2 --- /dev/null +++ b/pkg/apis/operators/shared/doc.go @@ -0,0 +1,4 @@ +// Package shared contains structs used by various API groups +// +k8s:deepcopy-gen=package,register +// +groupName=operators.coreos.com +package shared diff --git a/pkg/apis/operators/v1/phase.go b/pkg/apis/operators/shared/phase.go similarity index 92% rename from pkg/apis/operators/v1/phase.go rename to pkg/apis/operators/shared/phase.go index ffad055bb..a63e2f303 100644 --- a/pkg/apis/operators/v1/phase.go +++ b/pkg/apis/operators/shared/phase.go @@ -1,4 +1,4 @@ -package v1 +package shared // NewPhase returns a Phase object with the given name and message func NewPhase(name string, message string) *Phase { diff --git a/pkg/apis/operators/v1/phase_types.go b/pkg/apis/operators/shared/phase_types.go similarity index 98% rename from pkg/apis/operators/v1/phase_types.go rename to pkg/apis/operators/shared/phase_types.go index b7fc26f86..6acd48067 100644 --- a/pkg/apis/operators/v1/phase_types.go +++ b/pkg/apis/operators/shared/phase_types.go @@ -1,4 +1,4 @@ -package v1 +package shared import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apis/operators/v1/shared.go b/pkg/apis/operators/shared/shared.go similarity index 86% rename from pkg/apis/operators/v1/shared.go rename to pkg/apis/operators/shared/shared.go index ccf9b5817..0b79352e2 100644 --- a/pkg/apis/operators/v1/shared.go +++ b/pkg/apis/operators/shared/shared.go @@ -1,4 +1,4 @@ -package v1 +package shared import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -7,7 +7,7 @@ import ( // EnsureFinalizer ensures that the object's finalizer is included // in the ObjectMeta Finalizers slice. If it already exists, no state change occurs. // If it doesn't, the finalizer is appended to the slice. -func ensureFinalizer(objectMeta *metav1.ObjectMeta, expectedFinalizer string) { +func EnsureFinalizer(objectMeta *metav1.ObjectMeta, expectedFinalizer string) { // First check if the finalizer is already included in the object. for _, finalizer := range objectMeta.Finalizers { if finalizer == expectedFinalizer { @@ -22,7 +22,7 @@ func ensureFinalizer(objectMeta *metav1.ObjectMeta, expectedFinalizer string) { } // RemoveFinalizer removes the finalizer from the object's ObjectMeta. -func removeFinalizer(objectMeta *metav1.ObjectMeta, deletingFinalizer string) { +func RemoveFinalizer(objectMeta *metav1.ObjectMeta, deletingFinalizer string) { outFinalizers := make([]string, 0) for _, finalizer := range objectMeta.Finalizers { if finalizer == deletingFinalizer { diff --git a/pkg/apis/operators/shared/zz_generated.deepcopy.go b/pkg/apis/operators/shared/zz_generated.deepcopy.go new file mode 100644 index 000000000..51cebe6b0 --- /dev/null +++ b/pkg/apis/operators/shared/zz_generated.deepcopy.go @@ -0,0 +1,56 @@ +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by operator-sdk. DO NOT EDIT. + +package shared + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ObjectPhase) DeepCopyInto(out *ObjectPhase) { + *out = *in + out.Phase = in.Phase + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectPhase. +func (in *ObjectPhase) DeepCopy() *ObjectPhase { + if in == nil { + return nil + } + out := new(ObjectPhase) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Phase) DeepCopyInto(out *Phase) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Phase. +func (in *Phase) DeepCopy() *Phase { + if in == nil { + return nil + } + out := new(Phase) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/operators/v1/operatorsource_types.go b/pkg/apis/operators/v1/operatorsource_types.go index 1d2095173..28735d943 100644 --- a/pkg/apis/operators/v1/operatorsource_types.go +++ b/pkg/apis/operators/v1/operatorsource_types.go @@ -3,6 +3,7 @@ package v1 import ( "strings" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -74,7 +75,7 @@ type OperatorSourceAuthorizationToken struct { // OperatorSourceStatus defines the observed state of OperatorSource type OperatorSourceStatus struct { // Current phase of the OperatorSource object - CurrentPhase ObjectPhase `json:"currentPhase,omitempty"` + CurrentPhase shared.ObjectPhase `json:"currentPhase,omitempty"` // Packages is a comma separated list of package(s) each of which has been // downloaded and processed by Marketplace operator from the specified @@ -123,14 +124,14 @@ func (s *OperatorSourceSpec) IsEqual(other *OperatorSourceSpec) bool { // RemoveFinalizer removes the operator source finalizer from the // OperatorSource ObjectMeta. func (s *OperatorSource) RemoveFinalizer() { - removeFinalizer(&s.ObjectMeta, OpSrcFinalizer) + shared.RemoveFinalizer(&s.ObjectMeta, OpSrcFinalizer) } // EnsureFinalizer ensures that the operator source finalizer is included // in the ObjectMeta Finalizers slice. If it already exists, no state change occurs. // If it doesn't, the finalizer is appended to the slice. func (s *OperatorSource) EnsureFinalizer() { - ensureFinalizer(&s.ObjectMeta, OpSrcFinalizer) + shared.EnsureFinalizer(&s.ObjectMeta, OpSrcFinalizer) } func init() { diff --git a/pkg/apis/operators/v1/register.go b/pkg/apis/operators/v1/register.go index ae96d4b9e..a8a78c1eb 100644 --- a/pkg/apis/operators/v1/register.go +++ b/pkg/apis/operators/v1/register.go @@ -17,6 +17,5 @@ var ( // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} - OperatorSourceKind = "OperatorSource" - CatalogSourceConfigKind = "CatalogSourceConfig" + OperatorSourceKind = "OperatorSource" ) diff --git a/pkg/apis/operators/v1/zz_generated.deepcopy.go b/pkg/apis/operators/v1/zz_generated.deepcopy.go index 46bcc2d07..5b1e67426 100644 --- a/pkg/apis/operators/v1/zz_generated.deepcopy.go +++ b/pkg/apis/operators/v1/zz_generated.deepcopy.go @@ -24,126 +24,6 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CatalogSourceConfig) DeepCopyInto(out *CatalogSourceConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceConfig. -func (in *CatalogSourceConfig) DeepCopy() *CatalogSourceConfig { - if in == nil { - return nil - } - out := new(CatalogSourceConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CatalogSourceConfig) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CatalogSourceConfigList) DeepCopyInto(out *CatalogSourceConfigList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]CatalogSourceConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceConfigList. -func (in *CatalogSourceConfigList) DeepCopy() *CatalogSourceConfigList { - if in == nil { - return nil - } - out := new(CatalogSourceConfigList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CatalogSourceConfigList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CatalogSourceConfigSpec) DeepCopyInto(out *CatalogSourceConfigSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceConfigSpec. -func (in *CatalogSourceConfigSpec) DeepCopy() *CatalogSourceConfigSpec { - if in == nil { - return nil - } - out := new(CatalogSourceConfigSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CatalogSourceConfigStatus) DeepCopyInto(out *CatalogSourceConfigStatus) { - *out = *in - in.CurrentPhase.DeepCopyInto(&out.CurrentPhase) - if in.PackageRepositioryVersions != nil { - in, out := &in.PackageRepositioryVersions, &out.PackageRepositioryVersions - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceConfigStatus. -func (in *CatalogSourceConfigStatus) DeepCopy() *CatalogSourceConfigStatus { - if in == nil { - return nil - } - out := new(CatalogSourceConfigStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ObjectPhase) DeepCopyInto(out *ObjectPhase) { - *out = *in - out.Phase = in.Phase - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) - in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectPhase. -func (in *ObjectPhase) DeepCopy() *ObjectPhase { - if in == nil { - return nil - } - out := new(ObjectPhase) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OperatorSource) DeepCopyInto(out *OperatorSource) { *out = *in @@ -254,19 +134,3 @@ func (in *OperatorSourceStatus) DeepCopy() *OperatorSourceStatus { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Phase) DeepCopyInto(out *Phase) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Phase. -func (in *Phase) DeepCopy() *Phase { - if in == nil { - return nil - } - out := new(Phase) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/apis/operators/v1/catalogsourceconfig_types.go b/pkg/apis/operators/v2/catalogsourceconfig_types.go similarity index 94% rename from pkg/apis/operators/v1/catalogsourceconfig_types.go rename to pkg/apis/operators/v2/catalogsourceconfig_types.go index 99ed8b003..ff884d23c 100644 --- a/pkg/apis/operators/v1/catalogsourceconfig_types.go +++ b/pkg/apis/operators/v2/catalogsourceconfig_types.go @@ -1,8 +1,9 @@ -package v1 +package v2 import ( "strings" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" @@ -53,7 +54,7 @@ type CatalogSourceConfigSpec struct { // CatalogSourceConfigStatus defines the observed state of CatalogSourceConfig type CatalogSourceConfigStatus struct { // Current phase of the CatalogSourceConfig object. - CurrentPhase ObjectPhase `json:"currentPhase,omitempty"` + CurrentPhase shared.ObjectPhase `json:"currentPhase,omitempty"` // Map of packages (key) and their app registry package version (value) PackageRepositioryVersions map[string]string `json:"packageRepositioryVersions,omitempty"` @@ -79,13 +80,13 @@ func (csc *CatalogSourceConfig) EnsureGVK() { // RemoveFinalizer removes the operator source finalizer from the // CatatalogSourceConfig ObjectMeta. func (csc *CatalogSourceConfig) RemoveFinalizer() { - removeFinalizer(&csc.ObjectMeta, CSCFinalizer) + shared.RemoveFinalizer(&csc.ObjectMeta, CSCFinalizer) } // EnsureFinalizer ensures that the CatatalogSourceConfig finalizer is included // in the ObjectMeta. func (csc *CatalogSourceConfig) EnsureFinalizer() { - ensureFinalizer(&csc.ObjectMeta, CSCFinalizer) + shared.EnsureFinalizer(&csc.ObjectMeta, CSCFinalizer) } func (csc *CatalogSourceConfig) EnsureDisplayName() { diff --git a/pkg/apis/operators/v2/doc.go b/pkg/apis/operators/v2/doc.go new file mode 100644 index 000000000..1a150951c --- /dev/null +++ b/pkg/apis/operators/v2/doc.go @@ -0,0 +1,4 @@ +// Package v2 contains API Schema definitions for the operators v2 API group +// +k8s:deepcopy-gen=package,register +// +groupName=operators.coreos.com +package v2 diff --git a/pkg/apis/operators/v2/register.go b/pkg/apis/operators/v2/register.go new file mode 100644 index 000000000..d78935c4c --- /dev/null +++ b/pkg/apis/operators/v2/register.go @@ -0,0 +1,21 @@ +// NOTE: Boilerplate only. Ignore this file. + +// Package v2 contains API Schema definitions for the operators v2 API group +// +k8s:deepcopy-gen=package,register +// +groupName=operators.coreos.com +package v2 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" +) + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: "operators.coreos.com", Version: "v2"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} + + CatalogSourceConfigKind = "CatalogSourceConfig" +) diff --git a/pkg/apis/operators/v2/zz_generated.deepcopy.go b/pkg/apis/operators/v2/zz_generated.deepcopy.go new file mode 100644 index 000000000..9dac0d05f --- /dev/null +++ b/pkg/apis/operators/v2/zz_generated.deepcopy.go @@ -0,0 +1,126 @@ +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v2 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceConfig) DeepCopyInto(out *CatalogSourceConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceConfig. +func (in *CatalogSourceConfig) DeepCopy() *CatalogSourceConfig { + if in == nil { + return nil + } + out := new(CatalogSourceConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CatalogSourceConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceConfigList) DeepCopyInto(out *CatalogSourceConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CatalogSourceConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceConfigList. +func (in *CatalogSourceConfigList) DeepCopy() *CatalogSourceConfigList { + if in == nil { + return nil + } + out := new(CatalogSourceConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CatalogSourceConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceConfigSpec) DeepCopyInto(out *CatalogSourceConfigSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceConfigSpec. +func (in *CatalogSourceConfigSpec) DeepCopy() *CatalogSourceConfigSpec { + if in == nil { + return nil + } + out := new(CatalogSourceConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceConfigStatus) DeepCopyInto(out *CatalogSourceConfigStatus) { + *out = *in + in.CurrentPhase.DeepCopyInto(&out.CurrentPhase) + if in.PackageRepositioryVersions != nil { + in, out := &in.PackageRepositioryVersions, &out.PackageRepositioryVersions + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceConfigStatus. +func (in *CatalogSourceConfigStatus) DeepCopy() *CatalogSourceConfigStatus { + if in == nil { + return nil + } + out := new(CatalogSourceConfigStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/catalogsourceconfig/cache.go b/pkg/catalogsourceconfig/cache.go index 4bbdd98a9..518c57234 100644 --- a/pkg/catalogsourceconfig/cache.go +++ b/pkg/catalogsourceconfig/cache.go @@ -3,7 +3,7 @@ package catalogsourceconfig import ( "sort" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "k8s.io/apimachinery/pkg/types" ) @@ -18,7 +18,7 @@ import ( // app-registry repositories being added or removed but with existing // repositories being updated. type cache struct { - entries map[types.UID]*marketplace.CatalogSourceConfigSpec + entries map[types.UID]*v2.CatalogSourceConfigSpec } // Cache is the interface for the CatalogSourceConfig caching functions. @@ -26,32 +26,32 @@ type Cache interface { // Get returns the cached CatalogSourceConfigSpec of the CatalogSourceConfig // object if it is present in the cache. The bool value indicates if the // Spec for the object was in the cache or not. - Get(csc *marketplace.CatalogSourceConfig) (*marketplace.CatalogSourceConfigSpec, bool) + Get(csc *v2.CatalogSourceConfig) (*v2.CatalogSourceConfigSpec, bool) // IsEntryStale figures out if the CatalogSourceConfigSpec in the // CatalogSourceConfig object matches its entry in the cache. Cache is // considered stale if it does not match. pkgStale is true then the Packages // have changed. If targetStale is true then the TargetNamespace has // changed. This implies that pkgStale is also true. - IsEntryStale(csc *marketplace.CatalogSourceConfig) (pkgStale bool, targetStale bool) + IsEntryStale(csc *v2.CatalogSourceConfig) (pkgStale bool, targetStale bool) // Evict removes the entry for the CatalogSourceConfig object from the cache. - Evict(csc *marketplace.CatalogSourceConfig) + Evict(csc *v2.CatalogSourceConfig) // Set adds the CatalogSourceConfigSpec for the CatalogSourceConfig object // into the cache. - Set(csc *marketplace.CatalogSourceConfig) + Set(csc *v2.CatalogSourceConfig) } -func (c *cache) Get(csc *marketplace.CatalogSourceConfig) (*marketplace.CatalogSourceConfigSpec, bool) { +func (c *cache) Get(csc *v2.CatalogSourceConfig) (*v2.CatalogSourceConfigSpec, bool) { entry, found := c.entries[csc.ObjectMeta.UID] if !found { - return &marketplace.CatalogSourceConfigSpec{}, false + return &v2.CatalogSourceConfigSpec{}, false } return entry, true } -func (c *cache) IsEntryStale(csc *marketplace.CatalogSourceConfig) (bool, bool) { +func (c *cache) IsEntryStale(csc *v2.CatalogSourceConfig) (bool, bool) { spec, found := c.Get(csc) // Found is false if the CSC wasn't found in the cache. So it must be stale. if !found { @@ -79,7 +79,7 @@ func (c *cache) IsEntryStale(csc *marketplace.CatalogSourceConfig) (bool, bool) return false, false } -func (c *cache) Evict(csc *marketplace.CatalogSourceConfig) { +func (c *cache) Evict(csc *v2.CatalogSourceConfig) { UID := csc.ObjectMeta.UID _, found := c.entries[UID] if !found { @@ -88,8 +88,8 @@ func (c *cache) Evict(csc *marketplace.CatalogSourceConfig) { delete(c.entries, UID) } -func (c *cache) Set(csc *marketplace.CatalogSourceConfig) { - c.entries[csc.ObjectMeta.UID] = &marketplace.CatalogSourceConfigSpec{ +func (c *cache) Set(csc *v2.CatalogSourceConfig) { + c.entries[csc.ObjectMeta.UID] = &v2.CatalogSourceConfigSpec{ Packages: csc.GetPackages(), TargetNamespace: csc.Spec.TargetNamespace, } @@ -98,6 +98,6 @@ func (c *cache) Set(csc *marketplace.CatalogSourceConfig) { // NewCache returns an initialized Cache func NewCache() Cache { return &cache{ - entries: make(map[types.UID]*marketplace.CatalogSourceConfigSpec), + entries: make(map[types.UID]*v2.CatalogSourceConfigSpec), } } diff --git a/pkg/catalogsourceconfig/cache_test.go b/pkg/catalogsourceconfig/cache_test.go index 1b1f62d8c..e4e2aef5c 100644 --- a/pkg/catalogsourceconfig/cache_test.go +++ b/pkg/catalogsourceconfig/cache_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/catalogsourceconfig" "github.com/stretchr/testify/assert" @@ -14,7 +14,7 @@ import ( var cache catalogsourceconfig.Cache var inPackages []string -var csc *marketplace.CatalogSourceConfig +var csc *v2.CatalogSourceConfig var testUID types.UID func TestMain(m *testing.M) { @@ -82,12 +82,12 @@ func TestStale(t *testing.T) { assert.True(t, targetStale) } -func helperNewCatalogSourceConfig(UID types.UID, targetNamespace, packages string) *marketplace.CatalogSourceConfig { - return &marketplace.CatalogSourceConfig{ +func helperNewCatalogSourceConfig(UID types.UID, targetNamespace, packages string) *v2.CatalogSourceConfig { + return &v2.CatalogSourceConfig{ ObjectMeta: metav1.ObjectMeta{ UID: UID, }, - Spec: marketplace.CatalogSourceConfigSpec{ + Spec: v2.CatalogSourceConfigSpec{ TargetNamespace: targetNamespace, Packages: packages, }, diff --git a/pkg/catalogsourceconfig/configuring.go b/pkg/catalogsourceconfig/configuring.go index 45cb9f939..41b9cf0c6 100644 --- a/pkg/catalogsourceconfig/configuring.go +++ b/pkg/catalogsourceconfig/configuring.go @@ -3,7 +3,8 @@ package catalogsourceconfig import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" wrapper "github.com/operator-framework/operator-marketplace/pkg/client" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/grpccatalog" @@ -49,7 +50,7 @@ type configuringReconciler struct { // Upon success, it returns "Succeeded" as the next and final desired phase. // On error, the function returns "Failed" as the next desired phase // and Message is set to the appropriate error message. -func (r *configuringReconciler) Reconcile(ctx context.Context, in *marketplace.CatalogSourceConfig) (out *marketplace.CatalogSourceConfig, nextPhase *marketplace.Phase, err error) { +func (r *configuringReconciler) Reconcile(ctx context.Context, in *v2.CatalogSourceConfig) (out *v2.CatalogSourceConfig, nextPhase *shared.Phase, err error) { if in.Status.CurrentPhase.Name != phase.Configuring { err = phase.ErrWrongReconcilerInvoked return @@ -85,7 +86,7 @@ func (r *configuringReconciler) Reconcile(ctx context.Context, in *marketplace.C // field is updated at the end of the configuring phase if successful. It iterates // over the list of packages and creates a new map of PackageName:Version for each // package in the spec. -func (r *configuringReconciler) EnsurePackagesInStatus(csc *marketplace.CatalogSourceConfig) { +func (r *configuringReconciler) EnsurePackagesInStatus(csc *v2.CatalogSourceConfig) { newPackageRepositioryVersions := make(map[string]string) packageIDs := csc.GetPackageIDs() for _, packageID := range packageIDs { diff --git a/pkg/catalogsourceconfig/deleted.go b/pkg/catalogsourceconfig/deleted.go index 92d041aa3..e456ebe9c 100644 --- a/pkg/catalogsourceconfig/deleted.go +++ b/pkg/catalogsourceconfig/deleted.go @@ -3,7 +3,8 @@ package catalogsourceconfig import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" wrapper "github.com/operator-framework/operator-marketplace/pkg/client" "github.com/operator-framework/operator-marketplace/pkg/grpccatalog" "github.com/operator-framework/operator-marketplace/pkg/phase" @@ -53,7 +54,7 @@ type deletedReconciler struct { // // nextPhase represents the next desired phase for the given CatalogSourceConfig // object. If nil is returned, it implies that no phase transition is expected. -func (r *deletedReconciler) Reconcile(ctx context.Context, in *marketplace.CatalogSourceConfig) (out *marketplace.CatalogSourceConfig, nextPhase *marketplace.Phase, err error) { +func (r *deletedReconciler) Reconcile(ctx context.Context, in *v2.CatalogSourceConfig) (out *v2.CatalogSourceConfig, nextPhase *shared.Phase, err error) { out = in // Evict the catalogsourceconfig data from the cache. diff --git a/pkg/catalogsourceconfig/factory.go b/pkg/catalogsourceconfig/factory.go index a6bc34166..50a55856e 100644 --- a/pkg/catalogsourceconfig/factory.go +++ b/pkg/catalogsourceconfig/factory.go @@ -5,7 +5,7 @@ import ( "github.com/sirupsen/logrus" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/phase" @@ -27,7 +27,7 @@ import ( // // On error, the object is transitioned into "Failed" phase. type PhaseReconcilerFactory interface { - GetPhaseReconciler(log *logrus.Entry, csc *marketplace.CatalogSourceConfig) (Reconciler, error) + GetPhaseReconciler(log *logrus.Entry, csc *v2.CatalogSourceConfig) (Reconciler, error) } // phaseReconcilerFactory implements PhaseReconcilerFactory interface. @@ -37,7 +37,7 @@ type phaseReconcilerFactory struct { cache Cache } -func (f *phaseReconcilerFactory) GetPhaseReconciler(log *logrus.Entry, csc *marketplace.CatalogSourceConfig) (Reconciler, error) { +func (f *phaseReconcilerFactory) GetPhaseReconciler(log *logrus.Entry, csc *v2.CatalogSourceConfig) (Reconciler, error) { // If the object has a deletion timestamp, it means it has been marked for // deletion. Return a deleted reconciler to remove that csc data from // the cache, and remove the finalizer so the garbage collector can diff --git a/pkg/catalogsourceconfig/failed.go b/pkg/catalogsourceconfig/failed.go index f4f19a960..1ca0cc6fb 100644 --- a/pkg/catalogsourceconfig/failed.go +++ b/pkg/catalogsourceconfig/failed.go @@ -3,7 +3,8 @@ package catalogsourceconfig import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/phase" "github.com/sirupsen/logrus" ) @@ -27,7 +28,7 @@ type failedReconciler struct { // // Given that nil is returned here, it implies that no phase transition is // expected. -func (r *failedReconciler) Reconcile(ctx context.Context, in *marketplace.CatalogSourceConfig) (out *marketplace.CatalogSourceConfig, nextPhase *marketplace.Phase, err error) { +func (r *failedReconciler) Reconcile(ctx context.Context, in *v2.CatalogSourceConfig) (out *v2.CatalogSourceConfig, nextPhase *shared.Phase, err error) { if in.Status.CurrentPhase.Name != phase.Failed { err = phase.ErrWrongReconcilerInvoked return diff --git a/pkg/catalogsourceconfig/handler.go b/pkg/catalogsourceconfig/handler.go index a1ffc019d..d1aebedd1 100644 --- a/pkg/catalogsourceconfig/handler.go +++ b/pkg/catalogsourceconfig/handler.go @@ -8,7 +8,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/sirupsen/logrus" ) @@ -29,7 +29,7 @@ func NewHandler(mgr manager.Manager, client client.Client) Handler { // Handler is the interface that wraps the Handle method type Handler interface { - Handle(ctx context.Context, catalogSourceConfig *marketplace.CatalogSourceConfig) error + Handle(ctx context.Context, catalogSourceConfig *v2.CatalogSourceConfig) error } type catalogsourceconfighandler struct { @@ -45,7 +45,7 @@ type catalogsourceconfighandler struct { } // Handle handles a new event associated with the CatalogSourceConfig type. -func (h *catalogsourceconfighandler) Handle(ctx context.Context, in *marketplace.CatalogSourceConfig) error { +func (h *catalogsourceconfighandler) Handle(ctx context.Context, in *v2.CatalogSourceConfig) error { log := getLoggerWithCatalogSourceConfigTypeFields(in) reconciler, err := h.factory.GetPhaseReconciler(log, in) @@ -88,7 +88,7 @@ func (h *catalogsourceconfighandler) Handle(ctx context.Context, in *marketplace // getLoggerWithCatalogSourceConfigTypeFields returns a logger entry that can be // used for consistent logging. -func getLoggerWithCatalogSourceConfigTypeFields(csc *marketplace.CatalogSourceConfig) *logrus.Entry { +func getLoggerWithCatalogSourceConfigTypeFields(csc *v2.CatalogSourceConfig) *logrus.Entry { return logrus.WithFields(logrus.Fields{ "type": csc.TypeMeta.Kind, "targetNamespace": csc.Spec.TargetNamespace, diff --git a/pkg/catalogsourceconfig/initial.go b/pkg/catalogsourceconfig/initial.go index 6a000d4f9..60d663b19 100644 --- a/pkg/catalogsourceconfig/initial.go +++ b/pkg/catalogsourceconfig/initial.go @@ -3,7 +3,8 @@ package catalogsourceconfig import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/phase" "github.com/sirupsen/logrus" ) @@ -26,7 +27,7 @@ type initialReconciler struct { // phase. This is the first phase in the reconciliation process. // // Upon success, it returns "Configuring" as the next desired phase. -func (r *initialReconciler) Reconcile(ctx context.Context, in *marketplace.CatalogSourceConfig) (out *marketplace.CatalogSourceConfig, nextPhase *marketplace.Phase, err error) { +func (r *initialReconciler) Reconcile(ctx context.Context, in *v2.CatalogSourceConfig) (out *v2.CatalogSourceConfig, nextPhase *shared.Phase, err error) { if in.Status.CurrentPhase.Name != phase.Initial { err = phase.ErrWrongReconcilerInvoked return diff --git a/pkg/catalogsourceconfig/reconciler.go b/pkg/catalogsourceconfig/reconciler.go index b16630e53..67d15aab7 100644 --- a/pkg/catalogsourceconfig/reconciler.go +++ b/pkg/catalogsourceconfig/reconciler.go @@ -3,7 +3,8 @@ package catalogsourceconfig import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" ) // Reconciler is the interface that wraps the Reconcile method. @@ -32,5 +33,5 @@ import ( // Reconcile operation is expected to be idempotent so that in the event of // multiple invocations there would be no adverse or side effect. type Reconciler interface { - Reconcile(ctx context.Context, in *marketplace.CatalogSourceConfig) (out *marketplace.CatalogSourceConfig, nextPhase *marketplace.Phase, err error) + Reconcile(ctx context.Context, in *v2.CatalogSourceConfig) (out *v2.CatalogSourceConfig, nextPhase *shared.Phase, err error) } diff --git a/pkg/catalogsourceconfig/succeeded.go b/pkg/catalogsourceconfig/succeeded.go index 3677999b6..d055312eb 100644 --- a/pkg/catalogsourceconfig/succeeded.go +++ b/pkg/catalogsourceconfig/succeeded.go @@ -3,7 +3,8 @@ package catalogsourceconfig import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/phase" "github.com/sirupsen/logrus" ) @@ -28,7 +29,7 @@ type succeededReconciler struct { // // Given that nil is returned here, it implies that no phase transition is // expected. -func (r *succeededReconciler) Reconcile(ctx context.Context, in *marketplace.CatalogSourceConfig) (out *marketplace.CatalogSourceConfig, nextPhase *marketplace.Phase, err error) { +func (r *succeededReconciler) Reconcile(ctx context.Context, in *v2.CatalogSourceConfig) (out *v2.CatalogSourceConfig, nextPhase *shared.Phase, err error) { if in.Status.CurrentPhase.Name != phase.Succeeded { err = phase.ErrWrongReconcilerInvoked return diff --git a/pkg/catalogsourceconfig/triggerer.go b/pkg/catalogsourceconfig/triggerer.go index 352ec2a75..18268cfbd 100644 --- a/pkg/catalogsourceconfig/triggerer.go +++ b/pkg/catalogsourceconfig/triggerer.go @@ -5,7 +5,8 @@ import ( "fmt" "strings" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/phase" @@ -53,7 +54,7 @@ func (t *triggerer) Trigger(notification datastore.PackageUpdateNotification) er options := &client.ListOptions{} options.SetLabelSelector(fmt.Sprintf("%s!=true", datastore.DatastoreLabel)) - cscs := &marketplace.CatalogSourceConfigList{} + cscs := &v2.CatalogSourceConfigList{} if err := t.client.List(context.TODO(), options, cscs); err != nil { return err } @@ -76,7 +77,7 @@ func (t *triggerer) Trigger(notification datastore.PackageUpdateNotification) er return utilerrors.NewAggregate(allErrors) } -func (t *triggerer) setPackages(instance *marketplace.CatalogSourceConfig, notification datastore.PackageUpdateNotification) (packages string, updateNeeded bool) { +func (t *triggerer) setPackages(instance *v2.CatalogSourceConfig, notification datastore.PackageUpdateNotification) (packages string, updateNeeded bool) { packageList := make([]string, 0) for _, pkg := range instance.GetPackageIDs() { // If this is a refresh notification, we need to access the datastore to determine @@ -125,11 +126,11 @@ func (t *triggerer) setPackages(instance *marketplace.CatalogSourceConfig, notif return } -func (t *triggerer) update(instance *marketplace.CatalogSourceConfig, packages string) error { +func (t *triggerer) update(instance *v2.CatalogSourceConfig, packages string) error { out := instance.DeepCopy() // We want to Set the phase to Initial to kick off reconciliation anew. - nextPhase := &marketplace.Phase{ + nextPhase := &shared.Phase{ Name: phase.Initial, Message: "Package(s) have update(s), scheduling for reconciliation", } diff --git a/pkg/catalogsourceconfig/update.go b/pkg/catalogsourceconfig/update.go index e9d84b2c5..3e02fa68b 100644 --- a/pkg/catalogsourceconfig/update.go +++ b/pkg/catalogsourceconfig/update.go @@ -3,7 +3,8 @@ package catalogsourceconfig import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/builders" "github.com/operator-framework/operator-marketplace/pkg/phase" "github.com/sirupsen/logrus" @@ -32,7 +33,7 @@ type updateReconciler struct { // Reconcile reconciles an CatalogSourceConfig object that needs to be updated. // It returns "Configuring" as the next desired phase. -func (r *updateReconciler) Reconcile(ctx context.Context, in *marketplace.CatalogSourceConfig) (out *marketplace.CatalogSourceConfig, nextPhase *marketplace.Phase, err error) { +func (r *updateReconciler) Reconcile(ctx context.Context, in *v2.CatalogSourceConfig) (out *v2.CatalogSourceConfig, nextPhase *shared.Phase, err error) { out = in.DeepCopy() // The TargetNamespace of the CatalogSourceConfig object has changed @@ -48,7 +49,7 @@ func (r *updateReconciler) Reconcile(ctx context.Context, in *marketplace.Catalo r.cache.Evict(in) // Drop existing Status field so that reconciliation can start anew. - out.Status = marketplace.CatalogSourceConfigStatus{} + out.Status = v2.CatalogSourceConfigStatus{} nextPhase = phase.GetNext(phase.Configuring) r.log.Info("Spec has changed, scheduling for configuring") @@ -59,7 +60,7 @@ func (r *updateReconciler) Reconcile(ctx context.Context, in *marketplace.Catalo // deleteObjects attempts to delete the CatalogSource in the old TargetNamespace. // This is just an attempt, because if we are not aware of the the old namespace // we will not be able to succeed. -func (r *updateReconciler) deleteObjects(in *marketplace.CatalogSourceConfig) { +func (r *updateReconciler) deleteObjects(in *v2.CatalogSourceConfig) { cachedCSCSpec, found := r.cache.Get(in) // This generally won't happen as it is because the cached Spec has changed // when we are in the update reconciler. diff --git a/pkg/controller/catalogsourceconfig/catalogsourceconfig_controller.go b/pkg/controller/catalogsourceconfig/catalogsourceconfig_controller.go index 190d0a7d9..bc6162166 100644 --- a/pkg/controller/catalogsourceconfig/catalogsourceconfig_controller.go +++ b/pkg/controller/catalogsourceconfig/catalogsourceconfig_controller.go @@ -3,7 +3,7 @@ package catalogsourceconfig import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" catalogsourceconfighandler "github.com/operator-framework/operator-marketplace/pkg/catalogsourceconfig" "github.com/operator-framework/operator-marketplace/pkg/status" log "github.com/sirupsen/logrus" @@ -45,7 +45,7 @@ func newReconciler(mgr manager.Manager) (reconcile.Reconciler, error) { return &ReconcileCatalogSourceConfig{ CatalogSourceConfigHandler: catalogsourceconfighandler.NewHandler(mgr, client), - client: client, + client: client, }, nil } @@ -58,7 +58,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to primary resource CatalogSourceConfig - err = c.Watch(&source.Kind{Type: &marketplace.CatalogSourceConfig{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(&source.Kind{Type: &v2.CatalogSourceConfig{}}, &handler.EnqueueRequestForObject{}) if err != nil { return err } @@ -92,7 +92,7 @@ func (r *ReconcileCatalogSourceConfig) Reconcile(request reconcile.Request) (rec } }() // Fetch the CatalogSourceConfig instance - instance := &marketplace.CatalogSourceConfig{} + instance := &v2.CatalogSourceConfig{} err = r.client.Get(context.TODO(), request.NamespacedName, instance) if err != nil { if errors.IsNotFound(err) { diff --git a/pkg/controller/operatorsource/operatorsource_controller.go b/pkg/controller/operatorsource/operatorsource_controller.go index cb9983f76..3cd3aa93a 100644 --- a/pkg/controller/operatorsource/operatorsource_controller.go +++ b/pkg/controller/operatorsource/operatorsource_controller.go @@ -3,7 +3,7 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" operatorsourcehandler "github.com/operator-framework/operator-marketplace/pkg/operatorsource" "github.com/operator-framework/operator-marketplace/pkg/status" log "github.com/sirupsen/logrus" @@ -41,7 +41,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to primary resource OperatorSource - err = c.Watch(&source.Kind{Type: &marketplace.OperatorSource{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(&source.Kind{Type: &v1.OperatorSource{}}, &handler.EnqueueRequestForObject{}) if err != nil { return err } @@ -75,7 +75,7 @@ func (r *ReconcileOperatorSource) Reconcile(request reconcile.Request) (reconcil } }() // Fetch the OperatorSource instance - instance := &marketplace.OperatorSource{} + instance := &v1.OperatorSource{} err = r.client.Get(context.TODO(), request.NamespacedName, instance) if err != nil { if errors.IsNotFound(err) { diff --git a/pkg/datastore/datastore.go b/pkg/datastore/datastore.go index 147666e9d..afcb7c67b 100644 --- a/pkg/datastore/datastore.go +++ b/pkg/datastore/datastore.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "k8s.io/apimachinery/pkg/types" ) @@ -73,7 +73,7 @@ type Writer interface { // successfully processed and stored in datastore. // err will be set to nil if there was no error and all manifests were // processed and stored successfully. - Write(opsrc *marketplace.OperatorSource, rawManifests []*RegistryMetadata) (count int, err error) + Write(opsrc *v1.OperatorSource, rawManifests []*RegistryMetadata) (count int, err error) // RemoveOperatorSource removes everything associated with a given operator // source from the underlying datastore. @@ -83,7 +83,7 @@ type Writer interface { // AddOperatorSource registers a new OperatorSource object with the // the underlying datastore. - AddOperatorSource(opsrc *marketplace.OperatorSource) + AddOperatorSource(opsrc *v1.OperatorSource) // GetOperatorSource returns the Spec of the OperatorSource object // associated with the UID specified in opsrcUID. @@ -150,7 +150,7 @@ func (ds *memoryDatastore) ReadRepositoryVersion(packageID string) (version stri return } -func (ds *memoryDatastore) Write(opsrc *marketplace.OperatorSource, registryMetas []*RegistryMetadata) (count int, err error) { +func (ds *memoryDatastore) Write(opsrc *v1.OperatorSource, registryMetas []*RegistryMetadata) (count int, err error) { if opsrc == nil || registryMetas == nil { err = errors.New("invalid argument") return @@ -235,7 +235,7 @@ func (ds *memoryDatastore) CheckPackages(packageIDs []string) error { return nil } -func (ds *memoryDatastore) AddOperatorSource(opsrc *marketplace.OperatorSource) { +func (ds *memoryDatastore) AddOperatorSource(opsrc *v1.OperatorSource) { ds.rows.AddEmpty(opsrc) } diff --git a/pkg/datastore/datastore_test.go b/pkg/datastore/datastore_test.go index a11dd63de..7620f10db 100644 --- a/pkg/datastore/datastore_test.go +++ b/pkg/datastore/datastore_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,7 +23,7 @@ func TestWrite(t *testing.T) { "service-catalog", } - opsrc := &marketplace.OperatorSource{ + opsrc := &v1.OperatorSource{ ObjectMeta: metav1.ObjectMeta{ UID: types.UID("123456"), }, @@ -61,13 +61,13 @@ func TestWrite(t *testing.T) { // when we do a read the metadata that associates the repository to the opsrc // is maintained. func TestReadOpsrcMeta(t *testing.T) { - opsrc := &marketplace.OperatorSource{ + opsrc := &v1.OperatorSource{ ObjectMeta: metav1.ObjectMeta{ UID: types.UID("123456"), Name: "operators-opsrc", Namespace: "operators", }, - Spec: marketplace.OperatorSourceSpec{ + Spec: v1.OperatorSourceSpec{ Endpoint: "https://quay.io/cnr", RegistryNamespace: "registry-namespace", }, @@ -102,13 +102,13 @@ func TestReadOpsrcMeta(t *testing.T) { // In this test we make sure that we properly relate multiple opsrcs // to the correct repositories. func TestReadOpsrcMetaMultipleOpsrc(t *testing.T) { - opsrc := &marketplace.OperatorSource{ + opsrc := &v1.OperatorSource{ ObjectMeta: metav1.ObjectMeta{ UID: types.UID("123456"), Name: "operators-opsrc", Namespace: "operators", }, - Spec: marketplace.OperatorSourceSpec{ + Spec: v1.OperatorSourceSpec{ Endpoint: "https://quay.io/cnr", RegistryNamespace: "registry-namespace", }, @@ -129,13 +129,13 @@ func TestReadOpsrcMetaMultipleOpsrc(t *testing.T) { _, err := ds.Write(opsrc, metadata) require.NoError(t, err) - opsrc2 := &marketplace.OperatorSource{ + opsrc2 := &v1.OperatorSource{ ObjectMeta: metav1.ObjectMeta{ UID: types.UID("456789"), Name: "operators-different", Namespace: "operators", }, - Spec: marketplace.OperatorSourceSpec{ + Spec: v1.OperatorSourceSpec{ Endpoint: "https://quay-diff.io/cnr", RegistryNamespace: "registry-namespace-diff", }, diff --git a/pkg/datastore/row.go b/pkg/datastore/row.go index 5cdbce494..147ba4027 100644 --- a/pkg/datastore/row.go +++ b/pkg/datastore/row.go @@ -3,7 +3,7 @@ package datastore import ( "sync" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "k8s.io/apimachinery/pkg/types" ) @@ -29,7 +29,7 @@ type OperatorSourceKey struct { // // We compare the Spec of the received OperatorSource object to the one // in datastore. - Spec *marketplace.OperatorSourceSpec + Spec *v1.OperatorSourceSpec } // operatorSourceRow is what gets stored in datastore after an OperatorSource CR @@ -71,7 +71,7 @@ type operatorSourceRowMap struct { // AddEmpty adds a new operator source to the map with an empty set of // registry metadata. -func (m *operatorSourceRowMap) AddEmpty(opsrc *marketplace.OperatorSource) { +func (m *operatorSourceRowMap) AddEmpty(opsrc *v1.OperatorSource) { m.lock.Lock() defer m.lock.Unlock() @@ -80,14 +80,14 @@ func (m *operatorSourceRowMap) AddEmpty(opsrc *marketplace.OperatorSource) { // Add adds a new operator source to the map with an the specified set of // registry metadata. -func (m *operatorSourceRowMap) Add(opsrc *marketplace.OperatorSource, repositories map[string]*Repository) { +func (m *operatorSourceRowMap) Add(opsrc *v1.OperatorSource, repositories map[string]*Repository) { m.lock.Lock() defer m.lock.Unlock() m.add(opsrc, repositories) } -func (m *operatorSourceRowMap) add(opsrc *marketplace.OperatorSource, repositories map[string]*Repository) { +func (m *operatorSourceRowMap) add(opsrc *v1.OperatorSource, repositories map[string]*Repository) { m.Sources[opsrc.GetUID()] = &operatorSourceRow{ OperatorSourceKey: OperatorSourceKey{ UID: opsrc.GetUID(), diff --git a/pkg/grpccatalog/grpccatalog.go b/pkg/grpccatalog/grpccatalog.go index cc1d657b1..c1f06d89a 100644 --- a/pkg/grpccatalog/grpccatalog.go +++ b/pkg/grpccatalog/grpccatalog.go @@ -6,7 +6,7 @@ import ( "strings" olm "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" - "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/builders" wrapper "github.com/operator-framework/operator-marketplace/pkg/client" "github.com/operator-framework/operator-marketplace/pkg/datastore" @@ -47,7 +47,7 @@ func (r *GrpcCatalog) EnsureResources(key types.NamespacedName, displayName, pub return fmt.Errorf("GrpcCatalog.reader is not defined") } // Ensure that the packages in the spec are available in the datastore - err := r.reader.CheckPackages(v1.GetValidPackageSliceFromString(packages)) + err := r.reader.CheckPackages(v2.GetValidPackageSliceFromString(packages)) if err != nil { return err } diff --git a/pkg/operatorsource/appregistryhelper.go b/pkg/operatorsource/appregistryhelper.go index 2bd81aae5..1e24ff07b 100644 --- a/pkg/operatorsource/appregistryhelper.go +++ b/pkg/operatorsource/appregistryhelper.go @@ -3,7 +3,7 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/appregistry" interface_client "github.com/operator-framework/operator-marketplace/pkg/client" @@ -14,7 +14,7 @@ import ( // SetupAppRegistryOptions generates an Options object based on the OperatorSource spec. It passes along // the opsrc endpoint and, if defined, retrieves the authorization token from the specified Secret // object. -func SetupAppRegistryOptions(client interface_client.Client, spec *marketplace.OperatorSourceSpec, namespace string) (appregistry.Options, error) { +func SetupAppRegistryOptions(client interface_client.Client, spec *v1.OperatorSourceSpec, namespace string) (appregistry.Options, error) { options := appregistry.Options{ Source: spec.Endpoint, } diff --git a/pkg/operatorsource/configuring.go b/pkg/operatorsource/configuring.go index 1fbc04700..c4f0de3ab 100644 --- a/pkg/operatorsource/configuring.go +++ b/pkg/operatorsource/configuring.go @@ -4,7 +4,8 @@ import ( "context" "errors" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/appregistry" interface_client "github.com/operator-framework/operator-marketplace/pkg/client" "github.com/operator-framework/operator-marketplace/pkg/datastore" @@ -67,7 +68,7 @@ type configuringReconciler struct { // // If the corresponding CatalogSourceConfig object already exists // then no further action is taken. -func (r *configuringReconciler) Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) { +func (r *configuringReconciler) Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) { if in.GetCurrentPhaseName() != phase.Configuring { err = phase.ErrWrongReconcilerInvoked return @@ -139,7 +140,7 @@ func (r *configuringReconciler) Reconcile(ctx context.Context, in *marketplace.O // It returns the list of packages to be written to the OperatorSource status. error is set // when there is an issue downloading the metadata. In that case the list of packages // will be empty. -func (r *configuringReconciler) getManifestMetadata(spec *marketplace.OperatorSourceSpec, namespace string) ([]*datastore.RegistryMetadata, error) { +func (r *configuringReconciler) getManifestMetadata(spec *v1.OperatorSourceSpec, namespace string) ([]*datastore.RegistryMetadata, error) { metadata := make([]*datastore.RegistryMetadata, 0) @@ -166,7 +167,7 @@ func (r *configuringReconciler) getManifestMetadata(spec *marketplace.OperatorSo // this is a new OperatorSource and in this case we should force all // CatalogSourceConfigs to compare their versions to what's in the datastore // after we update it. The function returns the whether a resync is needed and an error -func (r *configuringReconciler) writeMetadataToDatastore(in *marketplace.OperatorSource, out *marketplace.OperatorSource, metadata []*datastore.RegistryMetadata) (bool, error) { +func (r *configuringReconciler) writeMetadataToDatastore(in *v1.OperatorSource, out *v1.OperatorSource, metadata []*datastore.RegistryMetadata) (bool, error) { preUpdateDatastorePackageList := r.datastore.GetPackageIDsByOperatorSource(out.GetUID()) diff --git a/pkg/operatorsource/configuring_test.go b/pkg/operatorsource/configuring_test.go index 9c30b49fa..4a9594294 100644 --- a/pkg/operatorsource/configuring_test.go +++ b/pkg/operatorsource/configuring_test.go @@ -5,13 +5,14 @@ import ( "testing" "github.com/stretchr/testify/assert" - "k8s.io/api/apps/v1" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" gomock "github.com/golang/mock/gomock" "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/appregistry" "github.com/operator-framework/operator-marketplace/pkg/builders" "github.com/operator-framework/operator-marketplace/pkg/datastore" @@ -27,7 +28,7 @@ func TestReconcile_ScheduledForConfiguring_Succeeded(t *testing.T) { controller := gomock.NewController(t) defer controller.Finish() - nextPhaseWant := &marketplace.Phase{ + nextPhaseWant := &shared.Phase{ Name: phase.Succeeded, Message: phase.GetMessage(phase.Succeeded), } @@ -35,7 +36,7 @@ func TestReconcile_ScheduledForConfiguring_Succeeded(t *testing.T) { writer := mocks.NewDatastoreWriter(controller) reader := mocks.NewDatastoreReader(controller) factory := mocks.NewAppRegistryClientFactory(controller) - fakeclient := NewFakeClientWithChildResources(&v1.Deployment{}, &corev1.Service{}, &v1alpha1.CatalogSource{}) + fakeclient := NewFakeClientWithChildResources(&appsv1.Deployment{}, &corev1.Service{}, &v1alpha1.CatalogSource{}) refresher := mocks.NewSyncerPackageRefreshNotificationSender(controller) reconciler := operatorsource.NewConfiguringReconcilerWithClientInterface(helperGetContextLogger(), factory, writer, reader, fakeclient, refresher) @@ -116,7 +117,7 @@ func TestReconcile_OperatorSourceReturnsEmptyManifestList_Failed(t *testing.T) { opsrcGot, nextPhaseGot, errGot := reconciler.Reconcile(ctx, opsrcIn) assert.Error(t, errGot) - nextPhaseWant := &marketplace.Phase{ + nextPhaseWant := &shared.Phase{ Name: phase.Failed, Message: errGot.Error(), } @@ -132,7 +133,7 @@ func TestReconcile_NotConfigured_NewCatalogConfigSourceObjectCreated(t *testing. controller := gomock.NewController(t) defer controller.Finish() - nextPhaseWant := &marketplace.Phase{ + nextPhaseWant := &shared.Phase{ Name: phase.Succeeded, Message: phase.GetMessage(phase.Succeeded), } @@ -141,7 +142,7 @@ func TestReconcile_NotConfigured_NewCatalogConfigSourceObjectCreated(t *testing. reader := mocks.NewDatastoreReader(controller) factory := mocks.NewAppRegistryClientFactory(controller) registryClient := mocks.NewAppRegistryClient(controller) - fakeclient := NewFakeClientWithChildResources(&v1.Deployment{}, &corev1.Service{}, &v1alpha1.CatalogSource{}) + fakeclient := NewFakeClientWithChildResources(&appsv1.Deployment{}, &corev1.Service{}, &v1alpha1.CatalogSource{}) refresher := mocks.NewSyncerPackageRefreshNotificationSender(controller) reconciler := operatorsource.NewConfiguringReconciler(helperGetContextLogger(), factory, writer, reader, fakeclient, refresher) @@ -189,7 +190,7 @@ func TestReconcile_NotConfigured_NewCatalogConfigSourceObjectCreated(t *testing. reader.EXPECT().Read(gomock.Any()).Return(&datastore.OpsrcRef{}, nil).AnyTimes() cscWant := helperNewCatalogSourceConfigWithLabels(opsrcIn.Namespace, opsrcIn.Name, labelsWant) - cscWant.Spec = marketplace.CatalogSourceConfigSpec{ + cscWant.Spec = v2.CatalogSourceConfigSpec{ TargetNamespace: opsrcIn.Namespace, Packages: packages, } @@ -210,7 +211,7 @@ func TestReconcile_CatalogSourceConfigAlreadyExists_Updated(t *testing.T) { defer controller.Finish() namespace, name := "marketplace", "foo" - nextPhaseWant := &marketplace.Phase{ + nextPhaseWant := &shared.Phase{ Name: phase.Succeeded, Message: phase.GetMessage(phase.Succeeded), } @@ -263,7 +264,7 @@ func TestReconcile_CatalogSourceConfigAlreadyExists_Updated(t *testing.T) { // Then we expect a read to the datastore reader.EXPECT().Read(gomock.Any()).Return(&datastore.OpsrcRef{}, nil).AnyTimes() - fakeclient := NewFakeClientWithChildResources(&v1.Deployment{}, &corev1.Service{}, &v1alpha1.CatalogSource{}) + fakeclient := NewFakeClientWithChildResources(&appsv1.Deployment{}, &corev1.Service{}, &v1alpha1.CatalogSource{}) reconciler := operatorsource.NewConfiguringReconciler(helperGetContextLogger(), factory, writer, reader, fakeclient, refresher) @@ -283,7 +284,7 @@ func TestReconcile_UpdateError_MovedToFailedPhase(t *testing.T) { namespace, name := "marketplace", "foo" updateError := k8s_errors.NewServerTimeout(schema.GroupResource{}, "operation", 1) - nextPhaseWant := &marketplace.Phase{ + nextPhaseWant := &shared.Phase{ Name: phase.Configuring, Message: updateError.Error(), } diff --git a/pkg/operatorsource/deleted.go b/pkg/operatorsource/deleted.go index e8bc690e1..4524e0f14 100644 --- a/pkg/operatorsource/deleted.go +++ b/pkg/operatorsource/deleted.go @@ -5,7 +5,8 @@ import ( "github.com/operator-framework/operator-marketplace/pkg/grpccatalog" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" wrapper "github.com/operator-framework/operator-marketplace/pkg/client" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/phase" @@ -55,7 +56,7 @@ type deletedReconciler struct { // // nextPhase represents the next desired phase for the given OperatorSource // object. If nil is returned, it implies that no phase transition is expected. -func (r *deletedReconciler) Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) { +func (r *deletedReconciler) Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) { out = in // Delete the operator source manifests. diff --git a/pkg/operatorsource/factory.go b/pkg/operatorsource/factory.go index b5783f174..816822d58 100644 --- a/pkg/operatorsource/factory.go +++ b/pkg/operatorsource/factory.go @@ -6,7 +6,7 @@ import ( log "github.com/sirupsen/logrus" "sigs.k8s.io/controller-runtime/pkg/client" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/appregistry" @@ -30,7 +30,7 @@ type PhaseReconcilerFactory interface { // opsrc represents the given OperatorSource object // // On error, the object is transitioned into "Failed" phase. - GetPhaseReconciler(logger *log.Entry, opsrc *marketplace.OperatorSource) (Reconciler, error) + GetPhaseReconciler(logger *log.Entry, opsrc *v1.OperatorSource) (Reconciler, error) } // phaseReconcilerFactory implements PhaseReconcilerFactory interface. @@ -41,7 +41,7 @@ type phaseReconcilerFactory struct { refresher PackageRefreshNotificationSender } -func (s *phaseReconcilerFactory) GetPhaseReconciler(logger *log.Entry, opsrc *marketplace.OperatorSource) (Reconciler, error) { +func (s *phaseReconcilerFactory) GetPhaseReconciler(logger *log.Entry, opsrc *v1.OperatorSource) (Reconciler, error) { currentPhase := opsrc.GetCurrentPhaseName() // If the object has a deletion timestamp, it means it has been marked for diff --git a/pkg/operatorsource/failed.go b/pkg/operatorsource/failed.go index b2aaf9468..d6f39d2fb 100644 --- a/pkg/operatorsource/failed.go +++ b/pkg/operatorsource/failed.go @@ -3,7 +3,8 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/phase" log "github.com/sirupsen/logrus" ) @@ -33,7 +34,7 @@ type failedReconciler struct { // // nextPhase represents the next desired phase for the given OperatorSource // object. If nil is returned, it implies that no phase transition is expected. -func (r *failedReconciler) Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) { +func (r *failedReconciler) Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) { if in.GetCurrentPhaseName() != phase.Failed { err = phase.ErrWrongReconcilerInvoked return diff --git a/pkg/operatorsource/handler.go b/pkg/operatorsource/handler.go index 8bac46de7..361012e0b 100644 --- a/pkg/operatorsource/handler.go +++ b/pkg/operatorsource/handler.go @@ -3,7 +3,8 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/appregistry" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/phase" @@ -45,7 +46,7 @@ func NewHandler(mgr manager.Manager, client client.Client) Handler { // ctx represents the parent context. // event encapsulates the event fired by operator sdk. type Handler interface { - Handle(ctx context.Context, operatorSource *marketplace.OperatorSource) error + Handle(ctx context.Context, operatorSource *v1.OperatorSource) error } // operatorsourcehandler implements the Handler interface @@ -59,7 +60,7 @@ type operatorsourcehandler struct { newCacheReconciler NewOutOfSyncCacheReconcilerFunc } -func (h *operatorsourcehandler) Handle(ctx context.Context, in *marketplace.OperatorSource) error { +func (h *operatorsourcehandler) Handle(ctx context.Context, in *v1.OperatorSource) error { logger := log.WithFields(log.Fields{ "type": in.TypeMeta.Kind, "namespace": in.GetNamespace(), @@ -95,7 +96,7 @@ func (h *operatorsourcehandler) Handle(ctx context.Context, in *marketplace.Oper return h.transition(ctx, logger, out, status, err) } -func (h *operatorsourcehandler) transition(ctx context.Context, logger *log.Entry, opsrc *marketplace.OperatorSource, nextPhase *marketplace.Phase, reconciliationErr error) error { +func (h *operatorsourcehandler) transition(ctx context.Context, logger *log.Entry, opsrc *v1.OperatorSource, nextPhase *shared.Phase, reconciliationErr error) error { // If reconciliation threw an error, we can't quit just yet. We need to // figure out whether the OperatorSource object needs to be updated. diff --git a/pkg/operatorsource/handler_test.go b/pkg/operatorsource/handler_test.go index 3993add78..0133b83aa 100644 --- a/pkg/operatorsource/handler_test.go +++ b/pkg/operatorsource/handler_test.go @@ -6,7 +6,8 @@ import ( "testing" "github.com/golang/mock/gomock" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/datastore" mocks "github.com/operator-framework/operator-marketplace/pkg/mocks/operatorsource_mocks" "github.com/operator-framework/operator-marketplace/pkg/operatorsource" @@ -47,7 +48,7 @@ func TestHandle_PhaseHasChanged_UpdateExpected(t *testing.T) { cacheReconciler.EXPECT().Reconcile(ctx, opsrcIn).Return(opsrcOut, nil, nil) // We expect the phase reconciler to successfully reconcile the object inside event. - nextPhaseExpected := &marketplace.Phase{ + nextPhaseExpected := &shared.Phase{ Name: "validating", Message: "validation is in progress", } @@ -62,7 +63,7 @@ func TestHandle_PhaseHasChanged_UpdateExpected(t *testing.T) { // We expect the object to be updated successfully. namespacedName := types.NamespacedName{Name: "foo", Namespace: "marketplace"} - opsrcGot := &marketplace.OperatorSource{} + opsrcGot := &v1.OperatorSource{} fakeclient.Get(ctx, namespacedName, opsrcGot) assert.Equal(t, opsrcOut, opsrcGot) @@ -111,7 +112,7 @@ func TestHandle_PhaseHasNotChanged_NoUpdateExpected(t *testing.T) { // We expect no changes to the object namespacedName := types.NamespacedName{Name: "foo", Namespace: "namespace"} - opsrcGot := &marketplace.OperatorSource{} + opsrcGot := &v1.OperatorSource{} fakeclient.Get(ctx, namespacedName, opsrcGot) assert.Equal(t, opsrcIn, opsrcGot) @@ -148,7 +149,7 @@ func TestHandle_UpdateError_ReconciliationErrorReturned(t *testing.T) { // We expect the phase reconciler to throw an error. reconcileErrorExpected := errors.New("reconciliation error") - nextPhaseExpected := &marketplace.Phase{ + nextPhaseExpected := &shared.Phase{ Name: "Failed", Message: "Reconciliation has failed", } diff --git a/pkg/operatorsource/helper_test.go b/pkg/operatorsource/helper_test.go index 8f52e544d..db557cf97 100644 --- a/pkg/operatorsource/helper_test.go +++ b/pkg/operatorsource/helper_test.go @@ -5,9 +5,11 @@ import ( "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" "github.com/operator-framework/operator-marketplace/pkg/apis" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" log "github.com/sirupsen/logrus" - "k8s.io/api/apps/v1" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -19,45 +21,45 @@ func helperGetContextLogger() *log.Entry { return log.NewEntry(log.New()) } -func helperNewOperatorSourceWithEndpoint(namespace, name, endpointType string) *marketplace.OperatorSource { - return &marketplace.OperatorSource{ +func helperNewOperatorSourceWithEndpoint(namespace, name, endpointType string) *v1.OperatorSource { + return &v1.OperatorSource{ TypeMeta: metav1.TypeMeta{ APIVersion: fmt.Sprintf("%s/%s", - marketplace.SchemeGroupVersion.Group, marketplace.SchemeGroupVersion.Version), - Kind: marketplace.OperatorSourceKind, + v1.SchemeGroupVersion.Group, v1.SchemeGroupVersion.Version), + Kind: v1.OperatorSourceKind, }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: marketplace.OperatorSourceSpec{ + Spec: v1.OperatorSourceSpec{ Type: endpointType, Endpoint: "http://localhost:5000/cnr", }, } } -func helperNewOperatorSourceWithPhase(namespace, name, phase string) *marketplace.OperatorSource { - return &marketplace.OperatorSource{ +func helperNewOperatorSourceWithPhase(namespace, name, phase string) *v1.OperatorSource { + return &v1.OperatorSource{ TypeMeta: metav1.TypeMeta{ APIVersion: fmt.Sprintf("%s/%s", - marketplace.SchemeGroupVersion.Group, marketplace.SchemeGroupVersion.Version), - Kind: marketplace.OperatorSourceKind, + v1.SchemeGroupVersion.Group, v1.SchemeGroupVersion.Version), + Kind: v1.OperatorSourceKind, }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: marketplace.OperatorSourceSpec{ + Spec: v1.OperatorSourceSpec{ Type: "appregistry", Endpoint: "http://localhost:5000/cnr", }, - Status: marketplace.OperatorSourceStatus{ - CurrentPhase: marketplace.ObjectPhase{ - Phase: marketplace.Phase{ + Status: v1.OperatorSourceStatus{ + CurrentPhase: shared.ObjectPhase{ + Phase: shared.Phase{ Name: phase, }, }, @@ -65,12 +67,12 @@ func helperNewOperatorSourceWithPhase(namespace, name, phase string) *marketplac } } -func helperNewCatalogSourceConfig(namespace, name string) *marketplace.CatalogSourceConfig { - return &marketplace.CatalogSourceConfig{ +func helperNewCatalogSourceConfig(namespace, name string) *v2.CatalogSourceConfig { + return &v2.CatalogSourceConfig{ TypeMeta: metav1.TypeMeta{ APIVersion: fmt.Sprintf("%s/%s", - marketplace.SchemeGroupVersion.Group, marketplace.SchemeGroupVersion.Version), - Kind: marketplace.CatalogSourceConfigKind, + v2.SchemeGroupVersion.Group, v2.SchemeGroupVersion.Version), + Kind: v2.CatalogSourceConfigKind, }, ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -79,7 +81,7 @@ func helperNewCatalogSourceConfig(namespace, name string) *marketplace.CatalogSo } } -func helperNewCatalogSourceConfigWithLabels(namespace, name string, opsrcLabels map[string]string) *marketplace.CatalogSourceConfig { +func helperNewCatalogSourceConfigWithLabels(namespace, name string, opsrcLabels map[string]string) *v2.CatalogSourceConfig { csc := helperNewCatalogSourceConfig(namespace, name) // This is the default label that should get added to CatalogSourceConfig. @@ -102,7 +104,7 @@ func NewFakeClient() client.Client { return fake.NewFakeClientWithScheme(scheme) } -func NewFakeClientWithCSC(csc *marketplace.CatalogSourceConfig) client.Client { +func NewFakeClientWithCSC(csc *v2.CatalogSourceConfig) client.Client { objs := []runtime.Object{ csc, } @@ -113,7 +115,7 @@ func NewFakeClientWithCSC(csc *marketplace.CatalogSourceConfig) client.Client { return fake.NewFakeClientWithScheme(scheme, objs...) } -func NewFakeClientWithOpsrc(opsrc *marketplace.OperatorSource) client.Client { +func NewFakeClientWithOpsrc(opsrc *v1.OperatorSource) client.Client { scheme := runtime.NewScheme() apis.AddToScheme(scheme) @@ -124,7 +126,7 @@ func NewFakeClientWithOpsrc(opsrc *marketplace.OperatorSource) client.Client { return fake.NewFakeClientWithScheme(scheme, objs...) } -func NewFakeClientWithChildResources(deployment *v1.Deployment, service *corev1.Service, cs *v1alpha1.CatalogSource) client.Client { +func NewFakeClientWithChildResources(deployment *appsv1.Deployment, service *corev1.Service, cs *v1alpha1.CatalogSource) client.Client { objs := []runtime.Object{ deployment, } diff --git a/pkg/operatorsource/initial.go b/pkg/operatorsource/initial.go index 150806503..d621fce56 100644 --- a/pkg/operatorsource/initial.go +++ b/pkg/operatorsource/initial.go @@ -3,7 +3,8 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/phase" log "github.com/sirupsen/logrus" @@ -39,7 +40,7 @@ type initialReconciler struct { // object. If nil is returned, it implies that no phase transition is expected. // // Upon success, it returns "Validating" as the next desired phase. -func (r *initialReconciler) Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) { +func (r *initialReconciler) Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) { if in.GetCurrentPhaseName() != phase.Initial { err = phase.ErrWrongReconcilerInvoked return diff --git a/pkg/operatorsource/outofsync.go b/pkg/operatorsource/outofsync.go index 8bf40885c..e5c5b6367 100644 --- a/pkg/operatorsource/outofsync.go +++ b/pkg/operatorsource/outofsync.go @@ -3,7 +3,8 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/phase" log "github.com/sirupsen/logrus" @@ -47,7 +48,7 @@ type outOfSyncCacheReconciler struct { // // nextPhase represents the next desired phase for the given OperatorSource // object. If nil is returned, it implies that no phase transition is expected. -func (r *outOfSyncCacheReconciler) Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) { +func (r *outOfSyncCacheReconciler) Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) { out = in.DeepCopy() currentPhase := in.GetCurrentPhaseName() diff --git a/pkg/operatorsource/pollhelper.go b/pkg/operatorsource/pollhelper.go index 669385fb0..6e7b4ceba 100644 --- a/pkg/operatorsource/pollhelper.go +++ b/pkg/operatorsource/pollhelper.go @@ -4,7 +4,8 @@ import ( "context" "errors" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/appregistry" wrapper "github.com/operator-framework/operator-marketplace/pkg/client" "github.com/operator-framework/operator-marketplace/pkg/datastore" @@ -72,7 +73,7 @@ func (h *pollHelper) HasUpdate(source *datastore.OperatorSourceKey) (*datastore. } func (h *pollHelper) TriggerPurge(source *datastore.OperatorSourceKey) (deleted bool, updateErr error) { - instance := &marketplace.OperatorSource{} + instance := &v1.OperatorSource{} // Get the current state of the given object before we make any decision. if err := h.client.Get(context.TODO(), source.Name, instance); err != nil { @@ -92,7 +93,7 @@ func (h *pollHelper) TriggerPurge(source *datastore.OperatorSourceKey) (deleted instance.EnsureGVK() // We want to purge the OperatorSource object so that the cache can rebuild. - nextPhase := &marketplace.Phase{ + nextPhase := &shared.Phase{ Name: phase.OperatorSourcePurging, Message: "Remote registry has been updated", } diff --git a/pkg/operatorsource/purging.go b/pkg/operatorsource/purging.go index dbcb9e6ea..9aef87193 100644 --- a/pkg/operatorsource/purging.go +++ b/pkg/operatorsource/purging.go @@ -3,7 +3,8 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" wrapper "github.com/operator-framework/operator-marketplace/pkg/client" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/phase" @@ -54,7 +55,7 @@ type purgingReconciler struct { // field and trigger reconciliation anew from "Validating" phase. // // If the purge fails the OperatorSource object is moved to "Failed" phase. -func (r *purgingReconciler) Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) { +func (r *purgingReconciler) Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) { if in.GetCurrentPhaseName() != phase.OperatorSourcePurging { err = phase.ErrWrongReconcilerInvoked return @@ -75,7 +76,7 @@ func (r *purgingReconciler) Reconcile(ctx context.Context, in *marketplace.Opera // The reason we are not mutating current phase is because it is the // responsibility of the caller to set the new phase appropriately. tmp := out.Status.CurrentPhase - out.Status = marketplace.OperatorSourceStatus{} + out.Status = v1.OperatorSourceStatus{} out.Status.CurrentPhase = tmp nextPhase = phase.GetNext(phase.Initial) diff --git a/pkg/operatorsource/purging_test.go b/pkg/operatorsource/purging_test.go index 13f700ee2..1cb03a6df 100644 --- a/pkg/operatorsource/purging_test.go +++ b/pkg/operatorsource/purging_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" gomock "github.com/golang/mock/gomock" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" mocks "github.com/operator-framework/operator-marketplace/pkg/mocks/operatorsource_mocks" "github.com/operator-framework/operator-marketplace/pkg/operatorsource" "github.com/operator-framework/operator-marketplace/pkg/phase" @@ -25,7 +25,7 @@ func TestReconcileWithPurging(t *testing.T) { opsrcIn := helperNewOperatorSourceWithPhase("marketplace", "foo", phase.OperatorSourcePurging) opsrcWant := opsrcIn.DeepCopy() - nextPhaseWant := &marketplace.Phase{ + nextPhaseWant := &shared.Phase{ Name: phase.Initial, Message: phase.GetMessage(phase.Initial), } diff --git a/pkg/operatorsource/reconciler.go b/pkg/operatorsource/reconciler.go index 716862156..3412c2c11 100644 --- a/pkg/operatorsource/reconciler.go +++ b/pkg/operatorsource/reconciler.go @@ -3,7 +3,8 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" ) // Reconciler is the interface that wraps the Reconcile method. @@ -32,5 +33,5 @@ import ( // Reconcile operation is expected to be idempotent so that in the event of // multiple invocations there would be no adverse or side effect. type Reconciler interface { - Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) + Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) } diff --git a/pkg/operatorsource/succeeded.go b/pkg/operatorsource/succeeded.go index 0853f51cf..f5fa8dabe 100644 --- a/pkg/operatorsource/succeeded.go +++ b/pkg/operatorsource/succeeded.go @@ -3,7 +3,8 @@ package operatorsource import ( "context" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/phase" log "github.com/sirupsen/logrus" ) @@ -35,7 +36,7 @@ type succeededReconciler struct { // // nextPhase represents the next desired phase for the given OperatorSource // object. If nil is returned, it implies that no phase transition is expected. -func (r *succeededReconciler) Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) { +func (r *succeededReconciler) Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) { if in.GetCurrentPhaseName() != phase.Succeeded { err = phase.ErrWrongReconcilerInvoked return diff --git a/pkg/operatorsource/validating.go b/pkg/operatorsource/validating.go index 3b3c83187..df850d35e 100644 --- a/pkg/operatorsource/validating.go +++ b/pkg/operatorsource/validating.go @@ -5,7 +5,8 @@ import ( "fmt" "net/url" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/datastore" "github.com/operator-framework/operator-marketplace/pkg/phase" log "github.com/sirupsen/logrus" @@ -42,7 +43,7 @@ type validatingReconciler struct { // // On success, it returns "Configuring" as the next phase. // On error, it returns "Failed" as the next phase. -func (r *validatingReconciler) Reconcile(ctx context.Context, in *marketplace.OperatorSource) (out *marketplace.OperatorSource, nextPhase *marketplace.Phase, err error) { +func (r *validatingReconciler) Reconcile(ctx context.Context, in *v1.OperatorSource) (out *v1.OperatorSource, nextPhase *shared.Phase, err error) { if in.GetCurrentPhaseName() != phase.OperatorSourceValidating { err = phase.ErrWrongReconcilerInvoked return diff --git a/pkg/phase/phase.go b/pkg/phase/phase.go index 7badfcf6a..ecffaa98b 100644 --- a/pkg/phase/phase.go +++ b/pkg/phase/phase.go @@ -3,7 +3,7 @@ package phase import ( "errors" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" ) // The following list is the set of phases a Marketplace object can be in while @@ -69,11 +69,11 @@ func GetMessage(phaseName string) string { } // GetNext returns a Phase object with the given phase name and default message -func GetNext(name string) *marketplace.Phase { - return marketplace.NewPhase(name, GetMessage(name)) +func GetNext(name string) *shared.Phase { + return shared.NewPhase(name, GetMessage(name)) } // GetNextWithMessage returns a Phase object with the given phase name and default message -func GetNextWithMessage(name string, message string) *marketplace.Phase { - return marketplace.NewPhase(name, message) +func GetNextWithMessage(name string, message string) *shared.Phase { + return shared.NewPhase(name, message) } diff --git a/pkg/phase/transitioner.go b/pkg/phase/transitioner.go index 1c773c8c2..35c1e733b 100644 --- a/pkg/phase/transitioner.go +++ b/pkg/phase/transitioner.go @@ -1,7 +1,7 @@ package phase import ( - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/clock" ) @@ -29,7 +29,7 @@ func NewTransitioner() Transitioner { // no transition took place. If a new phase is being set then LastTransitionTime // is set appropriately, otherwise it is left untouched. type Transitioner interface { - TransitionInto(currentPhase *marketplace.ObjectPhase, nextPhase *marketplace.Phase) (changed bool) + TransitionInto(currentPhase *shared.ObjectPhase, nextPhase *shared.Phase) (changed bool) } // transitioner implements Transitioner interface. @@ -37,7 +37,7 @@ type transitioner struct { clock clock.Clock } -func (t *transitioner) TransitionInto(currentPhase *marketplace.ObjectPhase, nextPhase *marketplace.Phase) (changed bool) { +func (t *transitioner) TransitionInto(currentPhase *shared.ObjectPhase, nextPhase *shared.Phase) (changed bool) { if currentPhase == nil || nextPhase == nil { return false } @@ -63,7 +63,7 @@ func (t *transitioner) TransitionInto(currentPhase *marketplace.ObjectPhase, nex // // If both Phase and Message are equal, the function will return false // indicating no change. Otherwise, the function will return true. -func hasPhaseChanged(currentPhase *marketplace.ObjectPhase, nextPhase *marketplace.Phase) bool { +func hasPhaseChanged(currentPhase *shared.ObjectPhase, nextPhase *shared.Phase) bool { if currentPhase.Name == nextPhase.Name && currentPhase.Message == nextPhase.Message { return false } diff --git a/pkg/phase/transitioner_test.go b/pkg/phase/transitioner_test.go index a6c1ffcbb..bc1f2243f 100644 --- a/pkg/phase/transitioner_test.go +++ b/pkg/phase/transitioner_test.go @@ -6,18 +6,19 @@ import ( "github.com/stretchr/testify/assert" - marketplace "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/shared" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" "github.com/operator-framework/operator-marketplace/pkg/phase" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/clock" ) var ( - phaseWantValidating = marketplace.Phase{ + phaseWantValidating = shared.Phase{ Name: "Validating", Message: "Scheduled for validation", } - nextPhaseAfterValidating = &marketplace.Phase{ + nextPhaseAfterValidating = &shared.Phase{ Name: phaseWantValidating.Name, Message: phaseWantValidating.Message, } @@ -30,9 +31,9 @@ func TestTransitionInto_IdenticalPhase_FalseExpected(t *testing.T) { clock := clock.NewFakeClock(time.Now()) transitioner := phase.NewTransitionerWithClock(clock) - opsrcIn := &marketplace.OperatorSource{ - Status: marketplace.OperatorSourceStatus{ - CurrentPhase: marketplace.ObjectPhase{ + opsrcIn := &v1.OperatorSource{ + Status: v1.OperatorSourceStatus{ + CurrentPhase: shared.ObjectPhase{ Phase: phaseWantValidating, }, }, @@ -54,10 +55,10 @@ func TestTransitionInto_BothPhaseAndMessageAreDifferent_TrueExpected(t *testing. clock := clock.NewFakeClock(now) transitioner := phase.NewTransitionerWithClock(clock) - opsrcIn := &marketplace.OperatorSource{ - Status: marketplace.OperatorSourceStatus{ - CurrentPhase: marketplace.ObjectPhase{ - Phase: marketplace.Phase{ + opsrcIn := &v1.OperatorSource{ + Status: v1.OperatorSourceStatus{ + CurrentPhase: shared.ObjectPhase{ + Phase: shared.Phase{ Name: "Initial", Message: "Not validated", }, @@ -82,15 +83,15 @@ func TestTransitionInto_MessageIsDifferent_TrueExpected(t *testing.T) { clock := clock.NewFakeClock(now) transitioner := phase.NewTransitionerWithClock(clock) - phaseWant := marketplace.Phase{ + phaseWant := shared.Phase{ Name: "Failed", Message: "Second try- reason 2", } - opsrcIn := &marketplace.OperatorSource{ - Status: marketplace.OperatorSourceStatus{ - CurrentPhase: marketplace.ObjectPhase{ - Phase: marketplace.Phase{ + opsrcIn := &v1.OperatorSource{ + Status: v1.OperatorSourceStatus{ + CurrentPhase: shared.ObjectPhase{ + Phase: shared.Phase{ Name: phaseWant.Name, Message: "First try- reason 1", }, @@ -98,7 +99,7 @@ func TestTransitionInto_MessageIsDifferent_TrueExpected(t *testing.T) { }, } - nextPhase := &marketplace.Phase{ + nextPhase := &shared.Phase{ Name: phaseWant.Name, Message: phaseWant.Message, } diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index d84a790e8..8e919b2d1 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -5,7 +5,7 @@ import ( "strconv" "time" - "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v1" + "github.com/operator-framework/operator-marketplace/pkg/apis/operators/v2" "github.com/operator-framework/operator-marketplace/pkg/builders" wrapper "github.com/operator-framework/operator-marketplace/pkg/client" "github.com/operator-framework/operator-marketplace/pkg/datastore" @@ -248,7 +248,7 @@ func (r *registry) getLabel() map[string]string { // |