Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #24: handling userRedHatImage bool value #27

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .osdk-scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

1 change: 1 addition & 0 deletions deploy/crds/apps.m88i.io_nexus_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ spec:
required:
- persistence
- replicas
- useRedHatImage
type: object
status:
description: NexusStatus defines the observed state of Nexus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ spec:
required:
- persistence
- replicas
- useRedHatImage
type: object
status:
description: NexusStatus defines the observed state of Nexus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down Expand Up @@ -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: {}
Expand Down Expand Up @@ -269,4 +269,4 @@ spec:
provider:
name: m88i Labs
replaces: nexus-operator.v0.1.0
version: 0.2.0
version: 0.2.0-rc1
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hack/go-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion hack/go-vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
3 changes: 1 addition & 2 deletions pkg/apis/apps/v1alpha1/nexus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions pkg/apis/apps/v1alpha1/zz_generated.openapi.go
Original file line number Diff line number Diff line change
@@ -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.
//
Expand Down Expand Up @@ -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{
Expand Down
7 changes: 3 additions & 4 deletions pkg/controller/nexus/nexus_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/nexus/resource/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ package version

var (
// Version of the Operator :-)
Version = "0.2.0"
Version = "0.2.0-rc1"
)