本文整理匯總了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
}
示例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())
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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))
}
}