Fix by comments

Signed-off-by: peimingming <peimingming@corp.netease.com>
This commit is contained in:
peimingming 2019-07-19 17:04:40 +08:00
parent f32670058a
commit 9f777ed43f
2 changed files with 8 additions and 7 deletions

View File

@ -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)
}

View File

@ -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{}