Skip to content

Commit e33c2c9

Browse files
committed
Add archive logs target CRD
1 parent 8c27675 commit e33c2c9

File tree

20 files changed

+2943
-4
lines changed

20 files changed

+2943
-4
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
CORALOGIX_REGION: ${{ secrets.CORALOGIX_REGION }}
2424
CORALOGIX_API_KEY: ${{ secrets.CORALOGIX_API_KEY }}
2525
SCOPE_RECONCILE_INTERVAL_SECONDS: 30
26+
AWS_REGION: ${{ secrets.AWS_REGION }}
27+
LOGS_BUCKET: ${{ secrets.LOGS_BUCKET }}
2628
steps:
2729
- name: Checkout
2830
uses: actions/checkout@v2

.github/workflows/helm-e2e-tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
IMG_TAG: 0.0.1
2020
CORALOGIX_REGION: ${{ secrets.CORALOGIX_REGION }}
2121
CORALOGIX_API_KEY: ${{ secrets.CORALOGIX_API_KEY }}
22+
AWS_REGION: ${{ secrets.AWS_REGION }}
23+
LOGS_BUCKET: ${{ secrets.LOGS_BUCKET }}
2224
steps:
2325
- name: Checkout
2426
uses: actions/checkout@v2
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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 v1alpha1
16+
17+
import (
18+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
19+
20+
cxsdk "github.com/coralogix/coralogix-management-sdk/go"
21+
)
22+
23+
// Added in version v1.0.0
24+
// ArchiveLogsTargetSpec defines the desired state of a Coralogix archive logs target.
25+
// +kubebuilder:validation:XValidation:rule="has(self.s3Target) != has(self.ibmCosTarget)",message="Exactly one of s3Target or ibmCosTarget must be specified"
26+
type ArchiveLogsTargetSpec struct {
27+
// The S3 target configuration.
28+
// +optional
29+
S3Target *S3Target `json:"s3Target,omitempty"`
30+
// The IBM COS target configuration.
31+
// +optional
32+
IbmCosTarget *IbmCosTarget `json:"ibmCosTarget,omitempty"`
33+
}
34+
35+
type S3Target struct {
36+
// The region of the S3 bucket.
37+
Region string `json:"region,omitempty"`
38+
Bucket string `json:"bucketName,omitempty"`
39+
}
40+
41+
type IbmCosTarget struct {
42+
// BucketCrn is the CRN of the IBM COS bucket.
43+
BucketCrn string `json:"bucketCrn,omitempty"`
44+
// Endpoint is the endpoint URL for the IBM COS service.
45+
Endpoint string `json:"endpoint,omitempty"`
46+
// ServiceCrn is the CRN of the service instance.
47+
// +optional
48+
ServiceCrn *string `json:"serviceCrn,omitempty"`
49+
// BucketType defines the type of the bucket.
50+
// +kubebuilder:validation:Enum=UNSPECIFIED;EXTERNAL;INTERNAL
51+
// +optional
52+
BucketType *string `json:"bucketType,omitempty"`
53+
}
54+
55+
type ArchiveLogsTargetStatus struct {
56+
// ID is the identifier of the archive logs target.
57+
ID *string `json:"id,omitempty"` // The ID of the archive logs target, if applicable.
58+
// +optional
59+
Conditions []metav1.Condition `json:"conditions,omitempty"`
60+
}
61+
62+
func (s *ArchiveLogsTargetSpec) ExtractSetTargetRequest(isTargetActive bool) (*cxsdk.SetTargetRequest, error) {
63+
if s.S3Target != nil {
64+
return &cxsdk.SetTargetRequest{
65+
IsActive: isTargetActive,
66+
TargetSpec: &cxsdk.SetTargetRequestS3{
67+
S3: &cxsdk.S3TargetSpec{
68+
Region: &s.S3Target.Region,
69+
Bucket: s.S3Target.Bucket,
70+
},
71+
},
72+
}, nil
73+
} else {
74+
var bucketType cxsdk.IbmBucketType
75+
if s.IbmCosTarget.BucketType != nil {
76+
switch *s.IbmCosTarget.BucketType {
77+
case "UNSPECIFIED":
78+
bucketType = cxsdk.IbmBucketTypeUnspecified
79+
case "EXTERNAL":
80+
bucketType = cxsdk.IbmBucketTypeExternal
81+
case "INTERNAL":
82+
bucketType = cxsdk.IbmBucketTypeInternal
83+
84+
}
85+
}
86+
87+
return &cxsdk.SetTargetRequest{
88+
IsActive: true,
89+
TargetSpec: &cxsdk.SetTargetRequestIbmCos{
90+
IbmCos: &cxsdk.IBMCosTargetSpec{
91+
BucketCrn: s.IbmCosTarget.BucketCrn,
92+
Endpoint: s.IbmCosTarget.Endpoint,
93+
ServiceCrn: s.IbmCosTarget.ServiceCrn,
94+
BucketType: &bucketType,
95+
},
96+
},
97+
}, nil
98+
}
99+
}
100+
101+
func (i *ArchiveLogsTarget) GetConditions() []metav1.Condition {
102+
return i.Status.Conditions
103+
}
104+
105+
func (i *ArchiveLogsTarget) SetConditions(conditions []metav1.Condition) {
106+
i.Status.Conditions = conditions
107+
}
108+
109+
// ArchiveLogsTarget is the Schema for the archive logs targets API.
110+
111+
// +kubebuilder:object:root=true
112+
// +kubebuilder:subresource:status
113+
type ArchiveLogsTarget struct {
114+
metav1.TypeMeta `json:",inline"`
115+
metav1.ObjectMeta `json:"metadata,omitempty"`
116+
117+
Spec ArchiveLogsTargetSpec `json:"spec,omitempty"`
118+
Status ArchiveLogsTargetStatus `json:"status,omitempty"`
119+
}
120+
121+
// ArchiveLogsTargetList contains a list of ArchiveLogsTarget.
122+
// +kubebuilder:object:root=true
123+
type ArchiveLogsTargetList struct {
124+
metav1.TypeMeta `json:",inline"`
125+
metav1.ListMeta `json:"metadata,omitempty"`
126+
Items []ArchiveLogsTarget `json:"items"`
127+
}
128+
129+
func init() {
130+
SchemeBuilder.Register(&ArchiveLogsTarget{}, &ArchiveLogsTargetList{})
131+
}

api/coralogix/v1alpha1/zz_generated.deepcopy.go

Lines changed: 151 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/coralogix-operator/templates/cluster_role.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ rules:
4949
- alerts
5050
- alertschedulers
5151
- apikeys
52+
- archivelogstargets
5253
- connectors
5354
- customroles
5455
- dashboards
@@ -80,6 +81,7 @@ rules:
8081
- alerts/finalizers
8182
- alertschedulers/finalizers
8283
- apikeys/finalizers
84+
- archivelogstargets/finalizers
8385
- connectors/finalizers
8486
- customroles/finalizers
8587
- dashboards/finalizers
@@ -105,6 +107,7 @@ rules:
105107
- alerts/status
106108
- alertschedulers/status
107109
- apikeys/status
110+
- archivelogstargets/status
108111
- connectors/status
109112
- customroles/status
110113
- dashboards/status

0 commit comments

Comments
 (0)