From 845b9c23fe9f91864b3ca7922fc6c99aad89d0f2 Mon Sep 17 00:00:00 2001 From: Artur Mullakhmetov Date: Thu, 26 Mar 2020 18:24:21 +0300 Subject: [PATCH] Return error code in case of formatting failure. --- command/acl/bootstrap/bootstrap.go | 1 + command/acl/policy/create/policy_create.go | 1 + command/acl/policy/list/policy_list.go | 1 + command/acl/policy/read/policy_read.go | 1 + command/acl/policy/update/policy_update.go | 1 + command/acl/role/create/role_create.go | 1 + command/acl/role/list/role_list.go | 1 + command/acl/role/read/role_read.go | 1 + command/acl/role/update/role_update.go | 1 + command/acl/token/clone/token_clone.go | 1 + command/acl/token/create/token_create.go | 1 + command/acl/token/list/token_list.go | 1 + command/acl/token/read/token_read.go | 1 + command/acl/token/update/token_update.go | 1 + 14 files changed, 14 insertions(+) diff --git a/command/acl/bootstrap/bootstrap.go b/command/acl/bootstrap/bootstrap.go index 00287ff6c2..37ec63a9da 100644 --- a/command/acl/bootstrap/bootstrap.go +++ b/command/acl/bootstrap/bootstrap.go @@ -63,6 +63,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatToken(t) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/policy/create/policy_create.go b/command/acl/policy/create/policy_create.go index f8557b6a6b..e09cad0623 100644 --- a/command/acl/policy/create/policy_create.go +++ b/command/acl/policy/create/policy_create.go @@ -137,6 +137,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatPolicy(p) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/policy/list/policy_list.go b/command/acl/policy/list/policy_list.go index bff705e593..3d1e819345 100644 --- a/command/acl/policy/list/policy_list.go +++ b/command/acl/policy/list/policy_list.go @@ -69,6 +69,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatPolicyList(policies) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/policy/read/policy_read.go b/command/acl/policy/read/policy_read.go index 751e648920..703443bf79 100644 --- a/command/acl/policy/read/policy_read.go +++ b/command/acl/policy/read/policy_read.go @@ -91,6 +91,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatPolicy(p) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/policy/update/policy_update.go b/command/acl/policy/update/policy_update.go index b2d129021a..2e2623f319 100644 --- a/command/acl/policy/update/policy_update.go +++ b/command/acl/policy/update/policy_update.go @@ -168,6 +168,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatPolicy(p) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/role/create/role_create.go b/command/acl/role/create/role_create.go index 1bcd7d4467..aae712a46c 100644 --- a/command/acl/role/create/role_create.go +++ b/command/acl/role/create/role_create.go @@ -123,6 +123,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatRole(r) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/role/list/role_list.go b/command/acl/role/list/role_list.go index 2bebb141e8..9fc1bd1247 100644 --- a/command/acl/role/list/role_list.go +++ b/command/acl/role/list/role_list.go @@ -69,6 +69,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatRoleList(roles) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/role/read/role_read.go b/command/acl/role/read/role_read.go index 93654cb5d2..8b77717d7f 100644 --- a/command/acl/role/read/role_read.go +++ b/command/acl/role/read/role_read.go @@ -103,6 +103,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatRole(r) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/role/update/role_update.go b/command/acl/role/update/role_update.go index f47785aa31..a26858e29c 100644 --- a/command/acl/role/update/role_update.go +++ b/command/acl/role/update/role_update.go @@ -208,6 +208,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatRole(r) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/token/clone/token_clone.go b/command/acl/token/clone/token_clone.go index 684f6eb159..f08644f772 100644 --- a/command/acl/token/clone/token_clone.go +++ b/command/acl/token/clone/token_clone.go @@ -84,6 +84,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatToken(t) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/token/create/token_create.go b/command/acl/token/create/token_create.go index f66fd2b5c4..03e04e5331 100644 --- a/command/acl/token/create/token_create.go +++ b/command/acl/token/create/token_create.go @@ -154,6 +154,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatToken(t) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/token/list/token_list.go b/command/acl/token/list/token_list.go index dcf23e82c8..c89340db63 100644 --- a/command/acl/token/list/token_list.go +++ b/command/acl/token/list/token_list.go @@ -68,6 +68,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatTokenList(tokens) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/token/read/token_read.go b/command/acl/token/read/token_read.go index f996b7187a..377d0a3b9e 100644 --- a/command/acl/token/read/token_read.go +++ b/command/acl/token/read/token_read.go @@ -97,6 +97,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatToken(t) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out) diff --git a/command/acl/token/update/token_update.go b/command/acl/token/update/token_update.go index b79c00e2a5..5e2c2224cd 100644 --- a/command/acl/token/update/token_update.go +++ b/command/acl/token/update/token_update.go @@ -284,6 +284,7 @@ func (c *cmd) Run(args []string) int { out, err := formatter.FormatToken(t) if err != nil { c.UI.Error(err.Error()) + return 1 } if out != "" { c.UI.Info(out)