mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 00:14:15 -03:00
add test for metallb and simplify logic
This commit is contained in:
@@ -157,6 +157,99 @@ tests:
|
||||
metallb.universe.tf/allow-shared-ip: test-release-name-common-test
|
||||
traefik.ingress.kubernetes.io/service.serversscheme: https
|
||||
|
||||
- it: should add metallb shared ip annotation without externalTrafficPolicy
|
||||
set:
|
||||
global:
|
||||
metallb:
|
||||
addServiceAnnotations: true
|
||||
service:
|
||||
my-service1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
port-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 12345
|
||||
workload:
|
||||
my-workload:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *serviceDoc
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *serviceDoc
|
||||
isSubset:
|
||||
path: metadata.annotations
|
||||
content:
|
||||
metallb.universe.tf/allow-shared-ip: test-release-name-common-test
|
||||
|
||||
- it: should add metallb shared ip annotation with externalTrafficPolicy set to Cluster
|
||||
set:
|
||||
global:
|
||||
metallb:
|
||||
addServiceAnnotations: true
|
||||
service:
|
||||
my-service1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: LoadBalancer
|
||||
externalTrafficPolicy: Cluster
|
||||
ports:
|
||||
port-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 12345
|
||||
workload:
|
||||
my-workload:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *serviceDoc
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *serviceDoc
|
||||
isSubset:
|
||||
path: metadata.annotations
|
||||
content:
|
||||
metallb.universe.tf/allow-shared-ip: test-release-name-common-test
|
||||
|
||||
- it: should NOT add metallb shared ip annotation with externalTrafficPolicy set to Local
|
||||
set:
|
||||
global:
|
||||
metallb:
|
||||
addServiceAnnotations: true
|
||||
service:
|
||||
my-service1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: LoadBalancer
|
||||
externalTrafficPolicy: Local
|
||||
ports:
|
||||
port-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 12345
|
||||
workload:
|
||||
my-workload:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *serviceDoc
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *serviceDoc
|
||||
notExists:
|
||||
path: metadata.annotations.metallb\.universe\.tf/allow-shared-ip
|
||||
|
||||
- it: should pass with correct selector with targetSelector
|
||||
set:
|
||||
service:
|
||||
|
||||
@@ -20,11 +20,8 @@ annotations: The annotations variable reference, to append the MetalLB annotatio
|
||||
|
||||
{{- if (hasKey $rootCtx.Values.global "metallb") -}}
|
||||
{{- if $rootCtx.Values.global.metallb.addServiceAnnotations -}}
|
||||
{{- if $objectData.externalTrafficPolicy -}}
|
||||
{{- if ne $objectData.externalTrafficPolicy "Local" -}}
|
||||
{{- $_ := set $annotations "metallb.universe.tf/allow-shared-ip" $sharedKey -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/* If externalTrafficPolicy is not set or is not Local, add the shared key as annotation */}}
|
||||
{{- if ne $objectData.externalTrafficPolicy "Local" -}}
|
||||
{{- $_ := set $annotations "metallb.universe.tf/allow-shared-ip" $sharedKey -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user