|
| 1 | +From 3c6378423df820eff9d876b25297470e5bb50974 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Matt Farina < [email protected]> |
| 3 | +Date: Tue, 29 Jul 2025 15:37:57 -0400 |
| 4 | +Subject: [PATCH 1/2] Handle messy index files |
| 5 | + |
| 6 | +Signed-off-by: Matt Farina < [email protected]> |
| 7 | +(cherry picked from commit 69efc0d4fbcc143e0b196253f6e82808aaa57fc3) |
| 8 | +(cherry picked from commit 039b0b18d3c83c9aa3a80da67f3cf1c2d965a598) |
| 9 | +--- |
| 10 | + pkg/repo/index.go | 1 + |
| 11 | + pkg/repo/index_test.go | 1 + |
| 12 | + 2 files changed, 2 insertions(+) |
| 13 | + |
| 14 | +diff --git a/pkg/repo/index.go b/pkg/repo/index.go |
| 15 | +index 8009c15..c55fc65 100644 |
| 16 | +--- a/pkg/repo/index.go |
| 17 | ++++ b/pkg/repo/index.go |
| 18 | +@@ -357,6 +357,7 @@ func loadIndex(data []byte, source string) (*IndexFile, error) { |
| 19 | + for idx := len(cvs) - 1; idx >= 0; idx-- { |
| 20 | + if cvs[idx] == nil { |
| 21 | + log.Printf("skipping loading invalid entry for chart %q from %s: empty entry", name, source) |
| 22 | ++ cvs = append(cvs[:idx], cvs[idx+1:]...) |
| 23 | + continue |
| 24 | + } |
| 25 | + // When metadata section missing, initialize with no data |
| 26 | +diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go |
| 27 | +index eb9e245..22e87f6 100644 |
| 28 | +--- a/pkg/repo/index_test.go |
| 29 | ++++ b/pkg/repo/index_test.go |
| 30 | +@@ -67,6 +67,7 @@ entries: |
| 31 | + grafana: |
| 32 | + - apiVersion: v2 |
| 33 | + name: grafana |
| 34 | ++ - null |
| 35 | + foo: |
| 36 | + - |
| 37 | + bar: |
| 38 | +-- |
| 39 | +2.45.4 |
| 40 | + |
| 41 | + |
| 42 | +From c1286a4ff5d56d6d4c76ba0b76297f4343af34e3 Mon Sep 17 00:00:00 2001 |
| 43 | +From: Matt Farina < [email protected]> |
| 44 | +Date: Thu, 31 Jul 2025 09:25:12 -0400 |
| 45 | +Subject: [PATCH 2/2] fix Chart.yaml handling |
| 46 | + |
| 47 | +Signed-off-by: Matt Farina < [email protected]> |
| 48 | +(cherry picked from commit f13afaacd6f8f9dca4ad914d87fabbe129692eda) |
| 49 | +Signed-off-by: Azure Linux Security Servicing Account < [email protected]> |
| 50 | +Upstream-reference: https://github.com/helm/helm/commit/ec5f59e2db56533d042a124f5bae54dd87b558e6.patch |
| 51 | +--- |
| 52 | + pkg/chartutil/dependencies.go | 5 +++-- |
| 53 | + pkg/lint/rules/chartfile.go | 3 +++ |
| 54 | + pkg/lint/rules/chartfile_test.go | 10 ++++++++++ |
| 55 | + 3 files changed, 16 insertions(+), 2 deletions(-) |
| 56 | + |
| 57 | +diff --git a/pkg/chartutil/dependencies.go b/pkg/chartutil/dependencies.go |
| 58 | +index 205d99e..b7c9bb3 100644 |
| 59 | +--- a/pkg/chartutil/dependencies.go |
| 60 | ++++ b/pkg/chartutil/dependencies.go |
| 61 | +@@ -16,6 +16,7 @@ limitations under the License. |
| 62 | + package chartutil |
| 63 | + |
| 64 | + import ( |
| 65 | ++ "fmt" |
| 66 | + "log" |
| 67 | + "strings" |
| 68 | + |
| 69 | +@@ -255,8 +256,8 @@ func processImportValues(c *chart.Chart, merge bool) error { |
| 70 | + for _, riv := range r.ImportValues { |
| 71 | + switch iv := riv.(type) { |
| 72 | + case map[string]interface{}: |
| 73 | +- child := iv["child"].(string) |
| 74 | +- parent := iv["parent"].(string) |
| 75 | ++ child := fmt.Sprintf("%v", iv["child"]) |
| 76 | ++ parent := fmt.Sprintf("%v", iv["parent"]) |
| 77 | + |
| 78 | + outiv = append(outiv, map[string]string{ |
| 79 | + "child": child, |
| 80 | +diff --git a/pkg/lint/rules/chartfile.go b/pkg/lint/rules/chartfile.go |
| 81 | +index 910602b..555ec71 100644 |
| 82 | +--- a/pkg/lint/rules/chartfile.go |
| 83 | ++++ b/pkg/lint/rules/chartfile.go |
| 84 | +@@ -151,6 +151,9 @@ func validateChartVersion(cf *chart.Metadata) error { |
| 85 | + |
| 86 | + func validateChartMaintainer(cf *chart.Metadata) error { |
| 87 | + for _, maintainer := range cf.Maintainers { |
| 88 | ++ if maintainer == nil { |
| 89 | ++ return errors.New("a maintainer entry is empty") |
| 90 | ++ } |
| 91 | + if maintainer.Name == "" { |
| 92 | + return errors.New("each maintainer requires a name") |
| 93 | + } else if maintainer.Email != "" && !govalidator.IsEmail(maintainer.Email) { |
| 94 | +diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go |
| 95 | +index a06d7dc..b46e220 100644 |
| 96 | +--- a/pkg/lint/rules/chartfile_test.go |
| 97 | ++++ b/pkg/lint/rules/chartfile_test.go |
| 98 | +@@ -143,6 +143,16 @@ func TestValidateChartMaintainer(t *testing.T) { |
| 99 | + t.Errorf("validateChartMaintainer(%s, %s) to return no error, got %s", test.Name, test.Email, err.Error()) |
| 100 | + } |
| 101 | + } |
| 102 | ++ |
| 103 | ++ // Testing for an empty maintainer |
| 104 | ++ badChart.Maintainers = []*chart.Maintainer{nil} |
| 105 | ++ err := validateChartMaintainer(badChart) |
| 106 | ++ if err == nil { |
| 107 | ++ t.Errorf("validateChartMaintainer did not return error for nil maintainer as expected") |
| 108 | ++ } |
| 109 | ++ if err.Error() != "a maintainer entry is empty" { |
| 110 | ++ t.Errorf("validateChartMaintainer returned unexpected error for nil maintainer: %s", err.Error()) |
| 111 | ++ } |
| 112 | + } |
| 113 | + |
| 114 | + func TestValidateChartSources(t *testing.T) { |
| 115 | +-- |
| 116 | +2.45.4 |
| 117 | + |
0 commit comments