代码拉取完成,页面将自动刷新
package quota
import ()
type ListQuotas struct {
ui terminal.UI
config configuration.Reader
quotaRepo api.QuotaRepository
}
func NewListQuotas(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) (cmd *ListQuotas) {
cmd = new(ListQuotas)
cmd.ui = ui
cmd.config = config
cmd.quotaRepo = quotaRepo
return
}
func (command *ListQuotas) Metadata() command_metadata.CommandMetadata {
return command_metadata.CommandMetadata{
Name: "quotas",
Description: "List available usage quotas",
Usage: "CF_NAME quotas",
}
}
func (cmd *ListQuotas) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) {
reqs = []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return
}
func (cmd *ListQuotas) Run(c *cli.Context) {
cmd.ui.Say("Getting quotas as %s...", terminal.EntityNameColor(cmd.config.Username()))
quotas, apiErr := cmd.quotaRepo.FindAll()
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{"name", "memory limit", "routes", "service instances", "paid service plans"})
for _, quota := range quotas {
table.Add([]string{
quota.Name,
formatters.ByteSize(quota.MemoryLimit * formatters.MEGABYTE),
fmt.Sprintf("%d", quota.RoutesLimit),
fmt.Sprintf("%d", quota.ServicesLimit),
formatters.Allowed(quota.NonBasicServicesAllowed),
})
}
table.Print()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。