refactor: bubble up error handling so that standard exit codes can be set at the top-level

LogFail shouldn't be called internally if at all possible.
This commit is contained in:
Jose Diaz-Gonzalez
2021-02-03 04:29:57 -05:00
parent ccdbaa84f9
commit d09a7506df
26 changed files with 113 additions and 80 deletions

View File

@@ -83,7 +83,7 @@ func main() {
proxyType := args.Arg(1)
err = proxy.CommandSet(appName, proxyType)
default:
common.LogFail(fmt.Sprintf("Invalid plugin subcommand call: %s", subcommand))
err = fmt.Errorf("Invalid plugin subcommand call: %s", subcommand)
}
if err != nil {

View File

@@ -20,21 +20,21 @@ func main() {
switch trigger {
case "proxy-is-enabled":
appName := flag.Arg(0)
proxy.TriggerProxyIsEnabled(appName)
err = proxy.TriggerProxyIsEnabled(appName)
case "proxy-type":
appName := flag.Arg(0)
proxy.TriggerProxyType(appName)
err = proxy.TriggerProxyType(appName)
case "post-certs-remove":
appName := flag.Arg(0)
proxy.TriggerPostCertsRemove(appName)
err = proxy.TriggerPostCertsRemove(appName)
case "post-certs-update":
appName := flag.Arg(0)
proxy.TriggerPostCertsUpdate(appName)
err = proxy.TriggerPostCertsUpdate(appName)
case "report":
appName := flag.Arg(0)
err = proxy.ReportSingleApp(appName, "", "")
default:
common.LogFail(fmt.Sprintf("Invalid plugin trigger call: %s", trigger))
err = fmt.Errorf("Invalid plugin trigger call: %s", trigger)
}
if err != nil {