@@ -291,6 +291,28 @@ func (s *IngressTemplateTest) TestDifferentValuesInputs() {
291291 s .Require ().Contains (ingress .Labels , "app.kubernetes.io/name" )
292292 },
293293 },
294+ {
295+ Name : "TestHttpIngressLabelMergeOverwrite" ,
296+ HelmOptionsExtraArgs : map [string ][]string {"install" : {"--debug" }},
297+ Values : map [string ]string {
298+ "global.ingress.enabled" : "true" ,
299+ "global.ingress.labels.app" : "custom-override" ,
300+ "global.ingress.labels.environment" : "production" ,
301+ "global.ingress.labels.team" : "platform" ,
302+ },
303+ Verifier : func (t * testing.T , output string , err error ) {
304+ var ingress netv1.Ingress
305+ helm .UnmarshalK8SYaml (t , output , & ingress )
306+
307+ // then - global ingress labels should override chart labels for same keys
308+ s .Require ().Equal ("custom-override" , ingress .Labels ["app" ], "global labels should override chart labels for same key" )
309+ // and global-specific labels should be present
310+ s .Require ().Equal ("production" , ingress .Labels ["environment" ], "global labels should be present" )
311+ s .Require ().Equal ("platform" , ingress .Labels ["team" ], "global labels should be present" )
312+ // standard chart labels should still be there for non-conflicting keys
313+ s .Require ().Contains (ingress .Labels , "app.kubernetes.io/name" )
314+ },
315+ },
294316 }
295317
296318 testhelpers .RunTestCasesE (s .T (), s .chartPath , s .release , s .namespace , s .templates , testCases )
@@ -387,6 +409,29 @@ func (s *GrpcIngressTemplateTest) TestDifferentValuesInputs() {
387409 require .NotContains (t , output , "kind: Ingress" )
388410 },
389411 },
412+ {
413+ Name : "TestGrpcIngressLabelMergeOverwrite" ,
414+ HelmOptionsExtraArgs : map [string ][]string {"install" : {"--debug" }},
415+ Values : map [string ]string {
416+ "orchestration.enabled" : "true" ,
417+ "orchestration.ingress.grpc.enabled" : "true" ,
418+ "orchestration.ingress.grpc.labels.app" : "grpc-override" ,
419+ "orchestration.ingress.grpc.labels.environment" : "grpc-env" ,
420+ "orchestration.ingress.grpc.labels.protocol" : "grpc" ,
421+ },
422+ Verifier : func (t * testing.T , output string , err error ) {
423+ var ingress netv1.Ingress
424+ helm .UnmarshalK8SYaml (t , output , & ingress )
425+
426+ // then - grpc-specific labels should override chart labels for same keys
427+ s .Require ().Equal ("grpc-override" , ingress .Labels ["app" ], "grpc labels should override chart labels for same key" )
428+ // and grpc-specific labels should be present
429+ s .Require ().Equal ("grpc-env" , ingress .Labels ["environment" ], "grpc-specific labels should be present" )
430+ s .Require ().Equal ("grpc" , ingress .Labels ["protocol" ], "grpc-specific labels should be present" )
431+ // standard chart labels should still be there for non-conflicting keys
432+ s .Require ().Contains (ingress .Labels , "app.kubernetes.io/name" )
433+ },
434+ },
390435 }
391436
392437 testhelpers .RunTestCasesE (s .T (), s .chartPath , s .release , s .namespace , s .templates , testCases )
0 commit comments