From b72eefb8cf4135e36c58d8f1e67db65b6fdc3911 Mon Sep 17 00:00:00 2001 From: Marwan Sulaiman Date: Mon, 24 Oct 2022 09:13:19 -0400 Subject: [PATCH] Add secret flag --- webhook/create_webhook.go | 2 ++ webhook/forward.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/webhook/create_webhook.go b/webhook/create_webhook.go index 474606e..e221763 100644 --- a/webhook/create_webhook.go +++ b/webhook/create_webhook.go @@ -22,6 +22,7 @@ type hookConfig struct { ContentType string `json:"content_type"` InsecureSSL string `json:"insecure_ssl"` URL string `json:"url"` + Secret string `json:"secret,omitempty"` } type createHookResponse struct { @@ -54,6 +55,7 @@ func createHook(o *hookOptions) (string, func() error, error) { Config: hookConfig{ ContentType: "json", InsecureSSL: "0", + Secret: o.Secret, }, } diff --git a/webhook/forward.go b/webhook/forward.go index 330aae2..c79aaff 100644 --- a/webhook/forward.go +++ b/webhook/forward.go @@ -26,6 +26,7 @@ type hookOptions struct { Repo string Org string Port int + Secret string } // NewCmdForward returns a forward command. @@ -89,6 +90,7 @@ func NewCmdForward(runF func(*hookOptions) error) *cobra.Command { cmd.Flags().IntVarP(&opts.Port, "port", "P", 0, "(optional) Local port where the server which will receive webhooks is running") cmd.Flags().StringVarP(&opts.Host, "host", "H", "", "(optional) Host address of GitHub API, default: api.github.com") cmd.Flags().StringVarP(&opts.Org, "org", "O", "", "Name of the org where the webhook is installed") + cmd.Flags().StringVarP(&opts.Secret, "secret", "S", "", "(optional) webhook secret for incoing events") return cmd }