(args []string)
| 25 | } |
| 26 | |
| 27 | func (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 | |
| 72 | func convertBytesFlagToNullInt(flag flag.BytesWithUnlimited) *types.NullInt { |
| 73 | if !flag.IsSet { |
nothing calls this directly
no test coverage detected