本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin.CliConnection.GetCurrentOrg方法的典型用法代码示例。如果您正苦于以下问题:Golang CliConnection.GetCurrentOrg方法的具体用法?Golang CliConnection.GetCurrentOrg怎么用?Golang CliConnection.GetCurrentOrg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/plugin.CliConnection
的用法示例。
在下文中一共展示了CliConnection.GetCurrentOrg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: introduction
func introduction(cliConnection plugin.CliConnection, args string) {
currOrg, _ := cliConnection.GetCurrentOrg()
currSpace, _ := cliConnection.GetCurrentSpace()
currUsername, _ := cliConnection.Username()
fmt.Println("Getting apps matching", table.EntityNameColor(args), "in org", table.EntityNameColor(currOrg.Name), "/ space", table.EntityNameColor(currSpace.Name), "as", table.EntityNameColor(currUsername))
fmt.Println(table.SuccessColor("OK"))
fmt.Println("")
}
示例2: 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()
}
}
示例3: CreateContextRoute
func CreateContextRoute(cliConnection plugin.CliConnection, args []string) {
space := args[1]
domain := args[2]
host := args[3]
path := args[4]
myOrg, _ := cliConnection.GetCurrentOrg()
output, err := cliConnection.CliCommandWithoutTerminalOutput("curl", fmt.Sprintf("v2/spaces?q=name:%s&q=organization_guid:%s", space, myOrg.Guid))
FreakOut(err)
spaces := SpacesModel{}
err = json.Unmarshal([]byte(output[0]), &spaces)
FreakOut(err)
if len(spaces.Resources) == 0 {
fmt.Printf("Space %s not found", space)
return
}
spaceGuid := spaces.Resources[0].Metadata.Guid
output, err = cliConnection.CliCommandWithoutTerminalOutput("curl", fmt.Sprintf("v2/domains?q=name:%s", domain))
FreakOut(err)
domains := DomainsModel{}
err = json.Unmarshal([]byte(output[0]), &domains)
FreakOut(err)
if len(domains.Resources) == 0 {
fmt.Printf("Domain %s not found", domain)
return
}
domainGuid := domains.Resources[0].Metadata.Guid
output, err = cliConnection.CliCommandWithoutTerminalOutput("curl", "v2/routes", "-X", "POST", "-d",
fmt.Sprintf(`{"host":"%s","domain_guid":"%s","space_guid":"%s","path":"%s"}`, host, domainGuid, spaceGuid, path))
FreakOut(err)
route := RouteModel{}
err = json.Unmarshal([]byte(output[0]), &route)
FreakOut(err)
routeGuid := route.Metadata.Guid
if routeGuid == "" {
error := ErrorModel{}
err = json.Unmarshal([]byte(output[0]), &error)
FreakOut(err)
fmt.Printf("Failed to create route: %s", error.Description)
return
}
fmt.Printf("Route successfully created.")
}