From 8b6a36468f5ca491a04e93bd43d8c55fb740fde0 Mon Sep 17 00:00:00 2001 From: Marco Rizzi Date: Wed, 24 Apr 2024 22:12:38 +0200 Subject: [PATCH] Case sensitive management for input options keys (#435) Signed-off-by: mrizzi --- cmd/verify.go | 2 +- cmd/verify_test.go | 22 ++++++++++++++++++ ...1.0-v3.with-additionalproperties-false.tgz | Bin 0 -> 1028 bytes 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 internal/chartverifier/checks/chart-0.1.0-v3.with-additionalproperties-false.tgz diff --git a/cmd/verify.go b/cmd/verify.go index 829a10c4..6c152f2e 100644 --- a/cmd/verify.go +++ b/cmd/verify.go @@ -110,7 +110,7 @@ func convertToMap(values []string) map[string]interface{} { valueMap := make(map[string]interface{}) for _, val := range values { parts := strings.SplitN(val, "=", 2) - valueMap[strings.ToLower(parts[0])] = parts[1] + valueMap[parts[0]] = parts[1] } return valueMap } diff --git a/cmd/verify_test.go b/cmd/verify_test.go index 3439443d..2938a6fd 100644 --- a/cmd/verify_test.go +++ b/cmd/verify_test.go @@ -114,6 +114,28 @@ func TestCertify(t *testing.T) { require.Contains(t, output.String(), expected) }, }, + { + name: "Should succeed when the chart exists and a chart value is overridden", + args: []string{ + "-e", "helm-lint", + "-S", "replicaCount=2", + "-E", + "../internal/chartverifier/checks/chart-0.1.0-v3.with-additionalproperties-false.tgz", + }, + validateErrorFunc: func(err error) { + require.NoError(t, err) + }, + validateOutputFunc: func(output *bytes.Buffer) { + require.NotEmpty(t, output.String()) + + expected := "results:\n" + + " - check: v1.0/helm-lint\n" + + " type: Mandatory\n" + + " outcome: PASS\n" + + " reason: Helm lint successful\n" + require.Contains(t, output.String(), expected) + }, + }, { name: "Should display JSON certificate when option --output and argument values are given", args: []string{ diff --git a/internal/chartverifier/checks/chart-0.1.0-v3.with-additionalproperties-false.tgz b/internal/chartverifier/checks/chart-0.1.0-v3.with-additionalproperties-false.tgz new file mode 100644 index 0000000000000000000000000000000000000000..d26bc6390e1302f137fd1f96b16c6691bd8d3087 GIT binary patch literal 1028 zcmV+f1pE6RiwFS6C@E$D1MOICZ`(Ey?q~iAP8raxh$+gigMkeg+yM=SZN@TWABJI| zC0b%bkt|8sb&Bq{?@0MAZWj+|lQpO>044G6o;%5Wj>qH`vp$`Kk*ruPpWK5`N{9VE zhHEw&(EV#GJvzi$f0%W<-F|n}!!#SvE`5UOeI#=zjq}VxDzz0iH{##zj_KQ1!Q1O2 z5oW{{w@zp^#)~du#%v!mk_`z(1$Vg>#>ctu@e3|%oQL&-=i1^Qn;Ex?d+w0PgGJ@N zapN>yE|-MAX0?%=Z$}SB-#;2F(6A$b0`Q!R?>X z-U}}y=2a|i?Sei0)!u&Y+ecgfJ%>J>K@*=se?Avw&CEw^29NcBS^u#A8^GVG{y&7= zI{#(pTBu@-Cvg${#0;vrX9e>tbck(_RQi ziA&3W0&RXRN~JBohZx8BKj;k(&wu@4@5KLykTX1G-gB!Q_8PZK052=9@T?KCfW03Z zmS003<_J2&zg5Cv*O;)?!VN4NiA$+xxMn`D!1^2xim;Q21qVN0?aeb)0D$6U{8tYC z%2+-ZuX%x&0_?u{n&4lQTw$%EXGjS{w}&Nkf&`K0mw#Qt;gbWzMAtO{Tum-