-
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathstack_processor_process_stacks_helpers.go
More file actions
185 lines (170 loc) · 7.52 KB
/
Copy pathstack_processor_process_stacks_helpers.go
File metadata and controls
185 lines (170 loc) · 7.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package exec
import (
"github.com/cloudposse/atmos/pkg/perf"
"github.com/cloudposse/atmos/pkg/schema"
)
// Map capacity hints for component processing to reduce reallocation overhead.
const (
componentVarsCapacity = 32 // Typical component has 10-50 variables.
componentSettingsCapacity = 16 // Typical component has 5-20 settings.
componentSmallMapCapacity = 8 // For env, auth, providers, hooks, backend sections (5-15 items).
componentOverridesCapacity = 4 // Overrides are typically sparse (0-10 items).
)
// ComponentProcessorOptions contains configuration for processing a component.
type ComponentProcessorOptions struct {
ComponentType string
Component string
Stack string
StackName string
ComponentMap map[string]any
AllComponentsMap map[string]any
ComponentsBasePath string
CheckBaseComponentExists bool
// Global configurations.
GlobalVars map[string]any
GlobalSettings map[string]any
GlobalEnv map[string]any
GlobalAuth map[string]any
GlobalSecrets map[string]any
GlobalDependencies map[string]any
GlobalMetadata map[string]any
GlobalCommand string
AtmosGlobalAuthMap map[string]any // Pre-converted atmosConfig.Auth to prevent race conditions
// Terraform-specific options.
TerraformProviders map[string]any
TerraformRequiredProviders map[string]any
TerraformRequiredVersion string
GlobalAndTerraformHooks map[string]any
GlobalAndTerraformGenerate map[string]any
GlobalBackendType string
GlobalBackendSection map[string]any
GlobalRemoteStateBackendType string
GlobalRemoteStateBackendSection map[string]any
GlobalSourceSection map[string]any
GlobalProvisionSection map[string]any
// Kubernetes-specific global defaults (lowest precedence in the final merge).
GlobalKubernetesProvider string
GlobalKubernetesPaths any
GlobalKubernetesManifests any
GlobalKubernetesRender map[string]any
GlobalKubernetesValidate any
// Atmos configuration.
AtmosConfig *schema.AtmosConfiguration
}
// ComponentProcessorResult contains the processed component data.
type ComponentProcessorResult struct {
ComponentVars map[string]any
ComponentSettings map[string]any
ComponentEnv map[string]any
ComponentMetadata map[string]any
ComponentDependencies map[string]any
ComponentLocals map[string]any // Component-level locals for template processing.
ComponentCommand string
ComponentProvider string
ComponentPaths any
ComponentManifests any
ComponentValidate any
// ComponentPlugins holds the Helm CLI plugins list (helm/helmfile components).
ComponentPlugins any
ComponentRender map[string]any
// ComponentHelm holds native Helm component fields (chart, values, values_files,
// repositories, version, repository, namespace, name, render) as a single bag.
ComponentHelm map[string]any
ComponentOverrides map[string]any
ComponentOverridesVars map[string]any
ComponentOverridesSettings map[string]any
ComponentOverridesEnv map[string]any
ComponentOverridesAuth map[string]any
ComponentOverridesCommand string
BaseComponentName string
BaseComponentVars map[string]any
BaseComponentSettings map[string]any
BaseComponentEnv map[string]any
BaseComponentAuth map[string]any
BaseComponentMetadata map[string]any
BaseComponentDependencies map[string]any
BaseComponentLocals map[string]any // Base component locals for inheritance.
BaseComponentCommand string
BaseComponentProvider string
BaseComponentPaths any
BaseComponentManifests any
BaseComponentValidate any
// BaseComponentPlugins holds the inherited Helm CLI plugins list from base components.
BaseComponentPlugins any
BaseComponentRender map[string]any
// BaseComponentHelm holds the inherited native Helm fields from base components.
BaseComponentHelm map[string]any
ComponentInheritanceChain []string
BaseComponents []string
// Terraform-specific fields.
ComponentProviders map[string]any
ComponentRequiredProviders map[string]any
ComponentRequiredVersion string
ComponentHooks map[string]any
ComponentTest map[string]any
ComponentMocks map[string]any
// ComponentSecrets holds the component-level `secrets:` declaration section.
ComponentSecrets map[string]any
ComponentOverridesSecrets map[string]any
BaseComponentSecrets map[string]any
ComponentGenerate map[string]any
ComponentAuth map[string]any
// ComponentProvision holds provisioning configuration for the component (e.g., workdir settings).
ComponentProvision map[string]any
ComponentBackendType string
ComponentBackendSection map[string]any
ComponentRemoteStateBackendType string
ComponentRemoteStateBackendSection map[string]any
ComponentOverridesProviders map[string]any
ComponentOverridesRequiredProviders map[string]any
ComponentOverridesRequiredVersion string
ComponentOverridesHooks map[string]any
ComponentOverridesGenerate map[string]any
BaseComponentProviders map[string]any
BaseComponentRequiredProviders map[string]any
BaseComponentRequiredVersion string
BaseComponentHooks map[string]any
BaseComponentTest map[string]any
BaseComponentMocks map[string]any
BaseComponentGenerate map[string]any
BaseComponentBackendType string
BaseComponentBackendSection map[string]any
BaseComponentRemoteStateBackendType string
BaseComponentRemoteStateBackendSection map[string]any
ComponentSourceSection map[string]any
BaseComponentSourceSection map[string]any
BaseComponentProvisionSection map[string]any
// ComponentRetry holds the raw retry configuration from the concrete component
// (decoded to a typed *schema.RetryConfig only after deep-merge with base + overrides).
ComponentRetry map[string]any
// ComponentOverridesRetry holds the retry section from the component's `overrides:`
// block, which wins over both base and concrete component retry config.
ComponentOverridesRetry map[string]any
// BaseComponentRetry holds the retry configuration inherited from base components
// (deep-merged across the full inheritance chain by ProcessBaseComponentConfig).
BaseComponentRetry map[string]any
}
// processComponent processes a component extracting common configuration sections.
func processComponent(opts *ComponentProcessorOptions) (*ComponentProcessorResult, error) {
defer perf.Track(opts.AtmosConfig, "exec.processComponent")()
result := &ComponentProcessorResult{
ComponentVars: make(map[string]any, componentVarsCapacity),
ComponentSettings: make(map[string]any, componentSettingsCapacity),
ComponentEnv: make(map[string]any, componentSmallMapCapacity),
ComponentMetadata: make(map[string]any, componentSettingsCapacity),
BaseComponents: []string{},
}
// Extract component sections.
if err := extractComponentSections(opts, result); err != nil {
return nil, err
}
// Process overrides.
if err := processComponentOverrides(opts, result); err != nil {
return nil, err
}
// Process component inheritance.
if err := processComponentInheritance(opts, result); err != nil {
return nil, err
}
return result, nil
}