Skip to content

Commit 2942a7d

Browse files
author
Robin LIORET
committed
feat: helm v2-alpha: add nodeSelector, tolerations and affinity to the chart converter
1 parent ea9c4fc commit 2942a7d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

pkg/plugins/optional/helm/v2alpha/scaffolds/internal/kustomize/chart_converter.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func (c *ChartConverter) ExtractDeploymentConfig() map[string]interface{} {
105105
}
106106

107107
extractPodSecurityContext(specMap, config)
108+
extractPodNodeSelector(specMap, config)
109+
extractPodTolerations(specMap, config)
110+
extractPodAffinity(specMap, config)
108111

109112
container := firstManagerContainer(specMap)
110113
if container == nil {
@@ -149,6 +152,48 @@ func extractPodSecurityContext(specMap map[string]interface{}, config map[string
149152
config["podSecurityContext"] = podSecurityContext
150153
}
151154

155+
func extractPodNodeSelector(specMap map[string]interface{}, config map[string]interface{}) {
156+
raw, found, err := unstructured.NestedFieldNoCopy(specMap, "nodeSelector")
157+
if !found || err != nil {
158+
return
159+
}
160+
161+
result, ok := raw.(map[string]interface{})
162+
if !ok || len(result) == 0 {
163+
return
164+
}
165+
166+
config["podNodeSelector"] = result
167+
}
168+
169+
func extractPodTolerations(specMap map[string]interface{}, config map[string]interface{}) {
170+
raw, found, err := unstructured.NestedFieldNoCopy(specMap, "tolerations")
171+
if !found || err != nil {
172+
return
173+
}
174+
175+
result, ok := raw.([]interface{})
176+
if !ok || len(result) == 0 {
177+
return
178+
}
179+
180+
config["podTolerations"] = result
181+
}
182+
183+
func extractPodAffinity(specMap map[string]interface{}, config map[string]interface{}) {
184+
raw, found, err := unstructured.NestedFieldNoCopy(specMap, "affinity")
185+
if !found || err != nil {
186+
return
187+
}
188+
189+
result, ok := raw.(map[string]interface{})
190+
if !ok || len(result) == 0 {
191+
return
192+
}
193+
194+
config["podAffinity"] = result
195+
}
196+
152197
func firstManagerContainer(specMap map[string]interface{}) map[string]interface{} {
153198
containers, found, err := unstructured.NestedFieldNoCopy(specMap, "containers")
154199
if !found || err != nil {

0 commit comments

Comments
 (0)