(args []string)
| 26 | } |
| 27 | |
| 28 | func (cmd UpdateSpaceQuotaCommand) Execute(args []string) error { |
| 29 | if cmd.PaidServicePlans && cmd.NoPaidServicePlans { |
| 30 | return translatableerror.ArgumentCombinationError{ |
| 31 | Args: []string{"--allow-paid-service-plans", "--disallow-paid-service-plans"}, |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | err := cmd.SharedActor.CheckTarget(true, false) |
| 36 | if err != nil { |
| 37 | return err |
| 38 | } |
| 39 | |
| 40 | user, err := cmd.Actor.GetCurrentUser() |
| 41 | if err != nil { |
| 42 | return err |
| 43 | } |
| 44 | |
| 45 | oldQuotaName := cmd.RequiredArgs.SpaceQuota |
| 46 | orgGUID := cmd.Config.TargetedOrganization().GUID |
| 47 | |
| 48 | cmd.UI.DisplayTextWithFlavor("Updating space quota {{.QuotaName}} for org {{.OrgName}} as {{.User}}...", |
| 49 | map[string]interface{}{ |
| 50 | "QuotaName": oldQuotaName, |
| 51 | "OrgName": cmd.Config.TargetedOrganizationName(), |
| 52 | "User": user.Name, |
| 53 | }) |
| 54 | |
| 55 | var paidServicesAllowed *bool |
| 56 | if cmd.PaidServicePlans || cmd.NoPaidServicePlans { |
| 57 | paidServicesAllowed = &cmd.PaidServicePlans |
| 58 | } |
| 59 | |
| 60 | updatedQuotaLimits := v7action.QuotaLimits{ |
| 61 | TotalMemoryInMB: convertMegabytesFlagToNullInt(cmd.TotalMemory), |
| 62 | PerProcessMemoryInMB: convertMegabytesFlagToNullInt(cmd.PerProcessMemory), |
| 63 | TotalInstances: convertIntegerLimitFlagToNullInt(cmd.NumAppInstances), |
| 64 | PaidServicesAllowed: paidServicesAllowed, |
| 65 | TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances), |
| 66 | TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes), |
| 67 | TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts), |
| 68 | TotalLogVolume: convertBytesFlagToNullInt(cmd.TotalLogVolume), |
| 69 | } |
| 70 | |
| 71 | warnings, err := cmd.Actor.UpdateSpaceQuota(oldQuotaName, orgGUID, cmd.NewName, updatedQuotaLimits) |
| 72 | cmd.UI.DisplayWarnings(warnings) |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | |
| 77 | cmd.UI.DisplayOK() |
| 78 | |
| 79 | return nil |
| 80 | } |
nothing calls this directly
no test coverage detected