Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions scripts/ci/s3-promoter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func run() {
// Copy each staging object to production location and delete the staging version
for _, obj := range stagingObjects {
stagingKey := *obj.Key
relativeKey := strings.TrimPrefix(stagingKey, basePrefix+"staging/")
destinationKey := basePrefix + "release/" + relativeKey
destinationKey := productionKey(stagingKey, basePrefix)

fmt.Printf("Promoting %s -> %s\n", stagingKey, destinationKey)

Expand All @@ -94,6 +93,14 @@ func run() {
fmt.Printf("Successfully promoted %d files from staging to production.\n", len(stagingObjects))
}

// productionKey maps a staging object key to its production location. The
// channel (beta, release, ...) is already encoded in the key, so promotion only
// drops the staging/ segment and adds no prefix of its own.
func productionKey(stagingKey, basePrefix string) string {
relativeKey := strings.TrimPrefix(stagingKey, basePrefix+"staging/")
return basePrefix + relativeKey
}

func createClient() {
var err error

Expand Down
Loading