From 9de4d7367c127221a495f9f6d54f99e4d3216c63 Mon Sep 17 00:00:00 2001 From: Derek Strickland <1111455+DerekStrickland@users.noreply.github.com> Date: Tue, 21 Jun 2022 06:01:23 -0400 Subject: [PATCH] cli: fix detach handling (#13405) Fix detach handling for: - `deployment fail` - `deployment promote` - `deployment resume` - `deployment unblock` - `job promote` --- .changelog/13405.txt | 3 +++ command/deployment_fail.go | 7 ++++++- command/deployment_promote.go | 10 ++++++++-- command/deployment_resume.go | 7 ++++++- command/deployment_unblock.go | 7 ++++++- command/job_promote.go | 10 ++++++++-- 6 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 .changelog/13405.txt diff --git a/.changelog/13405.txt b/.changelog/13405.txt new file mode 100644 index 000000000..fac6e67f2 --- /dev/null +++ b/.changelog/13405.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: Fixed remaining bugs where the evaluation ID was not printed when the `-detach` flag was passed +`` diff --git a/command/deployment_fail.go b/command/deployment_fail.go index 625f90e85..3e0557a4d 100644 --- a/command/deployment_fail.go +++ b/command/deployment_fail.go @@ -132,7 +132,12 @@ func (c *DeploymentFailCommand) Run(args []string) int { evalCreated := u.EvalID != "" // Nothing to do - if detach || !evalCreated { + if !evalCreated { + return 0 + } + + if detach { + c.Ui.Output("Evaluation ID: " + u.EvalID) return 0 } diff --git a/command/deployment_promote.go b/command/deployment_promote.go index 1450644d6..9e44c29d3 100644 --- a/command/deployment_promote.go +++ b/command/deployment_promote.go @@ -140,9 +140,15 @@ func (c *DeploymentPromoteCommand) Run(args []string) int { return 1 } - // Nothing to do evalCreated := u.EvalID != "" - if detach || !evalCreated { + + // Nothing to do + if !evalCreated { + return 0 + } + + if detach { + c.Ui.Output("Evaluation ID: " + u.EvalID) return 0 } diff --git a/command/deployment_resume.go b/command/deployment_resume.go index f3d4a31b1..156dfcafa 100644 --- a/command/deployment_resume.go +++ b/command/deployment_resume.go @@ -124,7 +124,12 @@ func (c *DeploymentResumeCommand) Run(args []string) int { evalCreated := u.EvalID != "" // Nothing to do - if detach || !evalCreated { + if !evalCreated { + return 0 + } + + if detach { + c.Ui.Output("Evaluation ID: " + u.EvalID) return 0 } diff --git a/command/deployment_unblock.go b/command/deployment_unblock.go index ede63fe29..23b6e138f 100644 --- a/command/deployment_unblock.go +++ b/command/deployment_unblock.go @@ -124,7 +124,12 @@ func (c *DeploymentUnblockCommand) Run(args []string) int { evalCreated := u.EvalID != "" // Nothing to do - if detach || !evalCreated { + if !evalCreated { + return 0 + } + + if detach { + c.Ui.Output("Evaluation ID: " + u.EvalID) return 0 } diff --git a/command/job_promote.go b/command/job_promote.go index 9ec99eb9a..5d308b17d 100644 --- a/command/job_promote.go +++ b/command/job_promote.go @@ -161,9 +161,15 @@ func (c *JobPromoteCommand) Run(args []string) int { return 1 } - // Nothing to do evalCreated := u.EvalID != "" - if detach || !evalCreated { + + // Nothing to do + if !evalCreated { + return 0 + } + + if detach { + c.Ui.Output("Evaluation ID: " + u.EvalID) return 0 }