Skip to content

Commit

Permalink
fix nacos auth error (#2953) (#2956)
Browse files Browse the repository at this point in the history
Signed-off-by: allenshen <[email protected]>
  • Loading branch information
AllenShen authored Aug 11, 2023
1 parent 0a900b2 commit a30a6d6
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions pkg/tool/nacos/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ func (c *Client) ListConfigs(namespaceID string) ([]*types.NacosConfig, error) {
numString := strconv.Itoa(pageNum)
sizeString := strconv.Itoa(pageSize)
params := httpclient.SetQueryParams(map[string]string{
"dataId": "",
"group": "",
"search": "accurate",
"pageNo": numString,
"pageSize": sizeString,
"tenant": namespaceID,
"dataId": "",
"group": "",
"search": "accurate",
"pageNo": numString,
"pageSize": sizeString,
"tenant": namespaceID,
"accessToken": c.token,
})
if _, err := c.Client.Get(url, params, httpclient.SetResult(res)); err != nil {
return nil, errors.Wrap(err, "list nacos config failed")
Expand All @@ -175,10 +176,11 @@ func (c *Client) GetConfig(dataID, group, namespaceID string) (*types.NacosConfi
url := "/v1/cs/configs"
res := &config{}
params := httpclient.SetQueryParams(map[string]string{
"dataId": dataID,
"group": group,
"tenant": namespaceID,
"show": "all",
"dataId": dataID,
"group": group,
"tenant": namespaceID,
"show": "all",
"accessToken": c.token,
})
if _, err := c.Client.Get(url, params, httpclient.SetResult(res)); err != nil {
return nil, errors.Wrap(err, "get nacos config failed")
Expand All @@ -195,11 +197,12 @@ func (c *Client) UpdateConfig(dataID, group, namespaceID, content, format string
namespaceID = getNamespaceID(namespaceID)
path := "/v1/cs/configs"
formValues := map[string]string{
"dataId": dataID,
"group": group,
"tenant": namespaceID,
"content": content,
"type": setFormat(format),
"dataId": dataID,
"group": group,
"tenant": namespaceID,
"content": content,
"type": setFormat(format),
"accessToken": c.token,
}
if _, err := c.Client.Post(path, httpclient.SetFormData(formValues)); err != nil {
return errors.Wrap(err, "update nacos config failed")
Expand Down

0 comments on commit a30a6d6

Please sign in to comment.