Skip to content

Commit

Permalink
feat: Define GrafanaCommonStatus struct, add it to resources that are…
Browse files Browse the repository at this point in the history
… ready
  • Loading branch information
Baarsgaard committed Nov 12, 2024
1 parent 54abb09 commit 9d89880
Show file tree
Hide file tree
Showing 19 changed files with 113 additions and 65 deletions.
13 changes: 13 additions & 0 deletions api/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// WARN Run `make` on all file changes

type ValueFrom struct {
TargetPath string `json:"targetPath"`
ValueFrom ValueFromSource `json:"valueFrom"`
Expand Down Expand Up @@ -37,3 +39,14 @@ type GrafanaCommonSpec struct {
// +optional
AllowCrossNamespaceImport *bool `json:"allowCrossNamespaceImport,omitempty"`
}

// The most recent observed state of a Grafana resource
type GrafanaCommonStatus struct {
// Detect resource changes
Hash string `json:"hash,omitempty"`
LastMessage string `json:"lastMessage,omitempty"`
// Last time the resource was synchronized
LastResync metav1.Time `json:"lastResync,omitempty"`
// Results when synchonizing resource with Grafana instances
Conditions []metav1.Condition `json:"conditions,omitempty"`
}
2 changes: 2 additions & 0 deletions api/v1beta1/grafanaalertrulegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ type AlertQuery struct {
RelativeTimeRange *models.RelativeTimeRange `json:"relativeTimeRange,omitempty"`
}

// TODO Implement GrafanaCommonStatus
// GrafanaAlertRuleGroupStatus defines the observed state of GrafanaAlertRuleGroup
type GrafanaAlertRuleGroupStatus struct {
// Results when synchonizing resource with Grafana instances
Conditions []metav1.Condition `json:"conditions"`
}

Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/grafanacontactpoint_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ type GrafanaContactPointSpec struct {
Type string `json:"type,omitempty"`
}

// TODO Implement GrafanaCommonStatus
// GrafanaContactPointStatus defines the observed state of GrafanaContactPoint
type GrafanaContactPointStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Results when synchonizing resource with Grafana instances
Conditions []metav1.Condition `json:"conditions"`
}

Expand Down
12 changes: 5 additions & 7 deletions api/v1beta1/grafanadashboard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,15 @@ type GrafanaComDashboardReference struct {

// GrafanaDashboardStatus defines the observed state of GrafanaDashboard
type GrafanaDashboardStatus struct {
GrafanaCommonStatus `json:",inline"`

ContentCache []byte `json:"contentCache,omitempty"`
ContentTimestamp metav1.Time `json:"contentTimestamp,omitempty"`
ContentUrl string `json:"contentUrl,omitempty"`
Hash string `json:"hash,omitempty"`
// TODO(V1) Remove
// The dashboard instanceSelector can't find matching grafana instances
NoMatchingInstances bool `json:"NoMatchingInstances,omitempty"`
// Last time the dashboard was resynced
LastResync metav1.Time `json:"lastResync,omitempty"`
UID string `json:"uid,omitempty"`

Conditions []metav1.Condition `json:"conditions,omitempty"`
NoMatchingInstances bool `json:"NoMatchingInstances,omitempty"`
UID string `json:"uid,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
9 changes: 3 additions & 6 deletions api/v1beta1/grafanafolder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,11 @@ type GrafanaFolderSpec struct {

// GrafanaFolderStatus defines the observed state of GrafanaFolder
type GrafanaFolderStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Hash string `json:"hash,omitempty"`
GrafanaCommonStatus `json:",inline"`

// TODO(V1) Remove
// The folder instanceSelector can't find matching grafana instances
NoMatchingInstances bool `json:"NoMatchingInstances,omitempty"`
// Last time the folder was resynced
LastResync metav1.Time `json:"lastResync,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/grafananotificationpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ func (r *Route) ToModelRoute() *models.Route {
return out
}

// TODO Implement GrafanaCommonStatus
// GrafanaNotificationPolicyStatus defines the observed state of GrafanaNotificationPolicy
type GrafanaNotificationPolicyStatus struct {
// Results when synchonizing resource with Grafana instances
Conditions []metav1.Condition `json:"conditions"`
}

Expand Down
41 changes: 25 additions & 16 deletions api/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ spec:
GrafanaAlertRuleGroup
properties:
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ spec:
description: GrafanaContactPointStatus defines the observed state of GrafanaContactPoint
properties:
conditions:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ spec:
instances
type: boolean
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down Expand Up @@ -480,9 +481,12 @@ spec:
contentUrl:
type: string
hash:
description: Detect resource changes
type: string
lastMessage:
type: string
lastResync:
description: Last time the dashboard was resynced
description: Last time the resource was synchronized
format: date-time
type: string
uid:
Expand Down
9 changes: 5 additions & 4 deletions config/crd/bases/grafana.integreatly.org_grafanafolders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ spec:
instances
type: boolean
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down Expand Up @@ -204,12 +205,12 @@ spec:
type: object
type: array
hash:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
description: Detect resource changes
type: string
lastMessage:
type: string
lastResync:
description: Last time the folder was resynced
description: Last time the resource was synchronized
format: date-time
type: string
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ spec:
of GrafanaNotificationPolicy
properties:
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ spec:
GrafanaAlertRuleGroup
properties:
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ spec:
description: GrafanaContactPointStatus defines the observed state of GrafanaContactPoint
properties:
conditions:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ spec:
instances
type: boolean
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down Expand Up @@ -480,9 +481,12 @@ spec:
contentUrl:
type: string
hash:
description: Detect resource changes
type: string
lastMessage:
type: string
lastResync:
description: Last time the dashboard was resynced
description: Last time the resource was synchronized
format: date-time
type: string
uid:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ spec:
instances
type: boolean
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down Expand Up @@ -204,12 +205,12 @@ spec:
type: object
type: array
hash:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
description: Detect resource changes
type: string
lastMessage:
type: string
lastResync:
description: Last time the folder was resynced
description: Last time the resource was synchronized
format: date-time
type: string
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ spec:
of GrafanaNotificationPolicy
properties:
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down
21 changes: 13 additions & 8 deletions deploy/kustomize/base/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ spec:
GrafanaAlertRuleGroup
properties:
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down Expand Up @@ -530,9 +531,7 @@ spec:
description: GrafanaContactPointStatus defines the observed state of GrafanaContactPoint
properties:
conditions:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down Expand Up @@ -1014,6 +1013,7 @@ spec:
instances
type: boolean
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down Expand Up @@ -1078,9 +1078,12 @@ spec:
contentUrl:
type: string
hash:
description: Detect resource changes
type: string
lastMessage:
type: string
lastResync:
description: Last time the dashboard was resynced
description: Last time the resource was synchronized
format: date-time
type: string
uid:
Expand Down Expand Up @@ -1510,6 +1513,7 @@ spec:
instances
type: boolean
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down Expand Up @@ -1566,12 +1570,12 @@ spec:
type: object
type: array
hash:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
description: Detect resource changes
type: string
lastMessage:
type: string
lastResync:
description: Last time the folder was resynced
description: Last time the resource was synchronized
format: date-time
type: string
type: object
Expand Down Expand Up @@ -1773,6 +1777,7 @@ spec:
of GrafanaNotificationPolicy
properties:
conditions:
description: Results when synchonizing resource with Grafana instances
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
Expand Down
Loading

0 comments on commit 9d89880

Please sign in to comment.