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

Method bindAppToServices

cf/commands/application/push.go:481–515  ·  view source on GitHub ↗
(services []string, app models.Application)

Source from the content-addressed store, hash-verified

479}
480
481func (cmd *Push) bindAppToServices(services []string, app models.Application) error {
482 for _, serviceName := range services {
483 serviceInstance, err := cmd.serviceRepo.FindInstanceByName(serviceName)
484
485 if err != nil {
486 return errors.New(T("Could not find service {{.OfferingName}} to bind to {{.AppName}}",
487 map[string]interface{}{"OfferingName": serviceName, "AppName": app.Name}))
488 }
489
490 cmd.ui.Say(T("Binding service {{.OfferingName}} to app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
491 map[string]interface{}{
492 "OfferingName": terminal.EntityNameColor(serviceInstance.Name),
493 "AppName": terminal.EntityNameColor(app.Name),
494 "OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
495 "SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
496 "Username": terminal.EntityNameColor(cmd.config.Username())}))
497
498 err = cmd.serviceBinder.BindApplication(app, serviceInstance, nil)
499
500 switch httpErr := err.(type) {
501 case errors.HTTPError:
502 if httpErr.ErrorCode() == errors.ServiceBindingAppServiceTaken {
503 err = nil
504 }
505 }
506
507 if err != nil {
508 return errors.New(T("Could not bind to service {{.OfferingName}}\nError: {{.Err}}",
509 map[string]interface{}{"OfferingName": serviceName, "Err": err.Error()}))
510 }
511
512 cmd.ui.Ok()
513 }
514 return nil
515}
516
517func (cmd *Push) fetchStackGUID(appParams *models.AppParams) error {
518 if appParams.StackName == nil {

Callers 1

ExecuteMethod · 0.95

Calls 11

NewFunction · 0.92
EntityNameColorFunction · 0.92
FindInstanceByNameMethod · 0.65
SayMethod · 0.65
OrganizationFieldsMethod · 0.65
SpaceFieldsMethod · 0.65
UsernameMethod · 0.65
BindApplicationMethod · 0.65
ErrorCodeMethod · 0.65
ErrorMethod · 0.65
OkMethod · 0.65

Tested by

no test coverage detected