Skip to content

Commit

Permalink
add debug logs
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Singh <[email protected]>
  • Loading branch information
theBeginner86 committed Dec 25, 2024
1 parent 0a5b9b4 commit fd1dbba
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/kanvas-snapshot/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func CreateMesheryDesign(uri, name, email string) (string, error) {
func GenerateSnapshot(contentID, assetLocation string, ghAccessToken string) error {
payload := fmt.Sprintf(`{"ref":"master","inputs":{"contentID":"%s","assetLocation":"%s"}}`, contentID, assetLocation)
req, err := http.NewRequest("POST", "https://api.github.com/repos/meshery/helm-kanvas-snapshot/actions/workflows/kanvas.yml/dispatches", bytes.NewBuffer([]byte(payload)))
fmt.Println(err)
if err != nil {
return err
}
Expand All @@ -217,11 +218,24 @@ func GenerateSnapshot(contentID, assetLocation string, ghAccessToken string) err

client := &http.Client{}
resp, err := client.Do(req)
fmt.Println(err)
if err != nil {
return err
}
defer resp.Body.Close()

// read response

// Decode response
var result map[string]interface{}
err = json.NewDecoder(resp.Body).Decode(&result)
if err != nil {
body, _ := io.ReadAll(resp.Body)
return errors.ErrDecodingAPI(fmt.Errorf("failed to decode json. body: %s, error: %w", body, err))
}

fmt.Printf("%#v\n", result)

return nil
}

Expand Down

0 comments on commit fd1dbba

Please sign in to comment.