mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 17:47:46 +01:00
Fix by comments
Signed-off-by: peimingming <peimingming@corp.netease.com>
This commit is contained in:
parent
f32670058a
commit
9f777ed43f
@ -87,9 +87,10 @@ func (a *adapter) FetchCharts(filters []*model.Filter) ([]*model.Resource, error
|
||||
|
||||
func (a *adapter) ChartExist(name, version string) (bool, error) {
|
||||
versionList, err := a.client.fetchChartDetail(name)
|
||||
if err != nil && err == ErrHTTPNotFound {
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
if err != nil {
|
||||
if err == ErrHTTPNotFound {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
@ -116,7 +117,7 @@ func (a *adapter) DownloadChart(name, version string) (io.ReadCloser, error) {
|
||||
}
|
||||
|
||||
func (a *adapter) download(version *chartVersion) (io.ReadCloser, error) {
|
||||
if version.Attributes.URLs == nil || len(version.Attributes.URLs) == 0 || len(version.Attributes.URLs[0]) == 0 {
|
||||
if len(version.Attributes.URLs) == 0 || len(version.Attributes.URLs[0]) == 0 {
|
||||
return nil, fmt.Errorf("cannot got the download url for chart %s", version.ID)
|
||||
}
|
||||
|
||||
|
@ -76,10 +76,10 @@ func (c *Client) fetchChartDetail(chartName string) (*chartVersionList, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNotFound {
|
||||
return nil, fmt.Errorf("fetch chart detail error %d: %s", resp.StatusCode, string(body))
|
||||
} else if resp.StatusCode == http.StatusNotFound {
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return nil, ErrHTTPNotFound
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("fetch chart detail error %d: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
|
||||
list := &chartVersionList{}
|
||||
|
Loading…
Reference in New Issue
Block a user