Skip to content

Commit 84a04c2

Browse files
author
Michael Chinigo
authored
Support the --no-wait flag for cf continue-deployment [main] (#3123)
* Support the --no-wait flag for `cf continue-deployment` * Update assertion on `cf continue-deployment` help text
1 parent 39b9f3c commit 84a04c2

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

command/v7/continue_deployment_command.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ type ContinueDeploymentCommand struct {
99
BaseCommand
1010

1111
RequiredArgs flag.AppName `positional-args:"yes"`
12-
usage interface{} `usage:"CF_NAME continue-deployment APP_NAME\n\nEXAMPLES:\n cf continue-deployment my-app"`
12+
NoWait bool `long:"no-wait" description:"Exit when the first instance of the web process is healthy"`
13+
usage interface{} `usage:"CF_NAME continue-deployment APP_NAME [--no-wait]\n\nEXAMPLES:\n cf continue-deployment my-app"`
1314
relatedCommands interface{} `related_commands:"app, push"`
1415
}
1516

@@ -58,7 +59,7 @@ func (cmd *ContinueDeploymentCommand) Execute(args []string) error {
5859
cmd.UI.DisplayText(instanceDetails)
5960
}
6061

61-
warnings, err = cmd.Actor.PollStartForDeployment(application, deployment.GUID, false, handleInstanceDetails)
62+
warnings, err = cmd.Actor.PollStartForDeployment(application, deployment.GUID, cmd.NoWait, handleInstanceDetails)
6263
cmd.UI.DisplayNewline()
6364
cmd.UI.DisplayWarnings(warnings)
6465
if err != nil {

command/v7/continue_deployment_command_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var _ = Describe("Continue deployment command", func() {
2828
fakeActor *v7fakes.FakeActor
2929
binaryName string
3030
appName string
31+
noWait bool
3132
spaceGUID string
3233
executeErr error
3334
)
@@ -44,6 +45,7 @@ var _ = Describe("Continue deployment command", func() {
4445

4546
cmd = ContinueDeploymentCommand{
4647
RequiredArgs: flag.AppName{AppName: appName},
48+
NoWait: noWait,
4749
BaseCommand: BaseCommand{
4850
UI: testUI,
4951
Config: fakeConfig,
@@ -126,10 +128,13 @@ var _ = Describe("Continue deployment command", func() {
126128

127129
When("getting the app succeeds", func() {
128130
var appGUID string
131+
var returnedApplication resources.Application
132+
129133
BeforeEach(func() {
130134
appGUID = "some-app-guid"
135+
returnedApplication = resources.Application{Name: appName, GUID: appGUID}
131136
fakeActor.GetApplicationByNameAndSpaceReturns(
132-
resources.Application{Name: appName, GUID: appGUID},
137+
returnedApplication,
133138
v7action.Warnings{"get-app-warning"},
134139
nil,
135140
)
@@ -202,6 +207,32 @@ var _ = Describe("Continue deployment command", func() {
202207
Expect(executeErr).ToNot(HaveOccurred())
203208
})
204209

210+
When("the --no-wait flag is not provided", func() {
211+
It("polls and waits", func() {
212+
Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1))
213+
214+
invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0)
215+
Expect(invokedApplication).To(Equal(returnedApplication))
216+
Expect(invokedGuid).To(Equal(deploymentGUID))
217+
Expect(invokedNoWait).To(Equal(false))
218+
})
219+
})
220+
221+
When("the --no-wait flag is provided", func() {
222+
BeforeEach(func() {
223+
cmd.NoWait = true
224+
})
225+
226+
It("polls without waiting", func() {
227+
Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1))
228+
229+
invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0)
230+
Expect(invokedApplication).To(Equal(returnedApplication))
231+
Expect(invokedGuid).To(Equal(deploymentGUID))
232+
Expect(invokedNoWait).To(Equal(true))
233+
})
234+
})
235+
205236
When("polling the application fails", func() {
206237
BeforeEach(func() {
207238
fakeActor.PollStartForDeploymentReturns(

integration/v7/isolated/continue_deployment_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ var _ = Describe("Continue Deployment", func() {
2828
Eventually(session).Should(Say(`\n`))
2929

3030
Eventually(session).Should(Say(`USAGE:`))
31-
Eventually(session).Should(Say(`cf continue-deployment APP_NAME\n`))
31+
Eventually(session).Should(Say(`cf continue-deployment APP_NAME \[--no-wait\]\n`))
3232
Eventually(session).Should(Say(`\n`))
3333

3434
Eventually(session).Should(Say(`EXAMPLES:`))
3535
Eventually(session).Should(Say(`cf continue-deployment my-app\n`))
3636
Eventually(session).Should(Say(`\n`))
3737

38+
Eventually(session).Should(Say(`OPTIONS:`))
39+
Eventually(session).Should(Say(`--no-wait\s+Exit when the first instance of the web process is healthy`))
40+
Eventually(session).Should(Say(`\n`))
41+
3842
Eventually(session).Should(Say(`SEE ALSO:`))
3943
Eventually(session).Should(Say(`app, push`))
4044

0 commit comments

Comments
 (0)