Skip to content

Commit

Permalink
chore: Unify TLS settings for logpipeline beta1 (#1495)
Browse files Browse the repository at this point in the history
Co-authored-by: Stanislav Khalash <stanislav.khalash@sap.com>
Co-authored-by: Hisar Balik <hisar.balik@sap.com>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent edaab6a commit cf42a50
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 80 deletions.
20 changes: 10 additions & 10 deletions apis/telemetry/v1alpha1/logpipeline_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ func (lp *LogPipeline) ConvertTo(dstRaw conversion.Hub) error {
return nil
}

func v1Alpha1OtlpTLSToV1Beta1(tls *OtlpTLS) *telemetryv1beta1.OTLPTLS {
func v1Alpha1OtlpTLSToV1Beta1(tls *OtlpTLS) *telemetryv1beta1.OutputTLS {
if tls == nil {
return nil
}

betaTLS := &telemetryv1beta1.OTLPTLS{
Insecure: tls.Insecure,
InsecureSkipVerify: tls.InsecureSkipVerify,
betaTLS := &telemetryv1beta1.OutputTLS{
Disabled: tls.Insecure,
SkipCertificateValidation: tls.InsecureSkipVerify,
}

if tls.CA != nil {
Expand Down Expand Up @@ -150,8 +150,8 @@ func v1Alpha1ValueTypeToV1Beta1(src ValueType) telemetryv1beta1.ValueType {
}
}

func v1Alpha1TLSToV1Beta1(src TLSConfig) telemetryv1beta1.LogPipelineHTTPOutputTLS {
var dst telemetryv1beta1.LogPipelineHTTPOutputTLS
func v1Alpha1TLSToV1Beta1(src TLSConfig) telemetryv1beta1.OutputTLS {
var dst telemetryv1beta1.OutputTLS

if src.CA != nil {
ca := v1Alpha1ValueTypeToV1Beta1(*src.CA)
Expand Down Expand Up @@ -236,14 +236,14 @@ func (lp *LogPipeline) ConvertFrom(srcRaw conversion.Hub) error {
return nil
}

func v1Beta1OtlpTLSToV1Alpha1(tls *telemetryv1beta1.OTLPTLS) *OtlpTLS {
func v1Beta1OtlpTLSToV1Alpha1(tls *telemetryv1beta1.OutputTLS) *OtlpTLS {
if tls == nil {
return nil
}

alphaTLS := &OtlpTLS{
Insecure: tls.Insecure,
InsecureSkipVerify: tls.InsecureSkipVerify,
Insecure: tls.Disabled,
InsecureSkipVerify: tls.SkipCertificateValidation,
}

if tls.CA != nil {
Expand Down Expand Up @@ -296,7 +296,7 @@ func v1Beta1BasicAuthOptionsToV1Alpha1(basic *telemetryv1beta1.BasicAuthOptions)
}
}

func v1Beta1TLSToV1Alpha1(src telemetryv1beta1.LogPipelineHTTPOutputTLS) TLSConfig {
func v1Beta1TLSToV1Alpha1(src telemetryv1beta1.OutputTLS) TLSConfig {
var dst TLSConfig
if src.CA != nil {
ca := v1Beta1ValueTypeToV1Alpha1(*src.CA)
Expand Down
18 changes: 9 additions & 9 deletions apis/telemetry/v1alpha1/logpipeline_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestConvertFrom(t *testing.T) {
Port: "8080",
Compress: "on",
Format: "json",
TLSConfig: telemetryv1beta1.LogPipelineHTTPOutputTLS{
TLSConfig: telemetryv1beta1.OutputTLS{
SkipCertificateValidation: true,
CA: &telemetryv1beta1.ValueType{
Value: "ca",
Expand Down Expand Up @@ -243,12 +243,12 @@ func TestConvertFrom(t *testing.T) {
Prefix: "prefix2",
},
},
TLS: &telemetryv1beta1.OTLPTLS{
Insecure: true,
InsecureSkipVerify: true,
CA: &telemetryv1beta1.ValueType{Value: "ca"},
Cert: &telemetryv1beta1.ValueType{Value: "cert"},
Key: &telemetryv1beta1.ValueType{Value: "key"},
TLS: &telemetryv1beta1.OutputTLS{
Disabled: true,
SkipCertificateValidation: true,
CA: &telemetryv1beta1.ValueType{Value: "ca"},
Cert: &telemetryv1beta1.ValueType{Value: "cert"},
Key: &telemetryv1beta1.ValueType{Value: "key"},
},
},
},
Expand Down Expand Up @@ -333,8 +333,8 @@ func requireLogPipelinesEquivalent(t *testing.T, x *LogPipeline, y *telemetryv1b
require.Equal(t, xOTLP.Headers[1].Name, yOTLP.Headers[1].Name, "OTLP header name mismatch")
require.Equal(t, xOTLP.Headers[1].ValueType.Value, yOTLP.Headers[1].ValueType.Value, "OTLP header value mismatch")
require.Equal(t, xOTLP.Headers[1].Prefix, yOTLP.Headers[1].Prefix, "OTLP header prefix mismatch")
require.Equal(t, xOTLP.TLS.Insecure, yOTLP.TLS.Insecure, "OTLP TLS insecure mismatch")
require.Equal(t, xOTLP.TLS.InsecureSkipVerify, yOTLP.TLS.InsecureSkipVerify, "OTLP TLS insecure skip verify mismatch")
require.Equal(t, xOTLP.TLS.Insecure, yOTLP.TLS.Disabled, "OTLP TLS insecure mismatch")
require.Equal(t, xOTLP.TLS.InsecureSkipVerify, yOTLP.TLS.SkipCertificateValidation, "OTLP TLS insecure skip verify mismatch")
require.Equal(t, xOTLP.TLS.CA.Value, yOTLP.TLS.CA.Value, "OTLP TLS CA mismatch")
require.Equal(t, xOTLP.TLS.Cert.Value, yOTLP.TLS.Cert.Value, "OTLP TLS cert mismatch")
require.Equal(t, xOTLP.TLS.Key.Value, yOTLP.TLS.Key.Value, "OTLP TLS key mismatch")
Expand Down
4 changes: 2 additions & 2 deletions apis/telemetry/v1beta1/logpipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ type LogPipelineHTTPOutput struct {
// Data format to be used in the HTTP request body. Default is `json`.
Format string `json:"format,omitempty"`
// Configures TLS for the HTTP target server.
TLSConfig LogPipelineHTTPOutputTLS `json:"tls,omitempty"`
TLSConfig OutputTLS `json:"tls,omitempty"`
// Enables de-dotting of Kubernetes labels and annotations for compatibility with ElasticSearch based backends. Dots (.) will be replaced by underscores (_). Default is `false`.
Dedot bool `json:"dedot,omitempty"`
}

// +kubebuilder:validation:XValidation:rule="has(self.cert) == has(self.key)", message="Can define either both 'cert' and 'key', or neither"
type LogPipelineHTTPOutputTLS struct {
type OutputTLS struct {
// Indicates if TLS is disabled or enabled. Default is `false`.
Disabled bool `json:"disabled,omitempty"`
// If `true`, the validation of certificates is skipped. Default is `false`.
Expand Down
2 changes: 1 addition & 1 deletion apis/telemetry/v1beta1/secret_refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func getRefsInOTLPOutput(OTLPOut *OTLPOutput) []SecretKeyRef {
refs = appendIfSecretRef(refs, header.ValueType)
}

if OTLPOut.TLS != nil && !OTLPOut.TLS.Insecure {
if OTLPOut.TLS != nil && !OTLPOut.TLS.Disabled {
if OTLPOut.TLS.CA != nil {
refs = appendIfSecretRef(refs, *OTLPOut.TLS.CA)
}
Expand Down
8 changes: 4 additions & 4 deletions apis/telemetry/v1beta1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ type Header struct {

// +kubebuilder:validation:XValidation:rule="has(self.cert) == has(self.key)", message="Can define either both 'cert' and 'key', or neither"
type OTLPTLS struct {
// Defines whether to send requests using plaintext instead of TLS.
Insecure bool `json:"insecure,omitempty"`
// Defines whether to send requests using plaintext instead of TLS. Default is false.
Disabled bool `json:"disabled,omitempty"`
// Defines whether to skip server certificate verification when using TLS.
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
SkipCertificateValidation bool `json:"SkipCertificateValidation,omitempty"`
// Defines an optional CA certificate for server certificate verification when using TLS. The certificate must be provided in PEM format.
CA *ValueType `json:"ca,omitempty"`
// Defines a client certificate to use when using TLS. The certificate must be provided in PEM format.
Expand Down Expand Up @@ -95,7 +95,7 @@ type OTLPOutput struct {
// Defines custom headers to be added to outgoing HTTP or GRPC requests.
Headers []Header `json:"headers,omitempty"`
// Defines TLS options for the OTLP output.
TLS *OTLPTLS `json:"tls,omitempty"`
TLS *OutputTLS `json:"tls,omitempty"`
}

type AuthenticationOptions struct {
Expand Down
62 changes: 31 additions & 31 deletions apis/telemetry/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -1378,13 +1378,9 @@ spec:
type: object
type: object
type: object
insecure:
description: Defines whether to send requests using plaintext
instead of TLS.
type: boolean
insecureSkipVerify:
description: Defines whether to skip server certificate
verification when using TLS.
disabled:
description: Indicates if TLS is disabled or enabled.
Default is `false`.
type: boolean
key:
description: Defines the client key to use when using
Expand Down Expand Up @@ -1417,6 +1413,10 @@ spec:
type: object
type: object
type: object
skipCertificateValidation:
description: If `true`, the validation of certificates
is skipped. Default is `false`.
type: boolean
type: object
x-kubernetes-validations:
- message: Can define either both 'cert' and 'key', or neither
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,13 +1099,9 @@ spec:
type: object
type: object
type: object
insecure:
description: Defines whether to send requests using plaintext
instead of TLS.
type: boolean
insecureSkipVerify:
description: Defines whether to skip server certificate
verification when using TLS.
disabled:
description: Indicates if TLS is disabled or enabled.
Default is `false`.
type: boolean
key:
description: Defines the client key to use when using
Expand Down Expand Up @@ -1138,6 +1134,10 @@ spec:
type: object
type: object
type: object
skipCertificateValidation:
description: If `true`, the validation of certificates
is skipped. Default is `false`.
type: boolean
type: object
x-kubernetes-validations:
- message: Can define either both 'cert' and 'key', or neither
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,9 @@ spec:
type: object
type: object
type: object
insecure:
description: Defines whether to send requests using plaintext
instead of TLS.
type: boolean
insecureSkipVerify:
description: Defines whether to skip server certificate
verification when using TLS.
disabled:
description: Indicates if TLS is disabled or enabled.
Default is `false`.
type: boolean
key:
description: Defines the client key to use when using
Expand Down Expand Up @@ -734,6 +730,10 @@ spec:
type: object
type: object
type: object
skipCertificateValidation:
description: If `true`, the validation of certificates
is skipped. Default is `false`.
type: boolean
type: object
x-kubernetes-validations:
- message: Can define either both 'cert' and 'key', or neither
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/logs_basic_v1beta1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe(suite.ID(), Label(suite.LabelLogs, suite.LabelExperimental), Or
},
Port: strconv.Itoa(int(backend.Port())),
URI: "/",
TLSConfig: telemetryv1beta1.LogPipelineHTTPOutputTLS{
TLSConfig: telemetryv1beta1.OutputTLS{
Disabled: true,
SkipCertificateValidation: true,
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/logs_version_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var _ = Describe(suite.ID(), Label(suite.LabelLogs, suite.LabelExperimental), Or
},
Port: "443",
URI: "/",
TLSConfig: telemetryv1beta1.LogPipelineHTTPOutputTLS{
TLSConfig: telemetryv1beta1.OutputTLS{
Disabled: true,
},
},
Expand Down

0 comments on commit cf42a50

Please sign in to comment.