MCPcopy
hub / github.com/cloudfoundry/cli / StartApp

Method StartApp

command/v7/shared/app_stager.go:107–245  ·  view source on GitHub ↗
(app resources.Application, space configv3.Space, organization configv3.Organization, resourceGuid string, opts AppStartOpts)

Source from the content-addressed store, hash-verified

105}
106
107func (stager *Stager) StartApp(app resources.Application, space configv3.Space, organization configv3.Organization, resourceGuid string, opts AppStartOpts) error {
108 if len(opts.Strategy) > 0 {
109 stager.UI.DisplayText("Creating deployment for app {{.AppName}}...\n",
110 map[string]interface{}{
111 "AppName": app.Name,
112 },
113 )
114
115 var (
116 deploymentGUID string
117 warnings v7action.Warnings
118 err error
119 )
120
121 dep := resources.Deployment{
122 Strategy: opts.Strategy,
123 Relationships: resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: app.GUID}},
124 }
125
126 if opts.Strategy == constant.DeploymentStrategyCanary && len(opts.CanarySteps) > 0 {
127 dep.Options = resources.DeploymentOpts{CanaryDeploymentOptions: &resources.CanaryDeploymentOptions{Steps: opts.CanarySteps}}
128 }
129 switch opts.AppAction {
130 case constant.ApplicationRollingBack:
131 dep.RevisionGUID = resourceGuid
132 dep.Options.MaxInFlight = opts.MaxInFlight
133 deploymentGUID, warnings, err = stager.Actor.CreateDeployment(dep)
134 default:
135 dep.DropletGUID = resourceGuid
136 dep.Options.MaxInFlight = opts.MaxInFlight
137 deploymentGUID, warnings, err = stager.Actor.CreateDeployment(dep)
138 }
139
140 stager.UI.DisplayWarnings(warnings)
141 if err != nil {
142 return err
143 }
144
145 stager.UI.DisplayText("Waiting for app to deploy...\n")
146
147 handleInstanceDetails := func(instanceDetails string) {
148 stager.UI.DisplayText(instanceDetails)
149 }
150
151 warnings, err = stager.Actor.PollStartForDeployment(app, deploymentGUID, opts.NoWait, handleInstanceDetails)
152 stager.UI.DisplayNewline()
153 stager.UI.DisplayWarnings(warnings)
154 if err != nil {
155 return err
156 }
157
158 if opts.NoWait && opts.Strategy != constant.DeploymentStrategyCanary {
159 stager.UI.DisplayText("First instance restaged correctly, restaging remaining in the background")
160 return nil
161 }
162 } else {
163 user, err := stager.Actor.GetCurrentUser()
164 if err != nil {

Callers 1

StageAndStartMethod · 0.95

Calls 15

AppDisplayMethod · 0.95
NewAppSummaryDisplayerFunction · 0.85
StartedMethod · 0.80
DisplayTextMethod · 0.65
CreateDeploymentMethod · 0.65
DisplayWarningsMethod · 0.65
DisplayNewlineMethod · 0.65
GetCurrentUserMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
DisplayOKMethod · 0.65
StopApplicationMethod · 0.65

Tested by

no test coverage detected