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

Method Execute

command/v7/create_app_command.go:25–86  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

23}
24
25func (cmd CreateAppCommand) Execute(args []string) error {
26 err := cmd.SharedActor.CheckTarget(true, true)
27 if err != nil {
28 return err
29 }
30
31 user, err := cmd.Actor.GetCurrentUser()
32 if err != nil {
33 return err
34 }
35
36 cmd.UI.DisplayTextWithFlavor("Creating app {{.AppName}} in org {{.CurrentOrg}} / space {{.CurrentSpace}} as {{.CurrentUser}}...", map[string]interface{}{
37 "AppName": cmd.RequiredArgs.AppName,
38 "CurrentSpace": cmd.Config.TargetedSpace().Name,
39 "CurrentOrg": cmd.Config.TargetedOrganization().Name,
40 "CurrentUser": user.Name,
41 })
42
43 cmd.UI.DisplayText(fmt.Sprintf("Using app type %q", constant.AppLifecycleType(cmd.AppType)))
44
45 app := resources.Application{
46 Name: cmd.RequiredArgs.AppName,
47 LifecycleType: constant.AppLifecycleType(cmd.AppType),
48 LifecycleBuildpacks: cmd.Buildpacks,
49 }
50
51 if constant.AppLifecycleType(cmd.AppType) == constant.AppLifecycleTypeCNB {
52 err := command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCNB)
53 if err != nil {
54 return err
55 }
56
57 if len(cmd.Buildpacks) == 0 {
58 return errors.New("buildpack(s) must be provided when using --app-type cnb")
59 }
60
61 creds, err := cmd.Config.CNBCredentials()
62 if err != nil {
63 return err
64 }
65
66 app.Credentials = creds
67 }
68
69 _, warnings, err := cmd.Actor.CreateApplicationInSpace(
70 app,
71 cmd.Config.TargetedSpace().GUID,
72 )
73 cmd.UI.DisplayWarnings(warnings)
74 if err != nil {
75 switch err.(type) {
76 case ccerror.NameNotUniqueInSpaceError:
77 cmd.UI.DisplayText(err.Error())
78 default:
79 return err
80 }
81 }
82

Callers

nothing calls this directly

Calls 14

AppLifecycleTypeTypeAlias · 0.92
MinimumCCAPIVersionCheckFunction · 0.92
CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
TargetedSpaceMethod · 0.65
TargetedOrganizationMethod · 0.65
DisplayTextMethod · 0.65
APIVersionMethod · 0.65
CNBCredentialsMethod · 0.65
DisplayWarningsMethod · 0.65

Tested by

no test coverage detected