From ef846fc525f85b91c80a5a3f681402ad4a2b83b6 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 27 Dec 2023 20:43:46 +0100 Subject: [PATCH] Allow s3 storage location to be configured Fall back to us-east-1 when the setting key isn't found in the config.ini file --- worker/tasks.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/worker/tasks.go b/worker/tasks.go index 546a311..354e571 100644 --- a/worker/tasks.go +++ b/worker/tasks.go @@ -637,6 +637,7 @@ func (ctx *JobContext) UploadArtifacts() error { secretKey string bucket string prefix string + location string ) err := errors.New("Build artifacts were requested, but S3 " + "is not configured for this build runner.") @@ -655,13 +656,16 @@ func (ctx *JobContext) UploadArtifacts() error { if prefix, ok = config.Get("builds.sr.ht::worker", "s3-prefix"); !ok { return err } + if location, ok = config.Get("builds.sr.ht::worker", "s3-location"); !ok { + // default to old location + location = "us-east-1"; + } mc, err := minio.New(upstream, accessKey, secretKey, true) if err != nil { return err } - // TODO: Let users configure the bucket location - if err := mc.MakeBucket(bucket, "us-east-1"); err != nil { + if err := mc.MakeBucket(bucket, location); err != nil { if exists, err2 := mc.BucketExists(bucket); err2 != nil && exists { return err } -- 2.38.5