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