Ai
77 Star 124 Fork 105

openEuler/PilotGo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config.go 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
zhanghan 提交于 2025-08-08 13:26 +08:00 . Plugin client method modification
/*
* Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved.
* PilotGo licensed under the Mulan Permissive Software License, Version 2.
* See LICENSE file for more details.
* Author: zhanghan2021 <zhanghan@kylinos.cn>
* Date: Wed Sep 27 17:35:12 2023 +0800
*/
package client
import (
"encoding/json"
"errors"
"fmt"
"gitee.com/openeuler/PilotGo/sdk/common"
"gitee.com/openeuler/PilotGo/sdk/plugin/jwt"
"gitee.com/openeuler/PilotGo/sdk/utils/httputils"
)
func (c *Client) ApplyConfig(batch *common.Batch, path, content string) error {
serverInfo, err := c.Registry.Get("pilotgo-server")
if err != nil {
return err
}
url := fmt.Sprintf("http://%s:%s/api/v1/pluginapi/apply_config", serverInfo.Address, serverInfo.Port)
r, err := httputils.Put(url, &httputils.Params{
Cookie: map[string]string{
jwt.TokenCookie: c.token,
},
})
if err != nil {
return err
}
resp := &struct {
Status string
Error string
}{}
if err := json.Unmarshal(r.Body, resp); err != nil {
return err
}
if resp.Status != "ok" {
return errors.New(resp.Error)
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler/PilotGo.git
git@gitee.com:openeuler/PilotGo.git
openeuler
PilotGo
PilotGo
be4573e26691

搜索帮助