Skip to content

Commit

Permalink
cos backend support accelerate (#31425)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellertang committed Jul 15, 2022
1 parent c4a65f8 commit 0dbf071
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion internal/backend/remote-state/cos/backend.go
Expand Up @@ -113,6 +113,12 @@ func New() backend.Backend {
return nil, nil
},
},
"accelerate": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether to enable global Acceleration",
Default: false,
},
},
}

Expand All @@ -138,7 +144,16 @@ func (b *Backend) configure(ctx context.Context) error {
b.encrypt = data.Get("encrypt").(bool)
b.acl = data.Get("acl").(string)

u, err := url.Parse(fmt.Sprintf("https://%s.cos.%s.myqcloud.com", b.bucket, b.region))
var (
u *url.URL
err error
)
accelerate := data.Get("accelerate").(bool)
if accelerate {
u, err = url.Parse(fmt.Sprintf("https://%s.cos.accelerate.myqcloud.com", b.bucket))
} else {
u, err = url.Parse(fmt.Sprintf("https://%s.cos.%s.myqcloud.com", b.bucket, b.region))
}
if err != nil {
return err
}
Expand Down

0 comments on commit 0dbf071

Please sign in to comment.