本文整理汇总了Golang中github.com/tsuru/tsuru/cmd.Table.Rows方法的典型用法代码示例。如果您正苦于以下问题:Golang Table.Rows方法的具体用法?Golang Table.Rows怎么用?Golang Table.Rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/cmd.Table
的用法示例。
在下文中一共展示了Table.Rows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func (c *dockerLogInfo) Run(context *cmd.Context, client *cmd.Client) error {
u, err := cmd.GetURL("/docker/logs")
if err != nil {
return err
}
request, err := http.NewRequest("GET", u, nil)
if err != nil {
return err
}
response, err := client.Do(request)
if err != nil {
return err
}
defer response.Body.Close()
var conf map[string]container.DockerLogConfig
err = json.NewDecoder(response.Body).Decode(&conf)
if err != nil {
return err
}
baseConf := conf[""]
delete(conf, "")
t := cmd.Table{Headers: cmd.Row([]string{"Name", "Value"})}
fmt.Fprintf(context.Stdout, "Log driver [default]: %s\n", baseConf.Driver)
for optName, optValue := range baseConf.LogOpts {
t.AddRow(cmd.Row([]string{optName, optValue}))
}
if t.Rows() > 0 {
t.Sort()
context.Stdout.Write(t.Bytes())
}
poolNames := make([]string, 0, len(baseConf.LogOpts))
for poolName := range conf {
poolNames = append(poolNames, poolName)
}
sort.Strings(poolNames)
for _, poolName := range poolNames {
poolConf := conf[poolName]
t := cmd.Table{Headers: cmd.Row([]string{"Name", "Value"})}
fmt.Fprintf(context.Stdout, "\nLog driver [pool %s]: %s\n", poolName, poolConf.Driver)
for optName, optValue := range poolConf.LogOpts {
t.AddRow(cmd.Row([]string{optName, optValue}))
}
if t.Rows() > 0 {
t.Sort()
context.Stdout.Write(t.Bytes())
}
}
return nil
}
示例2: Run
func (c *dockerLogInfo) Run(context *cmd.Context, client *cmd.Client) error {
url, err := cmd.GetURL("/docker/logs")
if err != nil {
return err
}
request, err := http.NewRequest("GET", url, nil)
if err != nil {
return err
}
response, err := client.Do(request)
if err != nil {
return err
}
defer response.Body.Close()
var conf provision.ScopedConfig
err = json.NewDecoder(response.Body).Decode(&conf)
if err != nil {
return err
}
t := cmd.Table{Headers: cmd.Row([]string{"Name", "Value"})}
for _, envVar := range conf.Envs {
if envVar.Name == container.DockerLogDriverConfig {
fmt.Fprintf(context.Stdout, "Log driver [default]: %s\n", envVar.Value)
continue
}
t.AddRow(cmd.Row([]string{envVar.Name, fmt.Sprintf("%v", envVar.Value)}))
}
if t.Rows() > 0 {
t.Sort()
context.Stdout.Write(t.Bytes())
}
sort.Sort(provision.ConfigPoolEntryList(conf.Pools))
for _, pool := range conf.Pools {
t := cmd.Table{Headers: cmd.Row([]string{"Name", "Value"})}
for _, envVar := range pool.Envs {
if envVar.Name == container.DockerLogDriverConfig {
fmt.Fprintf(context.Stdout, "\nLog driver [pool %s]: %s\n", pool.Name, envVar.Value)
continue
}
t.AddRow(cmd.Row([]string{envVar.Name, fmt.Sprintf("%v", envVar.Value)}))
}
if t.Rows() > 0 {
t.Sort()
context.Stdout.Write(t.Bytes())
}
}
return nil
}