Skip to content

Commit ffe7dbc

Browse files
committed
try to add labels also to charts, programmatically
1 parent 8c2d398 commit ffe7dbc

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lib/k8s/environment/environment.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,25 @@ func (m *Environment) AddChart(f func(root cdk8s.Chart) ConnectedChart) *Environ
380380
}
381381
config.JSIIGlobalMu.Lock()
382382
defer config.JSIIGlobalMu.Unlock()
383-
m.Charts = append(m.Charts, f(m.root))
383+
chart := f(m.root)
384+
385+
h := cdk8s.NewHelm(m.root, ptr.Ptr(chart.GetName()), &cdk8s.HelmProps{
386+
Chart: ptr.Ptr(chart.GetPath()),
387+
HelmFlags: &[]*string{
388+
ptr.Ptr("--namespace"),
389+
ptr.Ptr(m.Cfg.Namespace),
390+
},
391+
ReleaseName: ptr.Ptr(chart.GetName()),
392+
Values: chart.GetValues(),
393+
})
394+
395+
componentLabels, err := getComponentLabels(m.Cfg.WorkloadLabels, chart.GetLabels())
396+
if err != nil {
397+
m.err = err
398+
}
399+
400+
addRequiredChainLinkLabels(h, componentLabels)
401+
m.Charts = append(m.Charts, chart)
384402
return m
385403
}
386404

@@ -1180,6 +1198,8 @@ func markNotSafeToEvict(preventPodEviction bool, m map[string]string) map[string
11801198
return m
11811199
}
11821200

1201+
// GetRequiredChainLinkNamespaceLabels returns the required chain.link namespace labels
1202+
// if `CHAINLINK_USER_TEAM` env var is not set it will return an error
11831203
func GetRequiredChainLinkNamespaceLabels(product, testType string) ([]string, error) {
11841204
var nsLabels []string
11851205
createdLabels, err := createRequiredChainLinkLabels(product, testType)
@@ -1194,6 +1214,8 @@ func GetRequiredChainLinkNamespaceLabels(product, testType string) ([]string, er
11941214
return nsLabels, nil
11951215
}
11961216

1217+
// GetRequiredChainLinkWorkloadLabels returns the required chain.link workload labels
1218+
// if `CHAINLINK_USER_TEAM` env var is not set it will return an error
11971219
func GetRequiredChainLinkWorkloadLabels(product, testType string) (map[string]string, error) {
11981220
createdLabels, err := createRequiredChainLinkLabels(product, testType)
11991221
if err != nil {

0 commit comments

Comments
 (0)