From 63ad9f6d5904666995e849e9165972afba0e5911 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 20 Apr 2026 15:49:52 -0400 Subject: [PATCH] fix: use pointer-to-struct for fields with json omitempty Use pointers for API struct fields marked "omitempty". "omitempty" does not work on non-pointer struct fields. A zero valued struct will serialize at least as "{}" and may contain zero valued fields if any fields are not "omitempty". This can cause problems with default values and round-trip (de)serialization and break even if the kubebuilder "+optional" comment is applied. Additional fixes: - Add nil-safe GetFoo() methods to avoid long !=nil tests. - Rename TracingObjectStorageSpec.GCSSTSSpec to GCSWIF to match its type and json tag - Update CEL validation rule to handle nil storage/objectStorage with has() guards - Add nil guards for Tracing, Storage, ObjectStorageSpec, and Operators in controller code - Remove spurious omitempty from required S3Spec.AccessKeySecret field - Fix ConfigMapKeySelector doc comments that incorrectly referenced "Secret" --- ....openshift.io_observabilityinstallers.yaml | 9 ++-- ....openshift.io_observabilityinstallers.yaml | 9 ++-- docs/api.md | 4 +- pkg/apis/observability/v1alpha1/tracing.go | 31 +++++++++-- .../observability/v1alpha1/tracing_test.go | 14 ++--- pkg/apis/observability/v1alpha1/types.go | 25 ++++++++- .../v1alpha1/zz_generated.deepcopy.go | 28 +++++++--- pkg/controllers/observability/reconcilers.go | 7 +-- .../observability/reconcilers_test.go | 20 +++---- .../observability/tempo_components.go | 52 +++++++++---------- test/e2e/observability_installer_test.go | 6 +-- 11 files changed, 133 insertions(+), 72 deletions(-) diff --git a/bundle/manifests/observability.openshift.io_observabilityinstallers.yaml b/bundle/manifests/observability.openshift.io_observabilityinstallers.yaml index c33ab3439..3d1307c71 100644 --- a/bundle/manifests/observability.openshift.io_observabilityinstallers.yaml +++ b/bundle/manifests/observability.openshift.io_observabilityinstallers.yaml @@ -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. @@ -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: diff --git a/deploy/crds/common/observability.openshift.io_observabilityinstallers.yaml b/deploy/crds/common/observability.openshift.io_observabilityinstallers.yaml index fc254d266..b67ebc63e 100644 --- a/deploy/crds/common/observability.openshift.io_observabilityinstallers.yaml +++ b/deploy/crds/common/observability.openshift.io_observabilityinstallers.yaml @@ -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. @@ -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: diff --git a/docs/api.md b/docs/api.md index 4329f770b..550f99792 100644 --- a/docs/api.md +++ b/docs/api.md @@ -4336,7 +4336,7 @@ ObjectStorageSpec defines the object storage configuration for tracing. gcsWIF object - GCSSToken defines the Google Cloud Storage configuration using short-lived tokens.
+ GCSWIF defines the Google Cloud Storage configuration using Workload Identity Federation.
false @@ -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. diff --git a/pkg/apis/observability/v1alpha1/tracing.go b/pkg/apis/observability/v1alpha1/tracing.go index 8a20f25d3..00db7132c 100644 --- a/pkg/apis/observability/v1alpha1/tracing.go +++ b/pkg/apis/observability/v1alpha1/tracing.go @@ -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. @@ -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. @@ -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. // @@ -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 +} diff --git a/pkg/apis/observability/v1alpha1/tracing_test.go b/pkg/apis/observability/v1alpha1/tracing_test.go index a0244ee9a..732ee7a85 100644 --- a/pkg/apis/observability/v1alpha1/tracing_test.go +++ b/pkg/apis/observability/v1alpha1/tracing_test.go @@ -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"}, }, @@ -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", @@ -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", @@ -335,8 +335,8 @@ func TestTracingSpecValidation(t *testing.T) { CommonCapabilitiesSpec: CommonCapabilitiesSpec{ Enabled: true, }, - Storage: TracingStorageSpec{ - ObjectStorageSpec: TracingObjectStorageSpec{}, + Storage: &TracingStorageSpec{ + ObjectStorageSpec: &TracingObjectStorageSpec{}, }, }, expectValid: false, diff --git a/pkg/apis/observability/v1alpha1/types.go b/pkg/apis/observability/v1alpha1/types.go index d5ba0d737..a5a551a4b 100644 --- a/pkg/apis/observability/v1alpha1/types.go +++ b/pkg/apis/observability/v1alpha1/types.go @@ -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. @@ -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. @@ -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. diff --git a/pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go index 29077f5c4..0a88097cf 100644 --- a/pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go @@ -59,7 +59,11 @@ func (in *AzureWIFSpec) DeepCopy() *AzureWIFSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CapabilitiesSpec) DeepCopyInto(out *CapabilitiesSpec) { *out = *in - in.Tracing.DeepCopyInto(&out.Tracing) + if in.Tracing != nil { + in, out := &in.Tracing, &out.Tracing + *out = new(TracingSpec) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapabilitiesSpec. @@ -75,7 +79,11 @@ func (in *CapabilitiesSpec) DeepCopy() *CapabilitiesSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CommonCapabilitiesSpec) DeepCopyInto(out *CommonCapabilitiesSpec) { *out = *in - in.Operators.DeepCopyInto(&out.Operators) + if in.Operators != nil { + in, out := &in.Operators, &out.Operators + *out = new(OperatorsSpec) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CommonCapabilitiesSpec. @@ -380,8 +388,8 @@ func (in *TracingObjectStorageSpec) DeepCopyInto(out *TracingObjectStorageSpec) *out = new(GCSSpec) **out = **in } - if in.GCSSTSSpec != nil { - in, out := &in.GCSSTSSpec, &out.GCSSTSSpec + if in.GCSWIF != nil { + in, out := &in.GCSWIF, &out.GCSWIF *out = new(GCSWIFSpec) **out = **in } @@ -406,7 +414,11 @@ func (in *TracingObjectStorageSpec) DeepCopy() *TracingObjectStorageSpec { func (in *TracingSpec) DeepCopyInto(out *TracingSpec) { *out = *in in.CommonCapabilitiesSpec.DeepCopyInto(&out.CommonCapabilitiesSpec) - in.Storage.DeepCopyInto(&out.Storage) + if in.Storage != nil { + in, out := &in.Storage, &out.Storage + *out = new(TracingStorageSpec) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TracingSpec. @@ -422,7 +434,11 @@ func (in *TracingSpec) DeepCopy() *TracingSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TracingStorageSpec) DeepCopyInto(out *TracingStorageSpec) { *out = *in - in.ObjectStorageSpec.DeepCopyInto(&out.ObjectStorageSpec) + if in.ObjectStorageSpec != nil { + in, out := &in.ObjectStorageSpec, &out.ObjectStorageSpec + *out = new(TracingObjectStorageSpec) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TracingStorageSpec. diff --git a/pkg/controllers/observability/reconcilers.go b/pkg/controllers/observability/reconcilers.go index a30ad0bac..4a6e3ef73 100644 --- a/pkg/controllers/observability/reconcilers.go +++ b/pkg/controllers/observability/reconcilers.go @@ -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)) @@ -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)) diff --git a/pkg/controllers/observability/reconcilers_test.go b/pkg/controllers/observability/reconcilers_test.go index 14c2372a1..d41c3cf8a 100644 --- a/pkg/controllers/observability/reconcilers_test.go +++ b/pkg/controllers/observability/reconcilers_test.go @@ -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{}, }, }, }, @@ -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", @@ -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, }, }, @@ -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, }, @@ -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, }, diff --git a/pkg/controllers/observability/tempo_components.go b/pkg/controllers/observability/tempo_components.go index 3502c83a8..83b6260d3 100644 --- a/pkg/controllers/observability/tempo_components.go +++ b/pkg/controllers/observability/tempo_components.go @@ -22,13 +22,10 @@ const ( func tempoStack(instance *obsv1alpha1.ObservabilityInstaller) *tempov1alpha1.TempoStack { var storageType tempov1alpha1.ObjectStorageSecretType - if instance.Spec.Capabilities != nil { - storageType = toTempoStorageType(instance.Spec.Capabilities.Tracing.Storage.ObjectStorageSpec) - } - var credentialMode tempov1alpha1.CredentialMode - if instance.Spec.Capabilities != nil { - credentialMode = toTempoCredentialMode(instance.Spec.Capabilities.Tracing.Storage.ObjectStorageSpec) + if oss := instance.Spec.GetCapabilities().GetTracing().GetStorage().GetObjectStorageSpec(); oss != nil { + storageType = toTempoStorageType(oss) } + credentialMode := toTempoCredentialMode(instance.Spec.GetCapabilities().GetTracing().GetStorage().GetObjectStorageSpec()) tempo := &tempov1alpha1.TempoStack{ TypeMeta: metav1.TypeMeta{ Kind: "TempoStack", @@ -63,10 +60,9 @@ func tempoStack(instance *obsv1alpha1.ObservabilityInstaller) *tempov1alpha1.Tem }, } - if instance.Spec.Capabilities != nil { - storageSpec := instance.Spec.Capabilities.Tracing.Storage.ObjectStorageSpec - tls := storageSpec.TLS - enableTLS := tls != nil || s3hasHTTPSEndpoint(storageSpec) + if storageSpec := instance.Spec.GetCapabilities().GetTracing().GetStorage().GetObjectStorageSpec(); storageSpec != nil { + tls := storageSpec.GetTLS() + enableTLS := tls != nil || s3hasHTTPSEndpoint(*storageSpec) if enableTLS { tempo.Spec.Storage.TLS = tempov1alpha1.TLSSpec{ @@ -130,8 +126,7 @@ func tempoStackSecrets(ctx context.Context, k8sClient client.Client, k8sReader c var objectStorageCAConfMap *corev1.ConfigMap var objectStorageTLSSecret *corev1.Secret - if instance.Spec.Capabilities != nil && instance.Spec.Capabilities.Tracing.Storage.ObjectStorageSpec.TLS != nil { - tlsSpec := instance.Spec.Capabilities.Tracing.Storage.ObjectStorageSpec.TLS + if tlsSpec := instance.Spec.GetCapabilities().GetTracing().GetStorage().GetObjectStorageSpec().GetTLS(); tlsSpec != nil { if tlsSpec.CAConfigMap != nil { caConfigMap := &corev1.ConfigMap{} err := k8sReader.Get(ctx, client.ObjectKey{ @@ -139,7 +134,7 @@ func tempoStackSecrets(ctx context.Context, k8sClient client.Client, k8sReader c Name: tlsSpec.CAConfigMap.Name, }, caConfigMap) if err != nil { - return nil, fmt.Errorf("failed to get object storage CA configmap %s: %w", instance.Spec.Capabilities.Tracing.Storage.ObjectStorageSpec.TLS.CAConfigMap.Name, err) + return nil, fmt.Errorf("failed to get object storage CA configmap %s: %w", tlsSpec.CAConfigMap.Name, err) } objectStorageCAConfMap = &corev1.ConfigMap{ @@ -207,8 +202,7 @@ func tempoStackSecrets(ctx context.Context, k8sClient client.Client, k8sReader c Namespace: instance.Namespace, }, } - if instance.Spec.Capabilities != nil { - objectStorageSpec := instance.Spec.Capabilities.Tracing.Storage.ObjectStorageSpec + if objectStorageSpec := instance.Spec.GetCapabilities().GetTracing().GetStorage().GetObjectStorageSpec(); objectStorageSpec != nil { if objectStorageSpec.S3 != nil { accessKeySecret := &corev1.Secret{} err := k8sClient.Get(ctx, client.ObjectKey{ @@ -279,22 +273,22 @@ func tempoStackSecrets(ctx context.Context, k8sClient client.Client, k8sReader c "bucketname": []byte(objectStorageSpec.GCS.Bucket), "key.json": keyJSONSecret.Data[objectStorageSpec.GCS.KeyJSONSecret.Key], } - } else if objectStorageSpec.GCSSTSSpec != nil { + } else if objectStorageSpec.GCSWIF != nil { keyJSONSecret := &corev1.Secret{} err := k8sClient.Get(ctx, client.ObjectKey{ Namespace: instance.Namespace, - Name: objectStorageSpec.GCSSTSSpec.KeyJSONSecret.Name, + Name: objectStorageSpec.GCSWIF.KeyJSONSecret.Name, }, keyJSONSecret) if err != nil { - return nil, fmt.Errorf("failed to get GCSSTS keyJSON secret %s: %w", objectStorageSpec.GCSSTSSpec.KeyJSONSecret.Name, err) + return nil, fmt.Errorf("failed to get GCSWIF keyJSON secret %s: %w", objectStorageSpec.GCSWIF.KeyJSONSecret.Name, err) } tempoSecret.Data = map[string][]byte{ - "bucketname": []byte(objectStorageSpec.GCSSTSSpec.Bucket), - "key.json": keyJSONSecret.Data[objectStorageSpec.GCSSTSSpec.KeyJSONSecret.Key], + "bucketname": []byte(objectStorageSpec.GCSWIF.Bucket), + "key.json": keyJSONSecret.Data[objectStorageSpec.GCSWIF.KeyJSONSecret.Key], } - if objectStorageSpec.GCSSTSSpec.Audience != "" { - tempoSecret.Data["audience"] = []byte(objectStorageSpec.GCSSTSSpec.Audience) + if objectStorageSpec.GCSWIF.Audience != "" { + tempoSecret.Data["audience"] = []byte(objectStorageSpec.GCSWIF.Audience) } } } @@ -321,21 +315,27 @@ func uiPlugin() *uiv1alpha1.UIPlugin { } } -func toTempoStorageType(objStorage obsv1alpha1.TracingObjectStorageSpec) tempov1alpha1.ObjectStorageSecretType { +func toTempoStorageType(objStorage *obsv1alpha1.TracingObjectStorageSpec) tempov1alpha1.ObjectStorageSecretType { + if objStorage == nil { + return "" + } if objStorage.S3 != nil || objStorage.S3STS != nil || objStorage.S3CCO != nil { return tempov1alpha1.ObjectStorageSecretS3 } else if objStorage.Azure != nil || objStorage.AzureWIF != nil { return tempov1alpha1.ObjectStorageSecretAzure - } else if objStorage.GCS != nil || objStorage.GCSSTSSpec != nil { + } else if objStorage.GCS != nil || objStorage.GCSWIF != nil { return tempov1alpha1.ObjectStorageSecretGCS } return "" } -func toTempoCredentialMode(objStorage obsv1alpha1.TracingObjectStorageSpec) tempov1alpha1.CredentialMode { +func toTempoCredentialMode(objStorage *obsv1alpha1.TracingObjectStorageSpec) tempov1alpha1.CredentialMode { + if objStorage == nil { + return "" + } if objStorage.S3 != nil || objStorage.Azure != nil || objStorage.GCS != nil { return tempov1alpha1.CredentialModeStatic - } else if objStorage.S3STS != nil || objStorage.AzureWIF != nil || objStorage.GCSSTSSpec != nil { + } else if objStorage.S3STS != nil || objStorage.AzureWIF != nil || objStorage.GCSWIF != nil { return tempov1alpha1.CredentialModeToken } else if objStorage.S3CCO != nil { return tempov1alpha1.CredentialModeTokenCCO diff --git a/test/e2e/observability_installer_test.go b/test/e2e/observability_installer_test.go index 66c21b5bb..c679c4d01 100644 --- a/test/e2e/observability_installer_test.go +++ b/test/e2e/observability_installer_test.go @@ -98,12 +98,12 @@ func testObservabilityInstallerTracing(t *testing.T) { }, Spec: obsv1alpha1.ObservabilityInstallerSpec{ Capabilities: &obsv1alpha1.CapabilitiesSpec{ - Tracing: obsv1alpha1.TracingSpec{ + Tracing: &obsv1alpha1.TracingSpec{ CommonCapabilitiesSpec: obsv1alpha1.CommonCapabilitiesSpec{ Enabled: true, }, - Storage: obsv1alpha1.TracingStorageSpec{ - ObjectStorageSpec: obsv1alpha1.TracingObjectStorageSpec{ + Storage: &obsv1alpha1.TracingStorageSpec{ + ObjectStorageSpec: &obsv1alpha1.TracingObjectStorageSpec{ S3: &obsv1alpha1.S3Spec{ Bucket: "tempo", Endpoint: "http://minio.minio.svc:9000",