mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-20 09:15:19 +01:00
Fix create ns failure in DockerHub (#7421)
Signed-off-by: cd1989 <chende@caicloud.io>
This commit is contained in:
parent
15846ac524
commit
c3375e4ac2
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user