Skip to content

Commit

Permalink
Merge pull request #986 from ioito/hotfix/qx-qcloud-permission
Browse files Browse the repository at this point in the history
fix(region): qcloud permission
  • Loading branch information
ioito authored Jun 17, 2024
2 parents 6cfb14a + 562051a commit a23804d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/multicloud/qcloud/qcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,20 @@ func (client *SQcloudClient) getSdkClient(regionId string) (*common.Client, erro
service := strings.Split(req.URL.Host, ".")[0]
action := params.Get("Action")
respCheck := func(resp *http.Response) error {
if client.cpcfg.UpdatePermission != nil {
if resp.ContentLength <= 0 {
return nil
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return errors.Wrapf(err, "ioutil.ReadAll")
}
resp.Body = io.NopCloser(bytes.NewBuffer(body))
obj, _ := jsonutils.Parse(body)
code := ""
if obj != nil {
code, _ = obj.GetString("Response", "Error", "Code")
}
if client.cpcfg.UpdatePermission != nil && code == "UnauthorizedOperation" {
client.cpcfg.UpdatePermission(service, action)
}
return nil
Expand Down

0 comments on commit a23804d

Please sign in to comment.