Skip to content

Commit

Permalink
bump ClusterCatalog API to v1
Browse files Browse the repository at this point in the history
Signed-off-by: Per Goncalves da Silva <[email protected]>
  • Loading branch information
Per Goncalves da Silva committed Sep 6, 2024
1 parent 6584e7e commit 5aadf86
Show file tree
Hide file tree
Showing 28 changed files with 319 additions and 319 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Procedure steps marked with an asterisk (`*`) are likely to change with future A

```sh
$ kubectl apply -f - << EOF
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: operatorhubio
Expand All @@ -42,13 +42,13 @@ Procedure steps marked with an asterisk (`*`) are likely to change with future A
Namespace:
Labels: <none>
Annotations: <none>
API Version: olm.operatorframework.io/v1alpha1
API Version: olm.operatorframework.io/v1
Kind: ClusterCatalog
Metadata:
Creation Timestamp: 2023-06-23T18:35:13Z
Generation: 1
Managed Fields:
API Version: olm.operatorframework.io/v1alpha1
API Version: olm.operatorframework.io/v1
Fields Type: FieldsV1
fieldsV1:
f:metadata:
Expand All @@ -66,7 +66,7 @@ Procedure steps marked with an asterisk (`*`) are likely to change with future A
Manager: kubectl-client-side-apply
Operation: Update
Time: 2023-06-23T18:35:13Z
API Version: olm.operatorframework.io/v1alpha1
API Version: olm.operatorframework.io/v1
Fields Type: FieldsV1
fieldsV1:
f:status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1

import (
"context"
Expand All @@ -22,7 +22,7 @@ import (
func TestPollIntervalCELValidationRules(t *testing.T) {
validators := fieldValidatorsFromFile(t, "../../../config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml")
pth := "openAPIV3Schema.properties.spec"
validator, found := validators["v1alpha1"][pth]
validator, found := validators["v1"][pth]
assert.True(t, found)

for name, tc := range map[string]struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the core v1alpha1 API group
// Package v1 contains API Schema definitions for the core v1 API group
// +kubebuilder:object:generate=true
// +groupName=olm.operatorframework.io
package v1alpha1
package v1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "olm.operatorframework.io", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "olm.operatorframework.io", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
crwebhook "sigs.k8s.io/controller-runtime/pkg/webhook"

"github.com/operator-framework/catalogd/api/core/v1alpha1"
"github.com/operator-framework/catalogd/api/core/v1"
corecontrollers "github.com/operator-framework/catalogd/internal/controllers/core"
"github.com/operator-framework/catalogd/internal/features"
"github.com/operator-framework/catalogd/internal/garbagecollection"
Expand All @@ -62,7 +62,7 @@ const storageDir = "catalogs"
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(v1alpha1.AddToScheme(scheme))
utilruntime.Must(v1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
name: v1
schema:
openAPIV3Schema:
description: ClusterCatalog is the Schema for the ClusterCatalogs API
Expand Down
2 changes: 1 addition & 1 deletion config/base/default/clustercatalogs/default-catalogs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: operatorhubio
Expand Down
4 changes: 2 additions & 2 deletions config/base/manager/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /mutate-olm-operatorframework-io-v1alpha1-clustercatalog
path: /mutate-olm-operatorframework-io-v1-clustercatalog
failurePolicy: Fail
name: inject-metadata-name.olm.operatorframework.io
rules:
- apiGroups:
- olm.operatorframework.io
apiVersions:
- v1alpha1
- v1F
operations:
- CREATE
- UPDATE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: operatorhubio
Expand Down
2 changes: 1 addition & 1 deletion docs/fetching-catalog-contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ This section outlines a way of exposing the `Catalogd` Service's endpoints outsi

```sh
$ kubectl apply -f - << EOF
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: operatorhubio
Expand Down
2 changes: 1 addition & 1 deletion hack/scripts/demo-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sleep 10
kubectl get crds -A

# create a catalog
kubectl apply -f config/samples/core_v1alpha1_catalog.yaml
kubectl apply -f config/samples/core_v1_clustercatalog.yaml
# shows catalog-sample
kubectl get catalog -A
# waiting for catalog to report ready status
Expand Down
50 changes: 25 additions & 25 deletions internal/controllers/core/clustercatalog_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/operator-framework/catalogd/api/core/v1alpha1"
"github.com/operator-framework/catalogd/api/core/v1"
catalogderrors "github.com/operator-framework/catalogd/internal/errors"
"github.com/operator-framework/catalogd/internal/source"
"github.com/operator-framework/catalogd/internal/storage"
Expand Down Expand Up @@ -69,7 +69,7 @@ func (r *ClusterCatalogReconciler) Reconcile(ctx context.Context, req ctrl.Reque
// TODO: Where and when should we be logging errors and at which level?
_ = log.FromContext(ctx).WithName("catalogd-controller")

existingCatsrc := v1alpha1.ClusterCatalog{}
existingCatsrc := v1.ClusterCatalog{}
if err := r.Client.Get(ctx, req.NamespacedName, &existingCatsrc); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
Expand All @@ -92,7 +92,7 @@ func (r *ClusterCatalogReconciler) Reconcile(ctx context.Context, req ctrl.Reque
return res, apimacherrors.NewAggregate([]error{reconcileErr, updateErr})
}
}
existingCatsrc.Status, reconciledCatsrc.Status = v1alpha1.ClusterCatalogStatus{}, v1alpha1.ClusterCatalogStatus{}
existingCatsrc.Status, reconciledCatsrc.Status = v1.ClusterCatalogStatus{}, v1.ClusterCatalogStatus{}
if !equality.Semantic.DeepEqual(existingCatsrc, reconciledCatsrc) {
if updateErr := r.Client.Update(ctx, reconciledCatsrc); updateErr != nil {
return res, apimacherrors.NewAggregate([]error{reconcileErr, updateErr})
Expand All @@ -104,7 +104,7 @@ func (r *ClusterCatalogReconciler) Reconcile(ctx context.Context, req ctrl.Reque
// SetupWithManager sets up the controller with the Manager.
func (r *ClusterCatalogReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&v1alpha1.ClusterCatalog{}).
For(&v1.ClusterCatalog{}).
Owns(&corev1.Pod{}).
Complete(r)
}
Expand All @@ -117,7 +117,7 @@ func (r *ClusterCatalogReconciler) SetupWithManager(mgr ctrl.Manager) error {
// to add the ctrl.Result type back as a return value. Adding a comment to ignore
// linting from the linter that was fussing about this.
// nolint:unparam
func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *v1alpha1.ClusterCatalog) (ctrl.Result, error) {
func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *v1.ClusterCatalog) (ctrl.Result, error) {
if catalog.DeletionTimestamp.IsZero() && !controllerutil.ContainsFinalizer(catalog, fbcDeletionFinalizer) {
controllerutil.AddFinalizer(catalog, fbcDeletionFinalizer)
return ctrl.Result{}, nil
Expand Down Expand Up @@ -172,7 +172,7 @@ func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *v1alp

var requeueAfter time.Duration
switch catalog.Spec.Source.Type {
case v1alpha1.SourceTypeImage:
case v1.SourceTypeImage:
if catalog.Spec.Source.Image != nil && catalog.Spec.Source.Image.PollInterval != nil {
requeueAfter = wait.Jitter(catalog.Spec.Source.Image.PollInterval.Duration, requeueJitterMaxFactor)
}
Expand All @@ -184,72 +184,72 @@ func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *v1alp
}
}

func updateStatusUnpackPending(status *v1alpha1.ClusterCatalogStatus, result *source.Result) {
func updateStatusUnpackPending(status *v1.ClusterCatalogStatus, result *source.Result) {
status.ResolvedSource = nil
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: v1alpha1.TypeUnpacked,
Type: v1.TypeUnpacked,
Status: metav1.ConditionFalse,
Reason: v1alpha1.ReasonUnpackPending,
Reason: v1.ReasonUnpackPending,
Message: result.Message,
})
}

func updateStatusUnpacking(status *v1alpha1.ClusterCatalogStatus, result *source.Result) {
func updateStatusUnpacking(status *v1.ClusterCatalogStatus, result *source.Result) {
status.ResolvedSource = nil
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: v1alpha1.TypeUnpacked,
Type: v1.TypeUnpacked,
Status: metav1.ConditionFalse,
Reason: v1alpha1.ReasonUnpacking,
Reason: v1.ReasonUnpacking,
Message: result.Message,
})
}

func updateStatusUnpacked(status *v1alpha1.ClusterCatalogStatus, result *source.Result, contentURL string, generation int64, lastUnpacked metav1.Time) {
func updateStatusUnpacked(status *v1.ClusterCatalogStatus, result *source.Result, contentURL string, generation int64, lastUnpacked metav1.Time) {
status.ResolvedSource = result.ResolvedSource
status.ContentURL = contentURL
status.ObservedGeneration = generation
status.LastUnpacked = lastUnpacked
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: v1alpha1.TypeUnpacked,
Type: v1.TypeUnpacked,
Status: metav1.ConditionTrue,
Reason: v1alpha1.ReasonUnpackSuccessful,
Reason: v1.ReasonUnpackSuccessful,
Message: result.Message,
})
}

func updateStatusUnpackFailing(status *v1alpha1.ClusterCatalogStatus, err error) error {
func updateStatusUnpackFailing(status *v1.ClusterCatalogStatus, err error) error {
status.ResolvedSource = nil
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: v1alpha1.TypeUnpacked,
Type: v1.TypeUnpacked,
Status: metav1.ConditionFalse,
Reason: v1alpha1.ReasonUnpackFailed,
Reason: v1.ReasonUnpackFailed,
Message: err.Error(),
})
return err
}

func updateStatusStorageError(status *v1alpha1.ClusterCatalogStatus, err error) error {
func updateStatusStorageError(status *v1.ClusterCatalogStatus, err error) error {
status.ResolvedSource = nil
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: v1alpha1.TypeUnpacked,
Type: v1.TypeUnpacked,
Status: metav1.ConditionFalse,
Reason: v1alpha1.ReasonStorageFailed,
Reason: v1.ReasonStorageFailed,
Message: fmt.Sprintf("failed to store bundle: %s", err.Error()),
})
return err
}

func updateStatusStorageDeleteError(status *v1alpha1.ClusterCatalogStatus, err error) error {
func updateStatusStorageDeleteError(status *v1.ClusterCatalogStatus, err error) error {
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: v1alpha1.TypeDelete,
Type: v1.TypeDelete,
Status: metav1.ConditionFalse,
Reason: v1alpha1.ReasonStorageDeleteFailed,
Reason: v1.ReasonStorageDeleteFailed,
Message: fmt.Sprintf("failed to delete storage: %s", err.Error()),
})
return err
}

func (r *ClusterCatalogReconciler) needsUnpacking(catalog *v1alpha1.ClusterCatalog) bool {
func (r *ClusterCatalogReconciler) needsUnpacking(catalog *v1.ClusterCatalog) bool {
// if ResolvedSource is nil, it indicates that this is the first time we're
// unpacking this catalog.
if catalog.Status.ResolvedSource == nil {
Expand Down
Loading

0 comments on commit 5aadf86

Please sign in to comment.