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

Method Execute

command/v7/create_org_quota_command.go:27–70  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

25}
26
27func (cmd CreateOrgQuotaCommand) Execute(args []string) error {
28 err := cmd.SharedActor.CheckTarget(false, false)
29 if err != nil {
30 return err
31 }
32
33 user, err := cmd.Actor.GetCurrentUser()
34 if err != nil {
35 return err
36 }
37
38 orgQuotaName := cmd.RequiredArgs.OrganizationQuotaName
39
40 cmd.UI.DisplayTextWithFlavor("Creating org quota {{.OrganizationQuotaName}} as {{.User}}...",
41 map[string]interface{}{
42 "User": user.Name,
43 "OrganizationQuotaName": orgQuotaName,
44 })
45
46 warnings, err := cmd.Actor.CreateOrganizationQuota(orgQuotaName, 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 cmd.UI.DisplayWarnings(warnings)
57
58 if _, ok := err.(ccerror.QuotaAlreadyExists); ok {
59 cmd.UI.DisplayWarning(err.Error())
60 cmd.UI.DisplayOK()
61 return nil
62 }
63
64 if err != nil {
65 return err
66 }
67 cmd.UI.DisplayOK()
68
69 return nil
70}
71
72func convertBytesFlagToNullInt(flag flag.BytesWithUnlimited) *types.NullInt {
73 if !flag.IsSet {

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected