From f50bdd5bb63d5090dc74569216db19a1dede66b4 Mon Sep 17 00:00:00 2001 From: Erik Ostien Date: Wed, 30 Oct 2024 13:26:11 +0100 Subject: [PATCH] PDI-2056: Upon Ping CLI encountering an Error, Make Exitcode 1 --- internal/commands/request/request_internal.go | 2 ++ main.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/internal/commands/request/request_internal.go b/internal/commands/request/request_internal.go index 4eee42d..7156eed 100644 --- a/internal/commands/request/request_internal.go +++ b/internal/commands/request/request_internal.go @@ -102,6 +102,8 @@ func runInternalPingOneRequest(uri string) (err error) { } if res.StatusCode < 200 || res.StatusCode >= 300 { + // Note we don't os.Exit(1) here because pingcli has executed + // without issue, despite a failed response to the custom request output.UserError("Failed Custom Request", fields) } else { output.Success("Custom request successful", fields) diff --git a/main.go b/main.go index 7048cbb..27a4119 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "os" "runtime/debug" "github.com/pingidentity/pingcli/cmd" @@ -33,5 +34,6 @@ func main() { err := rootCmd.Execute() if err != nil { output.UserError(fmt.Sprintf("Failed to execute pingcli: %v", err), nil) + os.Exit(1) } }