@@ -263,6 +263,7 @@ func (m *Environment) validateRequiredChainLinkLabels() error {
263263 }
264264
265265 for _ , child := range * children {
266+ // most of our workloads are Helm charts
266267 if h , ok := child .(cdk8s.Helm ); ok {
267268 for _ , ao := range * h .ApiObjects () {
268269 switch * ao .Kind () {
@@ -276,6 +277,19 @@ func (m *Environment) validateRequiredChainLinkLabels() error {
276277 }
277278 }
278279 }
280+ // but legacy runners have no Helm charts, but are programmatically defined as KubeJobs
281+ if j , ok := child .(k8s.KubeJob ); ok {
282+ // but secrets or role bindings can also be cast to KubeJob, so we need to check if kind is Job
283+ if j .Kind () == nil || * j .Kind () != "Job" {
284+ continue
285+ }
286+ for _ , l := range requiredChainLinkWorkloadLabels {
287+ maybeLabel := j .Metadata ().GetLabel (& l )
288+ if maybeLabel == nil {
289+ missingWorkloadLabels [* j .Name ()] = append (missingWorkloadLabels [* j .Name ()], l )
290+ }
291+ }
292+ }
279293 }
280294
281295 if len (missingWorkloadLabels ) > 0 {
@@ -380,25 +394,7 @@ func (m *Environment) AddChart(f func(root cdk8s.Chart) ConnectedChart) *Environ
380394 }
381395 config .JSIIGlobalMu .Lock ()
382396 defer config .JSIIGlobalMu .Unlock ()
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 )
397+ m .Charts = append (m .Charts , f (m .root ))
402398 return m
403399}
404400
0 commit comments