(contextApp models.AppParams, manifestApps []models.AppParams)
| 593 | } |
| 594 | |
| 595 | func (cmd *Push) createAppSetFromContextAndManifest(contextApp models.AppParams, manifestApps []models.AppParams) ([]models.AppParams, error) { |
| 596 | var err error |
| 597 | var apps []models.AppParams |
| 598 | |
| 599 | switch len(manifestApps) { |
| 600 | case 0: |
| 601 | if contextApp.Name == nil { |
| 602 | return nil, errors.New( |
| 603 | T("Incorrect Usage. The push command requires an app name. The app name can be supplied as an argument or with a manifest.yml file.") + |
| 604 | "\n\n" + |
| 605 | commandregistry.Commands.CommandUsage("push"), |
| 606 | ) |
| 607 | } |
| 608 | err = addApp(&apps, contextApp) |
| 609 | case 1: |
| 610 | err = checkCombinedDockerProperties(contextApp, manifestApps[0]) |
| 611 | if err != nil { |
| 612 | return nil, err |
| 613 | } |
| 614 | |
| 615 | manifestApps[0].Merge(&contextApp) |
| 616 | err = addApp(&apps, manifestApps[0]) |
| 617 | default: |
| 618 | selectedAppName := contextApp.Name |
| 619 | contextApp.Name = nil |
| 620 | |
| 621 | if !contextApp.IsEmpty() { |
| 622 | return nil, errors.New(T("Incorrect Usage. Command line flags (except -f) cannot be applied when pushing multiple apps from a manifest file.")) |
| 623 | } |
| 624 | |
| 625 | if selectedAppName != nil { |
| 626 | var foundApp bool |
| 627 | for _, appParams := range manifestApps { |
| 628 | if appParams.Name != nil && *appParams.Name == *selectedAppName { |
| 629 | foundApp = true |
| 630 | err = addApp(&apps, appParams) |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | if !foundApp { |
| 635 | err = errors.New(T("Could not find app named '{{.AppName}}' in manifest", map[string]interface{}{"AppName": *selectedAppName})) |
| 636 | } |
| 637 | } else { |
| 638 | for _, manifestApp := range manifestApps { |
| 639 | err = addApp(&apps, manifestApp) |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | if err != nil { |
| 645 | return nil, errors.New(T("Error: {{.Err}}", map[string]interface{}{"Err": err.Error()})) |
| 646 | } |
| 647 | |
| 648 | return apps, nil |
| 649 | } |
| 650 | |
| 651 | func checkCombinedDockerProperties(flagContext models.AppParams, manifestApp models.AppParams) error { |
| 652 | if manifestApp.DockerUsername != nil || flagContext.DockerUsername != nil { |
no test coverage detected