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 csv 4.0 #522

Merged
merged 4 commits into from
Sep 18, 2021
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
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