本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin.CliConnection.GetApp方法的典型用法代码示例。如果您正苦于以下问题:Golang CliConnection.GetApp方法的具体用法?Golang CliConnection.GetApp怎么用?Golang CliConnection.GetApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/plugin.CliConnection
的用法示例。
在下文中一共展示了CliConnection.GetApp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func (c *NozzlerCmd) Run(cliConnection plugin.CliConnection, args []string) {
var options *firehose.ClientOptions
traceLogger := trace.NewLogger(os.Stdout, true, os.Getenv("CF_TRACE"), "")
c.ui = terminal.NewUI(os.Stdin, os.Stdout, terminal.NewTeePrinter(os.Stdout), traceLogger)
switch args[0] {
case "nozzle":
options = c.buildClientOptions(args)
case "app-nozzle":
options = c.buildClientOptions(args)
appModel, err := cliConnection.GetApp(args[1])
if err != nil {
c.ui.Warn(err.Error())
return
}
options.AppGUID = appModel.Guid
default:
return
}
dopplerEndpoint, err := cliConnection.DopplerEndpoint()
if err != nil {
c.ui.Failed(err.Error())
}
authToken, err := cliConnection.AccessToken()
if err != nil {
c.ui.Failed(err.Error())
}
client := firehose.NewClient(authToken, dopplerEndpoint, options, c.ui)
client.Start()
}
示例2: CheckUpApps
// CheckUpApps performs checkup on applications and adds the result to triage map
func (c *DoctorPlugin) CheckUpApps(cliConnection plugin.CliConnection, triage []string, listOfRunningApps []plugin_models.GetAppsModel, listOfStoppedApps []plugin_models.GetAppsModel) []string {
const alarmCPU float64 = 85.0
for _, i := range listOfRunningApps {
app, err := cliConnection.GetApp(i.Name)
if err != nil {
c.ui.Failed(err.Error())
}
if len(app.StagingFailedReason) > 0 {
triage = append(triage, i.Name+" ___ StagingFailedReason: "+app.StagingFailedReason)
}
insts := app.Instances
for _, ins := range insts {
if ins.CpuUsage > alarmCPU {
triage = append(triage, i.Name+" ___ CPU usage over %85 percent!")
}
if float64(ins.DiskUsage) > float64(ins.DiskQuota)*0.80 {
triage = append(triage, i.Name+" ___ DiskUsage over %80 percent of DiskQuota")
}
if float64(ins.MemUsage) > float64(ins.MemQuota)*0.80 {
triage = append(triage, i.Name+" ___ MemUsage over %80 percent of MemQuota")
}
if float64(ins.MemUsage) < float64(ins.MemQuota)*0.15 {
triage = append(triage, i.Name+" ___ MemUsage lower than %15 percent of MemQuota, scaledown is an option.")
}
if len(insts) > 1 && float64(ins.MemUsage) < float64(ins.MemQuota)*0.15 && ins.CpuUsage < 10.0 {
triage = append(triage, i.Name+" ___ app has more than one instance running with very low resource consumption. candidate for scaling down.")
}
}
routes := app.Routes
if len(routes) == 0 {
triage = append(triage, i.Name+" ___ You have a running application that does not have a route!")
}
}
for _, y := range listOfStoppedApps {
app, err := cliConnection.GetApp(y.Name)
if err != nil {
c.ui.Failed(err.Error())
}
if len(app.StagingFailedReason) > 0 {
triage = append(triage, y.Name+" ___ StagingFailedReason: "+app.StagingFailedReason)
}
}
return triage
}
示例3: Run
func (c *Test1) Run(cliConnection plugin.CliConnection, args []string) {
if args[0] == "new-api" {
token, _ := cliConnection.AccessToken()
fmt.Println("Access Token:", token)
fmt.Println("")
app, err := cliConnection.GetApp("test_app")
fmt.Println("err for test_app", err)
fmt.Println("test_app is: ", app)
hasOrg, _ := cliConnection.HasOrganization()
fmt.Println("Has Organization Targeted:", hasOrg)
currentOrg, _ := cliConnection.GetCurrentOrg()
fmt.Println("Current Org:", currentOrg)
org, _ := cliConnection.GetOrg(currentOrg.Name)
fmt.Println(currentOrg.Name, " Org:", org)
orgs, _ := cliConnection.GetOrgs()
fmt.Println("Orgs:", orgs)
hasSpace, _ := cliConnection.HasSpace()
fmt.Println("Has Space Targeted:", hasSpace)
currentSpace, _ := cliConnection.GetCurrentSpace()
fmt.Println("Current space:", currentSpace)
space, _ := cliConnection.GetSpace(currentSpace.Name)
fmt.Println("Space:", space)
spaces, _ := cliConnection.GetSpaces()
fmt.Println("Spaces:", spaces)
loggregator, _ := cliConnection.LoggregatorEndpoint()
fmt.Println("Loggregator Endpoint:", loggregator)
dopplerEndpoint, _ := cliConnection.DopplerEndpoint()
fmt.Println("Doppler Endpoint:", dopplerEndpoint)
user, _ := cliConnection.Username()
fmt.Println("Current user:", user)
userGUID, _ := cliConnection.UserGuid()
fmt.Println("Current user guid:", userGUID)
email, _ := cliConnection.UserEmail()
fmt.Println("Current user email:", email)
hasAPI, _ := cliConnection.HasAPIEndpoint()
fmt.Println("Has API Endpoint:", hasAPI)
api, _ := cliConnection.ApiEndpoint()
fmt.Println("Current api:", api)
version, _ := cliConnection.ApiVersion()
fmt.Println("Current api version:", version)
loggedIn, _ := cliConnection.IsLoggedIn()
fmt.Println("Is Logged In:", loggedIn)
isSSLDisabled, _ := cliConnection.IsSSLDisabled()
fmt.Println("Is SSL Disabled:", isSSLDisabled)
} else if args[0] == "test_1_cmd1" {
theFirstCmd()
} else if args[0] == "test_1_cmd2" {
theSecondCmd()
} else if args[0] == "CLI-MESSAGE-UNINSTALL" {
uninstalling()
}
}
示例4: Run
func (cmd *LogalyzerCmd) Run(cliConnection plugin.CliConnection, args []string) {
port := 8080
aggregationWindow := 2 * time.Second
bufferSize := 100
cmd.ui = terminal.NewUI(os.Stdin, terminal.NewTeePrinter())
cmd.sendChan = make(chan []byte, 256)
if len(args) < 2 {
cmd.ui.Say("Usage: %s\n", cmd.Usage())
cmd.ui.Failed("No App Name given")
}
fc := flags.NewFlagContext(setupFlags())
err := fc.Parse(args[2:]...)
if err != nil {
cmd.ui.Failed(err.Error())
}
if fc.IsSet("p") {
port = fc.Int("p")
}
if fc.IsSet("agg-window") {
aggregationWindow = time.Duration(fc.Int("agg-window")) * time.Second
}
if fc.IsSet("buffer-size") {
bufferSize = fc.Int("buffer-size")
}
appName := args[1]
dopplerEndpoint, err := cliConnection.DopplerEndpoint()
if err != nil {
cmd.ui.Failed(err.Error())
}
appModel, err := cliConnection.GetApp(appName)
if err != nil {
cmd.ui.Failed(err.Error())
}
authToken, err := cliConnection.AccessToken()
if err != nil {
cmd.ui.Failed(err.Error())
}
outputChan := make(chan *events.LogMessage)
errorChan := make(chan error)
dopplerConnection := noaa.NewConsumer(dopplerEndpoint, &tls.Config{InsecureSkipVerify: true}, nil)
go dopplerConnection.TailingLogs(appModel.Guid, authToken, outputChan, errorChan)
go cmd.happyCalcer(aggregationWindow, bufferSize)
go cmd.startServer(cmd.getAssetsDir(), port)
cmd.ui.Say("Webserver is started at http://localhost:%d", port)
for {
select {
case log := <-outputChan:
if log.GetMessageType() == events.LogMessage_ERR {
cmd.errCount++
}
cmd.logCount++
cmd.sendChan <- log.GetMessage()
case err := <-errorChan:
cmd.ui.Failed(err.Error())
}
}
}