grafana-cli: Fix file path processing, returning of errors (#26954)

* grafana-cli: Fix file path processing, returning of errors
This commit is contained in:
Arve Knudsen
2020-08-13 09:38:05 +02:00
committed by GitHub
parent 75e14aa120
commit 9f159c5e3d
5 changed files with 78 additions and 93 deletions

View File

@@ -146,7 +146,11 @@ func sendRequest(client http.Client, repoUrl string, subPaths ...string) (io.Rea
}
func createRequest(repoUrl string, subPaths ...string) (*http.Request, error) {
u, _ := url.Parse(repoUrl)
u, err := url.Parse(repoUrl)
if err != nil {
return nil, err
}
for _, v := range subPaths {
u.Path = path.Join(u.Path, v)
}
@@ -170,7 +174,7 @@ func handleResponse(res *http.Response) (io.ReadCloser, error) {
}
if res.StatusCode/100 != 2 && res.StatusCode/100 != 4 {
return nil, fmt.Errorf("Api returned invalid status: %s", res.Status)
return nil, fmt.Errorf("API returned invalid status: %s", res.Status)
}
if res.StatusCode/100 == 4 {