@@ -467,45 +467,24 @@ func (pm *instPodMutator) selectInstrumentationInstanceFromNamespace(ctx context
467
467
}
468
468
469
469
func (pm * instPodMutator ) validateInstrumentations (ctx context.Context , inst languageInstrumentations , podNamespace string ) error {
470
- var errs []error
471
- if inst .Java .Instrumentation != nil {
472
- if err := pm .validateInstrumentation (ctx , * inst .Java .Instrumentation , podNamespace ); err != nil {
473
- errs = append (errs , err )
474
- }
475
- }
476
- if inst .Python .Instrumentation != nil {
477
- if err := pm .validateInstrumentation (ctx , * inst .Python .Instrumentation , podNamespace ); err != nil {
478
- errs = append (errs , err )
479
- }
480
- }
481
- if inst .NodeJS .Instrumentation != nil {
482
- if err := pm .validateInstrumentation (ctx , * inst .NodeJS .Instrumentation , podNamespace ); err != nil {
483
- errs = append (errs , err )
484
- }
485
- }
486
- if inst .DotNet .Instrumentation != nil {
487
- if err := pm .validateInstrumentation (ctx , * inst .DotNet .Instrumentation , podNamespace ); err != nil {
488
- errs = append (errs , err )
489
- }
490
- }
491
- if inst .Go .Instrumentation != nil {
492
- if err := pm .validateInstrumentation (ctx , * inst .Go .Instrumentation , podNamespace ); err != nil {
493
- errs = append (errs , err )
494
- }
495
- }
496
- if inst .ApacheHttpd .Instrumentation != nil {
497
- if err := pm .validateInstrumentation (ctx , * inst .ApacheHttpd .Instrumentation , podNamespace ); err != nil {
498
- errs = append (errs , err )
499
- }
500
- }
501
- if inst .Nginx .Instrumentation != nil {
502
- if err := pm .validateInstrumentation (ctx , * inst .Nginx .Instrumentation , podNamespace ); err != nil {
503
- errs = append (errs , err )
504
- }
470
+ instrumentations := []struct {
471
+ instrumentation * v1alpha1.Instrumentation
472
+ }{
473
+ {inst .Java .Instrumentation },
474
+ {inst .Python .Instrumentation },
475
+ {inst .NodeJS .Instrumentation },
476
+ {inst .DotNet .Instrumentation },
477
+ {inst .Go .Instrumentation },
478
+ {inst .ApacheHttpd .Instrumentation },
479
+ {inst .Nginx .Instrumentation },
480
+ {inst .Sdk .Instrumentation },
505
481
}
506
- if inst .Sdk .Instrumentation != nil {
507
- if err := pm .validateInstrumentation (ctx , * inst .Sdk .Instrumentation , podNamespace ); err != nil {
508
- errs = append (errs , err )
482
+ var errs []error
483
+ for _ , i := range instrumentations {
484
+ if i .instrumentation != nil {
485
+ if err := pm .validateInstrumentation (ctx , i .instrumentation , podNamespace ); err != nil {
486
+ errs = append (errs , err )
487
+ }
509
488
}
510
489
}
511
490
@@ -515,7 +494,7 @@ func (pm *instPodMutator) validateInstrumentations(ctx context.Context, inst lan
515
494
return nil
516
495
}
517
496
518
- func (pm * instPodMutator ) validateInstrumentation (ctx context.Context , inst v1alpha1.Instrumentation , podNamespace string ) error {
497
+ func (pm * instPodMutator ) validateInstrumentation (ctx context.Context , inst * v1alpha1.Instrumentation , podNamespace string ) error {
519
498
// Check if secret and configmap exists
520
499
// If they don't exist pod cannot start
521
500
var errs []error
0 commit comments