mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix: add validation guards for Istio templates
- Gateway: credentialName only emitted for non-PASSTHROUGH TLS modes; fail when credentialName empty for SIMPLE/MUTUAL - VirtualService: fail when neither gateway.enabled nor virtualService.gateways is configured (prevents null gateways field) - Tests: add gateway.enabled to DestinationRule tests to satisfy VirtualService validation guard; add 4 validation guard test cases (total 40 Istio tests, all passing)
This commit is contained in:
parent
bd69eec692
commit
d06dd204a3
3 changed files with 95 additions and 0 deletions
|
|
@ -35,7 +35,12 @@ spec:
|
|||
protocol: HTTPS
|
||||
tls:
|
||||
mode: {{ .Values.istio.gateway.tls.mode | default "SIMPLE" }}
|
||||
{{- if ne (.Values.istio.gateway.tls.mode | default "SIMPLE") "PASSTHROUGH" }}
|
||||
{{- if not .Values.istio.gateway.tls.credentialName }}
|
||||
{{- fail "istio.gateway.tls.credentialName must be set for SIMPLE or MUTUAL TLS mode" }}
|
||||
{{- end }}
|
||||
credentialName: {{ .Values.istio.gateway.tls.credentialName | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.istio.gateway.tls.minProtocolVersion }}
|
||||
minProtocolVersion: {{ .Values.istio.gateway.tls.minProtocolVersion }}
|
||||
{{- end }}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ spec:
|
|||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
gateways:
|
||||
{{- if and (not .Values.istio.gateway.enabled) (not .Values.istio.virtualService.gateways) }}
|
||||
{{- fail "istio.virtualService: at least one gateway must be configured — either set istio.gateway.enabled=true or provide istio.virtualService.gateways" }}
|
||||
{{- end }}
|
||||
{{- if .Values.istio.gateway.enabled }}
|
||||
- {{ $fullName }}
|
||||
{{- end }}
|
||||
|
|
|
|||
|
|
@ -585,6 +585,8 @@ tests:
|
|||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
gateway:
|
||||
enabled: true
|
||||
destinationRule:
|
||||
enabled: true
|
||||
asserts:
|
||||
|
|
@ -602,6 +604,8 @@ tests:
|
|||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
gateway:
|
||||
enabled: true
|
||||
destinationRule:
|
||||
enabled: true
|
||||
asserts:
|
||||
|
|
@ -614,6 +618,8 @@ tests:
|
|||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
gateway:
|
||||
enabled: true
|
||||
destinationRule:
|
||||
enabled: true
|
||||
asserts:
|
||||
|
|
@ -626,6 +632,8 @@ tests:
|
|||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
gateway:
|
||||
enabled: true
|
||||
destinationRule:
|
||||
enabled: true
|
||||
trafficPolicy:
|
||||
|
|
@ -648,6 +656,8 @@ tests:
|
|||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
gateway:
|
||||
enabled: true
|
||||
destinationRule:
|
||||
enabled: true
|
||||
trafficPolicy:
|
||||
|
|
@ -665,6 +675,8 @@ tests:
|
|||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
gateway:
|
||||
enabled: true
|
||||
destinationRule:
|
||||
enabled: true
|
||||
labels:
|
||||
|
|
@ -685,6 +697,8 @@ tests:
|
|||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
gateway:
|
||||
enabled: true
|
||||
destinationRule:
|
||||
enabled: true
|
||||
asserts:
|
||||
|
|
@ -694,3 +708,76 @@ tests:
|
|||
- isNotNull:
|
||||
path: metadata.labels["helm.sh/chart"]
|
||||
template: istio-destinationrule.yaml
|
||||
|
||||
#
|
||||
# === Validation Guards ===
|
||||
#
|
||||
- it: should fail when VirtualService has no gateway source
|
||||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
hosts:
|
||||
- api.example.com
|
||||
gateway:
|
||||
enabled: false
|
||||
virtualService:
|
||||
enabled: true
|
||||
gateways: []
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "istio.virtualService: at least one gateway must be configured \u2014 either set istio.gateway.enabled=true or provide istio.virtualService.gateways"
|
||||
template: istio-virtualservice.yaml
|
||||
|
||||
- it: should fail when TLS enabled without credentialName for SIMPLE mode
|
||||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
hosts:
|
||||
- api.example.com
|
||||
gateway:
|
||||
enabled: true
|
||||
tls:
|
||||
enabled: true
|
||||
mode: SIMPLE
|
||||
credentialName: ""
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "istio.gateway.tls.credentialName must be set for SIMPLE or MUTUAL TLS mode"
|
||||
template: istio-gateway.yaml
|
||||
|
||||
- it: should fail when TLS enabled without credentialName for MUTUAL mode
|
||||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
hosts:
|
||||
- api.example.com
|
||||
gateway:
|
||||
enabled: true
|
||||
tls:
|
||||
enabled: true
|
||||
mode: MUTUAL
|
||||
credentialName: ""
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "istio.gateway.tls.credentialName must be set for SIMPLE or MUTUAL TLS mode"
|
||||
template: istio-gateway.yaml
|
||||
|
||||
- it: should not emit credentialName for PASSTHROUGH mode
|
||||
set:
|
||||
istio:
|
||||
enabled: true
|
||||
hosts:
|
||||
- api.example.com
|
||||
gateway:
|
||||
enabled: true
|
||||
tls:
|
||||
enabled: true
|
||||
mode: PASSTHROUGH
|
||||
asserts:
|
||||
- isNull:
|
||||
path: spec.servers[1].tls.credentialName
|
||||
template: istio-gateway.yaml
|
||||
- equal:
|
||||
path: spec.servers[1].tls.mode
|
||||
value: PASSTHROUGH
|
||||
template: istio-gateway.yaml
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue