Skip to content

Commit 57d5703

Browse files
committed
Fix context handling in collector webhook build validator
1 parent 62a3d26 commit 57d5703

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

apis/v1beta1/collector_webhook.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (c CollectorWebhook) ValidateCreate(ctx context.Context, obj runtime.Object
122122
c.metrics.create(ctx, otelcol)
123123
}
124124
if c.bv != nil {
125-
newWarnings := c.bv(*otelcol)
125+
newWarnings := c.bv(ctx, *otelcol)
126126
warnings = append(warnings, newWarnings...)
127127
}
128128
return warnings, nil
@@ -152,7 +152,7 @@ func (c CollectorWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj run
152152
}
153153

154154
if c.bv != nil {
155-
newWarnings := c.bv(*otelcol)
155+
newWarnings := c.bv(ctx, *otelcol)
156156
warnings = append(warnings, newWarnings...)
157157
}
158158
return warnings, nil
@@ -435,7 +435,7 @@ func checkAutoscalerSpec(autoscaler *AutoscalerSpec) error {
435435

436436
// BuildValidator enables running the manifest generators for the collector reconciler
437437
// +kubebuilder:object:generate=false
438-
type BuildValidator func(c OpenTelemetryCollector) admission.Warnings
438+
type BuildValidator func(ctx context.Context, c OpenTelemetryCollector) admission.Warnings
439439

440440
func NewCollectorWebhook(
441441
logger logr.Logger,

apis/v1beta1/collector_webhook_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestValidate(t *testing.T) {
8383
},
8484
}
8585

86-
bv := func(collector v1beta1.OpenTelemetryCollector) admission.Warnings {
86+
bv := func(_ context.Context, collector v1beta1.OpenTelemetryCollector) admission.Warnings {
8787
var warnings admission.Warnings
8888
cfg := config.New(
8989
config.WithCollectorImage("default-collector"),
@@ -518,7 +518,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
518518
},
519519
}
520520

521-
bv := func(collector v1beta1.OpenTelemetryCollector) admission.Warnings {
521+
bv := func(_ context.Context, collector v1beta1.OpenTelemetryCollector) admission.Warnings {
522522
var warnings admission.Warnings
523523
cfg := config.New(
524524
config.WithCollectorImage("default-collector"),
@@ -1365,7 +1365,7 @@ func TestOTELColValidatingWebhook(t *testing.T) {
13651365
},
13661366
}
13671367

1368-
bv := func(collector v1beta1.OpenTelemetryCollector) admission.Warnings {
1368+
bv := func(_ context.Context, collector v1beta1.OpenTelemetryCollector) admission.Warnings {
13691369
var warnings admission.Warnings
13701370
cfg := config.New(
13711371
config.WithCollectorImage("default-collector"),
@@ -1433,7 +1433,7 @@ func TestOTELColValidateUpdateWebhook(t *testing.T) {
14331433
},
14341434
}
14351435

1436-
bv := func(collector v1beta1.OpenTelemetryCollector) admission.Warnings {
1436+
bv := func(_ context.Context, collector v1beta1.OpenTelemetryCollector) admission.Warnings {
14371437
var warnings admission.Warnings
14381438
cfg := config.New(
14391439
config.WithCollectorImage("default-collector"),

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ func main() {
438438

439439
}
440440

441-
bv := func(collector otelv1beta1.OpenTelemetryCollector) admission.Warnings {
441+
bv := func(ctx context.Context, collector otelv1beta1.OpenTelemetryCollector) admission.Warnings {
442442
var warnings admission.Warnings
443-
params, newErr := collectorReconciler.GetParams(context.Background(), collector)
443+
params, newErr := collectorReconciler.GetParams(ctx, collector)
444444
if err != nil {
445445
warnings = append(warnings, newErr.Error())
446446
return warnings

0 commit comments

Comments
 (0)