diff --git a/.osdk-scorecard.yaml b/.osdk-scorecard.yaml index 96e4f47f..32a4acd0 100644 --- a/.osdk-scorecard.yaml +++ b/.osdk-scorecard.yaml @@ -8,5 +8,5 @@ scorecard: - olm: cr-manifest: - "deploy/crds/apps.m88i.io_v1alpha1_nexus_cr.yaml" - csv-path: "deploy/olm-catalog/nexus-operator/0.2.0/nexus-operator.v0.2.0.clusterserviceversion.yaml" + csv-path: "deploy/olm-catalog/nexus-operator/0.2.0-rc1/nexus-operator.v0.2.0-rc1.clusterserviceversion.yaml" diff --git a/deploy/crds/apps.m88i.io_nexus_crd.yaml b/deploy/crds/apps.m88i.io_nexus_crd.yaml index ce7bc74f..a90898d1 100644 --- a/deploy/crds/apps.m88i.io_nexus_crd.yaml +++ b/deploy/crds/apps.m88i.io_nexus_crd.yaml @@ -103,6 +103,7 @@ spec: required: - persistence - replicas + - useRedHatImage type: object status: description: NexusStatus defines the observed state of Nexus diff --git a/deploy/olm-catalog/nexus-operator/0.2.0/apps.m88i.io_nexus_crd.yaml b/deploy/olm-catalog/nexus-operator/0.2.0-rc1/apps.m88i.io_nexus_crd.yaml similarity index 99% rename from deploy/olm-catalog/nexus-operator/0.2.0/apps.m88i.io_nexus_crd.yaml rename to deploy/olm-catalog/nexus-operator/0.2.0-rc1/apps.m88i.io_nexus_crd.yaml index ce7bc74f..a90898d1 100644 --- a/deploy/olm-catalog/nexus-operator/0.2.0/apps.m88i.io_nexus_crd.yaml +++ b/deploy/olm-catalog/nexus-operator/0.2.0-rc1/apps.m88i.io_nexus_crd.yaml @@ -103,6 +103,7 @@ spec: required: - persistence - replicas + - useRedHatImage type: object status: description: NexusStatus defines the observed state of Nexus diff --git a/deploy/olm-catalog/nexus-operator/0.2.0/nexus-operator.v0.2.0.clusterserviceversion.yaml b/deploy/olm-catalog/nexus-operator/0.2.0-rc1/nexus-operator.v0.2.0-rc1.clusterserviceversion.yaml similarity index 99% rename from deploy/olm-catalog/nexus-operator/0.2.0/nexus-operator.v0.2.0.clusterserviceversion.yaml rename to deploy/olm-catalog/nexus-operator/0.2.0-rc1/nexus-operator.v0.2.0-rc1.clusterserviceversion.yaml index 4e96c346..0c6c7b5d 100644 --- a/deploy/olm-catalog/nexus-operator/0.2.0/nexus-operator.v0.2.0.clusterserviceversion.yaml +++ b/deploy/olm-catalog/nexus-operator/0.2.0-rc1/nexus-operator.v0.2.0-rc1.clusterserviceversion.yaml @@ -44,7 +44,7 @@ metadata: tectonic-visibility: ocs labels: nexus-operator: "true" - name: nexus-operator.v0.2.0 + name: nexus-operator.v0.2.0-rc1 namespace: placeholder spec: apiservicedefinitions: {} @@ -159,7 +159,7 @@ spec: fieldPath: metadata.name - name: OPERATOR_NAME value: nexus-operator - image: quay.io/m88i/nexus-operator:0.2.0 + image: quay.io/m88i/nexus-operator:0.2.0-rc1 imagePullPolicy: Always name: nexus-operator resources: {} @@ -269,4 +269,4 @@ spec: provider: name: m88i Labs replaces: nexus-operator.v0.1.0 - version: 0.2.0 + version: 0.2.0-rc1 diff --git a/deploy/olm-catalog/nexus-operator/nexus-operator.package.yaml b/deploy/olm-catalog/nexus-operator/nexus-operator.package.yaml index d3848c17..a5f70f2e 100644 --- a/deploy/olm-catalog/nexus-operator/nexus-operator.package.yaml +++ b/deploy/olm-catalog/nexus-operator/nexus-operator.package.yaml @@ -1,5 +1,5 @@ channels: -- currentCSV: nexus-operator.v0.1.0 +- currentCSV: nexus-operator.v0.2.0-rc1 name: alpha defaultChannel: alpha packageName: nexus-operator-hub diff --git a/deploy/operator.yaml b/deploy/operator.yaml index 0cff2afa..8fc590fe 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -15,7 +15,7 @@ spec: serviceAccountName: nexus-operator containers: - name: nexus-operator - image: quay.io/m88i/nexus-operator:0.2.0 + image: quay.io/m88i/nexus-operator:0.2.0-rc1 command: - nexus-operator imagePullPolicy: Always diff --git a/hack/go-build.sh b/hack/go-build.sh index 1b99885e..cdc3ec68 100755 --- a/hack/go-build.sh +++ b/hack/go-build.sh @@ -23,7 +23,7 @@ REPO=https://github.com/m88i/nexus-operator BRANCH=master REGISTRY=quay.io/m88i IMAGE=nexus-operator -TAG=0.2.0 +TAG=0.2.0-rc1 TAR=${BRANCH}.tar.gz URL=${REPO}/archive/${TAR} CFLAGS="" diff --git a/hack/go-vet.sh b/hack/go-vet.sh index 2d22da9a..937bc6db 100755 --- a/hack/go-vet.sh +++ b/hack/go-vet.sh @@ -21,6 +21,6 @@ if [[ -z ${CI} ]]; then ./hack/go-mod.sh operator-sdk generate k8s operator-sdk generate openapi - operator-sdk olm-catalog gen-csv --csv-version 0.2.0 --from-version 0.1.0 --update-crds # future: --from-version 0.5.0 + operator-sdk olm-catalog gen-csv --csv-version 0.2.0-rc1 --from-version 0.1.0 --update-crds # future: --from-version 0.5.0 fi go vet ./... \ No newline at end of file diff --git a/pkg/apis/apps/v1alpha1/nexus_types.go b/pkg/apis/apps/v1alpha1/nexus_types.go index 6287fdf6..fdc16a6e 100644 --- a/pkg/apis/apps/v1alpha1/nexus_types.go +++ b/pkg/apis/apps/v1alpha1/nexus_types.go @@ -64,12 +64,11 @@ type NexusSpec struct { // If you have access to Red Hat Container Catalog, turn this to true to use the certified image provided by Sonatype // Default: false - // +optional // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Use Red Hat Image" // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.description="Use Red Hat Image" // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" - UseRedHatImage bool `json:"useRedHatImage,omitempty"` + UseRedHatImage bool `json:"useRedHatImage"` // Networking definition // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=false diff --git a/pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go index 1d17d6d9..aa933233 100644 --- a/pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go @@ -1,4 +1,4 @@ -// Copyright 2019 Nexus Operator and/or its authors +// Copyright 2020 Nexus Operator and/or its authors // // This file is part of Nexus Operator. // diff --git a/pkg/apis/apps/v1alpha1/zz_generated.openapi.go b/pkg/apis/apps/v1alpha1/zz_generated.openapi.go index fd3cfc34..7b5bf199 100644 --- a/pkg/apis/apps/v1alpha1/zz_generated.openapi.go +++ b/pkg/apis/apps/v1alpha1/zz_generated.openapi.go @@ -1,4 +1,4 @@ -// Copyright 2019 Nexus Operator and/or its authors +// Copyright 2020 Nexus Operator and/or its authors // // This file is part of Nexus Operator. // @@ -154,7 +154,7 @@ func schema_pkg_apis_apps_v1alpha1_NexusSpec(ref common.ReferenceCallback) commo }, }, }, - Required: []string{"replicas", "persistence"}, + Required: []string{"replicas", "persistence", "useRedHatImage"}, }, }, Dependencies: []string{ diff --git a/pkg/controller/nexus/nexus_controller.go b/pkg/controller/nexus/nexus_controller.go index 150e6429..7460230a 100644 --- a/pkg/controller/nexus/nexus_controller.go +++ b/pkg/controller/nexus/nexus_controller.go @@ -155,11 +155,11 @@ func (r *ReconcileNexus) Reconcile(request reconcile.Request) (result reconcile. // Error reading the object - requeue the request. return result, err } - + cache := instance.DeepCopy() deployedRes := make(map[reflect.Type][]utilres.KubernetesResource) // In case of any errors from here, we should update the application status - defer r.updateNexusStatus(instance, &result, &err) + defer r.updateNexusStatus(instance, cache, &err) // default networking parameters if err = r.setDefaultNetworking(instance); err != nil { @@ -245,9 +245,8 @@ func (r *ReconcileNexus) setDefaultNetworking(nexus *appsv1alpha1.Nexus) (err er return nil } -func (r *ReconcileNexus) updateNexusStatus(nexus *appsv1alpha1.Nexus, result *reconcile.Result, err *error) { +func (r *ReconcileNexus) updateNexusStatus(nexus *appsv1alpha1.Nexus, cache *appsv1alpha1.Nexus, err *error) { log.Info("Updating application status before leaving") - cache := nexus.DeepCopy() if *err != nil { nexus.Status.NexusStatus = fmt.Sprintf("Failed to deploy Nexus: %s", *err) diff --git a/pkg/controller/nexus/resource/deployment.go b/pkg/controller/nexus/resource/deployment.go index 824fbcd5..9baea2dc 100644 --- a/pkg/controller/nexus/resource/deployment.go +++ b/pkg/controller/nexus/resource/deployment.go @@ -86,13 +86,13 @@ func newDeployment(nexus *v1alpha1.Nexus, pvc *v1.PersistentVolumeClaim) *appsv1 } func applyDefaultImage(nexus *v1alpha1.Nexus, deployment *appsv1.Deployment) { - if len(nexus.Spec.Image) == 0 { - if nexus.Spec.UseRedHatImage { - nexus.Spec.Image = nexusCertifiedLatestImage - } else { - nexus.Spec.Image = nexusCommunityLatestImage - } + if nexus.Spec.UseRedHatImage { + nexus.Spec.Image = nexusCertifiedLatestImage + } else if len(nexus.Spec.Image) == 0 { + nexus.Spec.UseRedHatImage = false + nexus.Spec.Image = nexusCommunityLatestImage } + deployment.Spec.Template.Spec.Containers[0].Image = nexus.Spec.Image } diff --git a/version/version.go b/version/version.go index 1e91d6d5..b6a62b74 100644 --- a/version/version.go +++ b/version/version.go @@ -19,5 +19,5 @@ package version var ( // Version of the Operator :-) - Version = "0.2.0" + Version = "0.2.0-rc1" )