~comcloudway/builds.sr.ht

ef846fc525f85b91c80a5a3f681402ad4a2b83b6 — Jakob Meier 10 months ago c32e005
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
1 files changed, 6 insertions(+), 2 deletions(-)

M worker/tasks.go
M worker/tasks.go => worker/tasks.go +6 -2
@@ 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
		}