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