当前位置: 首页>>代码示例>>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;未经允许,请勿转载。