diff --git a/README.md b/README.md index 673bcd59..6f0ee6ff 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ $ kind create cluster $ kubectl apply -f https://github.com/operator-framework/catalogd/config/crd/bases/ $ kubectl apply -f https://github.com/operator-framework/catalogd/config/ $ kubectl create ns test -$ kubectl apply -f config/samples/core_v1beta1_catalog.yaml +$ kubectl apply -f config/samples/core_v1alpha1_catalog.yaml $ kubectl get catalog -n test NAME AGE @@ -111,5 +111,5 @@ kubectl apply -f config/ ``` - Create the sample Catalog (this will trigger the reconciliation loop): ```sh -kubectl apply -f config/samples/core_v1beta1_catalog.yaml +kubectl apply -f config/samples/core_v1alpha1_catalog.yaml ``` diff --git a/pkg/apis/core/doc.go b/api/core/doc.go similarity index 100% rename from pkg/apis/core/doc.go rename to api/core/doc.go diff --git a/pkg/apis/core/v1beta1/bundlemetadata_types.go b/api/core/v1alpha1/bundlemetadata_types.go similarity index 99% rename from pkg/apis/core/v1beta1/bundlemetadata_types.go rename to api/core/v1alpha1/bundlemetadata_types.go index 4d410396..7af4908b 100644 --- a/pkg/apis/core/v1beta1/bundlemetadata_types.go +++ b/api/core/v1alpha1/bundlemetadata_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "encoding/json" diff --git a/pkg/apis/core/v1beta1/catalog_types.go b/api/core/v1alpha1/catalog_types.go similarity index 99% rename from pkg/apis/core/v1beta1/catalog_types.go rename to api/core/v1alpha1/catalog_types.go index 4a710650..c3f77526 100644 --- a/pkg/apis/core/v1beta1/catalog_types.go +++ b/api/core/v1alpha1/catalog_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apis/core/v1beta1/groupversion_info.go b/api/core/v1alpha1/groupversion_info.go similarity index 89% rename from pkg/apis/core/v1beta1/groupversion_info.go rename to api/core/v1alpha1/groupversion_info.go index 3546d26c..fe52555e 100644 --- a/pkg/apis/core/v1beta1/groupversion_info.go +++ b/api/core/v1alpha1/groupversion_info.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1beta1 contains API Schema definitions for the core v1alpha1 API group +// Package v1alpha1 contains API Schema definitions for the core v1alpha1 API group // +kubebuilder:object:generate=true // +groupName=catalogd.operatorframework.io -package v1beta1 +package v1alpha1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "catalogd.operatorframework.io", Version: "v1beta1"} + GroupVersion = schema.GroupVersion{Group: "catalogd.operatorframework.io", Version: "v1alpha1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/pkg/apis/core/v1beta1/package_types.go b/api/core/v1alpha1/package_types.go similarity index 99% rename from pkg/apis/core/v1beta1/package_types.go rename to api/core/v1alpha1/package_types.go index 89373065..236eac3c 100644 --- a/pkg/apis/core/v1beta1/package_types.go +++ b/api/core/v1alpha1/package_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( corev1 "k8s.io/api/core/v1" diff --git a/pkg/apis/core/v1beta1/zz_generated.deepcopy.go b/api/core/v1alpha1/zz_generated.deepcopy.go similarity index 99% rename from pkg/apis/core/v1beta1/zz_generated.deepcopy.go rename to api/core/v1alpha1/zz_generated.deepcopy.go index a2f1c22e..6900ef62 100644 --- a/pkg/apis/core/v1beta1/zz_generated.deepcopy.go +++ b/api/core/v1alpha1/zz_generated.deepcopy.go @@ -19,7 +19,7 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 import ( "encoding/json" diff --git a/pkg/apis/doc.go b/api/doc.go similarity index 98% rename from pkg/apis/doc.go rename to api/doc.go index 3b7ad4cd..2e2c18a5 100644 --- a/pkg/apis/doc.go +++ b/api/doc.go @@ -19,4 +19,4 @@ limitations under the License. // // +domain=operatorframework.io -package apis +package api diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 9df47ce5..89556c07 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -34,10 +34,10 @@ import ( "github.com/operator-framework/catalogd/internal/source" "github.com/operator-framework/catalogd/internal/version" - "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1" corecontrollers "github.com/operator-framework/catalogd/pkg/controllers/core" "github.com/operator-framework/catalogd/pkg/profile" //+kubebuilder:scaffold:imports + "github.com/operator-framework/catalogd/api/core/v1alpha1" ) var ( @@ -48,7 +48,7 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(v1beta1.AddToScheme(scheme)) + utilruntime.Must(v1alpha1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } diff --git a/config/crd/bases/catalogd.operatorframework.io_bundlemetadata.yaml b/config/crd/bases/catalogd.operatorframework.io_bundlemetadata.yaml index 694c95b5..21b89a5c 100644 --- a/config/crd/bases/catalogd.operatorframework.io_bundlemetadata.yaml +++ b/config/crd/bases/catalogd.operatorframework.io_bundlemetadata.yaml @@ -14,7 +14,7 @@ spec: singular: bundlemetadata scope: Cluster versions: - - name: v1beta1 + - name: v1alpha1 schema: openAPIV3Schema: description: BundleMetadata is the Schema for the bundlemetadata API diff --git a/config/crd/bases/catalogd.operatorframework.io_catalogs.yaml b/config/crd/bases/catalogd.operatorframework.io_catalogs.yaml index 48fe4c1c..0aa61315 100644 --- a/config/crd/bases/catalogd.operatorframework.io_catalogs.yaml +++ b/config/crd/bases/catalogd.operatorframework.io_catalogs.yaml @@ -14,7 +14,7 @@ spec: singular: catalog scope: Cluster versions: - - name: v1beta1 + - name: v1alpha1 schema: openAPIV3Schema: description: Catalog is the Schema for the Catalogs API diff --git a/config/crd/bases/catalogd.operatorframework.io_packages.yaml b/config/crd/bases/catalogd.operatorframework.io_packages.yaml index aa1d49ed..c0b47cd6 100644 --- a/config/crd/bases/catalogd.operatorframework.io_packages.yaml +++ b/config/crd/bases/catalogd.operatorframework.io_packages.yaml @@ -14,7 +14,7 @@ spec: singular: package scope: Cluster versions: - - name: v1beta1 + - name: v1alpha1 schema: openAPIV3Schema: description: Package is the Schema for the packages API diff --git a/config/samples/core_v1alpha1_catalog.yaml b/config/samples/core_v1alpha1_catalog.yaml new file mode 100644 index 00000000..1895a90a --- /dev/null +++ b/config/samples/core_v1alpha1_catalog.yaml @@ -0,0 +1,9 @@ +apiVersion: catalogd.operatorframework.io/v1alpha1 +kind: Catalog +metadata: + name: operatorhubio +spec: + source: + type: image + image: + ref: quay.io/operatorhubio/catalog:latest diff --git a/config/samples/core_v1beta1_catalog.yaml b/config/samples/core_v1beta1_catalog.yaml deleted file mode 100644 index 400c14be..00000000 --- a/config/samples/core_v1beta1_catalog.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: catalogd.operatorframework.io/v1beta1 -kind: Catalog -metadata: - name: operatorhubio -spec: - source: - type: image - image: - ref: quay.io/operatorhubio/catalog:latest \ No newline at end of file diff --git a/hack/scripts/generate-asciidemo.sh b/hack/scripts/generate-asciidemo.sh index 46d6b2ed..56ae6ad0 100755 --- a/hack/scripts/generate-asciidemo.sh +++ b/hack/scripts/generate-asciidemo.sh @@ -28,7 +28,7 @@ function run() { typeline 'kubectl get crds -A' typeline -x "# create a catalog" - typeline "kubectl apply -f config/samples/core_v1beta1_catalog.yaml" # or other + typeline "kubectl apply -f config/samples/core_v1alpha1_catalog.yaml" # or other typeline "kubectl get catalog -A" # shows catalog-sample typeline -x "# waiting for catalog to report ready status" typeline "kubectl wait --for=condition=Ready catalog/catalog-sample --timeout=1h" @@ -43,4 +43,3 @@ function run() { } run - diff --git a/internal/source/image.go b/internal/source/image.go index 7ef2e027..fd9701c8 100644 --- a/internal/source/image.go +++ b/internal/source/image.go @@ -21,7 +21,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - catalogdv1beta1 "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1" + catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1" ) type Image struct { @@ -33,9 +33,9 @@ type Image struct { const imageCatalogUnpackContainerName = "catalog" -func (i *Image) Unpack(ctx context.Context, catalog *catalogdv1beta1.Catalog) (*Result, error) { - if catalog.Spec.Source.Type != catalogdv1beta1.SourceTypeImage { - panic(fmt.Sprintf("source type %q is unable to handle specified catalog source type %q", catalogdv1beta1.SourceTypeImage, catalog.Spec.Source.Type)) +func (i *Image) Unpack(ctx context.Context, catalog *catalogdv1alpha1.Catalog) (*Result, error) { + if catalog.Spec.Source.Type != catalogdv1alpha1.SourceTypeImage { + panic(fmt.Sprintf("source type %q is unable to handle specified catalog source type %q", catalogdv1alpha1.SourceTypeImage, catalog.Spec.Source.Type)) } if catalog.Spec.Source.Image == nil { return nil, fmt.Errorf("catalog source image configuration is unset") @@ -63,7 +63,7 @@ func (i *Image) Unpack(ctx context.Context, catalog *catalogdv1beta1.Catalog) (* } } -func (i *Image) ensureUnpackPod(ctx context.Context, catalog *catalogdv1beta1.Catalog, pod *corev1.Pod) (controllerutil.OperationResult, error) { +func (i *Image) ensureUnpackPod(ctx context.Context, catalog *catalogdv1alpha1.Catalog, pod *corev1.Pod) (controllerutil.OperationResult, error) { existingPod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: i.PodNamespace, Name: catalog.Name}} if err := i.Client.Get(ctx, client.ObjectKeyFromObject(existingPod), existingPod); client.IgnoreNotFound(err) != nil { return controllerutil.OperationResultNone, err @@ -98,7 +98,7 @@ func (i *Image) ensureUnpackPod(ctx context.Context, catalog *catalogdv1beta1.Ca return controllerutil.OperationResultUpdated, nil } -func (i *Image) getDesiredPodApplyConfig(catalog *catalogdv1beta1.Catalog) *applyconfigurationcorev1.PodApplyConfiguration { +func (i *Image) getDesiredPodApplyConfig(catalog *catalogdv1alpha1.Catalog) *applyconfigurationcorev1.PodApplyConfiguration { // TODO: Address unpacker pod allowing root users for image sources // // In our current implementation, we are creating a pod that uses the image @@ -202,9 +202,9 @@ func (i *Image) succeededPodResult(ctx context.Context, pod *corev1.Pod) (*Resul return nil, fmt.Errorf("get catalog image digest: %v", err) } - resolvedSource := &catalogdv1beta1.CatalogSource{ - Type: catalogdv1beta1.SourceTypeImage, - Image: &catalogdv1beta1.ImageSource{Ref: digest}, + resolvedSource := &catalogdv1alpha1.CatalogSource{ + Type: catalogdv1alpha1.SourceTypeImage, + Image: &catalogdv1alpha1.ImageSource{Ref: digest}, } message := fmt.Sprintf("successfully unpacked the catalog image %q", digest) diff --git a/internal/source/unpacker.go b/internal/source/unpacker.go index 8c7c329e..cef68563 100644 --- a/internal/source/unpacker.go +++ b/internal/source/unpacker.go @@ -8,7 +8,7 @@ import ( "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/cluster" - catalogdv1beta1 "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1" + catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1" ) // TODO: This package is almost entirely copy/pasted from rukpak. We should look @@ -32,7 +32,7 @@ import ( // specifications. A source should treat a catalog root directory as an opaque // file tree and delegate catalog format concerns to catalog parsers. type Unpacker interface { - Unpack(context.Context, *catalogdv1beta1.Catalog) (*Result, error) + Unpack(context.Context, *catalogdv1alpha1.Catalog) (*Result, error) } // Result conveys progress information about unpacking catalog content. @@ -49,7 +49,7 @@ type Result struct { // For example, resolved image sources should reference a container image // digest rather than an image tag, and git sources should reference a // commit hash rather than a branch or tag. - ResolvedSource *catalogdv1beta1.CatalogSource + ResolvedSource *catalogdv1alpha1.CatalogSource // State is the current state of unpacking the catalog content. State State @@ -76,16 +76,16 @@ const ( ) type unpacker struct { - sources map[catalogdv1beta1.SourceType]Unpacker + sources map[catalogdv1alpha1.SourceType]Unpacker } // NewUnpacker returns a new composite Source that unpacks catalogs using the source // mapping provided by the configured sources. -func NewUnpacker(sources map[catalogdv1beta1.SourceType]Unpacker) Unpacker { +func NewUnpacker(sources map[catalogdv1alpha1.SourceType]Unpacker) Unpacker { return &unpacker{sources: sources} } -func (s *unpacker) Unpack(ctx context.Context, catalog *catalogdv1beta1.Catalog) (*Result, error) { +func (s *unpacker) Unpack(ctx context.Context, catalog *catalogdv1alpha1.Catalog) (*Result, error) { source, ok := s.sources[catalog.Spec.Source.Type] if !ok { return nil, fmt.Errorf("source type %q not supported", catalog.Spec.Source.Type) @@ -104,8 +104,8 @@ func NewDefaultUnpacker(systemNsCluster cluster.Cluster, namespace, unpackImage if err != nil { return nil, err } - return NewUnpacker(map[catalogdv1beta1.SourceType]Unpacker{ - catalogdv1beta1.SourceTypeImage: &Image{ + return NewUnpacker(map[catalogdv1alpha1.SourceType]Unpacker{ + catalogdv1alpha1.SourceTypeImage: &Image{ Client: systemNsCluster.GetClient(), KubeClient: kubeClient, PodNamespace: namespace, diff --git a/pkg/controllers/core/catalog_controller.go b/pkg/controllers/core/catalog_controller.go index 984b929f..2474a4b2 100644 --- a/pkg/controllers/core/catalog_controller.go +++ b/pkg/controllers/core/catalog_controller.go @@ -34,8 +34,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/predicate" + "github.com/operator-framework/catalogd/api/core/v1alpha1" "github.com/operator-framework/catalogd/internal/source" - corev1beta1 "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1" ) // TODO (everettraven): Add unit tests for the CatalogReconciler @@ -67,7 +67,7 @@ func (r *CatalogReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct // TODO: Where and when should we be logging errors and at which level? _ = log.FromContext(ctx).WithName("catalogd-controller") - existingCatsrc := corev1beta1.Catalog{} + existingCatsrc := v1alpha1.Catalog{} if err := r.Client.Get(ctx, req.NamespacedName, &existingCatsrc); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } @@ -86,7 +86,7 @@ func (r *CatalogReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct return res, apimacherrors.NewAggregate([]error{reconcileErr, updateErr}) } } - existingCatsrc.Status, reconciledCatsrc.Status = corev1beta1.CatalogStatus{}, corev1beta1.CatalogStatus{} + existingCatsrc.Status, reconciledCatsrc.Status = v1alpha1.CatalogStatus{}, v1alpha1.CatalogStatus{} if !equality.Semantic.DeepEqual(existingCatsrc, reconciledCatsrc) { if updateErr := r.Client.Update(ctx, reconciledCatsrc); updateErr != nil { return res, apimacherrors.NewAggregate([]error{reconcileErr, updateErr}) @@ -105,12 +105,12 @@ func (r *CatalogReconciler) SetupWithManager(mgr ctrl.Manager) error { // even though they already exist. This should be resolved by the fix // for https://github.com/operator-framework/catalogd/issues/6. The fix for // #6 should also remove the usage of `builder.WithPredicates(predicate.GenerationChangedPredicate{})` - For(&corev1beta1.Catalog{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + For(&v1alpha1.Catalog{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Owns(&corev1.Pod{}). Complete(r) } -func (r *CatalogReconciler) reconcile(ctx context.Context, catalog *corev1beta1.Catalog) (ctrl.Result, error) { +func (r *CatalogReconciler) reconcile(ctx context.Context, catalog *v1alpha1.Catalog) (ctrl.Result, error) { unpackResult, err := r.Unpacker.Unpack(ctx, catalog) if err != nil { return ctrl.Result{}, updateStatusUnpackFailing(&catalog.Status, fmt.Errorf("source bundle content: %v", err)) @@ -149,46 +149,46 @@ func (r *CatalogReconciler) reconcile(ctx context.Context, catalog *corev1beta1. } -func updateStatusUnpackPending(status *corev1beta1.CatalogStatus, result *source.Result) { +func updateStatusUnpackPending(status *v1alpha1.CatalogStatus, result *source.Result) { status.ResolvedSource = nil - status.Phase = corev1beta1.PhasePending + status.Phase = v1alpha1.PhasePending meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: corev1beta1.TypeUnpacked, + Type: v1alpha1.TypeUnpacked, Status: metav1.ConditionFalse, - Reason: corev1beta1.ReasonUnpackPending, + Reason: v1alpha1.ReasonUnpackPending, Message: result.Message, }) } -func updateStatusUnpacking(status *corev1beta1.CatalogStatus, result *source.Result) { +func updateStatusUnpacking(status *v1alpha1.CatalogStatus, result *source.Result) { status.ResolvedSource = nil - status.Phase = corev1beta1.PhaseUnpacking + status.Phase = v1alpha1.PhaseUnpacking meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: corev1beta1.TypeUnpacked, + Type: v1alpha1.TypeUnpacked, Status: metav1.ConditionFalse, - Reason: corev1beta1.ReasonUnpacking, + Reason: v1alpha1.ReasonUnpacking, Message: result.Message, }) } -func updateStatusUnpacked(status *corev1beta1.CatalogStatus, result *source.Result) { +func updateStatusUnpacked(status *v1alpha1.CatalogStatus, result *source.Result) { status.ResolvedSource = result.ResolvedSource - status.Phase = corev1beta1.PhaseUnpacked + status.Phase = v1alpha1.PhaseUnpacked meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: corev1beta1.TypeUnpacked, + Type: v1alpha1.TypeUnpacked, Status: metav1.ConditionTrue, - Reason: corev1beta1.ReasonUnpackSuccessful, + Reason: v1alpha1.ReasonUnpackSuccessful, Message: result.Message, }) } -func updateStatusUnpackFailing(status *corev1beta1.CatalogStatus, err error) error { +func updateStatusUnpackFailing(status *v1alpha1.CatalogStatus, err error) error { status.ResolvedSource = nil - status.Phase = corev1beta1.PhaseFailing + status.Phase = v1alpha1.PhaseFailing meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: corev1beta1.TypeUnpacked, + Type: v1alpha1.TypeUnpacked, Status: metav1.ConditionFalse, - Reason: corev1beta1.ReasonUnpackFailed, + Reason: v1alpha1.ReasonUnpackFailed, Message: err.Error(), }) return err @@ -197,15 +197,15 @@ func updateStatusUnpackFailing(status *corev1beta1.CatalogStatus, err error) err // syncBundleMetadata will create a `BundleMetadata` resource for each // "olm.bundle" object that exists for the given catalog contents. Returns an // error if any are encountered. -func (r *CatalogReconciler) syncBundleMetadata(ctx context.Context, declCfg *declcfg.DeclarativeConfig, catalog *corev1beta1.Catalog) error { - newBundles := map[string]*corev1beta1.BundleMetadata{} +func (r *CatalogReconciler) syncBundleMetadata(ctx context.Context, declCfg *declcfg.DeclarativeConfig, catalog *v1alpha1.Catalog) error { + newBundles := map[string]*v1alpha1.BundleMetadata{} for _, bundle := range declCfg.Bundles { bundleName := fmt.Sprintf("%s-%s", catalog.Name, bundle.Name) - bundleMeta := corev1beta1.BundleMetadata{ + bundleMeta := v1alpha1.BundleMetadata{ TypeMeta: metav1.TypeMeta{ - APIVersion: corev1beta1.GroupVersion.String(), + APIVersion: v1alpha1.GroupVersion.String(), Kind: "BundleMetadata", }, ObjectMeta: metav1.ObjectMeta{ @@ -214,7 +214,7 @@ func (r *CatalogReconciler) syncBundleMetadata(ctx context.Context, declCfg *dec "catalog": catalog.Name, }, OwnerReferences: []metav1.OwnerReference{{ - APIVersion: corev1beta1.GroupVersion.String(), + APIVersion: v1alpha1.GroupVersion.String(), Kind: "Catalog", Name: catalog.Name, UID: catalog.UID, @@ -222,7 +222,7 @@ func (r *CatalogReconciler) syncBundleMetadata(ctx context.Context, declCfg *dec Controller: pointer.Bool(true), }}, }, - Spec: corev1beta1.BundleMetadataSpec{ + Spec: v1alpha1.BundleMetadataSpec{ Catalog: corev1.LocalObjectReference{Name: catalog.Name}, Package: bundle.Package, Image: bundle.Image, @@ -230,7 +230,7 @@ func (r *CatalogReconciler) syncBundleMetadata(ctx context.Context, declCfg *dec } for _, relatedImage := range bundle.RelatedImages { - bundleMeta.Spec.RelatedImages = append(bundleMeta.Spec.RelatedImages, corev1beta1.RelatedImage{ + bundleMeta.Spec.RelatedImages = append(bundleMeta.Spec.RelatedImages, v1alpha1.RelatedImage{ Name: relatedImage.Name, Image: relatedImage.Image, }) @@ -242,7 +242,7 @@ func (r *CatalogReconciler) syncBundleMetadata(ctx context.Context, declCfg *dec continue } - bundleMeta.Spec.Properties = append(bundleMeta.Spec.Properties, corev1beta1.Property{ + bundleMeta.Spec.Properties = append(bundleMeta.Spec.Properties, v1alpha1.Property{ Type: prop.Type, Value: prop.Value, }) @@ -250,7 +250,7 @@ func (r *CatalogReconciler) syncBundleMetadata(ctx context.Context, declCfg *dec newBundles[bundleName] = &bundleMeta } - var existingBundles corev1beta1.BundleMetadataList + var existingBundles v1alpha1.BundleMetadataList if err := r.List(ctx, &existingBundles); err != nil { return fmt.Errorf("list existing bundle metadatas: %v", err) } @@ -276,21 +276,21 @@ func (r *CatalogReconciler) syncBundleMetadata(ctx context.Context, declCfg *dec // "olm.package" object that exists for the given catalog contents. // `Package.Spec.Channels` is populated by filtering all "olm.channel" objects // where the "packageName" == `Package.Name`. Returns an error if any are encountered. -func (r *CatalogReconciler) syncPackages(ctx context.Context, declCfg *declcfg.DeclarativeConfig, catalog *corev1beta1.Catalog) error { - newPkgs := map[string]*corev1beta1.Package{} +func (r *CatalogReconciler) syncPackages(ctx context.Context, declCfg *declcfg.DeclarativeConfig, catalog *v1alpha1.Catalog) error { + newPkgs := map[string]*v1alpha1.Package{} for _, pkg := range declCfg.Packages { name := fmt.Sprintf("%s-%s", catalog.Name, pkg.Name) - var icon *corev1beta1.Icon + var icon *v1alpha1.Icon if pkg.Icon != nil { - icon = &corev1beta1.Icon{ + icon = &v1alpha1.Icon{ Data: pkg.Icon.Data, MediaType: pkg.Icon.MediaType, } } - newPkgs[name] = &corev1beta1.Package{ + newPkgs[name] = &v1alpha1.Package{ TypeMeta: metav1.TypeMeta{ - APIVersion: corev1beta1.GroupVersion.String(), + APIVersion: v1alpha1.GroupVersion.String(), Kind: "Package", }, ObjectMeta: metav1.ObjectMeta{ @@ -299,7 +299,7 @@ func (r *CatalogReconciler) syncPackages(ctx context.Context, declCfg *declcfg.D "catalog": catalog.Name, }, OwnerReferences: []metav1.OwnerReference{{ - APIVersion: corev1beta1.GroupVersion.String(), + APIVersion: v1alpha1.GroupVersion.String(), Kind: "Catalog", Name: catalog.Name, UID: catalog.UID, @@ -307,13 +307,13 @@ func (r *CatalogReconciler) syncPackages(ctx context.Context, declCfg *declcfg.D Controller: pointer.Bool(true), }}, }, - Spec: corev1beta1.PackageSpec{ + Spec: v1alpha1.PackageSpec{ Catalog: corev1.LocalObjectReference{Name: catalog.Name}, Name: pkg.Name, DefaultChannel: pkg.DefaultChannel, Description: pkg.Description, Icon: icon, - Channels: []corev1beta1.PackageChannel{}, + Channels: []v1alpha1.PackageChannel{}, }, } } @@ -324,9 +324,9 @@ func (r *CatalogReconciler) syncPackages(ctx context.Context, declCfg *declcfg.D if !ok { return fmt.Errorf("channel %q references package %q which does not exist", ch.Name, ch.Package) } - pkgChannel := corev1beta1.PackageChannel{Name: ch.Name} + pkgChannel := v1alpha1.PackageChannel{Name: ch.Name} for _, entry := range ch.Entries { - pkgChannel.Entries = append(pkgChannel.Entries, corev1beta1.ChannelEntry{ + pkgChannel.Entries = append(pkgChannel.Entries, v1alpha1.ChannelEntry{ Name: entry.Name, Replaces: entry.Replaces, Skips: entry.Skips, @@ -336,7 +336,7 @@ func (r *CatalogReconciler) syncPackages(ctx context.Context, declCfg *declcfg.D pkg.Spec.Channels = append(pkg.Spec.Channels, pkgChannel) } - var existingPkgs corev1beta1.PackageList + var existingPkgs v1alpha1.PackageList if err := r.List(ctx, &existingPkgs); err != nil { return fmt.Errorf("list existing packages: %v", err) } diff --git a/pkg/controllers/core/catalog_controller_test.go b/pkg/controllers/core/catalog_controller_test.go index 9774f014..c38a2b5f 100644 --- a/pkg/controllers/core/catalog_controller_test.go +++ b/pkg/controllers/core/catalog_controller_test.go @@ -16,8 +16,8 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/operator-framework/catalogd/api/core/v1alpha1" "github.com/operator-framework/catalogd/internal/source" - catalogdv1beta1 "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1" "github.com/operator-framework/catalogd/pkg/controllers/core" ) @@ -32,7 +32,7 @@ type MockSource struct { shouldError bool } -func (ms *MockSource) Unpack(ctx context.Context, catalog *catalogdv1beta1.Catalog) (*source.Result, error) { +func (ms *MockSource) Unpack(ctx context.Context, catalog *v1alpha1.Catalog) (*source.Result, error) { if ms.shouldError { return nil, errors.New("mocksource error") } @@ -52,8 +52,8 @@ var _ = Describe("Catalogd Controller Test", func() { reconciler = &core.CatalogReconciler{ Client: cl, Unpacker: source.NewUnpacker( - map[catalogdv1beta1.SourceType]source.Unpacker{ - catalogdv1beta1.SourceTypeImage: mockSource, + map[v1alpha1.SourceType]source.Unpacker{ + v1alpha1.SourceTypeImage: mockSource, }, ), } @@ -82,7 +82,7 @@ var _ = Describe("Catalogd Controller Test", func() { When("the catalog exists", func() { var ( - catalog *catalogdv1beta1.Catalog + catalog *v1alpha1.Catalog cKey types.NamespacedName ) BeforeEach(func() { @@ -92,10 +92,10 @@ var _ = Describe("Catalogd Controller Test", func() { When("the catalog specifies an invalid source", func() { BeforeEach(func() { By("initializing cluster state") - catalog = &catalogdv1beta1.Catalog{ + catalog = &v1alpha1.Catalog{ ObjectMeta: metav1.ObjectMeta{Name: cKey.Name}, - Spec: catalogdv1beta1.CatalogSpec{ - Source: catalogdv1beta1.CatalogSource{ + Spec: v1alpha1.CatalogSpec{ + Source: v1alpha1.CatalogSource{ Type: "invalid-source", }, }, @@ -114,13 +114,13 @@ var _ = Describe("Catalogd Controller Test", func() { Expect(err).To(HaveOccurred()) // get the catalog and ensure status is set properly - cat := &catalogdv1beta1.Catalog{} + cat := &v1alpha1.Catalog{} Expect(cl.Get(ctx, cKey, cat)).To(Succeed()) Expect(cat.Status.ResolvedSource).To(BeNil()) - Expect(cat.Status.Phase).To(Equal(catalogdv1beta1.PhaseFailing)) - cond := meta.FindStatusCondition(cat.Status.Conditions, catalogdv1beta1.TypeUnpacked) + Expect(cat.Status.Phase).To(Equal(v1alpha1.PhaseFailing)) + cond := meta.FindStatusCondition(cat.Status.Conditions, v1alpha1.TypeUnpacked) Expect(cond).ToNot(BeNil()) - Expect(cond.Reason).To(Equal(catalogdv1beta1.ReasonUnpackFailed)) + Expect(cond.Reason).To(Equal(v1alpha1.ReasonUnpackFailed)) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) }) }) @@ -128,12 +128,12 @@ var _ = Describe("Catalogd Controller Test", func() { When("the catalog specifies a valid source", func() { BeforeEach(func() { By("initializing cluster state") - catalog = &catalogdv1beta1.Catalog{ + catalog = &v1alpha1.Catalog{ ObjectMeta: metav1.ObjectMeta{Name: cKey.Name}, - Spec: catalogdv1beta1.CatalogSpec{ - Source: catalogdv1beta1.CatalogSource{ + Spec: v1alpha1.CatalogSpec{ + Source: v1alpha1.CatalogSource{ Type: "image", - Image: &catalogdv1beta1.ImageSource{ + Image: &v1alpha1.ImageSource{ Ref: "somecatalog:latest", }, }, @@ -159,13 +159,13 @@ var _ = Describe("Catalogd Controller Test", func() { Expect(err).ToNot(HaveOccurred()) // get the catalog and ensure status is set properly - cat := &catalogdv1beta1.Catalog{} + cat := &v1alpha1.Catalog{} Expect(cl.Get(ctx, cKey, cat)).To(Succeed()) Expect(cat.Status.ResolvedSource).To(BeNil()) - Expect(cat.Status.Phase).To(Equal(catalogdv1beta1.PhasePending)) - cond := meta.FindStatusCondition(cat.Status.Conditions, catalogdv1beta1.TypeUnpacked) + Expect(cat.Status.Phase).To(Equal(v1alpha1.PhasePending)) + cond := meta.FindStatusCondition(cat.Status.Conditions, v1alpha1.TypeUnpacked) Expect(cond).ToNot(BeNil()) - Expect(cond.Reason).To(Equal(catalogdv1beta1.ReasonUnpackPending)) + Expect(cond.Reason).To(Equal(v1alpha1.ReasonUnpackPending)) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) }) }) @@ -182,13 +182,13 @@ var _ = Describe("Catalogd Controller Test", func() { Expect(err).ToNot(HaveOccurred()) // get the catalog and ensure status is set properly - cat := &catalogdv1beta1.Catalog{} + cat := &v1alpha1.Catalog{} Expect(cl.Get(ctx, cKey, cat)).To(Succeed()) Expect(cat.Status.ResolvedSource).To(BeNil()) - Expect(cat.Status.Phase).To(Equal(catalogdv1beta1.PhaseUnpacking)) - cond := meta.FindStatusCondition(cat.Status.Conditions, catalogdv1beta1.TypeUnpacked) + Expect(cat.Status.Phase).To(Equal(v1alpha1.PhaseUnpacking)) + cond := meta.FindStatusCondition(cat.Status.Conditions, v1alpha1.TypeUnpacked) Expect(cond).ToNot(BeNil()) - Expect(cond.Reason).To(Equal(catalogdv1beta1.ReasonUnpacking)) + Expect(cond.Reason).To(Equal(v1alpha1.ReasonUnpacking)) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) }) }) @@ -205,13 +205,13 @@ var _ = Describe("Catalogd Controller Test", func() { Expect(err).To(HaveOccurred()) // get the catalog and ensure status is set properly - cat := &catalogdv1beta1.Catalog{} + cat := &v1alpha1.Catalog{} Expect(cl.Get(ctx, cKey, cat)).To(Succeed()) Expect(cat.Status.ResolvedSource).To(BeNil()) - Expect(cat.Status.Phase).To(Equal(catalogdv1beta1.PhaseFailing)) - cond := meta.FindStatusCondition(cat.Status.Conditions, catalogdv1beta1.TypeUnpacked) + Expect(cat.Status.Phase).To(Equal(v1alpha1.PhaseFailing)) + cond := meta.FindStatusCondition(cat.Status.Conditions, v1alpha1.TypeUnpacked) Expect(cond).ToNot(BeNil()) - Expect(cond.Reason).To(Equal(catalogdv1beta1.ReasonUnpackFailed)) + Expect(cond.Reason).To(Equal(v1alpha1.ReasonUnpackFailed)) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) }) }) @@ -258,7 +258,7 @@ var _ = Describe("Catalogd Controller Test", func() { AfterEach(func() { // clean up package - pkg := &catalogdv1beta1.Package{ + pkg := &v1alpha1.Package{ ObjectMeta: metav1.ObjectMeta{ Name: testPackageMetaName, }, @@ -266,7 +266,7 @@ var _ = Describe("Catalogd Controller Test", func() { Expect(cl.Delete(ctx, pkg)).NotTo(HaveOccurred()) // clean up bundlemetadata - bm := &catalogdv1beta1.BundleMetadata{ + bm := &v1alpha1.BundleMetadata{ ObjectMeta: metav1.ObjectMeta{ Name: testBundleMetaName, }, @@ -276,19 +276,19 @@ var _ = Describe("Catalogd Controller Test", func() { It("should set unpacking status to 'unpacked'", func() { // get the catalog and ensure status is set properly - cat := &catalogdv1beta1.Catalog{} + cat := &v1alpha1.Catalog{} Expect(cl.Get(ctx, cKey, cat)).ToNot(HaveOccurred()) Expect(cat.Status.ResolvedSource).ToNot(BeNil()) - Expect(cat.Status.Phase).To(Equal(catalogdv1beta1.PhaseUnpacked)) - cond := meta.FindStatusCondition(cat.Status.Conditions, catalogdv1beta1.TypeUnpacked) + Expect(cat.Status.Phase).To(Equal(v1alpha1.PhaseUnpacked)) + cond := meta.FindStatusCondition(cat.Status.Conditions, v1alpha1.TypeUnpacked) Expect(cond).ToNot(BeNil()) - Expect(cond.Reason).To(Equal(catalogdv1beta1.ReasonUnpackSuccessful)) + Expect(cond.Reason).To(Equal(v1alpha1.ReasonUnpackSuccessful)) Expect(cond.Status).To(Equal(metav1.ConditionTrue)) }) It("should create BundleMetadata resources", func() { // validate bundlemetadata resources - bundlemetadatas := &catalogdv1beta1.BundleMetadataList{} + bundlemetadatas := &v1alpha1.BundleMetadataList{} Expect(cl.List(ctx, bundlemetadatas)).To(Succeed()) Expect(bundlemetadatas.Items).To(HaveLen(1)) bundlemetadata := bundlemetadatas.Items[0] @@ -304,7 +304,7 @@ var _ = Describe("Catalogd Controller Test", func() { It("should create Package resources", func() { // validate package resources - packages := &catalogdv1beta1.PackageList{} + packages := &v1alpha1.PackageList{} Expect(cl.List(ctx, packages)).To(Succeed()) Expect(packages.Items).To(HaveLen(1)) pack := packages.Items[0] diff --git a/pkg/controllers/core/suite_test.go b/pkg/controllers/core/suite_test.go index 6ec38f9b..ae5bd5dd 100644 --- a/pkg/controllers/core/suite_test.go +++ b/pkg/controllers/core/suite_test.go @@ -22,7 +22,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - catalogdv1beta1 "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1" + catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" @@ -64,7 +64,7 @@ var _ = BeforeSuite(func() { Expect(cfg).NotTo(BeNil()) sch = runtime.NewScheme() - Expect(catalogdv1beta1.AddToScheme(sch)).To(Succeed()) + Expect(catalogdv1alpha1.AddToScheme(sch)).To(Succeed()) Expect(corev1.AddToScheme(sch)).To(Succeed()) cl, err = client.New(cfg, client.Options{Scheme: sch}) diff --git a/pprof/README.md b/pprof/README.md index 307a30f9..612fc76a 100644 --- a/pprof/README.md +++ b/pprof/README.md @@ -1,6 +1,6 @@ ## pprof -This folder contains some profiles that can be read using [pprof](https://github.com/google/pprof) to show how the core kubernetes apiserver and the custom catalogd apiserver CPU & Memory utilization is affected by the creation and reconciliation of the sample `Catalog` CR found at `../config/samples/core_v1beta1_catalog.yaml`. +This folder contains some profiles that can be read using [pprof](https://github.com/google/pprof) to show how the core kubernetes apiserver and the custom catalogd apiserver CPU & Memory utilization is affected by the creation and reconciliation of the sample `Catalog` CR found at `../config/samples/core_v1alpha1_catalog.yaml`. Instead of providing static screenshots and losing the interactivity associated with these `pprof` profiles, each of the files with the extension `.pb` can be used to view the profiles that were the result of running `pprof` against the live processes. @@ -81,7 +81,7 @@ This section is being added as the pprof metrics don't necessarily show the whol This image shows the spike in CPU utilization and the increase in Memory consumption. In this scenario, the command: ``` -kubectl apply -f config/samples/core_v1beta1_catalog.yaml +kubectl apply -f config/samples/core_v1alpha1_catalog.yaml ``` was run right at 1:44 PM. @@ -108,7 +108,7 @@ With this, we can see that without the catalogd apiserver the core kube-apiserve This image shows the spike in CPU utilization and the increase in Memory consumption. In this scenario, the command: ``` -kubectl apply -f config/samples/core_v1beta1_catalog.yaml +kubectl apply -f config/samples/core_v1alpha1_catalog.yaml ``` was run right at 3:06 PM @@ -135,7 +135,7 @@ With this, we can see that with the catalogd apiserver the core kube-apiserver h This image shows the spike in CPU utilization and the increase in Memory consumption. In this scenario, the command: ``` -kubectl apply -f config/samples/core_v1beta1_catalog.yaml +kubectl apply -f config/samples/core_v1alpha1_catalog.yaml ``` was run right at 3:06 PM @@ -170,7 +170,7 @@ Overall, when running both the kube-apiserver and the catalogd apiserver the tot This image shows the spike in CPU utilization and the increase in Memory consumption. In this scenario, the command: ``` -kubectl apply -f config/samples/core_v1beta1_catalog.yaml +kubectl apply -f config/samples/core_v1alpha1_catalog.yaml ``` was run right at 3:06 PM