Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ spec:
- keyJSONSecret
type: object
gcsWIF:
description: GCSSToken defines the Google Cloud Storage
configuration using short-lived tokens.
description: GCSWIF defines the Google Cloud Storage
configuration using Workload Identity Federation.
properties:
audience:
description: Audience is the optional audience.
Expand Down Expand Up @@ -360,11 +360,12 @@ spec:
type: object
x-kubernetes-validations:
- message: Storage configuration is required when tracing is enabled
rule: (!has(self.enabled) || !self.enabled) || [has(self.storage.objectStorage.s3),
rule: (!has(self.enabled) || !self.enabled) || (has(self.storage)
&& has(self.storage.objectStorage) && [has(self.storage.objectStorage.s3),
has(self.storage.objectStorage.s3STS), has(self.storage.objectStorage.s3CCO),
has(self.storage.objectStorage.azure), has(self.storage.objectStorage.azureWIF),
has(self.storage.objectStorage.gcs), has(self.storage.objectStorage.gcsWIF)].filter(x,
x).size() > 0
x).size() > 0)
type: object
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ spec:
- keyJSONSecret
type: object
gcsWIF:
description: GCSSToken defines the Google Cloud Storage
configuration using short-lived tokens.
description: GCSWIF defines the Google Cloud Storage
configuration using Workload Identity Federation.
properties:
audience:
description: Audience is the optional audience.
Expand Down Expand Up @@ -360,11 +360,12 @@ spec:
type: object
x-kubernetes-validations:
- message: Storage configuration is required when tracing is enabled
rule: (!has(self.enabled) || !self.enabled) || [has(self.storage.objectStorage.s3),
rule: (!has(self.enabled) || !self.enabled) || (has(self.storage)
&& has(self.storage.objectStorage) && [has(self.storage.objectStorage.s3),
has(self.storage.objectStorage.s3STS), has(self.storage.objectStorage.s3CCO),
has(self.storage.objectStorage.azure), has(self.storage.objectStorage.azureWIF),
has(self.storage.objectStorage.gcs), has(self.storage.objectStorage.gcsWIF)].filter(x,
x).size() > 0
x).size() > 0)
type: object
type: object
status:
Expand Down
4 changes: 2 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4336,7 +4336,7 @@ ObjectStorageSpec defines the object storage configuration for tracing.
<td><b><a href="#observabilityinstallerspeccapabilitiestracingstorageobjectstoragegcswif">gcsWIF</a></b></td>
<td>object</td>
<td>
GCSSToken defines the Google Cloud Storage configuration using short-lived tokens.<br/>
GCSWIF defines the Google Cloud Storage configuration using Workload Identity Federation.<br/>
</td>
<td>false</td>
</tr><tr>
Expand Down Expand Up @@ -4574,7 +4574,7 @@ KeyJSON is the key.json file encoded in a secret.



GCSSToken defines the Google Cloud Storage configuration using short-lived tokens.
GCSWIF defines the Google Cloud Storage configuration using Workload Identity Federation.

<table>
<thead>
Expand Down
31 changes: 26 additions & 5 deletions pkg/apis/observability/v1alpha1/tracing.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package v1alpha1

// TracingSpec defines the desired state of the tracing capability.
// +kubebuilder:validation:XValidation:rule="(!has(self.enabled) || !self.enabled) || [has(self.storage.objectStorage.s3), has(self.storage.objectStorage.s3STS), has(self.storage.objectStorage.s3CCO), has(self.storage.objectStorage.azure), has(self.storage.objectStorage.azureWIF), has(self.storage.objectStorage.gcs), has(self.storage.objectStorage.gcsWIF)].filter(x, x).size() > 0",message="Storage configuration is required when tracing is enabled"
// +kubebuilder:validation:XValidation:rule="(!has(self.enabled) || !self.enabled) || (has(self.storage) && has(self.storage.objectStorage) && [has(self.storage.objectStorage.s3), has(self.storage.objectStorage.s3STS), has(self.storage.objectStorage.s3CCO), has(self.storage.objectStorage.azure), has(self.storage.objectStorage.azureWIF), has(self.storage.objectStorage.gcs), has(self.storage.objectStorage.gcsWIF)].filter(x, x).size() > 0)",message="Storage configuration is required when tracing is enabled"
type TracingSpec struct {
CommonCapabilitiesSpec `json:",inline"`

// Storage defines the storage for the tracing capability
Storage TracingStorageSpec `json:"storage,omitempty"`
Storage *TracingStorageSpec `json:"storage,omitempty"`
}

func (t *TracingSpec) GetStorage() *TracingStorageSpec {
if t != nil {
return t.Storage
}
return nil
}

// TracingStorageSpec defines the storage for tracing capability.
Expand All @@ -15,7 +22,14 @@ type TracingStorageSpec struct {
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Object storage config"
ObjectStorageSpec TracingObjectStorageSpec `json:"objectStorage,omitempty"`
ObjectStorageSpec *TracingObjectStorageSpec `json:"objectStorage,omitempty"`
}

func (s *TracingStorageSpec) GetObjectStorageSpec() *TracingObjectStorageSpec {
if s != nil {
return s.ObjectStorageSpec
}
return nil
}

// TracingObjectStorageSpec defines the object storage for the tracing capability.
Expand All @@ -35,8 +49,8 @@ type TracingObjectStorageSpec struct {

// GCS defines the Google Cloud Storage configuration.
GCS *GCSSpec `json:"gcs,omitempty"`
// GCSSToken defines the Google Cloud Storage configuration using short-lived tokens.
GCSSTSSpec *GCSWIFSpec `json:"gcsWIF,omitempty"`
// GCSWIF defines the Google Cloud Storage configuration using Workload Identity Federation.
GCSWIF *GCSWIFSpec `json:"gcsWIF,omitempty"`

// TLS configuration for reaching the object storage endpoint.
//
Expand All @@ -45,3 +59,10 @@ type TracingObjectStorageSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="TLS Config"
TLS *TLSSpec `json:"tls,omitempty"`
}

func (o *TracingObjectStorageSpec) GetTLS() *TLSSpec {
if o != nil {
return o.TLS
}
return nil
}
14 changes: 7 additions & 7 deletions pkg/apis/observability/v1alpha1/tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestTracingObjectStorageSpecValidation(t *testing.T) {
{
name: "only GCSWIFSpec specified",
spec: TracingObjectStorageSpec{
GCSSTSSpec: &GCSWIFSpec{
GCSWIF: &GCSWIFSpec{
Bucket: "test-bucket",
KeyJSONSecret: SecretKeySelector{Name: "test-secret", Key: "key"},
},
Expand Down Expand Up @@ -288,8 +288,8 @@ func TestTracingSpecValidation(t *testing.T) {
CommonCapabilitiesSpec: CommonCapabilitiesSpec{
Enabled: false,
},
Storage: TracingStorageSpec{
ObjectStorageSpec: TracingObjectStorageSpec{
Storage: &TracingStorageSpec{
ObjectStorageSpec: &TracingObjectStorageSpec{
S3: &S3Spec{
Bucket: "test-bucket",
Endpoint: "test-endpoint",
Expand All @@ -307,8 +307,8 @@ func TestTracingSpecValidation(t *testing.T) {
CommonCapabilitiesSpec: CommonCapabilitiesSpec{
Enabled: true,
},
Storage: TracingStorageSpec{
ObjectStorageSpec: TracingObjectStorageSpec{
Storage: &TracingStorageSpec{
ObjectStorageSpec: &TracingObjectStorageSpec{
S3: &S3Spec{
Bucket: "test-bucket",
Endpoint: "test-endpoint",
Expand All @@ -335,8 +335,8 @@ func TestTracingSpecValidation(t *testing.T) {
CommonCapabilitiesSpec: CommonCapabilitiesSpec{
Enabled: true,
},
Storage: TracingStorageSpec{
ObjectStorageSpec: TracingObjectStorageSpec{},
Storage: &TracingStorageSpec{
ObjectStorageSpec: &TracingObjectStorageSpec{},
},
},
expectValid: false,
Expand Down
25 changes: 23 additions & 2 deletions pkg/apis/observability/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ type ObservabilityInstallerSpec struct {
Capabilities *CapabilitiesSpec `json:"capabilities,omitempty"`
}

func (s *ObservabilityInstallerSpec) GetCapabilities() *CapabilitiesSpec {
if s != nil {
return s.Capabilities
}
return nil
}

// ObservabilityInstallerStatus defines the observed state of ObservabilityInstaller.
type ObservabilityInstallerStatus struct {
// OpenTelemetry defines the status of the OpenTelemetry capability.
Expand Down Expand Up @@ -98,7 +105,14 @@ type CapabilitiesSpec struct {
// The Tempo instance is configured with a single tenant called application.
// +optional
// +kubebuilder:validation:Optional
Tracing TracingSpec `json:"tracing,omitempty"`
Tracing *TracingSpec `json:"tracing,omitempty"`
}

func (c *CapabilitiesSpec) GetTracing() *TracingSpec {
if c != nil {
return c.Tracing
}
return nil
}

// CommonCapabilitiesSpec defines the common capabilities.
Expand All @@ -112,7 +126,14 @@ type CommonCapabilitiesSpec struct {
// Operators defines the operators installation for the capability.
// +optional
// +kubebuilder:validation:Optional
Operators OperatorsSpec `json:"operators,omitempty"`
Operators *OperatorsSpec `json:"operators,omitempty"`
}

func (c *CommonCapabilitiesSpec) GetOperators() *OperatorsSpec {
if c != nil {
return c.Operators
}
return nil
}

// OperatorsSpec defines the operators installation.
Expand Down
28 changes: 22 additions & 6 deletions pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go

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

7 changes: 4 additions & 3 deletions pkg/controllers/observability/reconcilers.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func getReconcilers(ctx context.Context, k8sClient client.Client, k8sReader clie
}

// Install operators and instances
if instance.Spec.Capabilities != nil && instance.Spec.Capabilities.Tracing.CommonCapabilitiesSpec.Enabled {
if tracing := instance.Spec.GetCapabilities().GetTracing(); tracing != nil && tracing.Enabled {
// install operators and instances
if operatorsStatus.ShouldInstall("opentelemetry") {
reconcilers = append(reconcilers, reconciler.NewCreateUpdateReconciler(otelSubs, instance))
Expand All @@ -133,8 +133,9 @@ func getReconcilers(ctx context.Context, k8sClient client.Client, k8sReader clie
}
}
// install operators only
if instance.Spec.Capabilities != nil &&
(instance.Spec.Capabilities.Tracing.CommonCapabilitiesSpec.Operators.Install != nil && *instance.Spec.Capabilities.Tracing.CommonCapabilitiesSpec.Operators.Install) {
if tracing := instance.Spec.GetCapabilities().GetTracing(); tracing != nil &&
tracing.GetOperators() != nil &&
(tracing.GetOperators().Install != nil && *tracing.GetOperators().Install) {
// install operators only
if operatorsStatus.ShouldInstall("opentelemetry") {
reconcilers = append(reconcilers, reconciler.NewCreateUpdateReconciler(otelSubs, instance))
Expand Down
20 changes: 10 additions & 10 deletions pkg/controllers/observability/reconcilers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ func TestGetReconcilers(t *testing.T) {
},
Spec: obsv1alpha1.ObservabilityInstallerSpec{
Capabilities: &obsv1alpha1.CapabilitiesSpec{
Tracing: obsv1alpha1.TracingSpec{
Tracing: &obsv1alpha1.TracingSpec{
CommonCapabilitiesSpec: obsv1alpha1.CommonCapabilitiesSpec{
Enabled: true,
Operators: obsv1alpha1.OperatorsSpec{},
Operators: &obsv1alpha1.OperatorsSpec{},
},
},
},
Expand Down Expand Up @@ -87,13 +87,13 @@ func TestGetReconcilers(t *testing.T) {
},
Spec: obsv1alpha1.ObservabilityInstallerSpec{
Capabilities: &obsv1alpha1.CapabilitiesSpec{
Tracing: obsv1alpha1.TracingSpec{
Tracing: &obsv1alpha1.TracingSpec{
CommonCapabilitiesSpec: obsv1alpha1.CommonCapabilitiesSpec{
Enabled: true,
Operators: obsv1alpha1.OperatorsSpec{},
Operators: &obsv1alpha1.OperatorsSpec{},
},
Storage: obsv1alpha1.TracingStorageSpec{
ObjectStorageSpec: obsv1alpha1.TracingObjectStorageSpec{
Storage: &obsv1alpha1.TracingStorageSpec{
ObjectStorageSpec: &obsv1alpha1.TracingObjectStorageSpec{
S3: &obsv1alpha1.S3Spec{
Bucket: "tempo",
Endpoint: "tmepo:111",
Expand Down Expand Up @@ -137,10 +137,10 @@ func TestGetReconcilers(t *testing.T) {
},
Spec: obsv1alpha1.ObservabilityInstallerSpec{
Capabilities: &obsv1alpha1.CapabilitiesSpec{
Tracing: obsv1alpha1.TracingSpec{
Tracing: &obsv1alpha1.TracingSpec{
CommonCapabilitiesSpec: obsv1alpha1.CommonCapabilitiesSpec{
Enabled: false,
Operators: obsv1alpha1.OperatorsSpec{
Operators: &obsv1alpha1.OperatorsSpec{
Install: &trueVal,
},
},
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestGetReconcilers(t *testing.T) {
},
Spec: obsv1alpha1.ObservabilityInstallerSpec{
Capabilities: &obsv1alpha1.CapabilitiesSpec{
Tracing: obsv1alpha1.TracingSpec{
Tracing: &obsv1alpha1.TracingSpec{
CommonCapabilitiesSpec: obsv1alpha1.CommonCapabilitiesSpec{
Enabled: false,
},
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestGetReconcilers(t *testing.T) {
},
Spec: obsv1alpha1.ObservabilityInstallerSpec{
Capabilities: &obsv1alpha1.CapabilitiesSpec{
Tracing: obsv1alpha1.TracingSpec{
Tracing: &obsv1alpha1.TracingSpec{
CommonCapabilitiesSpec: obsv1alpha1.CommonCapabilitiesSpec{
Enabled: true,
},
Expand Down
Loading
Loading