當前位置: 首頁>>代碼示例>>Golang>>正文


Golang App.Envs方法代碼示例

本文整理匯總了Golang中github.com/tsuru/tsuru/provision.App.Envs方法的典型用法代碼示例。如果您正苦於以下問題:Golang App.Envs方法的具體用法?Golang App.Envs怎麽用?Golang App.Envs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/tsuru/tsuru/provision.App的用法示例。


在下文中一共展示了App.Envs方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: runWithAgentCmds

// runWithAgentCmds returns the list of commands that should be passed when the
// provisioner will run a unit using tsuru_unit_agent to start.
//
// This will only be called for legacy containers that have not been re-
// deployed since the introduction of independent units per 'process' in
// 0.12.0.
func runWithAgentCmds(app provision.App) ([]string, error) {
	runCmd, err := config.GetString("docker:run-cmd:bin")
	if err != nil {
		return nil, err
	}
	host, _ := config.GetString("host")
	token := app.Envs()["TSURU_APP_TOKEN"].Value
	return []string{"tsuru_unit_agent", host, token, app.GetName(), runCmd}, nil
}
開發者ID:pedrosnk,項目名稱:tsuru,代碼行數:15,代碼來源:commands.go

示例2: extraRegisterCmds

func extraRegisterCmds(app provision.App) string {
	host, _ := config.GetString("host")
	if !strings.HasPrefix(host, "http") {
		host = "http://" + host
	}
	if !strings.HasSuffix(host, "/") {
		host += "/"
	}
	token := app.Envs()["TSURU_APP_TOKEN"].Value
	return fmt.Sprintf(`curl -fsSL -m15 -XPOST -d"hostname=$(hostname)" -o/dev/null -H"Content-Type:application/x-www-form-urlencoded" -H"Authorization:bearer %s" %sapps/%s/units/register`, token, host, app.GetName())
}
開發者ID:tsuru,項目名稱:tsuru,代碼行數:11,代碼來源:docker.go

示例3: deployCmds

func deployCmds(app provision.App, params ...string) ([]string, error) {
	deployCmd, err := config.GetString("docker:deploy-cmd")
	if err != nil {
		return nil, err
	}
	cmds := append([]string{deployCmd}, params...)
	host, _ := config.GetString("host")
	token := app.Envs()["TSURU_APP_TOKEN"].Value
	unitAgentCmds := []string{"tsuru_unit_agent", host, token, app.GetName(), `"` + strings.Join(cmds, " ") + `"`, "deploy"}
	finalCmd := strings.Join(unitAgentCmds, " ")
	return []string{"/bin/bash", "-lc", finalCmd}, nil
}
開發者ID:pedrosnk,項目名稱:tsuru,代碼行數:12,代碼來源:commands.go

示例4: deployCmds

func deployCmds(app provision.App, params ...string) ([]string, error) {
	deployCmd, err := config.GetString("docker:deploy-cmd")
	if err != nil {
		return nil, err
	}
	var envs string
	for _, env := range app.Envs() {
		envs += fmt.Sprintf(`%s=%s `, env.Name, strings.Replace(env.Value, " ", "", -1))
	}
	cmds := append([]string{deployCmd}, params...)
	return append(cmds, envs), nil
}
開發者ID:tomzhang,項目名稱:golang-devops-stuff,代碼行數:12,代碼來源:commands.go

示例5: deployCmds

// deployCmds returns the commands that is used when provisioner
// deploy an unit.
func deployCmds(app provision.App, version string) ([]string, error) {
	deployCmd, err := config.GetString("docker:deploy-cmd")
	if err != nil {
		return nil, err
	}
	appRepo := repository.ReadOnlyURL(app.GetName())
	var envs string
	for _, env := range app.Envs() {
		envs += fmt.Sprintf(`%s=%s `, env.Name, strings.Replace(env.Value, " ", "", -1))
	}
	cmds := []string{deployCmd, appRepo, version, envs}
	return cmds, nil
}
開發者ID:rochacon,項目名稱:tsuru,代碼行數:15,代碼來源:commands.go

示例6: runWithAgentCmds

// runWithAgentCmds returns the list of commands that should be passed when the
// provisioner will run a unit using tsuru_unit_agent to start.
func runWithAgentCmds(app provision.App, publicKey []byte) ([]string, error) {
	runCmd, err := config.GetString("docker:run-cmd:bin")
	if err != nil {
		return nil, err
	}
	ssh, err := sshCmds(publicKey)
	if err != nil {
		return nil, err
	}
	host := app.Envs()["TSURU_HOST"].Value
	token := app.Envs()["TSURU_APP_TOKEN"].Value
	unitAgentCmds := []string{"tsuru_unit_agent", host, token, app.GetName(), runCmd}
	unitAgentCmd := strings.Join(unitAgentCmds, " ")
	sshCmd := strings.Join(ssh, " && ")
	cmd := fmt.Sprintf("%s && %s", unitAgentCmd, sshCmd)
	cmds := []string{"/bin/bash", "-c", cmd}
	return cmds, nil
}
開發者ID:tomzhang,項目名稱:golang-devops-stuff,代碼行數:20,代碼來源:commands.go

示例7: addEnvsToConfig

func (c *Container) addEnvsToConfig(app provision.App, cfg *docker.Config) {
	sharedMount, _ := config.GetString("docker:sharedfs:mountpoint")
	sharedBasedir, _ := config.GetString("docker:sharedfs:hostdir")
	host, _ := config.GetString("host")
	for _, envData := range app.Envs() {
		cfg.Env = append(cfg.Env, fmt.Sprintf("%s=%s", envData.Name, envData.Value))
	}
	cfg.Env = append(cfg.Env, []string{
		fmt.Sprintf("%s=%s", "TSURU_HOST", host),
		fmt.Sprintf("%s=%s", "TSURU_PROCESSNAME", c.ProcessName),
	}...)
	if sharedMount != "" && sharedBasedir != "" {
		cfg.Volumes = map[string]struct{}{
			sharedMount: {},
		}
		cfg.Env = append(cfg.Env, fmt.Sprintf("TSURU_SHAREDFS_MOUNTPOINT=%s", sharedMount))
	}
}
開發者ID:4eek,項目名稱:tsuru,代碼行數:18,代碼來源:container.go


注:本文中的github.com/tsuru/tsuru/provision.App.Envs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。