本文整理匯總了Golang中cf/models.AppParams.DiskQuota方法的典型用法代碼示例。如果您正苦於以下問題:Golang AppParams.DiskQuota方法的具體用法?Golang AppParams.DiskQuota怎麽用?Golang AppParams.DiskQuota使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf/models.AppParams
的用法示例。
在下文中一共展示了AppParams.DiskQuota方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (cmd *Scale) Run(c *cli.Context) {
currentApp := cmd.appReq.GetApplication()
if !anyFlagsSet(c) {
cmd.ui.Say("Showing current scale of app %s in org %s / space %s as %s...",
terminal.EntityNameColor(currentApp.Name),
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
cmd.ui.Ok()
cmd.ui.Say("")
cmd.ui.Say("%s %s", terminal.HeaderColor("memory:"), formatters.ByteSize(currentApp.Memory*bytesInAMegabyte))
cmd.ui.Say("%s %s", terminal.HeaderColor("disk:"), formatters.ByteSize(currentApp.DiskQuota*bytesInAMegabyte))
cmd.ui.Say("%s %d", terminal.HeaderColor("instances:"), currentApp.InstanceCount)
return
}
params := models.AppParams{}
shouldRestart := false
if c.String("m") != "" {
memory, err := formatters.ToMegabytes(c.String("m"))
if err != nil {
cmd.ui.Failed("Invalid memory limit: %s\n%s", c.String("m"), err)
}
params.Memory = &memory
shouldRestart = true
}
if c.String("k") != "" {
diskQuota, err := formatters.ToMegabytes(c.String("k"))
if err != nil {
cmd.ui.Failed("Invalid disk quota: %s\n%s", c.String("k"), err)
}
params.DiskQuota = &diskQuota
shouldRestart = true
}
if c.IsSet("i") {
instances := c.Int("i")
if instances > 0 {
params.InstanceCount = &instances
} else {
cmd.ui.Failed("Invalid instance count: %d\nInstance count must be a positive integer", instances)
}
}
if shouldRestart && !cmd.confirmRestart(c, currentApp.Name) {
return
}
cmd.ui.Say("Scaling app %s in org %s / space %s as %s...",
terminal.EntityNameColor(currentApp.Name),
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
updatedApp, apiErr := cmd.appRepo.Update(currentApp.Guid, params)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
if shouldRestart {
cmd.restarter.ApplicationRestart(updatedApp)
}
}