github.com/sleungcy-sap/cli@v7.1.0+incompatible/command/v7/set_space_quota_command.go (about) 1 package v7 2 3 import ( 4 "code.cloudfoundry.org/cli/command/flag" 5 ) 6 7 type SetSpaceQuotaCommand struct { 8 BaseCommand 9 10 RequiredArgs flag.SetSpaceQuotaArgs `positional-args:"yes"` 11 usage interface{} `usage:"CF_NAME set-space-quota SPACE QUOTA"` 12 relatedCommands interface{} `related_commands:"space, spaces, space-quotas"` 13 } 14 15 func (cmd *SetSpaceQuotaCommand) Execute(args []string) error { 16 err := cmd.SharedActor.CheckTarget(true, false) 17 if err != nil { 18 return err 19 } 20 21 currentUser, err := cmd.Config.CurrentUserName() 22 if err != nil { 23 return err 24 } 25 26 cmd.UI.DisplayTextWithFlavor("Setting space quota {{.QuotaName}} to space {{.SpaceName}} as {{.UserName}}...", map[string]interface{}{ 27 "QuotaName": cmd.RequiredArgs.SpaceQuota, 28 "SpaceName": cmd.RequiredArgs.Space, 29 "UserName": currentUser, 30 }) 31 32 org := cmd.Config.TargetedOrganization() 33 space, warnings, err := cmd.Actor.GetSpaceByNameAndOrganization(cmd.RequiredArgs.Space, org.GUID) 34 cmd.UI.DisplayWarnings(warnings) 35 if err != nil { 36 return err 37 } 38 39 warnings, err = cmd.Actor.ApplySpaceQuotaByName(cmd.RequiredArgs.SpaceQuota, space.GUID, org.GUID) 40 cmd.UI.DisplayWarnings(warnings) 41 if err != nil { 42 return err 43 } 44 45 cmd.UI.DisplayOK() 46 47 return nil 48 }