Skip to content

Commit

Permalink
Fix pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay committed Feb 24, 2025
1 parent 5a89394 commit b842e99
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 9 deletions.
3 changes: 3 additions & 0 deletions api/tempo/v1alpha1/tempomonolithic_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,7 @@ func (r *TempoMonolithic) Default(ctrlConfig configv1alpha1.ProjectConfig) {
if r.Spec.Timeout.Duration == 0 {
r.Spec.Timeout = defaultTimeout
}
if r.Spec.Query == nil {
r.Spec.Query = &MonolithicQuerySpec{}
}
}
62 changes: 62 additions & 0 deletions api/tempo/v1alpha1/tempomonolithic_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Managed",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{},
},
},
},
Expand Down Expand Up @@ -83,6 +84,7 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Managed",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{},
},
},
},
Expand All @@ -109,6 +111,7 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Unmanaged",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{},
},
},
expected: &TempoMonolithic{
Expand All @@ -131,6 +134,7 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Unmanaged",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{},
},
},
},
Expand Down Expand Up @@ -203,6 +207,7 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Managed",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{},
},
},
},
Expand Down Expand Up @@ -278,6 +283,7 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Managed",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{},
},
},
},
Expand Down Expand Up @@ -345,6 +351,7 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Managed",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{},
},
},
},
Expand Down Expand Up @@ -412,6 +419,7 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Managed",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{},
},
},
},
Expand Down Expand Up @@ -478,6 +486,60 @@ func TestMonolithicDefault(t *testing.T) {
},
Management: "Managed",
Timeout: metav1.Duration{Duration: time.Hour},
Query: &MonolithicQuerySpec{},
},
},
},
{
name: "query defined",
input: &TempoMonolithic{
ObjectMeta: v1.ObjectMeta{
Name: "test",
Namespace: "testns",
},
Spec: TempoMonolithicSpec{
Storage: &MonolithicStorageSpec{
Traces: MonolithicTracesStorageSpec{
Backend: "memory",
Size: &twoGBQuantity,
},
},
Query: &MonolithicQuerySpec{
RBAC: RBACSpec{
Enabled: true,
},
},
},
},
expected: &TempoMonolithic{
ObjectMeta: v1.ObjectMeta{
Name: "test",
Namespace: "testns",
},
Spec: TempoMonolithicSpec{
Ingestion: &MonolithicIngestionSpec{
OTLP: &MonolithicIngestionOTLPSpec{
GRPC: &MonolithicIngestionOTLPProtocolsGRPCSpec{
Enabled: true,
},
HTTP: &MonolithicIngestionOTLPProtocolsHTTPSpec{
Enabled: true,
},
},
},
Storage: &MonolithicStorageSpec{
Traces: MonolithicTracesStorageSpec{
Backend: "memory",
Size: &twoGBQuantity,
},
},
Management: "Managed",
Timeout: metav1.Duration{Duration: time.Second * 30},
Query: &MonolithicQuerySpec{
RBAC: RBACSpec{
Enabled: true,
},
},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion api/tempo/v1alpha1/tempomonolithic_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type TempoMonolithicSpec struct {
//
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Query Configuration",xDescriptors="urn:alm:descriptor:com.tectonic.ui:advanced"
Query MonolithicQuerySpec `json:"query,omitempty"`
Query *MonolithicQuerySpec `json:"query,omitempty"`

MonolithicSchedulerSpec `json:",inline"`
}
Expand Down
6 changes: 5 additions & 1 deletion api/tempo/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion internal/manifests/monolithic/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func configureGateway(opts Options, sts *appsv1.StatefulSet) error {
args = append(args, fmt.Sprintf("--traces.read.endpoint=http://localhost:%d", manifestutils.PortJaegerQuery)) // Jaeger UI upstream
}

if tempo.Spec.Query.RBAC.Enabled {
if tempo.Spec.Query != nil && tempo.Spec.Query.RBAC.Enabled {
args = append(args, "--traces.query-rbac=true")
}

Expand Down
2 changes: 1 addition & 1 deletion internal/manifests/monolithic/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ func TestStatefulsetGatewayRBAC(t *testing.T) {
JaegerUI: &v1alpha1.MonolithicJaegerUISpec{
Enabled: false,
},
Query: v1alpha1.MonolithicQuerySpec{
Query: &v1alpha1.MonolithicQuerySpec{
RBAC: v1alpha1.RBACSpec{
Enabled: true,
},
Expand Down
4 changes: 2 additions & 2 deletions internal/webhooks/tempomonolithic_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (v *monolithicValidator) validateJaegerUI(tempo tempov1alpha1.TempoMonolith
"the openshiftRoute feature gate must be enabled to create a route for Jaeger UI",
)}
}
if tempo.Spec.Query.RBAC.Enabled && tempo.Spec.JaegerUI.Enabled {
if tempo.Spec.Query != nil && tempo.Spec.Query.RBAC.Enabled && tempo.Spec.JaegerUI.Enabled {
return field.ErrorList{
field.Invalid(field.NewPath("spec", "rbac", "enabled"), tempo.Spec.Query.RBAC.Enabled,
"cannot enable RBAC and jaeger query at the same time. The Jaeger UI does not support query RBAC",
Expand All @@ -152,7 +152,7 @@ func (v *monolithicValidator) validateJaegerUI(tempo tempov1alpha1.TempoMonolith
}

func (v *monolithicValidator) validateMultitenancy(tempo tempov1alpha1.TempoMonolithic) field.ErrorList {
if tempo.Spec.Query.RBAC.Enabled && (tempo.Spec.Multitenancy == nil || !tempo.Spec.Multitenancy.Enabled) {
if tempo.Spec.Query != nil && tempo.Spec.Query.RBAC.Enabled && (tempo.Spec.Multitenancy == nil || !tempo.Spec.Multitenancy.Enabled) {
return field.ErrorList{
field.Invalid(field.NewPath("spec", "rbac", "enabled"), tempo.Spec.Query.RBAC.Enabled,
"RBAC can only be enabled if multi-tenancy is enabled",
Expand Down
6 changes: 3 additions & 3 deletions internal/webhooks/tempomonolithic_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestMonolithicValidate(t *testing.T) {
name: "RBAC and jaeger UI enabled",
tempo: v1alpha1.TempoMonolithic{
Spec: v1alpha1.TempoMonolithicSpec{
Query: v1alpha1.MonolithicQuerySpec{
Query: &v1alpha1.MonolithicQuerySpec{
RBAC: v1alpha1.RBACSpec{
Enabled: true,
},
Expand All @@ -177,7 +177,7 @@ func TestMonolithicValidate(t *testing.T) {
name: "RBAC and multitenancy disabled",
tempo: v1alpha1.TempoMonolithic{
Spec: v1alpha1.TempoMonolithicSpec{
Query: v1alpha1.MonolithicQuerySpec{
Query: &v1alpha1.MonolithicQuerySpec{
RBAC: v1alpha1.RBACSpec{
Enabled: true,
},
Expand All @@ -198,7 +198,7 @@ func TestMonolithicValidate(t *testing.T) {
name: "RBAC and multitenancy nil",
tempo: v1alpha1.TempoMonolithic{
Spec: v1alpha1.TempoMonolithicSpec{
Query: v1alpha1.MonolithicQuerySpec{
Query: &v1alpha1.MonolithicQuerySpec{
RBAC: v1alpha1.RBACSpec{
Enabled: true,
},
Expand Down

0 comments on commit b842e99

Please sign in to comment.