@@ -14,6 +14,7 @@ import (
14
14
"io"
15
15
"net/http"
16
16
"os"
17
+ "slices"
17
18
"strings"
18
19
19
20
"github.com/cosi-project/runtime/pkg/controller"
@@ -68,6 +69,7 @@ type AcquireController struct {
68
69
EventPublisher talosruntime.Publisher
69
70
ValidationMode validation.RuntimeMode
70
71
ConfigPath string
72
+ ResourceState state.State
71
73
72
74
configSourcesUsed []string
73
75
}
@@ -345,7 +347,12 @@ func (ctrl *AcquireController) loadFromPlatform(ctx context.Context, logger *zap
345
347
return nil , fmt .Errorf ("failed to validate config acquired via platform %s: %w" , platformName , err )
346
348
}
347
349
348
- for _ , warning := range warnings {
350
+ warningsRuntime , err := cfg .RuntimeValidate (ctx , ctrl .ResourceState , ctrl .ValidationMode )
351
+ if err != nil {
352
+ return nil , fmt .Errorf ("failed to runtime validate config acquired via platform %s: %w" , platformName , err )
353
+ }
354
+
355
+ for _ , warning := range slices .Concat (warnings , warningsRuntime ) {
349
356
logger .Warn ("config validation warning" , zap .String ("platform" , platformName ), zap .String ("warning" , warning ))
350
357
}
351
358
@@ -364,7 +371,7 @@ func (ctrl *AcquireController) stateCmdline(ctx context.Context, r controller.Ru
364
371
return ctrl .stateMaintenanceEnter , nil , nil
365
372
}
366
373
367
- cfg , err := ctrl .loadFromCmdline (logger )
374
+ cfg , err := ctrl .loadFromCmdline (ctx , logger )
368
375
if err != nil {
369
376
return nil , nil , err
370
377
}
@@ -386,7 +393,9 @@ func (ctrl *AcquireController) stateCmdline(ctx context.Context, r controller.Ru
386
393
}
387
394
388
395
// loadFromCmdline is a helper function for stateCmdline.
389
- func (ctrl * AcquireController ) loadFromCmdline (logger * zap.Logger ) (config.Provider , error ) {
396
+ //
397
+ //nolint:gocyclo
398
+ func (ctrl * AcquireController ) loadFromCmdline (ctx context.Context , logger * zap.Logger ) (config.Provider , error ) {
390
399
cmdline := ctrl .CmdlineGetter ()
391
400
392
401
param := cmdline .Get (constants .KernelParamConfigInline )
@@ -435,7 +444,12 @@ func (ctrl *AcquireController) loadFromCmdline(logger *zap.Logger) (config.Provi
435
444
return nil , fmt .Errorf ("failed to validate config acquired via cmdline %s: %w" , constants .KernelParamConfigInline , err )
436
445
}
437
446
438
- for _ , warning := range warnings {
447
+ warningsRuntime , err := cfg .RuntimeValidate (ctx , ctrl .ResourceState , ctrl .ValidationMode )
448
+ if err != nil {
449
+ return nil , fmt .Errorf ("failed to validate config acquired via cmdline %s: %w" , constants .KernelParamConfigInline , err )
450
+ }
451
+
452
+ for _ , warning := range slices .Concat (warnings , warningsRuntime ) {
439
453
logger .Warn ("config validation warning" , zap .String ("cmdline" , constants .KernelParamConfigInline ), zap .String ("warning" , warning ))
440
454
}
441
455
0 commit comments