Skip to content

Commit

Permalink
Yield an error when the download of an spkg remote fails (non 200 code).
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Bourget committed Nov 11, 2024
1 parent 977e922 commit e2f145e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion manifest/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ func (r *Reader) readFromHttp(input string) error {
}
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("error downloading %q, status %s: %s", input, resp.Status, string(r.currentData))
}

b, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("error reading %q: %w", input, err)
Expand Down Expand Up @@ -398,9 +402,11 @@ func (r *Reader) resolveInputPath() error {
parts := strings.Split(input, "@")
registryURL := r.registryURL
if registryURL == "" {
// This is an extreme fallback, because this should be
// set by the WithRegistryURL option.
registryURL = "https://spkg.io"
}
r.currentInput = fmt.Sprintf("%s/v1/packages/%s-%s.spkg", registryURL, parts[0], parts[1])
r.currentInput = fmt.Sprintf("%s/v1/packages/%s/%s", registryURL, parts[0], parts[1])
return nil
}

Expand Down

0 comments on commit e2f145e

Please sign in to comment.