Commit c3375e4a authored by De Chen's avatar De Chen Committed by Wang Yan
Browse files

Fix create ns failure in DockerHub (#7421)


Signed-off-by: default avatarcd1989 <chende@caicloud.io>
parent 15846ac5
......@@ -198,7 +198,6 @@ func (a *adapter) CreateNamespace(namespace *model.Namespace) error {
// getNamespace get namespace from DockerHub, if the namespace not found, two nil would be returned.
func (a *adapter) getNamespace(namespace string) (*model.Namespace, error) {
resp, err := a.client.Do(http.MethodGet, getNamespacePath(namespace), nil)
if err != nil {
return nil, err
}
......@@ -214,7 +213,7 @@ func (a *adapter) getNamespace(namespace string) (*model.Namespace, error) {
}
if resp.StatusCode/100 != 2 {
log.Errorf("create namespace error: %d -- %s", resp.StatusCode, string(body))
log.Errorf("get namespace error: %d -- %s", resp.StatusCode, string(body))
return nil, fmt.Errorf("%d -- %s", resp.StatusCode, body)
}
......
......@@ -97,20 +97,5 @@ func (c *Client) Do(method, path string, body io.Reader) (*http.Response, error)
}
req.Header.Set("Authorization", fmt.Sprintf("JWT %s", c.token))
resp, err := c.client.Do(req)
if err != nil {
log.Errorf("unexpected error: %v", err)
return nil, err
}
if resp.StatusCode/100 != 2 {
b, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
return nil, err
}
return nil, fmt.Errorf("unexpected %d error from dockerhub: %s", resp.StatusCode, string(b))
}
return resp, nil
return c.client.Do(req)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment