当前位置: 首页>>代码示例>>Golang>>正文


Golang CliConnection.CliCommandWithoutTerminalOutput方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin.CliConnection.CliCommandWithoutTerminalOutput方法的典型用法代码示例。如果您正苦于以下问题:Golang CliConnection.CliCommandWithoutTerminalOutput方法的具体用法?Golang CliConnection.CliCommandWithoutTerminalOutput怎么用?Golang CliConnection.CliCommandWithoutTerminalOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/cli/plugin.CliConnection的用法示例。


在下文中一共展示了CliConnection.CliCommandWithoutTerminalOutput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Curl

func Curl(cli plugin.CliConnection, result interface{}, args ...string) error {
	output, err := cli.CliCommandWithoutTerminalOutput(append([]string{"curl"}, args...)...)
	if err != nil {
		return err
	}

	buf := []byte(strings.Join(output, "\n"))

	var errorResponse curlError
	err = json.Unmarshal(buf, &errorResponse)
	if err != nil {
		return err
	}

	if errorResponse.Code != 0 {
		return errors.New(errorResponse.Description)
	}

	if result != nil {
		err = json.Unmarshal(buf, result)
		if err != nil {
			return err
		}
	}

	return nil
}
开发者ID:sykesm,项目名称:diego-ssh,代码行数:27,代码来源:curl.go

示例2: Run

func (c *AppLister) Run(cliConnection plugin.CliConnection, args []string) {
	orgs, err := cliConnection.GetOrgs()
	if err != nil {
		fmt.Println("Error getting orgs:", err)
		os.Exit(1)
	}

	for _, org := range orgs {
		_, err := cliConnection.CliCommandWithoutTerminalOutput("t", "-o", org.Name)
		if err != nil {
			fmt.Println("Error targeting org: ", org.Name)
			os.Exit(1)
		}

		apps, err := cliConnection.GetApps()
		if err != nil {
			fmt.Println("Error getting applications from org: ", org.Name)
			os.Exit(1)
		}

		for _, app := range apps {
			fmt.Println(app.Name)
		}
	}
}
开发者ID:simonleung8,项目名称:cli-plugin-examples,代码行数:25,代码来源:main.go

示例3: getAppGuid

func getAppGuid(cliConnection plugin.CliConnection, appName string) string {
	repo := core_config.NewRepositoryFromFilepath(config_helpers.DefaultFilePath(), func(err error) {
		if err != nil {
			fmt.Println("\nERROR:", err)
			os.Exit(1)
		}
	})
	spaceGuid := repo.SpaceFields().Guid

	cmd := []string{"curl", fmt.Sprintf("/v2/spaces/%v/apps?q=name:%v&inline-relations-depth=1", spaceGuid, appName)}
	output, err := cliConnection.CliCommandWithoutTerminalOutput(cmd...)
	if err != nil {
		for _, e := range output {
			fmt.Println(e)
		}
		os.Exit(1)
	}

	search := &Search{}
	if err := json.Unmarshal([]byte(strings.Join(output, "")), &search); err != nil {
		fmt.Println("\nERROR:", err)
		os.Exit(1)
	}

	return search.Resources[0].Metadata.Guid
}
开发者ID:swisscom,项目名称:cf-statistics-plugin,代码行数:26,代码来源:plugin_hook.go

示例4: runServiceOpen

func (plugin OpenPlugin) runServiceOpen(cliConnection plugin.CliConnection, args []string) {
	output, err := cliConnection.CliCommandWithoutTerminalOutput("service", args[1], "--guid")
	if err != nil {
		fmt.Fprintln(os.Stdout, "error: service does not exist")
		os.Exit(1)
	}
	serviceInstanceGUID := strings.TrimSpace(output[0])

	output, err = cliConnection.CliCommandWithoutTerminalOutput("curl", fmt.Sprintf("/v2/service_instances/%s", serviceInstanceGUID))
	if err != nil {
		fmt.Fprintln(os.Stdout, "error: service does not exist")
		os.Exit(1)
	}
	jsonStr := ""
	for _, line := range output {
		jsonStr += line + "\n"
	}

	response := serviceInstanceResponse{}
	json.Unmarshal([]byte(jsonStr), &response)

	url := response.Entity.DashboardURL
	if url == "" {
		fmt.Println("No dashboard available")
	} else {
		open.Run(url)
	}
}
开发者ID:whitfiea,项目名称:cf-plugin-open,代码行数:28,代码来源:open.go

示例5: startedApps

func startedApps(cliConnection plugin.CliConnection, url string) ([]StartedApp, error) {
	appsJson, err := cliConnection.CliCommandWithoutTerminalOutput("curl", url)
	if nil != err {
		return nil, err
	}
	data := strings.Join(appsJson, "\n")
	var appsData map[string]interface{}
	json.Unmarshal([]byte(data), &appsData)

	apps := []StartedApp{}
	for _, app := range appsData["resources"].([]interface{}) {
		entity := app.(map[string]interface{})["entity"].(map[string]interface{})
		state := entity["state"].(string)
		if state == "STARTED" {
			metadata := app.(map[string]interface{})["metadata"].(map[string]interface{})
			result := StartedApp{
				Name:     entity["name"].(string),
				Guid:     metadata["guid"].(string),
				SpaceUrl: entity["space_url"].(string),
				State:    state,
			}
			apps = append(apps, result)
		}
	}

	if nil != appsData["next_url"] {
		next, _ := startedApps(cliConnection, appsData["next_url"].(string))
		apps = append(apps, next...)
	}

	return apps, err
}
开发者ID:davidehringer,项目名称:cf-ip-query-plugin,代码行数:32,代码来源:api.go

示例6: GetAllApps

func GetAllApps(cliConnection plugin.CliConnection) ([]AppModel, error) {
	response, err := cliConnection.CliCommandWithoutTerminalOutput("curl", "v2/apps")

	apps := AppsModel{}
	err = json.Unmarshal([]byte(response[0]), &apps)

	return apps.Resources, err
}
开发者ID:simonleung8,项目名称:cli-plugin-examples,代码行数:8,代码来源:apps_repository.go

示例7: Curl

// Curl calls cf curl  and return the resulting json. This method will panic if
// the api is depricated
func Curl(cli plugin.CliConnection, path string) (map[string]interface{}, error) {
	output, err := cli.CliCommandWithoutTerminalOutput("curl", path)

	if nil != err {
		return nil, err
	}

	return parseOutput(output)
}
开发者ID:krujos,项目名称:cfcurl,代码行数:11,代码来源:cfcurl.go

示例8: scaleUp

func (app *AppStatus) scaleUp(cliConnection plugin.CliConnection) {
	// If not already started, start it
	if app.state != "started" {
		cliConnection.CliCommandWithoutTerminalOutput("start", app.name)
		app.state = "started"
	}
	app.countRequested++
	cliConnection.CliCommandWithoutTerminalOutput("scale", "-i", strconv.Itoa(app.countRequested), app.name)
}
开发者ID:TomG713,项目名称:scaleover-plugin,代码行数:9,代码来源:scaleover_plugin.go

示例9: setServiceCreds

func setServiceCreds(conn plugin.CliConnection, name string, creds map[string]interface{}) error {
	marshaled, err := json.Marshal(creds)
	if err != nil {
		return err
	}

	_, err = conn.CliCommandWithoutTerminalOutput("uups", name, "-p", string(marshaled[:]))
	return err
}
开发者ID:jmcarp,项目名称:cf-mups,代码行数:9,代码来源:main.go

示例10: KillInstanceZero

func (plugin ConsolePlugin) KillInstanceZero(cliConnection plugin.CliConnection, appGuid string) {

	plugin.Log("Killing instance 0.\n", false)

	// Kill the first instance and wait for it to come back up
	appURL := fmt.Sprintf("/v2/apps/%v/instances/0", appGuid)
	cmd := []string{"curl", appURL, "-X", "DELETE"}

	cliConnection.CliCommandWithoutTerminalOutput(cmd...)
}
开发者ID:tianhonglouis,项目名称:cf-console,代码行数:10,代码来源:console.go

示例11: scaleDown

func (app *AppStatus) scaleDown(cliConnection plugin.CliConnection) {
	app.countRequested--
	// If going to zero, stop the app
	if app.countRequested == 0 {
		cliConnection.CliCommandWithoutTerminalOutput("stop", app.name)
		app.state = "stopped"
	} else {
		cliConnection.CliCommandWithoutTerminalOutput("scale", "-i", strconv.Itoa(app.countRequested), app.name)
	}
}
开发者ID:TomG713,项目名称:scaleover-plugin,代码行数:10,代码来源:scaleover_plugin.go

示例12: ChangeInstanceCount

func (plugin ConsolePlugin) ChangeInstanceCount(cliConnection plugin.CliConnection, appGuid string, instances int) {

	plugin.Log(fmt.Sprintf("Changing instance count to %v.\n", instances), false)

	appURL := fmt.Sprintf("/v2/apps/%v", appGuid)
	newCommand := fmt.Sprintf("{\"instances\":%v}", instances)
	cmd := []string{"curl", appURL, "-X", "PUT", "-d", newCommand}

	cliConnection.CliCommandWithoutTerminalOutput(cmd...)
}
开发者ID:tianhonglouis,项目名称:cf-console,代码行数:10,代码来源:console.go

示例13: organizationName

func organizationName(cliConnection plugin.CliConnection, org_url string) (string, error) {
	output, error := cliConnection.CliCommandWithoutTerminalOutput("curl", org_url)
	if error != nil {
		return "", error
	}
	data := strings.Join(output, "\n")
	var org map[string]interface{}
	json.Unmarshal([]byte(data), &org)
	entity := org["entity"].(map[string]interface{})
	return entity["name"].(string), error
}
开发者ID:davidehringer,项目名称:cf-ip-query-plugin,代码行数:11,代码来源:api.go

示例14: RetrieveAppNameEnv

func (c *CopyEnv) RetrieveAppNameEnv(cliConnection plugin.CliConnection, app_name string) ([]string, error) {
	output, err := cliConnection.CliCommandWithoutTerminalOutput("env", app_name)

	if err != nil {
		for _, val := range output {
			fmt.Println(val)
		}
	}

	return output, err
}
开发者ID:Samze,项目名称:copyenv,代码行数:11,代码来源:copyenv.go

示例15: GetAppsInOneOrg

func GetAppsInOneOrg(cliConnection plugin.CliConnection, orgName string) ([]plugin_models.GetAppsModel, error) {
	_, err := cliConnection.CliCommandWithoutTerminalOutput("target", "-o", orgName)
	if err != nil {
		return []plugin_models.GetAppsModel{}, errors.New("Failed to target org '" + orgName + "'")
	}

	apps, err := cliConnection.GetApps()
	if err != nil {
		return []plugin_models.GetAppsModel{}, errors.New("Failed to get apps in organization '" + orgName + "'")
	}

	return apps, nil
}
开发者ID:simonleung8,项目名称:cli-plugin-examples,代码行数:13,代码来源:list-apps.go


注:本文中的github.com/cloudfoundry/cli/plugin.CliConnection.CliCommandWithoutTerminalOutput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。