MCPcopy Index your code
hub / github.com/cloudfoundry/cli / createAppSetFromContextAndManifest

Method createAppSetFromContextAndManifest

cf/commands/application/push.go:595–649  ·  view source on GitHub ↗
(contextApp models.AppParams, manifestApps []models.AppParams)

Source from the content-addressed store, hash-verified

593}
594
595func (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
651func checkCombinedDockerProperties(flagContext models.AppParams, manifestApp models.AppParams) error {
652 if manifestApp.DockerUsername != nil || flagContext.DockerUsername != nil {

Callers 1

ExecuteMethod · 0.95

Calls 7

NewFunction · 0.92
addAppFunction · 0.85
CommandUsageMethod · 0.80
IsEmptyMethod · 0.65
ErrorMethod · 0.65
MergeMethod · 0.45

Tested by

no test coverage detected