本文整理匯總了Golang中cf/models.AppParams類的典型用法代碼示例。如果您正苦於以下問題:Golang AppParams類的具體用法?Golang AppParams怎麽用?Golang AppParams使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AppParams類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: addApp
func addApp(apps *[]models.AppParams, app models.AppParams) (err error) {
if app.Name == nil {
err = errors.New("App name is a required field")
}
if app.Path == nil {
cwd, _ := os.Getwd()
app.Path = &cwd
}
*apps = append(*apps, app)
return
}
示例2: Run
func (cmd *Scale) Run(c *cli.Context) {
currentApp := cmd.appReq.GetApplication()
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()),
)
params := models.AppParams{}
shouldRestart := false
if c.String("m") != "" {
memory, err := formatters.ToMegabytes(c.String("m"))
if err != nil {
cmd.ui.Say("Invalid value for memory")
cmd.ui.FailWithUsage(c, "scale")
return
}
params.Memory = &memory
shouldRestart = true
}
instances := c.Int("i")
if instances != -1 {
params.InstanceCount = &instances
}
updatedApp, apiResponse := cmd.appRepo.Update(currentApp.Guid, params)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
cmd.ui.Say("")
if shouldRestart {
cmd.restarter.ApplicationRestart(updatedApp)
}
}
示例3: createAppSetFromContextAndManifest
func (cmd *Push) createAppSetFromContextAndManifest(contextApp models.AppParams, manifestApps []models.AppParams) (apps []models.AppParams) {
var err error
switch len(manifestApps) {
case 0:
err = addApp(&apps, contextApp)
case 1:
manifestApps[0].Merge(&contextApp)
err = addApp(&apps, manifestApps[0])
default:
selectedAppName := contextApp.Name
contextApp.Name = nil
if !contextApp.IsEmpty() {
cmd.ui.Failed("%s", "Incorrect Usage. Command line flags (except -f) cannot be applied when pushing multiple apps from a manifest file.")
}
if selectedAppName != nil {
var manifestApp models.AppParams
manifestApp, err = findAppWithNameInManifest(*selectedAppName, manifestApps)
if err == nil {
addApp(&apps, manifestApp)
}
} else {
for _, manifestApp := range manifestApps {
addApp(&apps, manifestApp)
}
}
}
if err != nil {
cmd.ui.Failed("Error: %s", err)
}
return
}
示例4: fetchStackGuid
func (cmd *Push) fetchStackGuid(appParams *models.AppParams) {
if appParams.StackName == nil {
return
}
stackName := *appParams.StackName
cmd.ui.Say("Using stack %s...", terminal.EntityNameColor(stackName))
stack, apiErr := cmd.stackRepo.FindByName(stackName)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
appParams.StackGuid = &stack.Guid
}
示例5: fetchStackGuid
func (cmd *Push) fetchStackGuid(appParams *models.AppParams) {
if appParams.StackName == nil {
return
}
stackName := *appParams.StackName
cmd.ui.Say("Using stack %s...", terminal.EntityNameColor(stackName))
stack, apiResponse := cmd.stackRepo.FindByName(stackName)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
appParams.StackGuid = &stack.Guid
}
示例6: createApp
func (cmd *Push) createApp(appParams models.AppParams) (app models.Application, apiErr error) {
spaceGuid := cmd.config.SpaceFields().Guid
appParams.SpaceGuid = &spaceGuid
cmd.ui.Say("Creating app %s in org %s / space %s as %s...",
terminal.EntityNameColor(*appParams.Name),
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
app, apiErr = cmd.appRepo.Create(appParams)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
return
}
示例7: createApp
func (cmd *Push) createApp(appParams models.AppParams) (app models.Application, apiResponse net.ApiResponse) {
spaceGuid := cmd.config.SpaceFields().Guid
appParams.SpaceGuid = &spaceGuid
cmd.ui.Say("Creating app %s in org %s / space %s as %s...",
terminal.EntityNameColor(*appParams.Name),
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
app, apiResponse = cmd.appRepo.Create(appParams)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
cmd.ui.Say("")
return
}
示例8: 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)
}
}