From 80e3ac86cd918949d66f15aa53529ffa5af65a1f Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 20 Nov 2024 21:54:59 +0100 Subject: [PATCH] refactor: Embed GrafanaCommonStatus into all crds --- api/v1beta1/grafana_types.go | 2 + api/v1beta1/grafanaalertrulegroup_types.go | 9 +- api/v1beta1/grafanacontactpoint_types.go | 11 +-- api/v1beta1/grafanadashboard_types.go | 4 +- api/v1beta1/grafanadatasource_types.go | 2 + api/v1beta1/grafanafolder_types.go | 7 +- .../grafananotificationpolicy_types.go | 9 +- api/v1beta1/zz_generated.deepcopy.go | 85 +------------------ 8 files changed, 19 insertions(+), 110 deletions(-) diff --git a/api/v1beta1/grafana_types.go b/api/v1beta1/grafana_types.go index 8d4f2406b..9e7c03635 100644 --- a/api/v1beta1/grafana_types.go +++ b/api/v1beta1/grafana_types.go @@ -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"` diff --git a/api/v1beta1/grafanaalertrulegroup_types.go b/api/v1beta1/grafanaalertrulegroup_types.go index d00d81f1e..b9c33512a 100644 --- a/api/v1beta1/grafanaalertrulegroup_types.go +++ b/api/v1beta1/grafanaalertrulegroup_types.go @@ -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 @@ -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. diff --git a/api/v1beta1/grafanacontactpoint_types.go b/api/v1beta1/grafanacontactpoint_types.go index e32488c92..429856fba 100644 --- a/api/v1beta1/grafanacontactpoint_types.go +++ b/api/v1beta1/grafanacontactpoint_types.go @@ -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 @@ -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 diff --git a/api/v1beta1/grafanadashboard_types.go b/api/v1beta1/grafanadashboard_types.go index 1ce879a83..95a5fece0 100644 --- a/api/v1beta1/grafanadashboard_types.go +++ b/api/v1beta1/grafanadashboard_types.go @@ -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"` @@ -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 diff --git a/api/v1beta1/grafanadatasource_types.go b/api/v1beta1/grafanadatasource_types.go index dbdcd5a4e..d5ab403aa 100644 --- a/api/v1beta1/grafanadatasource_types.go +++ b/api/v1beta1/grafanadatasource_types.go @@ -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 diff --git a/api/v1beta1/grafanafolder_types.go b/api/v1beta1/grafanafolder_types.go index 88b3ac0da..18c1f080d 100644 --- a/api/v1beta1/grafanafolder_types.go +++ b/api/v1beta1/grafanafolder_types.go @@ -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 diff --git a/api/v1beta1/grafananotificationpolicy_types.go b/api/v1beta1/grafananotificationpolicy_types.go index 6c74643e1..19cbc17d6 100644 --- a/api/v1beta1/grafananotificationpolicy_types.go +++ b/api/v1beta1/grafananotificationpolicy_types.go @@ -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 @@ -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 { diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 1aa3b1200..2331a7e51 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -513,28 +513,6 @@ func (in *GrafanaAlertRuleGroupSpec) DeepCopy() *GrafanaAlertRuleGroupSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GrafanaAlertRuleGroupStatus) DeepCopyInto(out *GrafanaAlertRuleGroupStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaAlertRuleGroupStatus. -func (in *GrafanaAlertRuleGroupStatus) DeepCopy() *GrafanaAlertRuleGroupStatus { - if in == nil { - return nil - } - out := new(GrafanaAlertRuleGroupStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaClient) DeepCopyInto(out *GrafanaClient) { *out = *in @@ -595,7 +573,6 @@ func (in *GrafanaComDashboardReference) DeepCopy() *GrafanaComDashboardReference // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaCommonStatus) DeepCopyInto(out *GrafanaCommonStatus) { *out = *in - in.LastResync.DeepCopyInto(&out.LastResync) if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]metav1.Condition, len(*in)) @@ -712,28 +689,6 @@ func (in *GrafanaContactPointSpec) DeepCopy() *GrafanaContactPointSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GrafanaContactPointStatus) DeepCopyInto(out *GrafanaContactPointStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaContactPointStatus. -func (in *GrafanaContactPointStatus) DeepCopy() *GrafanaContactPointStatus { - if in == nil { - return nil - } - out := new(GrafanaContactPointStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaDashboard) DeepCopyInto(out *GrafanaDashboard) { *out = *in @@ -927,6 +882,7 @@ func (in *GrafanaDashboardSpec) DeepCopy() *GrafanaDashboardSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaDashboardStatus) DeepCopyInto(out *GrafanaDashboardStatus) { *out = *in + in.GrafanaCommonStatus.DeepCopyInto(&out.GrafanaCommonStatus) if in.ContentCache != nil { in, out := &in.ContentCache, &out.ContentCache *out = make([]byte, len(*in)) @@ -934,13 +890,6 @@ func (in *GrafanaDashboardStatus) DeepCopyInto(out *GrafanaDashboardStatus) { } in.ContentTimestamp.DeepCopyInto(&out.ContentTimestamp) in.LastResync.DeepCopyInto(&out.LastResync) - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaDashboardStatus. @@ -1147,6 +1096,7 @@ func (in *GrafanaDatasourceSpec) DeepCopy() *GrafanaDatasourceSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaDatasourceStatus) DeepCopyInto(out *GrafanaDatasourceStatus) { *out = *in + in.GrafanaCommonStatus.DeepCopyInto(&out.GrafanaCommonStatus) in.LastResync.DeepCopyInto(&out.LastResync) } @@ -1247,14 +1197,8 @@ func (in *GrafanaFolderSpec) DeepCopy() *GrafanaFolderSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaFolderStatus) DeepCopyInto(out *GrafanaFolderStatus) { *out = *in + in.GrafanaCommonStatus.DeepCopyInto(&out.GrafanaCommonStatus) in.LastResync.DeepCopyInto(&out.LastResync) - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaFolderStatus. @@ -1389,28 +1333,6 @@ func (in *GrafanaNotificationPolicySpec) DeepCopy() *GrafanaNotificationPolicySp return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GrafanaNotificationPolicyStatus) DeepCopyInto(out *GrafanaNotificationPolicyStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaNotificationPolicyStatus. -func (in *GrafanaNotificationPolicyStatus) DeepCopy() *GrafanaNotificationPolicyStatus { - if in == nil { - return nil - } - out := new(GrafanaNotificationPolicyStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaPlugin) DeepCopyInto(out *GrafanaPlugin) { *out = *in @@ -1527,6 +1449,7 @@ func (in *GrafanaSpec) DeepCopy() *GrafanaSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GrafanaStatus) DeepCopyInto(out *GrafanaStatus) { *out = *in + in.GrafanaCommonStatus.DeepCopyInto(&out.GrafanaCommonStatus) if in.Dashboards != nil { in, out := &in.Dashboards, &out.Dashboards *out = make(NamespacedResourceList, len(*in))