Skip to content

Commit 82dc218

Browse files
authored
chore: Sort telemetry.kyma-project.io API types (v1alpha1 and v1beta1) (#1564)
1 parent a3d4f8b commit 82dc218

Some content is hidden

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

43 files changed

+809
-826
lines changed

apis/telemetry/v1alpha1/logparser_types.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121
)
2222

23-
// LogParserSpec defines the desired state of LogParser.
24-
type LogParserSpec struct {
25-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
26-
// Important: Run "make" to regenerate code after modifying this file
23+
//nolint:gochecknoinits // SchemeBuilder's registration is required.
24+
func init() {
25+
SchemeBuilder.Register(&LogParser{}, &LogParserList{})
26+
}
2727

28-
// [Fluent Bit Parsers](https://docs.fluentbit.io/manual/pipeline/parsers). The parser specified here has no effect until it is referenced by a [Pod annotation](https://docs.fluentbit.io/manual/pipeline/filters/kubernetes#kubernetes-annotations) on your workload or by a [Parser Filter](https://docs.fluentbit.io/manual/pipeline/filters/parser) defined in a pipeline's filters section.
29-
Parser string `json:"parser,omitempty"`
28+
// +kubebuilder:object:root=true
29+
// LogParserList contains a list of LogParser.
30+
type LogParserList struct {
31+
metav1.TypeMeta `json:",inline"`
32+
metav1.ListMeta `json:"metadata,omitempty"`
33+
Items []LogParser `json:"items"`
3034
}
3135

3236
// +kubebuilder:object:root=true
@@ -35,7 +39,6 @@ type LogParserSpec struct {
3539
// +kubebuilder:printcolumn:name="Agent Healthy",type=string,JSONPath=`.status.conditions[?(@.type=="AgentHealthy")].status`
3640
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
3741
// +kubebuilder:deprecatedversion:warning="The LogParser API is deprecated. Instead, log in JSON format and use the JSON parsing feature of the LogPipeline"
38-
3942
// LogParser is the Schema for the logparsers API.
4043
type LogParser struct {
4144
metav1.TypeMeta `json:",inline"`
@@ -46,22 +49,17 @@ type LogParser struct {
4649
Status LogParserStatus `json:"status,omitempty"`
4750
}
4851

49-
// +kubebuilder:object:root=true
52+
// LogParserSpec defines the desired state of LogParser.
53+
type LogParserSpec struct {
54+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
55+
// Important: Run "make" to regenerate code after modifying this file
5056

51-
// LogParserList contains a list of LogParser.
52-
type LogParserList struct {
53-
metav1.TypeMeta `json:",inline"`
54-
metav1.ListMeta `json:"metadata,omitempty"`
55-
Items []LogParser `json:"items"`
57+
// [Fluent Bit Parsers](https://docs.fluentbit.io/manual/pipeline/parsers). The parser specified here has no effect until it is referenced by a [Pod annotation](https://docs.fluentbit.io/manual/pipeline/filters/kubernetes#kubernetes-annotations) on your workload or by a [Parser Filter](https://docs.fluentbit.io/manual/pipeline/filters/parser) defined in a pipeline's filters section.
58+
Parser string `json:"parser,omitempty"`
5659
}
5760

5861
// LogParserStatus shows the observed state of the LogParser.
5962
type LogParserStatus struct {
6063
// An array of conditions describing the status of the parser.
6164
Conditions []metav1.Condition `json:"conditions,omitempty"`
6265
}
63-
64-
//nolint:gochecknoinits // SchemeBuilder's registration is required.
65-
func init() {
66-
SchemeBuilder.Register(&LogParser{}, &LogParserList{})
67-
}

apis/telemetry/v1alpha1/logpipeline_conversion.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (lp *LogPipeline) ConvertTo(dstRaw conversion.Hub) error {
4343
Port: srcHTTPOutput.Port,
4444
Compress: srcHTTPOutput.Compress,
4545
Format: srcHTTPOutput.Format,
46-
TLSConfig: v1Alpha1TLSToV1Beta1(srcHTTPOutput.TLSConfig),
46+
TLSConfig: v1Alpha1TLSToV1Beta1(srcHTTPOutput.TLS),
4747
Dedot: srcHTTPOutput.Dedot,
4848
}
4949
}
@@ -86,19 +86,19 @@ func v1Alpha1OTLPInputToV1Beta1(otlp *OTLPInput) *telemetryv1beta1.OTLPInput {
8686
return input
8787
}
8888

89-
func v1Alpha1ApplicationToV1Beta1(application *ApplicationInput) *telemetryv1beta1.LogPipelineRuntimeInput {
89+
func v1Alpha1ApplicationToV1Beta1(application *LogPipelineApplicationInput) *telemetryv1beta1.LogPipelineRuntimeInput {
9090
if application == nil {
9191
return nil
9292
}
9393

9494
runtime := &telemetryv1beta1.LogPipelineRuntimeInput{
9595
Enabled: application.Enabled,
96-
Namespaces: telemetryv1beta1.LogPipelineInputNamespaces{
96+
Namespaces: telemetryv1beta1.LogPipelineNamespaceSelector{
9797
Include: application.Namespaces.Include,
9898
Exclude: application.Namespaces.Exclude,
9999
System: application.Namespaces.System,
100100
},
101-
Containers: telemetryv1beta1.LogPipelineInputContainers{
101+
Containers: telemetryv1beta1.LogPipelineContainerSelector{
102102
Include: application.Containers.Include,
103103
Exclude: application.Containers.Exclude,
104104
},
@@ -190,7 +190,7 @@ func v1Alpha1ValueTypeToV1Beta1(src ValueType) telemetryv1beta1.ValueType {
190190
}
191191
}
192192

193-
func v1Alpha1TLSToV1Beta1(src TLSConfig) telemetryv1beta1.OutputTLS {
193+
func v1Alpha1TLSToV1Beta1(src LogPipelineOutputTLS) telemetryv1beta1.OutputTLS {
194194
var dst telemetryv1beta1.OutputTLS
195195

196196
if src.CA != nil {
@@ -229,24 +229,24 @@ func (lp *LogPipeline) ConvertFrom(srcRaw conversion.Hub) error {
229229
dst.Spec.Input.OTLP = v1Beta1OTLPInputToV1Alpha1(src.Spec.Input.OTLP)
230230

231231
for _, f := range src.Spec.Files {
232-
dst.Spec.Files = append(dst.Spec.Files, FileMount(f))
232+
dst.Spec.Files = append(dst.Spec.Files, LogPipelineFileMount(f))
233233
}
234234

235235
for _, f := range src.Spec.Filters {
236-
dst.Spec.Filters = append(dst.Spec.Filters, Filter(f))
236+
dst.Spec.Filters = append(dst.Spec.Filters, LogPipelineFilter(f))
237237
}
238238

239239
if srcHTTPOutput := src.Spec.Output.HTTP; srcHTTPOutput != nil {
240-
dst.Spec.Output.HTTP = &HTTPOutput{
241-
Host: v1Beta1ValueTypeToV1Alpha1(srcHTTPOutput.Host),
242-
User: v1Beta1ValueTypeToV1Alpha1(srcHTTPOutput.User),
243-
Password: v1Beta1ValueTypeToV1Alpha1(srcHTTPOutput.Password),
244-
URI: srcHTTPOutput.URI,
245-
Port: srcHTTPOutput.Port,
246-
Compress: srcHTTPOutput.Compress,
247-
Format: srcHTTPOutput.Format,
248-
TLSConfig: v1Beta1TLSToV1Alpha1(srcHTTPOutput.TLSConfig),
249-
Dedot: srcHTTPOutput.Dedot,
240+
dst.Spec.Output.HTTP = &LogPipelineHTTPOutput{
241+
Host: v1Beta1ValueTypeToV1Alpha1(srcHTTPOutput.Host),
242+
User: v1Beta1ValueTypeToV1Alpha1(srcHTTPOutput.User),
243+
Password: v1Beta1ValueTypeToV1Alpha1(srcHTTPOutput.Password),
244+
URI: srcHTTPOutput.URI,
245+
Port: srcHTTPOutput.Port,
246+
Compress: srcHTTPOutput.Compress,
247+
Format: srcHTTPOutput.Format,
248+
TLS: v1Beta1TLSToV1Alpha1(srcHTTPOutput.TLSConfig),
249+
Dedot: srcHTTPOutput.Dedot,
250250
}
251251
}
252252

@@ -270,19 +270,19 @@ func (lp *LogPipeline) ConvertFrom(srcRaw conversion.Hub) error {
270270
return nil
271271
}
272272

273-
func v1Beta1RuntimeToV1Alpha1(runtime *telemetryv1beta1.LogPipelineRuntimeInput) *ApplicationInput {
273+
func v1Beta1RuntimeToV1Alpha1(runtime *telemetryv1beta1.LogPipelineRuntimeInput) *LogPipelineApplicationInput {
274274
if runtime == nil {
275275
return nil
276276
}
277277

278-
application := &ApplicationInput{
278+
application := &LogPipelineApplicationInput{
279279
Enabled: runtime.Enabled,
280-
Namespaces: InputNamespaces{
280+
Namespaces: LogPipelineNamespaceSelector{
281281
Include: runtime.Namespaces.Include,
282282
Exclude: runtime.Namespaces.Exclude,
283283
System: runtime.Namespaces.System,
284284
},
285-
Containers: InputContainers{
285+
Containers: LogPipelineContainerSelector{
286286
Include: runtime.Containers.Include,
287287
Exclude: runtime.Containers.Exclude,
288288
},
@@ -378,8 +378,8 @@ func v1Beta1BasicAuthOptionsToV1Alpha1(basic *telemetryv1beta1.BasicAuthOptions)
378378
}
379379
}
380380

381-
func v1Beta1TLSToV1Alpha1(src telemetryv1beta1.OutputTLS) TLSConfig {
382-
var dst TLSConfig
381+
func v1Beta1TLSToV1Alpha1(src telemetryv1beta1.OutputTLS) LogPipelineOutputTLS {
382+
var dst LogPipelineOutputTLS
383383

384384
if src.CA != nil {
385385
ca := v1Beta1ValueTypeToV1Alpha1(*src.CA)

apis/telemetry/v1alpha1/logpipeline_conversion_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ func TestConvertTo(t *testing.T) {
1717
Name: "log-pipeline-test",
1818
},
1919
Spec: LogPipelineSpec{
20-
Input: Input{
21-
Application: &ApplicationInput{
20+
Input: LogPipelineInput{
21+
Application: &LogPipelineApplicationInput{
2222
Enabled: ptr.To(true),
23-
Namespaces: InputNamespaces{
23+
Namespaces: LogPipelineNamespaceSelector{
2424
Include: []string{"default", "kube-system"},
2525
Exclude: []string{"kube-public"},
2626
System: true,
2727
},
28-
Containers: InputContainers{
28+
Containers: LogPipelineContainerSelector{
2929
Include: []string{"nginx", "app"},
3030
Exclude: []string{"sidecar"},
3131
},
@@ -41,15 +41,15 @@ func TestConvertTo(t *testing.T) {
4141
},
4242
},
4343
},
44-
Files: []FileMount{
44+
Files: []LogPipelineFileMount{
4545
{Name: "file1", Content: "file1-content"},
4646
},
47-
Filters: []Filter{
47+
Filters: []LogPipelineFilter{
4848
{Custom: "name stdout"},
4949
},
50-
Output: Output{
50+
Output: LogPipelineOutput{
5151
Custom: "custom-output",
52-
HTTP: &HTTPOutput{
52+
HTTP: &LogPipelineHTTPOutput{
5353
Host: ValueType{
5454
Value: "http://localhost",
5555
},
@@ -69,7 +69,7 @@ func TestConvertTo(t *testing.T) {
6969
Port: "8080",
7070
Compress: "on",
7171
Format: "json",
72-
TLSConfig: TLSConfig{
72+
TLS: LogPipelineOutputTLS{
7373
SkipCertificateValidation: true,
7474
CA: &ValueType{
7575
Value: "ca",
@@ -166,12 +166,12 @@ func TestConvertFrom(t *testing.T) {
166166
Input: telemetryv1beta1.LogPipelineInput{
167167
Runtime: &telemetryv1beta1.LogPipelineRuntimeInput{
168168
Enabled: ptr.To(true),
169-
Namespaces: telemetryv1beta1.LogPipelineInputNamespaces{
169+
Namespaces: telemetryv1beta1.LogPipelineNamespaceSelector{
170170
Include: []string{"default", "kube-system"},
171171
Exclude: []string{"kube-public"},
172172
System: true,
173173
},
174-
Containers: telemetryv1beta1.LogPipelineInputContainers{
174+
Containers: telemetryv1beta1.LogPipelineContainerSelector{
175175
Include: []string{"nginx", "app"},
176176
Exclude: []string{"sidecar"},
177177
},
@@ -332,10 +332,10 @@ func requireLogPipelinesEquivalent(t *testing.T, x *LogPipeline, y *telemetryv1b
332332
require.Equal(t, xHTTP.Port, yHTTP.Port, "HTTP port mismatch")
333333
require.Equal(t, xHTTP.Compress, yHTTP.Compress, "HTTP compress mismatch")
334334
require.Equal(t, xHTTP.Format, yHTTP.Format, "HTTP format mismatch")
335-
require.Equal(t, xHTTP.TLSConfig.SkipCertificateValidation, yHTTP.TLSConfig.SkipCertificateValidation, "HTTP TLS skip certificate validation mismatch")
336-
require.Equal(t, xHTTP.TLSConfig.CA.Value, yHTTP.TLSConfig.CA.Value, "HTTP TLS CA mismatch")
337-
require.Equal(t, xHTTP.TLSConfig.Cert.Value, yHTTP.TLSConfig.Cert.Value, "HTTP TLS cert mismatch")
338-
require.Equal(t, xHTTP.TLSConfig.Key.Value, yHTTP.TLSConfig.Key.Value, "HTTP TLS key mismatch")
335+
require.Equal(t, xHTTP.TLS.SkipCertificateValidation, yHTTP.TLSConfig.SkipCertificateValidation, "HTTP TLS skip certificate validation mismatch")
336+
require.Equal(t, xHTTP.TLS.CA.Value, yHTTP.TLSConfig.CA.Value, "HTTP TLS CA mismatch")
337+
require.Equal(t, xHTTP.TLS.Cert.Value, yHTTP.TLSConfig.Cert.Value, "HTTP TLS cert mismatch")
338+
require.Equal(t, xHTTP.TLS.Key.Value, yHTTP.TLSConfig.Key.Value, "HTTP TLS key mismatch")
339339

340340
xOTLP := x.Spec.Output.OTLP
341341
yOTLP := y.Spec.Output.OTLP

0 commit comments

Comments
 (0)