Skip to content

Commit

Permalink
chore(gha/ci): add logging when github api returns an error
Browse files Browse the repository at this point in the history
Signed-off-by: kaanyagci <[email protected]>
  • Loading branch information
kaanyagci committed Aug 11, 2024
1 parent 9dc6ead commit a3547d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/skaffold/skaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -70,9 +71,14 @@ func getLatestSkaffoldYamlVersion() (string, error) {
}
defer resp.Body.Close()

content, err := io.ReadAll(resp.Body)
if err != nil {
log.Printf("Error while reading the response body")
return "", err
}
// Check if the request was successful
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("error: unable to fetch the file. Status code: %d", resp.StatusCode)
return "", fmt.Errorf("error: unable to fetch the file. Status code: %d. Body: %s", resp.StatusCode, string(content))
}

// Decode the JSON response
Expand Down

0 comments on commit a3547d6

Please sign in to comment.