From e786a7a2de58d30b8e9b1c5b00e7d49b9890711f Mon Sep 17 00:00:00 2001 From: SHIVANSH-ux-ys Date: Wed, 2 Sep 2026 21:24:10 +0530 Subject: [PATCH] pkg/repo/v1: add RedirectURL support to IndexFile (#32528) Signed-off-by: SHIVANSH-ux-ys --- pkg/repo/v1/index.go | 5 +++++ pkg/repo/v1/index_test.go | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/repo/v1/index.go b/pkg/repo/v1/index.go index 99670eac8..40d88691b 100644 --- a/pkg/repo/v1/index.go +++ b/pkg/repo/v1/index.go @@ -52,6 +52,8 @@ var ( ErrNoChartName = errors.New("no chart name found") // ErrEmptyIndexYaml indicates that the content of index.yaml is empty. ErrEmptyIndexYaml = errors.New("empty index.yaml file") + // ErrRepositoryMoved indicates that the repository index has moved to a new URL. + ErrRepositoryMoved = errors.New("repository moved to new URL") ) // ChartVersions is a list of versioned chart references. @@ -87,6 +89,9 @@ type IndexFile struct { Entries map[string]ChartVersions `json:"entries"` PublicKeys []string `json:"publicKeys,omitempty"` + // RedirectURL specifies a new repository URL if this repository has moved. + RedirectURL string `json:"redirectURL,omitempty"` + // Annotations are additional mappings uninterpreted by Helm. They are made available for // other applications to add information to the index file. Annotations map[string]string `json:"annotations,omitempty"` diff --git a/pkg/repo/v1/index_test.go b/pkg/repo/v1/index_test.go index 9b46065a8..67f1244ad 100644 --- a/pkg/repo/v1/index_test.go +++ b/pkg/repo/v1/index_test.go @@ -128,6 +128,17 @@ func TestIndexFile(t *testing.T) { assert.Equal(t, "0.1.8", cv.Version, "Expected version: 0.1.8") } +func TestLoadIndex_RedirectURL(t *testing.T) { + yamlData := ` +apiVersion: v1 +redirectURL: https://new-org.github.io/charts +entries: {} +` + i, err := loadIndex([]byte(yamlData), "test") + require.NoError(t, err) + assert.Equal(t, "https://new-org.github.io/charts", i.RedirectURL) +} + func TestLoadIndex(t *testing.T) { tests := []struct { Name string