diff --git a/webhook.go b/webhook.go index fc45fa1..a01baa5 100644 --- a/webhook.go +++ b/webhook.go @@ -25,13 +25,14 @@ import ( ) const ( - version = "2.3.4" + version = "2.3.5" ) var ( ip = flag.String("ip", "", "ip the webhook should serve hooks on") port = flag.Int("port", 9000, "port the webhook should serve hooks on") verbose = flag.Bool("verbose", false, "show verbose output") + noPanic = flag.Bool("nopanic", false, "do not panic if hooks cannot be loaded when webhook is not running in verbose mode") hotReload = flag.Bool("hotreload", false, "watch hooks file for changes and reload them automatically") hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve") hooksURLPrefix = flag.String("urlprefix", "hooks", "url prefix to use for served hooks (protocol://yourserver:port/PREFIX/:hook-id)") @@ -73,6 +74,11 @@ func init() { err := hooks.LoadFromFile(*hooksFilePath) if err != nil { + if !*verbose && !*noPanic { + log.SetOutput(os.Stdout) + log.Fatalf("couldn't load any hooks from file! %+v\naborting webhook execution since the -verbose flag is set to false.\nIf, for some reason, you want webhook to start without the hooks, either use -verbose flag, or -nopanic", err) + } + log.Printf("couldn't load hooks from file! %+v\n", err) } else { log.Printf("loaded %d hook(s) from file\n", len(hooks)) diff --git a/webhook_windows.go b/webhook_windows.go index 5a70bdb..2351a4c 100644 --- a/webhook_windows.go +++ b/webhook_windows.go @@ -21,13 +21,14 @@ import ( ) const ( - version = "2.3.4" + version = "2.3.5" ) var ( ip = flag.String("ip", "", "ip the webhook should serve hooks on") port = flag.Int("port", 9000, "port the webhook should serve hooks on") verbose = flag.Bool("verbose", false, "show verbose output") + noPanic = flag.Bool("nopanic", false, "do not panic if hooks cannot be loaded when webhook is not running in verbose mode") hotReload = flag.Bool("hotreload", false, "watch hooks file for changes and reload them automatically") hooksFilePath = flag.String("hooks", "hooks.json", "path to the json file containing defined hooks the webhook should serve") hooksURLPrefix = flag.String("urlprefix", "hooks", "url prefix to use for served hooks (protocol://yourserver:port/PREFIX/:hook-id)") @@ -61,6 +62,11 @@ func init() { err := hooks.LoadFromFile(*hooksFilePath) if err != nil { + if !*verbose && !*noPanic { + log.SetOutput(os.Stdout) + log.Fatalf("couldn't load any hooks from file! %+v\naborting webhook execution since the -verbose flag is set to false.\nIf, for some reason, you want webhook to start without the hooks, either use -verbose flag, or -nopanic", err) + } + log.Printf("couldn't load hooks from file! %+v\n", err) } else { log.Printf("loaded %d hook(s) from file\n", len(hooks))