Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exit code flag #155

Merged
merged 4 commits into from
Jun 24, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[WIP] add exit-code flag
  • Loading branch information
kimschles committed Jun 21, 2019
commit 3fd3c04429d431341b96f3b7beb88704d564a273
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func main() {
webhook := flag.Bool("webhook", false, "Runs the webhook webserver.")
audit := flag.Bool("audit", false, "Runs a one-time audit.")
auditPath := flag.String("audit-path", "", "If specified, audits one or more YAML files instead of a cluster")
exitCode := flag.String("exit-code", "", "set a non-zero exit code when the audit contains error-level issues.")
dashboardPort := flag.Int("dashboard-port", 8080, "Port for the dashboard webserver")
dashboardBasePath := flag.String("dashboard-base-path", "/", "Path on which the dashboard is served")
webhookPort := flag.Int("webhook-port", 9876, "Port for the webhook webserver")
Expand Down Expand Up @@ -180,6 +181,11 @@ func startWebhookServer(c conf.Configuration, disableWebhookConfigInstaller bool
}
}

func exitAudit() {
// if the audit contains error-level issues, exit with code 1
ox.Exit(1)
}

func runAudit(c conf.Configuration, auditPath string, outputFile string, outputURL string, outputFormat string) {
k, err := kube.CreateResourceProvider(auditPath)
if err != nil {
Expand Down Expand Up @@ -242,6 +248,7 @@ func runAudit(c conf.Configuration, auditPath string, outputFile string, outputU
os.Exit(1)
}

// exitAudit here?
logrus.Infof("Received response: %v", body)
}

Expand Down