Skip to content

Commit

Permalink
br: fix S3 backup endpoint suffix (#30530) (#30885)
Browse files Browse the repository at this point in the history
close #30104
  • Loading branch information
ti-srebot authored Feb 22, 2022
1 parent 4d1f787 commit 31207ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion br/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 br/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 31207ae

Please sign in to comment.