Skip to content

Commit

Permalink
Fix csv 4.0 (grafana#522)
Browse files Browse the repository at this point in the history
* fix: spec.client is not working
* update auto generated code
* feat: crd migration working as expected
* remove required field
  • Loading branch information
pb82 authored Sep 18, 2021
1 parent 0638a35 commit fb8ed04
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 308 deletions.
11 changes: 9 additions & 2 deletions api/integreatly/v1alpha1/grafana_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ type JsonnetConfig struct {

// Grafana API client settings
type GrafanaClient struct {
TimeoutSeconds *int `json:"timeout,omitempty"`
PreferService bool `json:"preferService"`
TimeoutSeconds *int `json:"timeout,omitempty"`
PreferService *bool `json:"preferService,omitempty"`
}

// GrafanaService provides a means to configure the service
Expand Down Expand Up @@ -571,3 +571,10 @@ type GrafanaList struct {
func init() {
SchemeBuilder.Register(&Grafana{}, &GrafanaList{})
}

func (cr *Grafana) GetPreferServiceValue() bool {
if cr.Spec.Client != nil && cr.Spec.Client.PreferService != nil {
return *cr.Spec.Client.PreferService
}
return false
}
5 changes: 5 additions & 0 deletions api/integreatly/v1alpha1/zz_generated.deepcopy.go

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

558 changes: 260 additions & 298 deletions bundle/manifests/grafana-operator.clusterserviceversion.yaml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions bundle/manifests/integreatly.org_grafanadatasources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ spec:
- name
type: object
status:
properties:
message:
type: string
phase:
type: string
required:
- message
- phase
type: object
type: object
served: true
Expand Down
66 changes: 66 additions & 0 deletions bundle/manifests/integreatly.org_grafanas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ spec:
baseImage:
type: string
client:
description: Grafana API client settings
properties:
preferService:
type: boolean
timeout:
type: integer
type: object
config:
description: GrafanaConfig is the configuration for grafana
Expand Down Expand Up @@ -3301,6 +3307,66 @@ spec:
- config
type: object
status:
description: GrafanaStatus defines the observed state of Grafana
properties:
dashboards:
items:
description: Used to keep a dashboard reference without having access to the dashboard struct itself
properties:
folderId:
format: int64
type: integer
folderName:
type: string
hash:
type: string
name:
type: string
namespace:
type: string
uid:
type: string
required:
- folderId
- folderName
- hash
- name
- namespace
- uid
type: object
type: array
failedPlugins:
items:
description: GrafanaPlugin contains information about a single plugin
properties:
name:
type: string
version:
type: string
required:
- name
- version
type: object
type: array
installedPlugins:
items:
description: GrafanaPlugin contains information about a single plugin
properties:
name:
type: string
version:
type: string
required:
- name
- version
type: object
type: array
message:
type: string
phase:
type: string
previousServiceName:
type: string
type: object
type: object
served: true
Expand Down
2 changes: 0 additions & 2 deletions config/crd/bases/integreatly.org_grafanas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ spec:
type: boolean
timeout:
type: integer
required:
- preferService
type: object
config:
description: GrafanaConfig is the configuration for grafana
Expand Down
5 changes: 1 addition & 4 deletions controllers/grafana/grafana_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,7 @@ func (r *ReconcileGrafana) manageError(cr *grafanav1alpha1.Grafana, issue error,
func (r *ReconcileGrafana) getGrafanaAdminUrl(cr *grafanav1alpha1.Grafana, state *common.ClusterState) (string, error) {
// If preferService is true, we skip the routes and try to access grafana
// by using the service.
preferService := false
if cr.Spec.Client != nil {
preferService = cr.Spec.Client.PreferService
}
preferService := cr.GetPreferServiceValue()

// First try to use the route if it exists. Prefer the route because it also works
// when running the operator outside of the cluster
Expand Down
4 changes: 2 additions & 2 deletions controllers/grafana/grafana_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ func (i *GrafanaReconciler) getGrafanaReadiness(state *common.ClusterState, cr *
var actions []common.ClusterAction
cfg := config.GetControllerConfig()
openshift := cfg.GetConfigBool(config.ConfigOpenshift, false)
if openshift && cr.Spec.Ingress != nil && cr.Spec.Ingress.Enabled && (cr.Spec.Client == nil || !cr.Spec.Client.PreferService) {
if openshift && cr.Spec.Ingress != nil && cr.Spec.Ingress.Enabled && !cr.GetPreferServiceValue() {
// On OpenShift, check the route, only if preferService is false
actions = append(actions, common.RouteReadyAction{
Ref: state.GrafanaRoute,
Msg: "check route readiness",
})
}
if !openshift && cr.Spec.Ingress != nil && cr.Spec.Ingress.Enabled && (cr.Spec.Client == nil || !cr.Spec.Client.PreferService) {
if !openshift && cr.Spec.Ingress != nil && cr.Spec.Ingress.Enabled && !cr.GetPreferServiceValue() {
// On vanilla Kubernetes, check the ingress,only if preferService is false
actions = append(actions, common.IngressReadyAction{
Ref: state.GrafanaIngress,
Expand Down
2 changes: 2 additions & 0 deletions deploy/examples/Grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: Grafana
metadata:
name: example-grafana
spec:
client:
preferService: true
ingress:
enabled: True
pathType: Prefix
Expand Down

0 comments on commit fb8ed04

Please sign in to comment.