From 98c41c9e461576d1b530fe8104eaef4076389a35 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Thu, 21 Nov 2024 09:11:47 +0100 Subject: [PATCH] Re-add production bucket fix to release notes index The index still contains entries referring to the production bucket after the recent patches: ``` > curl -sfL https://dl.k8s.io/release/release-notes-index.json | jq . | rg -v dl.k8s.io { "v1.29.11": "gs://767373bbdcb8270361b96548387bf2a9ad0d48758c35/release/v1.29.11/release-notes.json", "v1.30.7": "gs://767373bbdcb8270361b96548387bf2a9ad0d48758c35/release/v1.30.7/release-notes.json", "v1.31.3": "gs://767373bbdcb8270361b96548387bf2a9ad0d48758c35/release/v1.31.3/release-notes.json", } ``` We fix that by slightly modifying the existing function and the tests. Signed-off-by: Sascha Grunert --- pkg/release/publish.go | 8 +++----- pkg/release/publish_test.go | 10 +++------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pkg/release/publish.go b/pkg/release/publish.go index 88b8945e745..cdd2fc234d8 100644 --- a/pkg/release/publish.go +++ b/pkg/release/publish.go @@ -402,12 +402,10 @@ func (p *Publisher) PublishToGcs( return nil } -// TODO: remove this function once https://cdn.dl.k8s.io/release/release-notes-index.json -// is fixed. func FixPublicReleaseNotesURL(gcsPath string) string { - const prefix = "https://storage.googleapis.com/" - for strings.HasPrefix(gcsPath, prefix) { - gcsPath = strings.TrimPrefix(gcsPath, prefix) + const prefix = "gs://" + ProductionBucket + if strings.HasPrefix(gcsPath, prefix) { + gcsPath = ProductionBucketURL + strings.TrimPrefix(gcsPath, prefix) } return gcsPath } diff --git a/pkg/release/publish_test.go b/pkg/release/publish_test.go index 26073e6dd71..62e2bec0696 100644 --- a/pkg/release/publish_test.go +++ b/pkg/release/publish_test.go @@ -383,13 +383,9 @@ func TestFixPublicReleaseNotesURL(t *testing.T) { input: "https://dl.k8s.io/release/v1.32.0-beta.0/release-notes.json", expected: "https://dl.k8s.io/release/v1.32.0-beta.0/release-notes.json", }, - "should fix wrong URL with 1 prefix": { - input: "https://storage.googleapis.com/https://dl.k8s.io/release/v1.32.0-alpha.3/release-notes.json", - expected: "https://dl.k8s.io/release/v1.32.0-alpha.3/release-notes.json", - }, - "should fix wrong URL with multiple prefixes": { - input: "https://storage.googleapis.com/https://storage.googleapis.com/https://dl.k8s.io/release/v1.28.1/release-notes.json", - expected: "https://dl.k8s.io/release/v1.28.1/release-notes.json", + "should fix URL referring to production bucket": { + input: "gs://767373bbdcb8270361b96548387bf2a9ad0d48758c35/release/v1.29.11/release-notes.json", + expected: "https://dl.k8s.io/release/v1.29.11/release-notes.json", }, } { t.Run(name, func(t *testing.T) {