code.cloudfoundry.org/cli@v7.1.0+incompatible/command/v7/update_space_quota_command.go (about) 1 package v7 2 3 import ( 4 "code.cloudfoundry.org/cli/actor/v7action" 5 "code.cloudfoundry.org/cli/command/flag" 6 "code.cloudfoundry.org/cli/command/translatableerror" 7 ) 8 9 type UpdateSpaceQuotaCommand struct { 10 BaseCommand 11 12 RequiredArgs flag.SpaceQuota `positional-args:"Yes"` 13 NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. -1 represents an unlimited amount."` 14 PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans."` 15 NoPaidServicePlans bool `long:"disallow-paid-service-plans" description:"Disallow provisioning instances of paid service plans."` 16 PerProcessMemory flag.MemoryWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` 17 TotalMemory flag.MemoryWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` 18 NewName string `short:"n" description:"New name"` 19 TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount."` 20 TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount."` 21 TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount."` 22 usage interface{} `usage:"CF_NAME update-space-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS]"` 23 relatedCommands interface{} `related_commands:"space, space-quota, space-quotas"` 24 } 25 26 func (cmd UpdateSpaceQuotaCommand) Execute(args []string) error { 27 if cmd.PaidServicePlans && cmd.NoPaidServicePlans { 28 return translatableerror.ArgumentCombinationError{ 29 Args: []string{"--allow-paid-service-plans", "--disallow-paid-service-plans"}, 30 } 31 } 32 33 err := cmd.SharedActor.CheckTarget(true, false) 34 if err != nil { 35 return err 36 } 37 38 user, err := cmd.Config.CurrentUser() 39 if err != nil { 40 return err 41 } 42 43 oldQuotaName := cmd.RequiredArgs.SpaceQuota 44 orgGUID := cmd.Config.TargetedOrganization().GUID 45 46 cmd.UI.DisplayTextWithFlavor("Updating space quota {{.QuotaName}} for org {{.OrgName}} as {{.User}}...", 47 map[string]interface{}{ 48 "QuotaName": oldQuotaName, 49 "OrgName": cmd.Config.TargetedOrganizationName(), 50 "User": user.Name, 51 }) 52 53 var paidServicesAllowed *bool 54 if cmd.PaidServicePlans || cmd.NoPaidServicePlans { 55 paidServicesAllowed = &cmd.PaidServicePlans 56 } 57 58 updatedQuotaLimits := v7action.QuotaLimits{ 59 TotalMemoryInMB: convertMegabytesFlagToNullInt(cmd.TotalMemory), 60 PerProcessMemoryInMB: convertMegabytesFlagToNullInt(cmd.PerProcessMemory), 61 TotalInstances: convertIntegerLimitFlagToNullInt(cmd.NumAppInstances), 62 PaidServicesAllowed: paidServicesAllowed, 63 TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances), 64 TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes), 65 TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts), 66 } 67 68 warnings, err := cmd.Actor.UpdateSpaceQuota(oldQuotaName, orgGUID, cmd.NewName, updatedQuotaLimits) 69 cmd.UI.DisplayWarnings(warnings) 70 if err != nil { 71 return err 72 } 73 74 cmd.UI.DisplayOK() 75 76 return nil 77 }