-
Notifications
You must be signed in to change notification settings - Fork 0
/
emit.go
42 lines (33 loc) · 943 Bytes
/
emit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"github.com/spf13/cobra"
"os"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetLevel(log.InfoLevel)
log.SetFormatter(&log.JSONFormatter{})
err := os.Setenv("TZ", "") // Use UTC by default :)
if err != nil {
log.Fatal("failed to set env - ", err)
}
rootcmd := &cobra.Command{
Use: "Emit",
Version: "v1",
Short: "Emit events to mimic popular webhook providers",
}
parsePersistentArgs(rootcmd)
if err := rootcmd.Execute(); err != nil {
log.Fatal(err)
}
}
func parsePersistentArgs(cmd *cobra.Command) {
var url string
var secret string
var idemKey string
cmd.PersistentFlags().StringVar(&url, "url", "", "URL to emit event to")
cmd.PersistentFlags().StringVar(&secret, "secret", "", "secret to use to encode hmac header")
cmd.PersistentFlags().StringVar(&idemKey, "idem-key", "", "Idempotency Key")
cmd.AddCommand(addShopifyCommand())
cmd.AddCommand(addGithubCommand())
}