Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
br: fix S3 backup endpoint suffix (#30530)
Browse files Browse the repository at this point in the history
  • Loading branch information
tongtongyin authored Dec 20, 2021
1 parent 5858c66 commit c9c688b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/storage/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c9c688b

Please sign in to comment.