Skip to content

Commit

Permalink
Print max-in-flight value as part of deployment information in proces…
Browse files Browse the repository at this point in the history
…s table

when it is set to non-default value (currently 1)

Co-authored-by: Greg Weresch <greg.weresch@broadcom.com>
  • Loading branch information
pivotalgeorge and weresch committed Aug 12, 2024
1 parent f9577eb commit ffa3f52
Show file tree
Hide file tree
Showing 3 changed files with 282 additions and 70 deletions.
2 changes: 2 additions & 0 deletions api/cloudcontroller/ccv3/constant/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ const (
DeploymentStatusValueActive DeploymentStatusValue = "ACTIVE"
DeploymentStatusValueFinalized DeploymentStatusValue = "FINALIZED"
)

const DeploymentMaxInFlightDefaultValue int = 1
20 changes: 8 additions & 12 deletions command/v7/shared/app_summary_displayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed
if summary.Deployment.StatusValue == constant.DeploymentStatusValueActive {
display.UI.DisplayNewline()
display.UI.DisplayText(display.getDeploymentStatusText(summary))

var maxInFlight = summary.Deployment.Options.MaxInFlight
if maxInFlight > 0 && maxInFlight != constant.DeploymentMaxInFlightDefaultValue {
display.UI.DisplayText(fmt.Sprintf("max-in-flight: %d", maxInFlight))
}

if summary.Deployment.Strategy == constant.DeploymentStrategyCanary && summary.Deployment.StatusReason == constant.DeploymentStatusReasonPaused {
display.UI.DisplayNewline()
display.UI.DisplayText(fmt.Sprintf("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", summary.Application.Name, summary.Application.Name))
Expand All @@ -171,25 +177,15 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed

func (display AppSummaryDisplayer) getDeploymentStatusText(summary v7action.DetailedApplicationSummary) string {
var lastStatusChangeTime = display.getLastStatusChangeTime(summary)

if lastStatusChangeTime != "" {
return fmt.Sprintf("%s deployment currently %s (since %s)",
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
summary.Deployment.StatusReason,
lastStatusChangeTime)
} else {
var sb strings.Builder
sb.WriteString(fmt.Sprintf("%s deployment currently %s.",
return fmt.Sprintf("%s deployment currently %s.",
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
summary.Deployment.StatusReason))

if summary.Deployment.Strategy == constant.DeploymentStrategyCanary && summary.Deployment.StatusReason == constant.DeploymentStatusReasonPaused {
sb.WriteString("\n")
sb.WriteString(fmt.Sprintf(
"Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.",
summary.Application.Name, summary.Application.Name))
}
return sb.String()
summary.Deployment.StatusReason)
}
}

Expand Down
Loading

0 comments on commit ffa3f52

Please sign in to comment.