From e85c443284089c51ce282bd879cd8a8414ae37ae Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Fri, 27 Aug 2021 09:03:45 +0200 Subject: [PATCH] Fixing #28: ingress host names and resource names have different sanitization needs --- charts/common/templates/_helpers.tpl | 2 +- charts/cron-job/charts/common-0.1.0.tgz | Bin 1794 -> 1775 bytes charts/onechart/charts/common-0.1.0.tgz | Bin 1794 -> 1775 bytes charts/onechart/templates/_helpers.tpl | 2 +- charts/onechart/templates/ingress.yaml | 4 ++-- .../onechart/tests/ingress_domain_test.yaml | 8 ++++---- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/common/templates/_helpers.tpl b/charts/common/templates/_helpers.tpl index efc1177..24ea469 100644 --- a/charts/common/templates/_helpers.tpl +++ b/charts/common/templates/_helpers.tpl @@ -6,5 +6,5 @@ Create robustName that can be used as Kubernetes resource name, and as subdomain \W – all but \w . */}} {{- define "common.robustName" -}} -{{ regexReplaceAll "[^0-9A-Za-z_\\.]+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" | trimPrefix "-" }} +{{ regexReplaceAll "\\W+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" }} {{- end }} diff --git a/charts/cron-job/charts/common-0.1.0.tgz b/charts/cron-job/charts/common-0.1.0.tgz index c9f6ba2e444dcec59ab36025b057dcbe63705e3f..47fc1a7d6ad54d2565613f1b3e41ddca448ade22 100644 GIT binary patch delta 1735 zcmV;&1~~bG4(|<+Jb!I(;yM=Y=lqJZwD)DYB_tH6gft(nI``gP?aqtZtIn57BavcNzzvp@7|DNAzANd{MZ~I>F;=Fz2`Rz{k{0O|S5P!>xB}x-{szB0M+xws3Z^$AD%-(>ZknoRWfRdv|z0tuo{C9iZ68^j0c8&jo*uz5; zLL5?#&`9@!yMNdKI%W-M&SsA3MTg+t5SE~FCqyck&739j@SQu#!#-Tv;jc;TM5swf zH0e74DPKH1K)%!F?xYwbO1~iyHo(0?hD4!jZjFa@po&S5j$Z0u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2Q_0g9b+N1WN^~%IzGebsRYPqN>8)+i28B6y?oK#m@rUV#QatO52AyDN=cZwZ zTECJJ<|U=J%d=+9aAy~drrbd56lwH}Vg}!c5L=lyZKR@O8@1N2AM&(vYk3APLx0NK z2{n^^c)^>wcZKg#)J7MnSw2rbDSJN`PVf_}GR`ukvWWjIJ^XQlS-`6L&r#5=;J<&| zeE)C9YVg0X0hW+KweRPlg&{M7#*BnA?o0#9lL-wTvW;0WNFAMf;4HZo@wc&H3zD^Xtj zxdPG$Cw9fCmG9wqmxX;fdyM}#SpiyE|35ye@_*3lHvGR0dzAmH+@GJTEq^H^Z;Y|O z!Xv`%Fn{g2V@lD4hdW&JD`W2Jmh9c6sf=Cgrmu(6We(?P#lHvp?Cqx`u^5 zAdgwwMV747=#Ahv1F*cm+<)unv-?|l{`wgHHw1lWEA`*u!vBBuj~o1N#U91~wxF-) zHPBi}PwJ|Kg{%qf&Fi(3&^h7s$wZOK!-vA%!+&UOG^P)xk&Q>wD7&X_IsX%z1hKJ@ z3ODa#mHz7;Rr&w0-#=>je;c+7Z>ce;ga#ua+W~MrK>@>*@ra2rB!4u#qGQy=+l8Me zOoL97L@J{}PmpsMb2)^VnsCCz_y81gYS>_ihVK)1K#CDuGc$od zJR@Lb3`pTd+K?>217`w>M_!&?o*Ajo+l3RiW#Rnf3?inqN5;%_+-DZPM~3fJ$9)zJ zlX1s>6t{XRI6N!nOl+^EVql&Y{1rpv5f&lsWZjkg)gx0K$_P6R4>s0VV_&oVKL7y#|5(t@B>*@80Q|0nE&u=k diff --git a/charts/onechart/charts/common-0.1.0.tgz b/charts/onechart/charts/common-0.1.0.tgz index 9425a52744c2ba489a4d37ddc0d89f4c1d074fb3..7a08785331da9939d067515a6c873988b604f353 100644 GIT binary patch delta 1735 zcmV;&1~~bG4(|<+Jb!I(1veV5<>7#&I? z@0@8dpXd6n=REZ%Y;2w7_}3UGjA&Gy524^AI*v)QGdkFW|9;S~;J@GRHu&F*-QTw% z!V%>Nt!yv2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maatHJ-m23SG{)xMvH7KY3S8Z#2gxHAnXPbM^Y$TnuhjL*&w08|KRs9{p%Xv`KM zPbWw@(2%FvplV;U2nWzID#g|V!+)R%)lFhBdYOk?%2Y-!L$Oj!|14k0RG7?nmZ*%1 zpa*c*&I!RS_=x0UYgXOv7Xz~{o&9ouV&9r3KcSh8eM`-xe!SCH*~pw#;Gr^@oh|WCdtt{r~u=%Kt&%Z}@*3_9*{Xxj#QwTYpkU-WX$l zg-3+jVgA~4$C`5e$|J~+BkFb6eUYylx_)Z5$p2Y>=X8hO%pvgV{J(ns+dn>P>i=7@ z8vd_tfX5DjD+PhMGvG>AP&x;$oEwy#4dC1I?ef}#P0D9Spk)ym+tF6ZW`DAIbqx!B zKpwNUi!52E(Hp^U24H!AxqsKuXZN@A{Pi*XZwUI%R_edQh5!FL_8a_f#U91~wxF-) zHPBi}PwJ|Kg{%qf&Fi(3&^h7s$wZOK!-vA%!+&UOG^P)xk&Q>wD7&X_IsX%z1hKJ@ z3ODa#mHz7;Rr&w0-#>2ne;c+7Z>ce;ga#ua+W~MrK>@>*@ra2rB!4u#qGQy=+l8Me zOoL97L@J{}PmpsMb2)^VnsCCz_y81gYS>_ihVK)1K#CDuGc$od zJR@Lb3`pTd+K?>217`w>M_!&?o*Ajo+l3RiW#Rnf3?inqN5;%_+-DZPM~3fJ$9)zJ zlX1s>6t{XRI6N!nOl+^EVql&Y{1rpv5f&lsWZjkg)gx0K$_P6R4>s0VV_&oVKL7y#|MrTr=m0nX024cT>Hq)$ diff --git a/charts/onechart/templates/_helpers.tpl b/charts/onechart/templates/_helpers.tpl index c0c138d..9c5df3c 100644 --- a/charts/onechart/templates/_helpers.tpl +++ b/charts/onechart/templates/_helpers.tpl @@ -68,5 +68,5 @@ Create robustName that can be used as Kubernetes resource name, and as subdomain \W – all but \w . */}} {{- define "robustName" -}} -{{ regexReplaceAll "[^0-9A-Za-z_\\.]+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" | trimPrefix "-" }} +{{ regexReplaceAll "\\W+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" }} {{- end }} diff --git a/charts/onechart/templates/ingress.yaml b/charts/onechart/templates/ingress.yaml index f7e952a..56248bd 100644 --- a/charts/onechart/templates/ingress.yaml +++ b/charts/onechart/templates/ingress.yaml @@ -29,11 +29,11 @@ spec: {{- if default false .ingress.tlsEnabled }} tls: - hosts: - - {{ template "robustName" .ingress.host | quote }} + - {{ .ingress.host | quote }} secretName: {{ printf "tls-%s" $resourceName }} {{- end }} rules: - - host: {{ template "robustName" .ingress.host | quote }} + - host: {{ .ingress.host | quote }} http: paths: - backend: diff --git a/charts/onechart/tests/ingress_domain_test.yaml b/charts/onechart/tests/ingress_domain_test.yaml index cb011b5..df420b6 100644 --- a/charts/onechart/tests/ingress_domain_test.yaml +++ b/charts/onechart/tests/ingress_domain_test.yaml @@ -23,7 +23,7 @@ tests: - backend: serviceName: release-name servicePort: 80 - - it: Should conform to DNS names + - it: Should pass ingress host name as is, user must sanitize it set: ingress: host: feature/my_branch.local @@ -33,12 +33,12 @@ tests: path: spec.tls value: - hosts: - - feature-my-branch.local + - feature/my_branch.local secretName: tls-release-name - equal: path: spec.rules value: - - host: feature-my-branch.local + - host: feature/my_branch.local http: paths: - backend: @@ -100,4 +100,4 @@ tests: value: - hosts: - chart-example.local - secretName: tls-release-name-chart-example.local + secretName: tls-release-name-chart-example-local