Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the --no-wait flag for cf continue-deployment [main] #3123

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions command/v7/continue_deployment_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ type ContinueDeploymentCommand struct {
BaseCommand

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

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

warnings, err = cmd.Actor.PollStartForDeployment(application, deployment.GUID, false, handleInstanceDetails)
warnings, err = cmd.Actor.PollStartForDeployment(application, deployment.GUID, cmd.NoWait, handleInstanceDetails)
cmd.UI.DisplayNewline()
cmd.UI.DisplayWarnings(warnings)
if err != nil {
Expand Down
33 changes: 32 additions & 1 deletion command/v7/continue_deployment_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var _ = Describe("Continue deployment command", func() {
fakeActor *v7fakes.FakeActor
binaryName string
appName string
noWait bool
spaceGUID string
executeErr error
)
Expand All @@ -44,6 +45,7 @@ var _ = Describe("Continue deployment command", func() {

cmd = ContinueDeploymentCommand{
RequiredArgs: flag.AppName{AppName: appName},
NoWait: noWait,
BaseCommand: BaseCommand{
UI: testUI,
Config: fakeConfig,
Expand Down Expand Up @@ -126,10 +128,13 @@ var _ = Describe("Continue deployment command", func() {

When("getting the app succeeds", func() {
var appGUID string
var returnedApplication resources.Application

BeforeEach(func() {
appGUID = "some-app-guid"
returnedApplication = resources.Application{Name: appName, GUID: appGUID}
fakeActor.GetApplicationByNameAndSpaceReturns(
resources.Application{Name: appName, GUID: appGUID},
returnedApplication,
v7action.Warnings{"get-app-warning"},
nil,
)
Expand Down Expand Up @@ -202,6 +207,32 @@ var _ = Describe("Continue deployment command", func() {
Expect(executeErr).ToNot(HaveOccurred())
})

When("the --no-wait flag is not provided", func() {
It("polls and waits", func() {
Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1))

invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0)
Expect(invokedApplication).To(Equal(returnedApplication))
Expect(invokedGuid).To(Equal(deploymentGUID))
Expect(invokedNoWait).To(Equal(false))
})
})

When("the --no-wait flag is provided", func() {
BeforeEach(func() {
cmd.NoWait = true
})

It("polls without waiting", func() {
Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1))

invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0)
Expect(invokedApplication).To(Equal(returnedApplication))
Expect(invokedGuid).To(Equal(deploymentGUID))
Expect(invokedNoWait).To(Equal(true))
})
})

When("polling the application fails", func() {
BeforeEach(func() {
fakeActor.PollStartForDeploymentReturns(
Expand Down
6 changes: 5 additions & 1 deletion integration/v7/isolated/continue_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ var _ = Describe("Continue Deployment", func() {
Eventually(session).Should(Say(`\n`))
chinigo marked this conversation as resolved.
Show resolved Hide resolved

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

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

Eventually(session).Should(Say(`OPTIONS:`))
Eventually(session).Should(Say(`--no-wait\s+Exit when the first instance of the web process is healthy`))
Eventually(session).Should(Say(`\n`))

Eventually(session).Should(Say(`SEE ALSO:`))
Eventually(session).Should(Say(`app, push`))

Expand Down
Loading