未验证 提交 dae04e2a 编写于 作者: R runzexia 提交者: soulseen

update

Signed-off-by: Nrunzexia <runzexia@yunify.com>
上级 2259924e
......@@ -22,6 +22,7 @@ import (
"encoding/json"
"flag"
"fmt"
"github.com/golang/glog"
"io/ioutil"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/models"
......@@ -257,25 +258,28 @@ func (c client) ListWorkspaceDevOpsProjects(workspace string) (*devops.PageableD
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/kapis/tenant.kubesphere.io/v1alpha2/workspaces/%s/devops", ksAPIServer, workspace), nil)
if err != nil {
glog.Error(err)
return nil, err
}
req.Header.Add(constants.UserNameHeader, constants.AdminUserName)
if err != nil {
return nil, err
}
log.Println(req.Method, req.URL)
glog.Info(req.Method, req.URL)
resp, err := c.client.Do(req)
if err != nil {
glog.Error(err)
return nil, err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
glog.Error(err)
return nil, err
}
if resp.StatusCode > http.StatusOK {
glog.Error(req.Method, req.URL, resp.StatusCode, string(data))
return nil, Error{resp.StatusCode, string(data)}
}
......@@ -283,6 +287,7 @@ func (c client) ListWorkspaceDevOpsProjects(workspace string) (*devops.PageableD
err = json.Unmarshal(data, &result)
if err != nil {
glog.Error(err)
return nil, err
}
return &result, nil
......@@ -293,25 +298,27 @@ func (c client) DeleteWorkspaceDevOpsProjects(workspace, devops string) error {
req, err := http.NewRequest(http.MethodDelete, fmt.Sprintf("%s/kapis/tenant.kubesphere.io/v1alpha2/workspaces/%s/devops/%s", ksAPIServer, workspace, devops), nil)
if err != nil {
glog.Error(err)
return err
}
req.Header.Add(constants.UserNameHeader, constants.AdminUserName)
if err != nil {
return err
}
log.Println(req.Method, req.URL)
glog.Info(req.Method, req.URL)
resp, err := c.client.Do(req)
if err != nil {
glog.Error(err)
return err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
glog.Error(err)
return err
}
if resp.StatusCode > http.StatusOK {
glog.Error(req.Method, req.URL, resp.StatusCode, string(data))
return Error{resp.StatusCode, string(data)}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册