Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ var initCmd = &cobra.Command{
}

configHandler := injector.Resolve("configHandler").(config.ConfigHandler)

// Initialize the config handler to ensure schema validator is available
if err := configHandler.Initialize(); err != nil {
return fmt.Errorf("failed to initialize config handler: %w", err)
}

// Load the schema to enable validation of --set flags
if err := configHandler.LoadContextConfig(); err != nil {
return fmt.Errorf("failed to load context config: %w", err)
}

// Set provider in context if it's been set (either via --provider or --platform)
if initProvider != "" {
Expand Down Expand Up @@ -136,6 +146,7 @@ var initCmd = &cobra.Command{
}
}

hasSetFlags := len(initSetFlags) > 0
for _, setFlag := range initSetFlags {
parts := strings.SplitN(setFlag, "=", 2)
if len(parts) == 2 {
Expand All @@ -145,6 +156,7 @@ var initCmd = &cobra.Command{
}
}

ctx = context.WithValue(ctx, "hasSetFlags", hasSetFlags)
ctx = context.WithValue(ctx, "quiet", false)
ctx = context.WithValue(ctx, "decrypt", false)
initPipeline, err := pipelines.WithPipeline(injector, ctx, "initPipeline")
Expand Down
6 changes: 4 additions & 2 deletions pkg/config/config_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type BaseConfigHandler struct {
loaded bool
shims *Shims
schemaValidator *SchemaValidator
contextValues map[string]any
}

// =============================================================================
Expand All @@ -74,8 +75,9 @@ type BaseConfigHandler struct {
// NewBaseConfigHandler creates a new BaseConfigHandler instance
func NewBaseConfigHandler(injector di.Injector) *BaseConfigHandler {
return &BaseConfigHandler{
injector: injector,
shims: NewShims(),
injector: injector,
shims: NewShims(),
contextValues: make(map[string]any),
}
}

Expand Down
Loading
Loading