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


Golang ScopedConfig.Envs方法代码示例

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


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

示例1: Run

func (c *dockerLogUpdate) Run(context *cmd.Context, client *cmd.Client) error {
	context.RawOutput()
	if c.restart {
		extra := ""
		if c.pool != "" {
			extra = fmt.Sprintf(" running on pool %s", c.pool)
		}
		msg := fmt.Sprintf("Are you sure you want to restart all apps%s?", extra)
		if !c.Confirm(context, msg) {
			return nil
		}
	}
	url, err := cmd.GetURL("/docker/logs")
	if err != nil {
		return err
	}
	envList := []provision.Entry{
		{Name: "log-driver", Value: c.logDriver},
	}
	for name, value := range c.logOpts {
		envList = append(envList, provision.Entry{Name: name, Value: value})
	}
	conf := provision.ScopedConfig{}
	if c.pool == "" {
		conf.Envs = envList
	} else {
		conf.Pools = []provision.PoolEntry{{
			Name: c.pool,
			Envs: envList,
		}}
	}
	b, err := json.Marshal(logsSetData{
		Restart: c.restart,
		Config:  conf,
	})
	if err != nil {
		return err
	}
	buffer := bytes.NewBuffer(b)
	request, err := http.NewRequest("POST", url, buffer)
	if err != nil {
		return err
	}
	request.Header.Set("Content-Type", "application/json")
	response, err := client.Do(request)
	if err != nil {
		return err
	}
	defer response.Body.Close()
	return cmd.StreamJSONResponse(context.Stdout, response)
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:51,代码来源:cmd.go

示例2: Run

func (c *EnvSetCmd) Run(context *cmd.Context, client *cmd.Client) error {
	context.RawOutput()
	url, err := cmd.GetURL("/docker/bs/env")
	if err != nil {
		return err
	}
	var envList []provision.Entry
	for _, arg := range context.Args {
		parts := strings.SplitN(arg, "=", 2)
		if len(parts) < 2 {
			return fmt.Errorf("invalid variable values")
		}
		if parts[0] == "" {
			return fmt.Errorf("invalid variable values")
		}
		envList = append(envList, provision.Entry{Name: parts[0], Value: parts[1]})
	}
	conf := provision.ScopedConfig{}
	if c.pool == "" {
		conf.Envs = envList
	} else {
		conf.Pools = []provision.PoolEntry{{
			Name: c.pool,
			Envs: envList,
		}}
	}
	b, err := json.Marshal(conf)
	if err != nil {
		return err
	}
	buffer := bytes.NewBuffer(b)
	request, err := http.NewRequest("POST", url, buffer)
	if err != nil {
		return err
	}
	request.Header.Set("Content-Type", "application/json")
	response, err := client.Do(request)
	if err != nil {
		return err
	}
	defer response.Body.Close()
	return cmd.StreamJSONResponse(context.Stdout, response)
}
开发者ID:botvs,项目名称:tsuru,代码行数:43,代码来源:cmd.go


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