Skip to content

Commit

Permalink
refactor: Embed GrafanaCommonStatus into all crds
Browse files Browse the repository at this point in the history
  • Loading branch information
Baarsgaard committed Nov 20, 2024
1 parent afe0801 commit 80e3ac8
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 110 deletions.
2 changes: 2 additions & 0 deletions api/v1beta1/grafana_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ type GrafanaPreferences struct {

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

Stage OperatorStageName `json:"stage,omitempty"`
StageStatus OperatorStageStatus `json:"stageStatus,omitempty"`
LastMessage string `json:"lastMessage,omitempty"`
Expand Down
9 changes: 2 additions & 7 deletions api/v1beta1/grafanaalertrulegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ type AlertQuery struct {
RelativeTimeRange *models.RelativeTimeRange `json:"relativeTimeRange,omitempty"`
}

// GrafanaAlertRuleGroupStatus defines the observed state of GrafanaAlertRuleGroup
type GrafanaAlertRuleGroupStatus struct {
Conditions []metav1.Condition `json:"conditions"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand All @@ -143,8 +138,8 @@ type GrafanaAlertRuleGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GrafanaAlertRuleGroupSpec `json:"spec,omitempty"`
Status GrafanaAlertRuleGroupStatus `json:"status,omitempty"`
Spec GrafanaAlertRuleGroupSpec `json:"spec,omitempty"`
Status GrafanaCommonStatus `json:"status,omitempty"`
}

// GroupName returns the name of alert rule group.
Expand Down
11 changes: 2 additions & 9 deletions api/v1beta1/grafanacontactpoint_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ type GrafanaContactPointSpec struct {
AllowCrossNamespaceImport *bool `json:"allowCrossNamespaceImport,omitempty"`
}

// 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
Conditions []metav1.Condition `json:"conditions"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand All @@ -77,8 +70,8 @@ type GrafanaContactPoint struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GrafanaContactPointSpec `json:"spec,omitempty"`
Status GrafanaContactPointStatus `json:"status,omitempty"`
Spec GrafanaContactPointSpec `json:"spec,omitempty"`
Status GrafanaCommonStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/grafanadashboard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ 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"`
Expand All @@ -189,8 +191,6 @@ type GrafanaDashboardStatus struct {
// Last time the dashboard was resynced
LastResync metav1.Time `json:"lastResync,omitempty"`
UID string `json:"uid,omitempty"`

Conditions []metav1.Condition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/grafanadatasource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ type GrafanaDatasourceSpec struct {

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

Hash string `json:"hash,omitempty"`
LastMessage string `json:"lastMessage,omitempty"`
// The datasource instanceSelector can't find matching grafana instances
Expand Down
7 changes: 3 additions & 4 deletions api/v1beta1/grafanafolder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@ 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
GrafanaCommonStatus `json:",inline"`

Hash string `json:"hash,omitempty"`
// 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"`
LastResync metav1.Time `json:"lastResync,omitempty"`
}

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

// GrafanaNotificationPolicyStatus defines the observed state of GrafanaNotificationPolicy
type GrafanaNotificationPolicyStatus struct {
Conditions []metav1.Condition `json:"conditions"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand All @@ -149,8 +144,8 @@ type GrafanaNotificationPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GrafanaNotificationPolicySpec `json:"spec,omitempty"`
Status GrafanaNotificationPolicyStatus `json:"status,omitempty"`
Spec GrafanaNotificationPolicySpec `json:"spec,omitempty"`
Status GrafanaCommonStatus `json:"status,omitempty"`
}

func (np *GrafanaNotificationPolicy) NamespacedResource() string {
Expand Down
85 changes: 4 additions & 81 deletions api/v1beta1/zz_generated.deepcopy.go

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

0 comments on commit 80e3ac8

Please sign in to comment.