diff --git a/Makefile b/Makefile index ab48e1da8..bd74adc9c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Current Operator version -VERSION ?= 4.0.0 +VERSION ?= 4.0.1 # Default bundle image tag BUNDLE_IMG ?= quay.io/grafana-operator/controller-bundle:v$(VERSION) # Options for 'bundle-build' diff --git a/api/integreatly/v1alpha1/grafanadatasource_types.go b/api/integreatly/v1alpha1/grafanadatasource_types.go index c06b6375d..86e9caef6 100644 --- a/api/integreatly/v1alpha1/grafanadatasource_types.go +++ b/api/integreatly/v1alpha1/grafanadatasource_types.go @@ -70,9 +70,9 @@ type GrafanaDataSourceFields struct { Name string `json:"name"` Type string `json:"type"` Uid string `json:"uid,omitempty"` - Access string `json:"access"` + Access string `json:"access,omitempty"` OrgId int `json:"orgId,omitempty"` - Url string `json:"url"` + Url string `json:"url,omitempty"` Password string `json:"password,omitempty"` User string `json:"user,omitempty"` Database string `json:"database,omitempty"` diff --git a/bundle/manifests/grafana-operator.clusterserviceversion.yaml b/bundle/manifests/grafana-operator.clusterserviceversion.yaml index 01238d824..bd69ea400 100644 --- a/bundle/manifests/grafana-operator.clusterserviceversion.yaml +++ b/bundle/manifests/grafana-operator.clusterserviceversion.yaml @@ -6,7 +6,7 @@ metadata: capabilities: Basic Install operators.operatorframework.io/builder: operator-sdk-v1.3.2 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 - name: grafana-operator.v4.0.0 + name: grafana-operator.v4.0.1 namespace: placeholder spec: apiservicedefinitions: {} @@ -18,6 +18,9 @@ spec: - kind: GrafanaDataSource name: grafanadatasources.integreatly.org version: v1alpha1 + - kind: GrafanaNotificationChannel + name: grafananotificationchannels.integreatly.org + version: v1alpha1 - kind: Grafana name: grafanas.integreatly.org version: v1alpha1 @@ -130,6 +133,26 @@ spec: - get - patch - update + - apiGroups: + - integreatly.org + resources: + - grafananotificationchannels + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - integreatly.org + resources: + - grafananotificationchannels/status + verbs: + - get + - patch + - update - apiGroups: - integreatly.org resources: @@ -229,7 +252,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.annotations['olm.targetNamespaces'] - image: quay.io/grafana-operator/grafana-operator:v4.0.0 + image: quay.io/grafana-operator/grafana-operator:v4.0.1 imagePullPolicy: Always livenessProbe: httpGet: @@ -301,4 +324,5 @@ spec: maturity: alpha provider: name: Red Hat - version: 4.0.0 + replaces: grafana-operator.v4.0.0 + version: 4.0.1 diff --git a/bundle/manifests/integreatly.org_grafanadatasources.yaml b/bundle/manifests/integreatly.org_grafanadatasources.yaml index 1fe68b2df..0592ef624 100644 --- a/bundle/manifests/integreatly.org_grafanadatasources.yaml +++ b/bundle/manifests/integreatly.org_grafanadatasources.yaml @@ -276,10 +276,8 @@ spec: withCredentials: type: boolean required: - - access - name - type - - url type: object type: array name: diff --git a/bundle/manifests/integreatly.org_grafananotificationchannels.yaml b/bundle/manifests/integreatly.org_grafananotificationchannels.yaml new file mode 100644 index 000000000..4a41dc8af --- /dev/null +++ b/bundle/manifests/integreatly.org_grafananotificationchannels.yaml @@ -0,0 +1,72 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.4.1 + creationTimestamp: null + name: grafananotificationchannels.integreatly.org +spec: + group: integreatly.org + names: + kind: GrafanaNotificationChannel + listKind: GrafanaNotificationChannelList + plural: grafananotificationchannels + singular: grafananotificationchannel + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: GrafanaNotificationChannel is the Schema for the GrafanaNotificationChannels API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: GrafanaNotificationChannelSpec defines the desired state of GrafanaNotificationChannel + properties: + json: + description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file' + type: string + name: + type: string + required: + - json + - name + type: object + status: + description: GrafanaNotificationChannelStatus defines the observed state of GrafanaNotificationChannel + properties: + hash: + type: string + id: + type: integer + message: + type: string + phase: + type: string + uid: + type: string + required: + - hash + - id + - message + - phase + - uid + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/bases/integreatly.org_grafanadatasources.yaml b/config/crd/bases/integreatly.org_grafanadatasources.yaml index dac217f0d..5e678a424 100644 --- a/config/crd/bases/integreatly.org_grafanadatasources.yaml +++ b/config/crd/bases/integreatly.org_grafanadatasources.yaml @@ -284,10 +284,8 @@ spec: withCredentials: type: boolean required: - - access - name - type - - url type: object type: array name: diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 8bc138ca1..06d1913a2 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -13,4 +13,4 @@ kind: Kustomization images: - name: controller newName: quay.io/grafana-operator/grafana-operator - newTag: v4.0.0 + newTag: v4.0.1 diff --git a/config/manifests/bases/grafana-operator.clusterserviceversion.yaml b/config/manifests/bases/grafana-operator.clusterserviceversion.yaml index dba7e1a29..32dd6f0cd 100644 --- a/config/manifests/bases/grafana-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/grafana-operator.clusterserviceversion.yaml @@ -145,4 +145,5 @@ spec: maturity: alpha provider: name: Red Hat + replaces: grafana-operator.v4.0.0 version: 0.0.0 diff --git a/controllers/grafanadatasource/datasource_controller.go b/controllers/grafanadatasource/datasource_controller.go index 6c987d8a3..9d4bcebfd 100644 --- a/controllers/grafanadatasource/datasource_controller.go +++ b/controllers/grafanadatasource/datasource_controller.go @@ -48,7 +48,7 @@ type GrafanaDatasourceReconciler struct { Scheme *runtime.Scheme Context context.Context Cancel context.CancelFunc - recorder record.EventRecorder + Recorder record.EventRecorder Logger logr.Logger } @@ -155,7 +155,7 @@ func (r *GrafanaDatasourceReconciler) reconcileDataSources(state *common.DataSou // finally, update the configmap err = r.Client.Update(r.Context, state.KnownDataSources) if err != nil { - r.recorder.Event(state.KnownDataSources, "Warning", "UpdateError", err.Error()) + r.Recorder.Event(state.KnownDataSources, "Warning", "UpdateError", err.Error()) } else { r.manageSuccess(updated) } @@ -194,7 +194,7 @@ func (i *GrafanaDatasourceReconciler) updateHash(known *v1.ConfigMap) (string, e // Handle error case: update datasource with error message and status func (r *GrafanaDatasourceReconciler) manageError(datasource *grafanav1alpha1.GrafanaDataSource, issue error) { - r.recorder.Event(datasource, "Warning", "ProcessingError", issue.Error()) + r.Recorder.Event(datasource, "Warning", "ProcessingError", issue.Error()) // datasource deleted if datasource == nil { @@ -227,7 +227,7 @@ func (r *GrafanaDatasourceReconciler) manageSuccess(datasources []grafanav1alpha err := r.Client.Status().Update(r.Context, &datasources[i]) if err != nil { - r.recorder.Event(&datasources[i], "Warning", "UpdateError", err.Error()) + r.Recorder.Event(&datasources[i], "Warning", "UpdateError", err.Error()) } } } diff --git a/controllers/model/grafanaDeployment.go b/controllers/model/grafanaDeployment.go index c925b7ef5..6486a579c 100644 --- a/controllers/model/grafanaDeployment.go +++ b/controllers/model/grafanaDeployment.go @@ -224,20 +224,23 @@ func getVolumes(cr *v1alpha1.Grafana) []v13.Volume { // nolint } // Volume to store the plugins - appendIfContainsPlugin := func(slice []v13.VolumeMount) bool { + appendIfContainsPlugin := func() bool { var foundGrafanaPluginsPath bool - if cr.Spec.Deployment.ExtraVolumeMounts != nil { - for _, item := range slice { + if cr.Spec.Deployment != nil { + for _, item := range cr.Spec.Deployment.ExtraVolumeMounts { if item.MountPath == config.GrafanaPluginsPath { foundGrafanaPluginsPath = true break } } } - volumes = append(volumes, cr.Spec.Deployment.ExtraVolumes...) + + if cr.Spec.Deployment != nil { + volumes = append(volumes, cr.Spec.Deployment.ExtraVolumes...) + } return foundGrafanaPluginsPath } - if !appendIfContainsPlugin(cr.Spec.Deployment.ExtraVolumeMounts) { + if !appendIfContainsPlugin() { volumes = append(volumes, v13.Volume{ Name: constants.GrafanaPluginsVolumeName, VolumeSource: v13.VolumeSource{ @@ -343,20 +346,23 @@ func getVolumeMounts(cr *v1alpha1.Grafana) []v13.VolumeMount { MountPath: config.GrafanaDataPath, }) - appendIfContainsPlugin := func(slice []v13.VolumeMount) bool { + appendIfContainsPlugin := func() bool { var foundGrafanaPluginsPath bool - if cr.Spec.Deployment.ExtraVolumeMounts != nil { - for _, item := range slice { + if cr.Spec.Deployment != nil { + for _, item := range cr.Spec.Deployment.ExtraVolumeMounts { if item.MountPath == config.GrafanaPluginsPath { foundGrafanaPluginsPath = true break } } } - mounts = append(mounts, cr.Spec.Deployment.ExtraVolumeMounts...) + + if cr.Spec.Deployment != nil { + mounts = append(mounts, cr.Spec.Deployment.ExtraVolumeMounts...) + } return foundGrafanaPluginsPath } - if !appendIfContainsPlugin(cr.Spec.Deployment.ExtraVolumeMounts) { + if !appendIfContainsPlugin() { mounts = append(mounts, v13.VolumeMount{ Name: constants.GrafanaPluginsVolumeName, MountPath: config.GrafanaPluginsPath, @@ -573,9 +579,12 @@ func getInitContainers(cr *v1alpha1.Grafana, plugins string) []v13.Container { } var volumeName = constants.GrafanaPluginsVolumeName - for _, item := range cr.Spec.Deployment.ExtraVolumeMounts { - if item.MountPath == config.GrafanaPluginsPath { - volumeName = item.Name + + if cr.Spec.Deployment != nil { + for _, item := range cr.Spec.Deployment.ExtraVolumeMounts { + if item.MountPath == config.GrafanaPluginsPath { + volumeName = item.Name + } } } diff --git a/documentation/api.md b/documentation/api.md index bd609c294..d355da708 100644 --- a/documentation/api.md +++ b/documentation/api.md @@ -396,13 +396,6 @@ GrafanaDataSourceSpec defines the desired state of GrafanaDataSource