From 08afbf476fecd626834243cc587eff0d8618b568 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Fri, 25 Feb 2022 16:23:31 -0800 Subject: [PATCH] cli: only return 1 on errors from op api We don't want people to expect stable error codes for errors, and I don't think these were useful for scripts anyway. --- command/operator_api.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/command/operator_api.go b/command/operator_api.go index 8b28ec4c1..be932b67a 100644 --- a/command/operator_api.go +++ b/command/operator_api.go @@ -160,7 +160,7 @@ func (c *OperatorAPICommand) Run(args []string) int { path, err := pathToURL(config, args[0]) if err != nil { c.Ui.Error(fmt.Sprintf("Error turning path into URL: %v", err)) - return 2 + return 1 } // Set Filter query param @@ -174,7 +174,7 @@ func (c *OperatorAPICommand) Run(args []string) int { out, err := c.apiToCurl(config, headerFlags.headers, path) if err != nil { c.Ui.Error(fmt.Sprintf("Error creating curl command: %v", err)) - return 3 + return 1 } c.Ui.Output(out) return 0 @@ -190,7 +190,7 @@ func (c *OperatorAPICommand) Run(args []string) int { if err := api.ConfigureTLS(client, config.TLSConfig); err != nil { c.Ui.Error(fmt.Sprintf("Error configuring TLS: %v", err)) - return 4 + return 1 } setQueryParams(config, path) @@ -200,7 +200,7 @@ func (c *OperatorAPICommand) Run(args []string) int { req, err := http.NewRequest(c.method, path.String(), c.body) if err != nil { c.Ui.Error(fmt.Sprintf("Error making request: %v", err)) - return 5 + return 1 } // Set headers from command line @@ -232,7 +232,7 @@ func (c *OperatorAPICommand) Run(args []string) int { resp, err := client.Do(req) if err != nil { c.Ui.Error(fmt.Sprintf("Error performing request: %v", err)) - return 6 + return 1 } defer resp.Body.Close() @@ -246,7 +246,7 @@ func (c *OperatorAPICommand) Run(args []string) int { n, err := io.Copy(os.Stdout, resp.Body) if err != nil { c.Ui.Error(fmt.Sprintf("Error reading response after %d bytes: %v", n, err)) - return 7 + return 1 } if len(resp.Trailer) > 0 {