Skip to content

Commit 3f549d8

Browse files
authored
Use CoralogixReconciler for ApiKey (#416)
1 parent 69f666f commit 3f549d8

File tree

68 files changed

+243
-247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+243
-247
lines changed

api/coralogix/object.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2024 Coralogix Ltd.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package coralogix
16+
17+
import (
18+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
19+
"sigs.k8s.io/controller-runtime/pkg/client"
20+
)
21+
22+
// Object is an interface that extends the client.Object interface with Coralogix-specific methods.
23+
type Object interface {
24+
client.Object
25+
HasIDInStatus() bool
26+
GetConditions() []metav1.Condition
27+
SetConditions(conditions []metav1.Condition)
28+
}

api/coralogix/v1alpha1/alertscheduler_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ func (a *AlertScheduler) SetConditions(conditions []metav1.Condition) {
221221
a.Status.Conditions = conditions
222222
}
223223

224+
func (a *AlertScheduler) HasIDInStatus() bool {
225+
return a.Status.ID != nil && *a.Status.ID != ""
226+
}
227+
224228
func (a *AlertScheduler) ExtractCreateAlertSchedulerRequest() (*cxsdk.CreateAlertSchedulerRuleRequest, error) {
225229
alertScheduler, err := a.extractAlertScheduler()
226230
if err != nil {

api/coralogix/v1alpha1/apikey_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ func (a *ApiKey) SetConditions(conditions []metav1.Condition) {
7575
a.Status.Conditions = conditions
7676
}
7777

78+
func (a *ApiKey) HasIDInStatus() bool {
79+
return a.Status.Id != nil && *a.Status.Id != ""
80+
}
81+
7882
// +kubebuilder:object:root=true
7983
// +kubebuilder:subresource:status
8084
// ApiKey is the Schema for the ApiKeys API.

api/coralogix/v1alpha1/archivelogstarget_types.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,16 @@ func (s *ArchiveLogsTargetSpec) ExtractSetTargetRequest(isTargetActive bool) (*c
9696
}, nil
9797
}
9898

99-
func (i *ArchiveLogsTarget) GetConditions() []metav1.Condition {
100-
return i.Status.Conditions
99+
func (a *ArchiveLogsTarget) GetConditions() []metav1.Condition {
100+
return a.Status.Conditions
101101
}
102102

103-
func (i *ArchiveLogsTarget) SetConditions(conditions []metav1.Condition) {
104-
i.Status.Conditions = conditions
103+
func (a *ArchiveLogsTarget) SetConditions(conditions []metav1.Condition) {
104+
a.Status.Conditions = conditions
105+
}
106+
107+
func (a *ArchiveLogsTarget) HasIDInStatus() bool {
108+
return a.Status.ID != nil && *a.Status.ID != ""
105109
}
106110

107111
// +kubebuilder:object:root=true

api/coralogix/v1alpha1/archivemetricstarget_types.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,16 @@ func (s *ArchiveMetricsTargetSpec) ExtractUpdateRequest() (*cxsdk.UpdateTenantRe
126126
}, nil
127127
}
128128

129-
func (i *ArchiveMetricsTarget) GetConditions() []metav1.Condition {
130-
return i.Status.Conditions
129+
func (a *ArchiveMetricsTarget) GetConditions() []metav1.Condition {
130+
return a.Status.Conditions
131131
}
132132

133-
func (i *ArchiveMetricsTarget) SetConditions(conditions []metav1.Condition) {
134-
i.Status.Conditions = conditions
133+
func (a *ArchiveMetricsTarget) SetConditions(conditions []metav1.Condition) {
134+
a.Status.Conditions = conditions
135+
}
136+
137+
func (a *ArchiveMetricsTarget) HasIDInStatus() bool {
138+
return a.Status.ID != nil && *a.Status.ID != ""
135139
}
136140

137141
// +kubebuilder:object:root=true

api/coralogix/v1alpha1/connector_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ func (c *Connector) SetConditions(conditions []metav1.Condition) {
8989
c.Status.Conditions = conditions
9090
}
9191

92+
func (c *Connector) HasIDInStatus() bool {
93+
return c.Status.Id != nil && *c.Status.Id != ""
94+
}
95+
9296
var (
9397
schemaToProtoConnectorType = map[string]cxsdk.ConnectorType{
9498
"slack": cxsdk.ConnectorTypeSlack,

api/coralogix/v1alpha1/customrole_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ func (c *CustomRole) SetConditions(conditions []metav1.Condition) {
7777
c.Status.Conditions = conditions
7878
}
7979

80+
func (c *CustomRole) HasIDInStatus() bool {
81+
return c.Status.ID != nil && *c.Status.ID != ""
82+
}
83+
8084
// +kubebuilder:object:root=true
8185
// +kubebuilder:subresource:status
8286

api/coralogix/v1alpha1/dashboard_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ func (d *Dashboard) SetConditions(conditions []metav1.Condition) {
166166
d.Status.Conditions = conditions
167167
}
168168

169+
func (d *Dashboard) HasIDInStatus() bool {
170+
return d.Status.ID != nil && *d.Status.ID != ""
171+
}
172+
169173
// +kubebuilder:object:root=true
170174
// +kubebuilder:storageversion
171175
// +kubebuilder:conversion:hub

api/coralogix/v1alpha1/dashboardsfolder_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ func (df *DashboardsFolder) SetConditions(conditions []metav1.Condition) {
101101
df.Status.Conditions = conditions
102102
}
103103

104+
func (df *DashboardsFolder) HasIDInStatus() bool {
105+
return df.Status.ID != nil && *df.Status.ID != ""
106+
}
107+
104108
// +kubebuilder:object:root=true
105109
// +kubebuilder:subresource:status
106110

api/coralogix/v1alpha1/events2metric_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ func (e2m *Events2Metric) SetConditions(conditions []metav1.Condition) {
234234
e2m.Status.Conditions = conditions
235235
}
236236

237+
func (e2m *Events2Metric) HasIDInStatus() bool {
238+
return e2m.Status.Id != nil && *e2m.Status.Id != ""
239+
}
240+
237241
// +kubebuilder:object:root=true
238242
// +kubebuilder:subresource:status
239243
// See also https://coralogix.com/docs/user-guides/monitoring-and-insights/events2metrics/

0 commit comments

Comments
 (0)