diff --git a/scripts/ci/s3-promoter/main.go b/scripts/ci/s3-promoter/main.go index a283fe6133..73b199cc7d 100644 --- a/scripts/ci/s3-promoter/main.go +++ b/scripts/ci/s3-promoter/main.go @@ -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) @@ -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