Skip to content

Commit

Permalink
Merge pull request #78 from meshery/theBeginner86-patch-2
Browse files Browse the repository at this point in the history
Update kanvas.yaml
  • Loading branch information
theBeginner86 authored Dec 25, 2024
2 parents 7f99dce + fd1dbba commit fa499d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/kanvas.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name: Kanvas Screenshot Service
'on':
pull_request:
types:
- opened
- synchronize
- reopened
workflow_dispatch:
inputs:
contentID:
Expand Down
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 fa499d4

Please sign in to comment.