-
Notifications
You must be signed in to change notification settings - Fork 927
/
push_command.go
616 lines (536 loc) · 21.6 KB
/
push_command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
package v7
import (
"os"
"strings"
"code.cloudfoundry.org/cli/command/v7/shared"
"code.cloudfoundry.org/cli/util/configv3"
"code.cloudfoundry.org/clock"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
"code.cloudfoundry.org/cli/actor/actionerror"
"code.cloudfoundry.org/cli/actor/sharedaction"
"code.cloudfoundry.org/cli/actor/v3action"
"code.cloudfoundry.org/cli/actor/v7action"
"code.cloudfoundry.org/cli/actor/v7pushaction"
"code.cloudfoundry.org/cli/command"
"code.cloudfoundry.org/cli/command/flag"
"code.cloudfoundry.org/cli/command/translatableerror"
v6shared "code.cloudfoundry.org/cli/command/v6/shared"
"code.cloudfoundry.org/cli/util/manifestparser"
"code.cloudfoundry.org/cli/util/progressbar"
"github.com/cloudfoundry/bosh-cli/director/template"
log "github.com/sirupsen/logrus"
)
//go:generate counterfeiter . ProgressBar
type ProgressBar interface {
v7pushaction.ProgressBar
Complete()
Ready()
}
//go:generate counterfeiter . PushActor
type PushActor interface {
CreatePushPlans(appNameArg string, spaceGUID string, orgGUID string, parser v7pushaction.ManifestParser, overrides v7pushaction.FlagOverrides) ([]v7pushaction.PushPlan, error)
// Prepare the space by creating needed apps/applying the manifest
PrepareSpace(pushPlans []v7pushaction.PushPlan, parser v7pushaction.ManifestParser) ([]string, <-chan *v7pushaction.PushEvent)
// UpdateApplicationSettings figures out the state of the world.
UpdateApplicationSettings(pushPlans []v7pushaction.PushPlan) ([]v7pushaction.PushPlan, v7pushaction.Warnings, error)
// Actualize applies any necessary changes.
Actualize(plan v7pushaction.PushPlan, progressBar v7pushaction.ProgressBar) <-chan *v7pushaction.PushEvent
}
//go:generate counterfeiter . V7ActorForPush
type V7ActorForPush interface {
AppActor
GetStreamingLogsForApplicationByNameAndSpace(appName string, spaceGUID string, client v7action.NOAAClient) (<-chan *v7action.LogMessage, <-chan error, v7action.Warnings, error)
RestartApplication(appGUID string, noWait bool) (v7action.Warnings, error)
}
//go:generate counterfeiter . ManifestParser
type ManifestParser interface {
v7pushaction.ManifestParser
ContainsMultipleApps() bool
InterpolateAndParse(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV, appName string) error
ContainsPrivateDockerImages() bool
}
//go:generate counterfeiter . ManifestLocator
type ManifestLocator interface {
Path(filepathOrDirectory string) (string, bool, error)
}
type PushCommand struct {
OptionalArgs flag.OptionalAppName `positional-args:"yes"`
HealthCheckTimeout flag.PositiveInteger `long:"app-start-timeout" short:"t" description:"Time (in seconds) allowed to elapse between starting up an app and the first healthy response from the app"`
Buildpacks []string `long:"buildpack" short:"b" description:"Custom buildpack by name (e.g. my-buildpack) or Git URL (e.g. 'https://github.com/cloudfoundry/java-buildpack.git') or Git URL with a branch or tag (e.g. 'https://github.com/cloudfoundry/java-buildpack.git#v3.3.0' for 'v3.3.0' tag). To use built-in buildpacks only, specify 'default' or 'null'"`
Disk flag.Megabytes `long:"disk" short:"k" description:"Disk limit (e.g. 256M, 1024M, 1G)"`
DockerImage flag.DockerImage `long:"docker-image" short:"o" description:"Docker image to use (e.g. user/docker-image-name)"`
DockerUsername string `long:"docker-username" description:"Repository username; used with password from environment variable CF_DOCKER_PASSWORD"`
DropletPath flag.PathWithExistenceCheck `long:"droplet" description:"Path to a tgz file with a pre-staged app"`
HealthCheckHTTPEndpoint string `long:"endpoint" description:"Valid path on the app for an HTTP health check. Only used when specifying --health-check-type=http"`
HealthCheckType flag.HealthCheckType `long:"health-check-type" short:"u" description:"Application health check type. Defaults to 'port'. 'http' requires a valid endpoint, for example, '/health'."`
Instances flag.Instances `long:"instances" short:"i" description:"Number of instances"`
PathToManifest flag.ManifestPathWithExistenceCheck `long:"manifest" short:"f" description:"Path to manifest"`
Memory flag.Megabytes `long:"memory" short:"m" description:"Memory limit (e.g. 256M, 1024M, 1G)"`
NoManifest bool `long:"no-manifest" description:""`
NoRoute bool `long:"no-route" description:"Do not map a route to this app"`
NoStart bool `long:"no-start" description:"Do not stage and start the app after pushing"`
NoWait bool `long:"no-wait" description:"Do not wait for the long-running operation to complete; push exits when one instance of the web process is healthy"`
AppPath flag.PathWithExistenceCheck `long:"path" short:"p" description:"Path to app directory or to a zip file of the contents of the app directory"`
RandomRoute bool `long:"random-route" description:"Create a random route for this app"`
Stack string `long:"stack" short:"s" description:"Stack to use (a stack is a pre-built file system, including an operating system, that can run apps)"`
StartCommand flag.Command `long:"start-command" short:"c" description:"Startup command, set to null to reset to default start command"`
Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy, either rolling or null."`
Vars []template.VarKV `long:"var" description:"Variable key value pair for variable substitution, (e.g., name=app1); can specify multiple times"`
PathsToVarsFiles []flag.PathWithExistenceCheck `long:"vars-file" description:"Path to a variable substitution file for manifest; can specify multiple times"`
dockerPassword interface{} `environmentName:"CF_DOCKER_PASSWORD" environmentDescription:"Password used for private docker repository"`
usage interface{} `usage:"CF_NAME push APP_NAME [-b BUILDPACK_NAME] [-c COMMAND]\n [-f MANIFEST_PATH | --no-manifest] [--no-start] [--no-wait] [-i NUM_INSTANCES]\n [-k DISK] [-m MEMORY] [-p PATH] [-s STACK] [-t HEALTH_TIMEOUT]\n [-u (process | port | http)] [--no-route | --random-route]\n [--var KEY=VALUE] [--vars-file VARS_FILE_PATH]...\n \n CF_NAME push APP_NAME --docker-image [REGISTRY_HOST:PORT/]IMAGE[:TAG] [--docker-username USERNAME]\n [-c COMMAND] [-f MANIFEST_PATH | --no-manifest] [--no-start] [--no-wait]\n [-i NUM_INSTANCES] [-k DISK] [-m MEMORY] [-p PATH] [-s STACK] [-t HEALTH_TIMEOUT] [-u (process | port | http)]\n [--no-route | --random-route ] [--var KEY=VALUE] [--vars-file VARS_FILE_PATH]..."`
envCFStagingTimeout interface{} `environmentName:"CF_STAGING_TIMEOUT" environmentDescription:"Max wait time for staging, in minutes" environmentDefault:"15"`
envCFStartupTimeout interface{} `environmentName:"CF_STARTUP_TIMEOUT" environmentDescription:"Max wait time for app instance startup, in minutes" environmentDefault:"5"`
Config command.Config
UI command.UI
NOAAClient v3action.NOAAClient
Actor PushActor
VersionActor V7ActorForPush
SharedActor command.SharedActor
ProgressBar ProgressBar
PWD string
ManifestLocator ManifestLocator
ManifestParser ManifestParser
}
func (cmd *PushCommand) Setup(config command.Config, ui command.UI) error {
cmd.Config = config
cmd.UI = ui
cmd.ProgressBar = progressbar.NewProgressBar()
sharedActor := sharedaction.NewActor(config)
cmd.SharedActor = sharedActor
ccClient, uaaClient, err := shared.NewClients(config, ui, true, "")
if err != nil {
return err
}
v7actor := v7action.NewActor(ccClient, config, sharedActor, uaaClient, clock.NewClock())
cmd.VersionActor = v7actor
cmd.Actor = v7pushaction.NewActor(v7actor, sharedActor)
cmd.NOAAClient = v6shared.NewNOAAClient(ccClient.Info.Logging(), config, uaaClient, ui)
currentDir, err := os.Getwd()
cmd.PWD = currentDir
cmd.ManifestLocator = manifestparser.NewLocator()
cmd.ManifestParser = manifestparser.NewParser()
return err
}
func (cmd PushCommand) Execute(args []string) error {
err := cmd.SharedActor.CheckTarget(true, true)
if err != nil {
return err
}
if !cmd.NoManifest {
if err = cmd.ReadManifest(); err != nil {
return err
}
}
err = cmd.ValidateFlags()
if err != nil {
return err
}
flagOverrides, err := cmd.GetFlagOverrides()
if err != nil {
return err
}
err = cmd.ValidateAllowedFlagsForMultipleApps(cmd.ManifestParser.ContainsMultipleApps())
if err != nil {
return err
}
flagOverrides.DockerPassword, err = cmd.GetDockerPassword(flagOverrides.DockerUsername, cmd.ManifestParser.ContainsPrivateDockerImages())
if err != nil {
return err
}
pushPlans, err := cmd.Actor.CreatePushPlans(
cmd.OptionalArgs.AppName,
cmd.Config.TargetedSpace().GUID,
cmd.Config.TargetedOrganization().GUID,
cmd.ManifestParser,
flagOverrides,
)
if err != nil {
return err
}
appNames, eventStream := cmd.Actor.PrepareSpace(pushPlans, cmd.ManifestParser)
err = cmd.eventStreamHandler(eventStream)
if err != nil {
return err
}
if len(appNames) == 0 {
return translatableerror.AppNameOrManifestRequiredError{}
}
user, err := cmd.Config.CurrentUser()
if err != nil {
return err
}
cmd.announcePushing(appNames, user)
cmd.UI.DisplayText("Getting app info...")
log.Info("generating the app plan")
pushPlans, warnings, err := cmd.Actor.UpdateApplicationSettings(pushPlans)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
log.WithField("number of plans", len(pushPlans)).Debug("completed generating plan")
for _, plan := range pushPlans {
log.WithField("app_name", plan.Application.Name).Info("actualizing")
eventStream := cmd.Actor.Actualize(plan, cmd.ProgressBar)
err := cmd.eventStreamHandler(eventStream)
if cmd.shouldDisplaySummary(err) {
summaryErr := cmd.displayAppSummary(plan)
if summaryErr != nil {
return summaryErr
}
}
if err != nil {
return cmd.mapErr(plan.Application.Name, err)
}
}
return nil
}
func (cmd PushCommand) shouldDisplaySummary(err error) bool {
if err == nil {
return true
}
_, ok := err.(actionerror.AllInstancesCrashedError)
return ok
}
func (cmd PushCommand) mapErr(appName string, err error) error {
switch err.(type) {
case actionerror.AllInstancesCrashedError:
return translatableerror.ApplicationUnableToStartError{
AppName: appName,
BinaryName: cmd.Config.BinaryName(),
}
case actionerror.StartupTimeoutError:
return translatableerror.StartupTimeoutError{
AppName: appName,
BinaryName: cmd.Config.BinaryName(),
}
}
return err
}
func (cmd PushCommand) announcePushing(appNames []string, user configv3.User) {
tokens := map[string]interface{}{
"AppName": strings.Join(appNames, ", "),
"OrgName": cmd.Config.TargetedOrganization().Name,
"SpaceName": cmd.Config.TargetedSpace().Name,
"Username": user.Name,
}
singular := "Pushing app {{.AppName}} to org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}..."
plural := "Pushing apps {{.AppName}} to org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}..."
if len(appNames) == 1 {
cmd.UI.DisplayTextWithFlavor(singular, tokens)
} else {
cmd.UI.DisplayTextWithFlavor(plural, tokens)
}
}
func (cmd PushCommand) displayAppSummary(plan v7pushaction.PushPlan) error {
log.Info("getting application summary info")
summary, warnings, err := cmd.VersionActor.GetDetailedAppSummary(
plan.Application.Name,
cmd.Config.TargetedSpace().GUID,
true,
)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
cmd.UI.DisplayNewline()
appSummaryDisplayer := shared.NewAppSummaryDisplayer(cmd.UI)
appSummaryDisplayer.AppDisplay(summary, true)
return nil
}
func (cmd PushCommand) eventStreamHandler(eventStream <-chan *v7pushaction.PushEvent) error {
for event := range eventStream {
cmd.UI.DisplayWarnings(event.Warnings)
if event.Err != nil {
return event.Err
}
_, err := cmd.processEvent(event.Event, event.Plan.Application.Name)
if err != nil {
return err
}
}
return nil
}
func (cmd PushCommand) processEvent(event v7pushaction.Event, appName string) (bool, error) {
switch event {
case v7pushaction.SkippingApplicationCreation:
cmd.UI.DisplayTextWithFlavor("Updating app {{.AppName}}...", map[string]interface{}{
"AppName": appName,
})
case v7pushaction.CreatingApplication:
cmd.UI.DisplayTextWithFlavor("Creating app {{.AppName}}...", map[string]interface{}{
"AppName": appName,
})
case v7pushaction.CreatingAndMappingRoutes:
cmd.UI.DisplayText("Mapping routes...")
case v7pushaction.CreatingArchive:
cmd.UI.DisplayText("Packaging files to upload...")
case v7pushaction.UploadingApplicationWithArchive:
cmd.UI.DisplayText("Uploading files...")
log.Debug("starting progress bar")
cmd.ProgressBar.Ready()
case v7pushaction.UploadingApplication:
cmd.UI.DisplayText("All files found in remote cache; nothing to upload.")
cmd.UI.DisplayText("Waiting for API to complete processing files...")
case v7pushaction.RetryUpload:
cmd.UI.DisplayText("Retrying upload due to an error...")
case v7pushaction.UploadWithArchiveComplete:
cmd.ProgressBar.Complete()
cmd.UI.DisplayNewline()
cmd.UI.DisplayText("Waiting for API to complete processing files...")
case v7pushaction.UploadingDroplet:
cmd.UI.DisplayText("Uploading droplet bits...")
cmd.ProgressBar.Ready()
case v7pushaction.UploadDropletComplete:
cmd.ProgressBar.Complete()
cmd.UI.DisplayNewline()
cmd.UI.DisplayText("Waiting for API to complete processing files...")
case v7pushaction.StoppingApplication:
cmd.UI.DisplayText("Stopping Application...")
case v7pushaction.StoppingApplicationComplete:
cmd.UI.DisplayText("Application Stopped")
case v7pushaction.ApplyManifest:
cmd.UI.DisplayText("Applying manifest...")
case v7pushaction.ApplyManifestComplete:
cmd.UI.DisplayText("Manifest applied")
case v7pushaction.StartingStaging:
cmd.UI.DisplayNewline()
cmd.UI.DisplayText("Staging app and tracing logs...")
logStream, errStream, warnings, err := cmd.VersionActor.GetStreamingLogsForApplicationByNameAndSpace(appName, cmd.Config.TargetedSpace().GUID, cmd.NOAAClient)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return false, err
}
go cmd.getLogs(logStream, errStream)
case v7pushaction.StagingComplete:
cmd.NOAAClient.Close()
case v7pushaction.RestartingApplication:
cmd.UI.DisplayNewline()
cmd.UI.DisplayTextWithFlavor(
"Waiting for app {{.AppName}} to start...",
map[string]interface{}{
"AppName": appName,
},
)
case v7pushaction.StartingDeployment:
cmd.UI.DisplayNewline()
cmd.UI.DisplayTextWithFlavor(
"Starting deployment for app {{.AppName}}...",
map[string]interface{}{
"AppName": appName,
},
)
case v7pushaction.WaitingForDeployment:
cmd.UI.DisplayText("Waiting for app to deploy...")
case v7pushaction.Complete:
return true, nil
default:
log.WithField("event", event).Debug("ignoring event")
}
return false, nil
}
func (cmd PushCommand) getLogs(logStream <-chan *v7action.LogMessage, errStream <-chan error) {
for {
select {
case logMessage, open := <-logStream:
if !open {
return
}
if logMessage.Staging() {
cmd.UI.DisplayLogMessage(logMessage, false)
}
case err, open := <-errStream:
if !open {
return
}
_, ok := err.(actionerror.NOAATimeoutError)
if ok {
cmd.UI.DisplayWarning("timeout connecting to log server, no log will be shown")
}
cmd.UI.DisplayWarning(err.Error())
}
}
}
func (cmd PushCommand) ReadManifest() error {
log.Info("reading manifest if exists")
pathsToVarsFiles := []string{}
for _, varfilepath := range cmd.PathsToVarsFiles {
pathsToVarsFiles = append(pathsToVarsFiles, string(varfilepath))
}
readPath := cmd.PWD
if len(cmd.PathToManifest) != 0 {
log.WithField("manifestPath", cmd.PathToManifest).Debug("reading '-f' provided manifest")
readPath = string(cmd.PathToManifest)
}
pathToManifest, exists, err := cmd.ManifestLocator.Path(readPath)
if err != nil {
return err
}
if exists {
log.WithField("manifestPath", pathToManifest).Debug("path to manifest")
err = cmd.ManifestParser.InterpolateAndParse(pathToManifest, pathsToVarsFiles, cmd.Vars, cmd.OptionalArgs.AppName)
if err != nil {
log.Errorln("reading manifest:", err)
return err
}
cmd.UI.DisplayText("Using manifest file {{.Path}}", map[string]interface{}{"Path": pathToManifest})
}
return nil
}
func (cmd PushCommand) GetFlagOverrides() (v7pushaction.FlagOverrides, error) {
return v7pushaction.FlagOverrides{
Buildpacks: cmd.Buildpacks,
Stack: cmd.Stack,
Disk: cmd.Disk.NullUint64,
DropletPath: string(cmd.DropletPath),
DockerImage: cmd.DockerImage.Path,
DockerUsername: cmd.DockerUsername,
HealthCheckEndpoint: cmd.HealthCheckHTTPEndpoint,
HealthCheckType: cmd.HealthCheckType.Type,
HealthCheckTimeout: cmd.HealthCheckTimeout.Value, Instances: cmd.Instances.NullInt,
Memory: cmd.Memory.NullUint64,
NoStart: cmd.NoStart,
NoWait: cmd.NoWait,
ProvidedAppPath: string(cmd.AppPath),
NoRoute: cmd.NoRoute,
RandomRoute: cmd.RandomRoute,
StartCommand: cmd.StartCommand.FilteredString,
Strategy: cmd.Strategy.Name,
}, nil
}
func (cmd PushCommand) ValidateAllowedFlagsForMultipleApps(containsMultipleApps bool) error {
if cmd.OptionalArgs.AppName != "" {
return nil
}
allowedFlagsMultipleApps := !(len(cmd.Buildpacks) > 0 ||
cmd.Disk.IsSet ||
cmd.DockerImage.Path != "" ||
cmd.DockerUsername != "" ||
cmd.DropletPath != "" ||
cmd.HealthCheckType.Type != "" ||
cmd.HealthCheckHTTPEndpoint != "" ||
cmd.HealthCheckTimeout.Value > 0 ||
cmd.Instances.IsSet ||
cmd.Stack != "" ||
cmd.Memory.IsSet ||
cmd.AppPath != "" ||
cmd.NoRoute ||
cmd.StartCommand.IsSet ||
cmd.Strategy.Name != "")
if containsMultipleApps && !allowedFlagsMultipleApps {
return translatableerror.CommandLineArgsWithMultipleAppsError{}
}
return nil
}
func (cmd PushCommand) ValidateFlags() error {
switch {
case cmd.DockerUsername != "" && cmd.DockerImage.Path == "":
return translatableerror.RequiredFlagsError{
Arg1: "--docker-image, -o",
Arg2: "--docker-username",
}
case cmd.DockerImage.Path != "" && cmd.Buildpacks != nil:
return translatableerror.ArgumentCombinationError{
Args: []string{
"--buildpack, -b",
"--docker-image, -o",
},
}
case cmd.DockerImage.Path != "" && cmd.AppPath != "":
return translatableerror.ArgumentCombinationError{
Args: []string{
"--docker-image, -o",
"--path, -p",
},
}
case cmd.DockerImage.Path != "" && cmd.Stack != "":
return translatableerror.ArgumentCombinationError{
Args: []string{
"--stack, -s",
"--docker-image, -o",
},
}
case cmd.NoManifest && cmd.PathToManifest != "":
return translatableerror.ArgumentCombinationError{
Args: []string{
"--no-manifest",
"--manifest, -f",
},
}
case cmd.NoManifest && len(cmd.PathsToVarsFiles) > 0:
return translatableerror.ArgumentCombinationError{
Args: []string{
"--no-manifest",
"--vars-file",
},
}
case cmd.NoManifest && len(cmd.Vars) > 0:
return translatableerror.ArgumentCombinationError{
Args: []string{
"--no-manifest",
"--vars",
},
}
case cmd.HealthCheckType.Type == constant.HTTP && cmd.HealthCheckHTTPEndpoint == "":
return translatableerror.RequiredFlagsError{
Arg1: "--endpoint",
Arg2: "--health-check-type=http, -u=http",
}
case 0 < len(cmd.HealthCheckHTTPEndpoint) && cmd.HealthCheckType.Type != constant.HTTP:
return translatableerror.RequiredFlagsError{
Arg1: "--health-check-type=http, -u=http",
Arg2: "--endpoint",
}
case cmd.DropletPath != "" && (cmd.DockerImage.Path != "" || cmd.DockerUsername != "" || cmd.AppPath != ""):
return translatableerror.ArgumentCombinationError{
Args: []string{
"--droplet",
"--docker-image, -o",
"--docker-username",
"-p",
},
}
case cmd.NoStart && cmd.Strategy == flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling}:
return translatableerror.ArgumentCombinationError{
Args: []string{
"--no-start",
"--strategy=rolling",
},
}
case cmd.NoStart && cmd.NoWait:
return translatableerror.ArgumentCombinationError{
Args: []string{
"--no-start",
"--no-wait",
},
}
case cmd.NoRoute && cmd.RandomRoute:
return translatableerror.ArgumentCombinationError{
Args: []string{
"--no-route",
"--random-route",
},
}
}
if len(cmd.ManifestParser.Apps()) == 1 {
app := cmd.ManifestParser.Apps()[0]
switch {
case len(cmd.Buildpacks) > 0 && app.Docker != nil:
return translatableerror.ArgumentManifestMismatchError{
Arg: "--buildpack, -b",
ManifestProperty: "docker",
}
case len(cmd.AppPath) > 0 && app.Docker != nil:
return translatableerror.ArgumentManifestMismatchError{
Arg: "--path, -p",
ManifestProperty: "docker",
}
case len(cmd.DockerImage.Path) > 0 && app.Path != "":
return translatableerror.ArgumentManifestMismatchError{
Arg: "--docker-image, -o",
ManifestProperty: "path",
}
}
}
return nil
}