From dae04e2ad34ac4869f08d2902103f9a67c8ba307 Mon Sep 17 00:00:00 2001 From: runzexia Date: Wed, 15 May 2019 17:09:07 +0800 Subject: [PATCH] update Signed-off-by: runzexia --- .../client/kubesphere/kubesphereclient.go | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pkg/simple/client/kubesphere/kubesphereclient.go b/pkg/simple/client/kubesphere/kubesphereclient.go index f5880525..e5e6c986 100644 --- a/pkg/simple/client/kubesphere/kubesphereclient.go +++ b/pkg/simple/client/kubesphere/kubesphereclient.go @@ -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)} } -- GitLab