forked from cloudfoundry/cli
/
space_quotas_command.go
47 lines (37 loc) · 1.16 KB
/
space_quotas_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
package v7
import (
"code.cloudfoundry.org/cli/command/v7/shared"
"code.cloudfoundry.org/cli/resources"
)
type SpaceQuotasCommand struct {
BaseCommand
usage interface{} `usage:"CF_NAME space-quotas"`
relatedCommands interface{} `related_commands:"space-quota, set-space-quota"`
}
func (cmd SpaceQuotasCommand) Execute(args []string) error {
err := cmd.SharedActor.CheckTarget(true, false)
if err != nil {
return err
}
user, err := cmd.Actor.GetCurrentUser()
if err != nil {
return err
}
cmd.UI.DisplayTextWithFlavor("Getting space quotas for org {{.OrgName}} as {{.Username}}...", map[string]interface{}{
"OrgName": cmd.Config.TargetedOrganizationName(),
"Username": user.Name,
})
cmd.UI.DisplayNewline()
orgQuotas, warnings, err := cmd.Actor.GetSpaceQuotasByOrgGUID(cmd.Config.TargetedOrganization().GUID)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
var quotas []resources.Quota
for _, orgQuota := range orgQuotas {
quotas = append(quotas, resources.Quota(orgQuota.Quota))
}
quotaDisplayer := shared.NewQuotaDisplayer(cmd.UI)
quotaDisplayer.DisplayQuotasTable(quotas, "No space quotas found.")
return nil
}