Skip to content

Commit

Permalink
⚠️ Bump CatalogExtension 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 de0a41e commit d847c22
Show file tree
Hide file tree
Showing 49 changed files with 706 additions and 706 deletions.
8 changes: 4 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ resources:
domain: operatorframework.io
group: olm
kind: ClusterExtension
path: github.com/operator-framework/operator-controller/api/v1alpha1
version: v1alpha1
path: github.com/operator-framework/operator-controller/api/v1
version: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: operatorframework.io
group: olm
kind: Extension
path: github.com/operator-framework/operator-controller/api/v1alpha1
version: v1alpha1
path: github.com/operator-framework/operator-controller/api/v1
version: v1
version: "3"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ kubectl wait --for=condition=Unpacked=True clustercatalog/operatorhubio --timeou
```bash
# Apply the sample ClusterExtension. Manifest already includes
# namespace and adequately privileged service account
kubectl apply -f config/samples/olm_v1alpha1_clusterextension.yaml
kubectl apply -f config/samples/olm_v1_clusterextension.yaml
```

#### Upgrade/Downgrade
Expand All @@ -87,7 +87,7 @@ kubectl delete clusterextension/argocd && kubectl delete namespace argocd

```bash
# Delete cluster-scoped resources
kubectl delete --ignore-not-found=true -f config/samples/olm_v1alpha1_clusterextension.yaml
kubectl delete --ignore-not-found=true -f config/samples/olm_v1_clusterextension.yaml
```

### Advanced Usage
Expand Down Expand Up @@ -133,7 +133,7 @@ kubectl create clusterrolebinding "argocd-operator-installer-cluster-admin" \
```bash
# Apply ClusterExtension
cat <<EOF
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: argocd
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_test
package v1_test

import (
"fmt"
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 olm v1alpha1 API group
// Package v1 contains API Schema definitions for the olm 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.

12 changes: 6 additions & 6 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
ocv1 "github.com/operator-framework/operator-controller/api/v1"
"github.com/operator-framework/operator-controller/internal/action"
"github.com/operator-framework/operator-controller/internal/applier"
"github.com/operator-framework/operator-controller/internal/authentication"
Expand Down Expand Up @@ -119,7 +119,7 @@ func main() {
systemNamespace = podNamespace()
}

dependentRequirement, err := k8slabels.NewRequirement(labels.OwnerKindKey, selection.In, []string{ocv1alpha1.ClusterExtensionKind})
dependentRequirement, err := k8slabels.NewRequirement(labels.OwnerKindKey, selection.In, []string{ocv1.ClusterExtensionKind})
if err != nil {
setupLog.Error(err, "unable to create dependent label selector for cache")
os.Exit(1)
Expand All @@ -135,8 +135,8 @@ func main() {
LeaderElectionID: "9c4404e7.operatorframework.io",
Cache: crcache.Options{
ByObject: map[client.Object]crcache.ByObject{
&ocv1alpha1.ClusterExtension{}: {Label: k8slabels.Everything()},
&catalogd.ClusterCatalog{}: {Label: k8slabels.Everything()},
&ocv1.ClusterExtension{}: {Label: k8slabels.Everything()},
&catalogd.ClusterCatalog{}: {Label: k8slabels.Everything()},
},
DefaultNamespaces: map[string]crcache.Config{
systemNamespace: {LabelSelector: k8slabels.Everything()},
Expand Down Expand Up @@ -171,7 +171,7 @@ func main() {
cfgGetter, err := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(),
helmclient.StorageDriverMapper(action.ChunkedStorageDriverMapper(coreClient, mgr.GetAPIReader(), systemNamespace)),
helmclient.ClientNamespaceMapper(func(obj client.Object) (string, error) {
ext := obj.(*ocv1alpha1.ClusterExtension)
ext := obj.(*ocv1.ClusterExtension)
return ext.Spec.Install.Namespace, nil
}),
helmclient.ClientRestConfigMapper(clientRestConfigMapper),
Expand Down Expand Up @@ -251,7 +251,7 @@ func main() {

cm := contentmanager.NewManager(clientRestConfigMapper, mgr.GetConfig(), mgr.GetRESTMapper())
err = clusterExtensionFinalizers.Register(controllers.ClusterExtensionCleanupContentManagerCacheFinalizer, finalizerFunc(func(ctx context.Context, obj client.Object) (crfinalizer.Result, error) {
ext := obj.(*ocv1alpha1.ClusterExtension)
ext := obj.(*ocv1.ClusterExtension)
err := cm.Delete(ext)
return crfinalizer.Result{}, err
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
singular: clusterextension
scope: Cluster
versions:
- name: v1alpha1
- name: v1
schema:
openAPIV3Schema:
description: ClusterExtension is the Schema for the clusterextensions API
Expand Down
2 changes: 1 addition & 1 deletion config/components/ca/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
apiVersion: kustomize.config.k8s.io/v1
kind: Component
# No namespace is specified here, otherwise, it will overwrite _all_ the other namespaces!
resources:
Expand Down
2 changes: 1 addition & 1 deletion config/components/coverage/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
apiVersion: kustomize.config.k8s.io/v1
kind: Component
namespace: olmv1-system
resources:
Expand Down
2 changes: 1 addition & 1 deletion config/components/tls/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
apiVersion: kustomize.config.k8s.io/v1
kind: Component
namespace: olmv1-system
resources:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/catalogd_operatorcatalog.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/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Append samples of your project ##
resources:
- olm_v1alpha1_clusterextension.yaml
- olm_v1alpha1_extension.yaml
- olm_v1_clusterextension.yaml
- olm_v1_extension.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
2 changes: 1 addition & 1 deletion config/samples/olm_v1alpha1_clusterextension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ subjects:
name: argocd-installer
namespace: argocd
---
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: argocd
Expand Down
6 changes: 3 additions & 3 deletions docs/Tasks/adding-a-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This catalog is distributed as an image [quay.io/operatorhubio/catalog](https://
1. Create a catalog custom resource (CR):

``` yaml title="clustercatalog_cr.yaml"
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: operatorhubio
Expand All @@ -43,7 +43,7 @@ This catalog is distributed as an image [quay.io/operatorhubio/catalog](https://
To disable polling, set a zero value, such as `0s`.

``` yaml title="Example `operatorhubio.yaml` CR"
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: operatorhub
Expand Down Expand Up @@ -91,7 +91,7 @@ This catalog is distributed as an image [quay.io/operatorhubio/catalog](https://
Namespace:
Labels: <none>
Annotations: <none>
API Version: olm.operatorframework.io/v1alpha1
API Version: olm.operatorframework.io/v1
Kind: ClusterCatalog
Metadata:
Creation Timestamp: 2024-03-12T19:34:50Z
Expand Down
4 changes: 2 additions & 2 deletions docs/Tasks/installing-an-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ After you add a catalog to your cluster, you can install an extension by creatin
1. Create a CR for the Kubernetes extension you want to install:

``` yaml title="Example CR"
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: <extension_name>
Expand Down Expand Up @@ -92,7 +92,7 @@ After you add a catalog to your cluster, you can install an extension by creatin
Namespace:
Labels: <none>
Annotations: <none>
API Version: olm.operatorframework.io/v1alpha1
API Version: olm.operatorframework.io/v1
Kind: ClusterExtension
Metadata:
Creation Timestamp: 2024-03-15T15:03:47Z
Expand Down
2 changes: 1 addition & 1 deletion docs/drafts/how-to-pin-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ To disable automatic updates, and pin the version of an extension, set `version`
Example:

```yaml
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: argocd
Expand Down
2 changes: 1 addition & 1 deletion docs/drafts/how-to-version-range-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Set the version for the desired package in the Catalog source to a comparison st
Example:

```yaml
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: argocd
Expand Down
2 changes: 1 addition & 1 deletion docs/drafts/how-to-z-stream-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ To restrict automatic updates to only z-stream patches and avoid breaking change
Example:

```yaml
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: argocd
Expand Down
4 changes: 2 additions & 2 deletions docs/drafts/upgrade-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If `1.0.0` is installed, OLM v1 behavior differs in the following ways:
You can change the default behavior of the upgrade constraints by setting the `upgradeConstraintPolicy` parameter in your cluster extension's custom resource (CR).

``` yaml hl_lines="10"
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: <extension_name>
Expand Down Expand Up @@ -81,7 +81,7 @@ If you set the field to `Ignore`, no upgrade constraints are set on the package.
Example `ClusterExtension` with `.spec.upgradeConstraintPolicy` field set to `Ignore`:

```yaml
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: extension-sample
Expand Down
4 changes: 2 additions & 2 deletions docs/refs/crd-upgrade-safety.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The CRD Upgrade Safety preflight check can be entirely disabled by adding the
`preflight.crdUpgradeSafety.disabled` field with a value of "true" to the ClusterExtension of the CRD.

```yaml
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: clusterextension-sample
Expand Down Expand Up @@ -103,7 +103,7 @@ spec:
singular: sample
scope: Namespaced
versions:
- name: v1alpha1
- name: v1
schema:
openAPIV3Schema:
properties:
Expand Down
4 changes: 2 additions & 2 deletions hack/test/pre-upgrade-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST_CLUSTER_CATALOG_NAME=$2
TEST_CLUSTER_EXTENSION_NAME=$3

kubectl apply -f - << EOF
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: ${TEST_CLUSTER_CATALOG_NAME}
Expand Down Expand Up @@ -128,7 +128,7 @@ roleRef:
EOF

kubectl apply -f - << EOF
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: ${TEST_CLUSTER_EXTENSION_NAME}
Expand Down
4 changes: 2 additions & 2 deletions internal/action/restconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
ocv1 "github.com/operator-framework/operator-controller/api/v1"
"github.com/operator-framework/operator-controller/internal/authentication"
)

func ServiceAccountRestConfigMapper(tokenGetter *authentication.TokenGetter) func(ctx context.Context, o client.Object, c *rest.Config) (*rest.Config, error) {
return func(ctx context.Context, o client.Object, c *rest.Config) (*rest.Config, error) {
cExt := o.(*ocv1alpha1.ClusterExtension)
cExt := o.(*ocv1.ClusterExtension)
saKey := types.NamespacedName{
Name: cExt.Spec.Install.ServiceAccount.Name,
Namespace: cExt.Spec.Install.Namespace,
Expand Down
8 changes: 4 additions & 4 deletions internal/applier/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
ocv1 "github.com/operator-framework/operator-controller/api/v1"
"github.com/operator-framework/operator-controller/internal/rukpak/convert"
"github.com/operator-framework/operator-controller/internal/rukpak/preflights/crdupgradesafety"
"github.com/operator-framework/operator-controller/internal/rukpak/util"
Expand Down Expand Up @@ -56,7 +56,7 @@ type Helm struct {
Preflights []Preflight
}

func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.ClusterExtension, objectLabels map[string]string, storageLabels map[string]string) ([]client.Object, string, error) {
func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1.ClusterExtension, objectLabels map[string]string, storageLabels map[string]string) ([]client.Object, string, error) {
chrt, err := convert.RegistryV1ToHelmChart(ctx, contentFS, ext.Spec.Install.Namespace, []string{corev1.NamespaceAll})
if err != nil {
return nil, "", err
Expand All @@ -79,7 +79,7 @@ func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.Clust

for _, preflight := range h.Preflights {
if ext.Spec.Install.Preflight != nil && ext.Spec.Install.Preflight.CRDUpgradeSafety != nil {
if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Install.Preflight.CRDUpgradeSafety.Policy == ocv1alpha1.CRDUpgradeSafetyPolicyDisabled {
if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Install.Preflight.CRDUpgradeSafety.Policy == ocv1.CRDUpgradeSafetyPolicyDisabled {
// Skip this preflight check because it is of type *crdupgradesafety.Preflight and the CRD Upgrade Safety
// preflight check has been disabled
continue
Expand Down Expand Up @@ -134,7 +134,7 @@ func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.Clust
return relObjects, state, nil
}

func (h *Helm) getReleaseState(cl helmclient.ActionInterface, ext *ocv1alpha1.ClusterExtension, chrt *chart.Chart, values chartutil.Values, post postrender.PostRenderer) (*release.Release, *release.Release, string, error) {
func (h *Helm) getReleaseState(cl helmclient.ActionInterface, ext *ocv1.ClusterExtension, chrt *chart.Chart, values chartutil.Values, post postrender.PostRenderer) (*release.Release, *release.Release, string, error) {
currentRelease, err := cl.Get(ext.GetName())
if err != nil && !errors.Is(err, driver.ErrReleaseNotFound) {
return nil, nil, StateError, err
Expand Down
6 changes: 3 additions & 3 deletions internal/bundleutil/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/operator-framework/operator-registry/alpha/declcfg"
"github.com/operator-framework/operator-registry/alpha/property"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
ocv1 "github.com/operator-framework/operator-controller/api/v1"
)

func GetVersion(b declcfg.Bundle) (*bsemver.Version, error) {
Expand All @@ -30,8 +30,8 @@ func GetVersion(b declcfg.Bundle) (*bsemver.Version, error) {
}

// MetadataFor returns a BundleMetadata for the given bundle name and version.
func MetadataFor(bundleName string, bundleVersion bsemver.Version) *ocv1alpha1.BundleMetadata {
return &ocv1alpha1.BundleMetadata{
func MetadataFor(bundleName string, bundleVersion bsemver.Version) *ocv1.BundleMetadata {
return &ocv1.BundleMetadata{
Name: bundleName,
Version: bundleVersion.String(),
}
Expand Down
Loading

0 comments on commit d847c22

Please sign in to comment.