Skip to content

Commit

Permalink
Merge pull request #3838 from saschagrunert/release-notes-index-fix-2
Browse files Browse the repository at this point in the history
Re-add production bucket fix to release notes index
  • Loading branch information
k8s-ci-robot authored Nov 21, 2024
2 parents e1105e7 + 98c41c9 commit b723b17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
8 changes: 3 additions & 5 deletions pkg/release/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 3 additions & 7 deletions pkg/release/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b723b17

Please sign in to comment.