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

Method Execute

command/v7/create_space_quota_command.go:26–71  ·  view source on GitHub ↗
([]string)

Source from the content-addressed store, hash-verified

24}
25
26func (cmd CreateSpaceQuotaCommand) Execute([]string) error {
27 err := cmd.SharedActor.CheckTarget(true, false)
28 if err != nil {
29 return err
30 }
31
32 user, err := cmd.Actor.GetCurrentUser()
33 if err != nil {
34 return err
35 }
36
37 cmd.UI.DisplayTextWithFlavor("Creating space quota {{.SpaceQuota}} for org {{.CurrentOrg}} as {{.CurrentUser}}...", map[string]interface{}{
38 "SpaceQuota": cmd.RequiredArgs.SpaceQuota,
39 "CurrentOrg": cmd.Config.TargetedOrganization().Name,
40 "CurrentUser": user.Name,
41 })
42
43 warnings, err := cmd.Actor.CreateSpaceQuota(
44 cmd.RequiredArgs.SpaceQuota,
45 cmd.Config.TargetedOrganization().GUID,
46 v7action.QuotaLimits{
47 TotalMemoryInMB: convertMegabytesFlagToNullInt(cmd.TotalMemory),
48 PerProcessMemoryInMB: convertMegabytesFlagToNullInt(cmd.PerProcessMemory),
49 TotalInstances: convertIntegerLimitFlagToNullInt(cmd.NumAppInstances),
50 PaidServicesAllowed: &cmd.PaidServicePlans,
51 TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances),
52 TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes),
53 TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts),
54 TotalLogVolume: convertBytesFlagToNullInt(cmd.TotalLogVolume),
55 },
56 )
57
58 cmd.UI.DisplayWarnings(warnings)
59 if err != nil {
60 switch err.(type) {
61 case ccerror.QuotaAlreadyExists:
62 cmd.UI.DisplayWarning(err.Error())
63 default:
64 return err
65 }
66 }
67
68 cmd.UI.DisplayOK()
69
70 return nil
71}

Callers

nothing calls this directly

Calls 12

CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
TargetedOrganizationMethod · 0.65
CreateSpaceQuotaMethod · 0.65
DisplayWarningsMethod · 0.65
DisplayWarningMethod · 0.65
ErrorMethod · 0.65
DisplayOKMethod · 0.65

Tested by

no test coverage detected