diff --git a/internal/exec/stack_processor_utils.go b/internal/exec/stack_processor_utils.go index b4cc48090..d4ba3e83d 100644 --- a/internal/exec/stack_processor_utils.go +++ b/internal/exec/stack_processor_utils.go @@ -327,6 +327,33 @@ func ProcessYAMLConfigFile( return nil, nil, nil, err } + // Add the `overrides` section for all components in this manifest + if len(finalTerraformOverrides) > 0 || len(finalHelmfileOverrides) > 0 { + if componentsSection, ok := stackConfigMap["components"].(map[string]any); ok { + // Terraform + if len(finalTerraformOverrides) > 0 { + if terraformSection, ok := componentsSection["terraform"].(map[string]any); ok { + for _, compSection := range terraformSection { + if componentSection, ok := compSection.(map[string]any); ok { + componentSection["overrides"] = finalTerraformOverrides + } + } + } + } + + // Helmfile + if len(finalHelmfileOverrides) > 0 { + if helmfileSection, ok := componentsSection["helmfile"].(map[string]any); ok { + for _, compSection := range helmfileSection { + if componentSection, ok := compSection.(map[string]any); ok { + componentSection["overrides"] = finalHelmfileOverrides + } + } + } + } + } + } + // Find and process all imports importStructs, err := ProcessImportSection(stackConfigMap, relativeFilePath) if err != nil { @@ -457,33 +484,6 @@ func ProcessYAMLConfigFile( } } - // Add the `overrides` section for all components in this manifest - if len(finalTerraformOverrides) > 0 || len(finalHelmfileOverrides) > 0 { - if componentsSection, ok := stackConfigMap["components"].(map[string]any); ok { - // Terraform - if len(finalTerraformOverrides) > 0 { - if terraformSection, ok := componentsSection["terraform"].(map[string]any); ok { - for _, compSection := range terraformSection { - if componentSection, ok := compSection.(map[string]any); ok { - componentSection[cfg.OverridesSectionName] = finalTerraformOverrides - } - } - } - } - - // Helmfile - if len(finalHelmfileOverrides) > 0 { - if helmfileSection, ok := componentsSection["helmfile"].(map[string]any); ok { - for _, compSection := range helmfileSection { - if componentSection, ok := compSection.(map[string]any); ok { - componentSection[cfg.OverridesSectionName] = finalHelmfileOverrides - } - } - } - } - } - } - if len(stackConfigMap) > 0 { stackConfigs = append(stackConfigs, stackConfigMap) }