github.com/loafoe/cli@v7.1.0+incompatible/command/v7/update_org_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 UpdateOrgQuotaCommand struct { 10 BaseCommand 11 12 RequiredArgs flag.OrganizationQuota `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-org-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:"org, org-quota"` 24 } 25 26 func (cmd UpdateOrgQuotaCommand) 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(false, 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.OrganizationQuotaName 44 45 cmd.UI.DisplayTextWithFlavor("Updating org quota {{.OrganizationQuotaName}} as {{.User}}...", 46 map[string]interface{}{ 47 "OrganizationQuotaName": oldQuotaName, 48 "User": user.Name, 49 }) 50 51 var paidServicesAllowed *bool 52 if cmd.PaidServicePlans || cmd.NoPaidServicePlans { 53 paidServicesAllowed = &cmd.PaidServicePlans 54 } 55 56 updatedQuotaLimits := v7action.QuotaLimits{ 57 TotalMemoryInMB: convertMegabytesFlagToNullInt(cmd.TotalMemory), 58 PerProcessMemoryInMB: convertMegabytesFlagToNullInt(cmd.PerProcessMemory), 59 TotalInstances: convertIntegerLimitFlagToNullInt(cmd.NumAppInstances), 60 PaidServicesAllowed: paidServicesAllowed, 61 TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances), 62 TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes), 63 TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts), 64 } 65 66 warnings, err := cmd.Actor.UpdateOrganizationQuota(oldQuotaName, cmd.NewName, updatedQuotaLimits) 67 cmd.UI.DisplayWarnings(warnings) 68 if err != nil { 69 return err 70 } 71 72 cmd.UI.DisplayOK() 73 74 return nil 75 }