diff --git a/library/common-test/tests/ingress/validation_test.yaml b/library/common-test/tests/ingress/validation_test.yaml index 0abb108a..a9315bfa 100644 --- a/library/common-test/tests/ingress/validation_test.yaml +++ b/library/common-test/tests/ingress/validation_test.yaml @@ -233,6 +233,21 @@ tests: - failedTemplate: errorMessage: Ingress - Expected [hosts.host] to not start with [http://], but got [http://test-host] + - it: should fail with host contain ":" + set: + operator: *operator + ingress: + my-ingress: + enabled: true + primary: true + hosts: + - host: test-host:123 + paths: + - path: /test-path + asserts: + - failedTemplate: + errorMessage: Ingress - Expected [hosts.host] to not contain [:], but got [test-host:123] + - it: should fail without paths set: operator: *operator diff --git a/library/common/templates/lib/ingress/_validation.tpl b/library/common/templates/lib/ingress/_validation.tpl index 5b0fd335..55cff13b 100644 --- a/library/common/templates/lib/ingress/_validation.tpl +++ b/library/common/templates/lib/ingress/_validation.tpl @@ -51,6 +51,9 @@ objectData: {{- if (hasPrefix "https://" $host) -}} {{- fail (printf "Ingress - Expected [hosts.host] to not start with [https://], but got [%s]" $host) -}} {{- end -}} + {{- if (contains ":" $host) -}} + {{- fail (printf "Ingress - Expected [hosts.host] to not contain [:], but got [%s]" $host) -}} + {{- end -}} {{- if not $h.paths -}} {{- fail "Ingress - Expected non-empty [hosts.paths]" -}}