diff --git a/pkg/storage/parse_test.go b/pkg/storage/parse_test.go index fc3ee47a0..542b5dde3 100644 --- a/pkg/storage/parse_test.go +++ b/pkg/storage/parse_test.go @@ -57,7 +57,7 @@ func (r *testStorageSuite) TestCreateStorage(c *C) { c.Assert(s3, NotNil) c.Assert(s3.Bucket, Equals, "bucket2") c.Assert(s3.Prefix, Equals, "prefix") - c.Assert(s3.Endpoint, Equals, "https://s3.example.com/") + c.Assert(s3.Endpoint, Equals, "https://s3.example.com") c.Assert(s3.ForcePathStyle, IsFalse) // nolint:lll diff --git a/pkg/storage/s3.go b/pkg/storage/s3.go index 6accafee7..f0a8a2a3a 100644 --- a/pkg/storage/s3.go +++ b/pkg/storage/s3.go @@ -155,7 +155,7 @@ func (options *S3BackendOptions) Apply(s3 *backuppb.S3) error { return errors.Annotate(berrors.ErrStorageInvalidConfig, "secret_access_key not found") } - s3.Endpoint = options.Endpoint + s3.Endpoint = strings.TrimSuffix(options.Endpoint, "/") s3.Region = options.Region // StorageClass, SSE and ACL are acceptable to be empty s3.StorageClass = options.StorageClass @@ -189,6 +189,7 @@ func (options *S3BackendOptions) parseFromFlags(flags *pflag.FlagSet) error { if err != nil { return errors.Trace(err) } + options.Endpoint = strings.TrimSuffix(options.Endpoint, "/") options.Region, err = flags.GetString(s3RegionOption) if err != nil { return errors.Trace(err)