github.com/redhat-appstudio/e2e-tests@v0.0.0-20230619105049-9a422b2094d7/magefiles/webhook.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "net/http" 6 7 "github.com/redhat-appstudio/e2e-tests/pkg/framework" 8 ) 9 10 // Webhook struct used for sending webhooks to https://smee.io/ 11 type Webhook struct { 12 Path string `json:"path"` 13 RepositoryURL string `json:"repository_url"` 14 Repository `json:"repository"` 15 } 16 17 // Repository struct - part of Webhook struct 18 type Repository struct { 19 FullName string `json:"full_name"` 20 PullNumber string `json:"pull_number"` 21 } 22 23 func (w *Webhook) CreateAndSend(saltSecret, webhookTarget string) (*http.Response, error) { 24 hook := &framework.GoWebHook{} 25 hook.Create(w, w.Path, saltSecret) 26 resp, err := hook.Send(webhookTarget) 27 if err != nil { 28 return nil, fmt.Errorf("error sending webhook: %+v", err) 29 } 30 return resp, nil 31 }