Skip to content

Commit 932b35d

Browse files
authoredFeb 22, 2022
chore: print the url of failed download (#96)
1 parent c5f7348 commit 932b35d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
 

‎pkg/registry/http.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (r SchemaRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8sVers
8080
}
8181

8282
if resp.StatusCode != http.StatusOK {
83-
return nil, fmt.Errorf("error while downloading schema - received HTTP status %d", resp.StatusCode)
83+
return nil, fmt.Errorf("error while downloading schema at %s - received HTTP status %d", url, resp.StatusCode)
8484
}
8585

8686
body, err := ioutil.ReadAll(resp.Body)

‎pkg/registry/http_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ func TestDownloadSchema(t *testing.T) {
6161
nil,
6262
fmt.Errorf("no schema found"),
6363
},
64+
{
65+
"getting 503",
66+
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {
67+
return &http.Response{
68+
StatusCode: http.StatusServiceUnavailable,
69+
Body: ioutil.NopCloser(strings.NewReader("http response mock body")),
70+
}, nil
71+
}),
72+
"http://kubernetesjson.dev",
73+
true,
74+
"Deployment",
75+
"v1",
76+
"1.18.0",
77+
nil,
78+
fmt.Errorf("error while downloading schema at http://kubernetesjson.dev - received HTTP status 503"),
79+
},
6480
{
6581
"200",
6682
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {

0 commit comments

Comments
 (0)
Please sign in to comment.