1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-09 13:36:56 +02:00

fix: upload gcs blobs to bucket root (#2409)

* fix: upload gcs blobs to bucket root

* test: blob upload to bucket root

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: Adam Bouqdib <adam@abemedia.co.uk>
This commit is contained in:
Carlos Alexandro Becker 2021-08-17 00:31:20 -03:00 committed by GitHub
parent 43b91b6baf
commit 3966921c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -127,6 +127,43 @@ func TestMinioUploadCustomBucketID(t *testing.T) {
require.NoError(t, Pipe{}.Publish(ctx))
}
func TestMinioUploadRootFolder(t *testing.T) {
listen := randomListen(t)
folder := t.TempDir()
tgzpath := filepath.Join(folder, "bin.tar.gz")
debpath := filepath.Join(folder, "bin.deb")
require.NoError(t, os.WriteFile(tgzpath, []byte("fake\ntargz"), 0o744))
require.NoError(t, os.WriteFile(debpath, []byte("fake\ndeb"), 0o744))
ctx := context.New(config.Project{
Dist: folder,
ProjectName: "testupload",
Blobs: []config.Blob{
{
Provider: "s3",
Bucket: "test",
Folder: "/",
Endpoint: "http://" + listen,
},
},
})
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tgzpath,
})
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debpath,
})
name := "root_folder"
start(t, name, listen)
prepareEnv()
require.NoError(t, Pipe{}.Default(ctx))
require.NoError(t, Pipe{}.Publish(ctx))
}
func TestMinioUploadInvalidCustomBucketID(t *testing.T) {
listen := randomListen(t)
folder := t.TempDir()

View File

@ -6,6 +6,7 @@ import (
"net/url"
"os"
"path"
"strings"
"github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/artifact"
@ -67,6 +68,7 @@ func doUpload(ctx *context.Context, conf config.Blob) error {
if err != nil {
return err
}
folder = strings.TrimPrefix(folder, "/")
bucketURL, err := urlFor(ctx, conf)
if err != nil {