Skip to content

Commit

Permalink
feat: return metadata logo fetch error
Browse files Browse the repository at this point in the history
  • Loading branch information
igorline committed Mar 30, 2024
1 parent c0efcad commit c86bed3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
ErrInvalidUrlLength = errors.New("url length should be no larger than 1024 character")
ErrInvalidUrl = errors.New("invalid url")

ErrImageFetchFailed = errors.New("error fetching operator logo")
ErrInvalidImageMimeType = errors.New("invalid image mime-type. only png is supported")
ErrInvalidImageExtension = errors.New(
"invalid image extension. only " + strings.Join(ImageExtensions, ",") + " is supported",
Expand Down
6 changes: 6 additions & 0 deletions types/operator_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ func isImageURL(urlString string) error {
if err != nil {
return err
}

// Check if the response status was an error
if imageResponse.StatusCode >= 400 {
return ErrImageFetchFailed
}

imageBytes, err := io.ReadAll(imageResponse.Body)
if err != nil {
return err
Expand Down

0 comments on commit c86bed3

Please sign in to comment.