本文整理汇总了Golang中github.com/juju/juju/cmd/output.Wrapper.PrintStatus方法的典型用法代码示例。如果您正苦于以下问题:Golang Wrapper.PrintStatus方法的具体用法?Golang Wrapper.PrintStatus怎么用?Golang Wrapper.PrintStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/cmd/output.Wrapper
的用法示例。
在下文中一共展示了Wrapper.PrintStatus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printMachine
func printMachine(w output.Wrapper, m machineStatus) {
// We want to display availability zone so extract from hardware info".
hw, err := instance.ParseHardware(m.Hardware)
if err != nil {
logger.Warningf("invalid hardware info %s for machine %v", m.Hardware, m)
}
az := ""
if hw.AvailabilityZone != nil {
az = *hw.AvailabilityZone
}
w.Print(m.Id)
w.PrintStatus(m.JujuStatus.Current)
w.Println(m.DNSName, m.InstanceId, m.Series, az)
for _, name := range utils.SortStringsNaturally(stringKeysFromMap(m.Containers)) {
printMachine(w, m.Containers[name])
}
}
示例2: FormatTabular
// FormatTabular writes a tabular summary of machines, applications, and
// units. Any subordinate items are indented by two spaces beneath
// their superior.
func FormatTabular(writer io.Writer, forceColor bool, value interface{}) error {
const maxVersionWidth = 15
const ellipsis = "..."
const truncatedWidth = maxVersionWidth - len(ellipsis)
fs, valueConverted := value.(formattedStatus)
if !valueConverted {
return errors.Errorf("expected value of type %T, got %T", fs, value)
}
// To format things into columns.
tw := output.TabWriter(writer)
if forceColor {
tw.SetColorCapable(forceColor)
}
w := output.Wrapper{tw}
p := w.Println
outputHeaders := func(values ...interface{}) {
p()
p(values...)
}
cloudRegion := fs.Model.Cloud
if fs.Model.CloudRegion != "" {
cloudRegion += "/" + fs.Model.CloudRegion
}
header := []interface{}{"MODEL", "CONTROLLER", "CLOUD/REGION", "VERSION"}
values := []interface{}{fs.Model.Name, fs.Model.Controller, cloudRegion, fs.Model.Version}
message := getModelMessage(fs.Model)
if message != "" {
header = append(header, "NOTES")
values = append(values, message)
}
// The first set of headers don't use outputHeaders because it adds the blank line.
p(header...)
p(values...)
units := make(map[string]unitStatus)
metering := false
relations := newRelationFormatter()
outputHeaders("APP", "VERSION", "STATUS", "SCALE", "CHARM", "STORE", "REV", "OS", "NOTES")
tw.SetColumnAlignRight(3)
tw.SetColumnAlignRight(6)
for _, appName := range utils.SortStringsNaturally(stringKeysFromMap(fs.Applications)) {
app := fs.Applications[appName]
version := app.Version
// Don't let a long version push out the version column.
if len(version) > maxVersionWidth {
version = version[:truncatedWidth] + ellipsis
}
// Notes may well contain other things later.
notes := ""
if app.Exposed {
notes = "exposed"
}
w.Print(appName, version)
w.PrintStatus(app.StatusInfo.Current)
scale, warn := fs.applicationScale(appName)
if warn {
w.PrintColor(output.WarningHighlight, scale)
} else {
w.Print(scale)
}
p(app.CharmName,
app.CharmOrigin,
app.CharmRev,
app.OS,
notes)
for un, u := range app.Units {
units[un] = u
if u.MeterStatus != nil {
metering = true
}
}
// Ensure that we pick a consistent name for peer relations.
sortedRelTypes := make([]string, 0, len(app.Relations))
for relType := range app.Relations {
sortedRelTypes = append(sortedRelTypes, relType)
}
sort.Strings(sortedRelTypes)
subs := set.NewStrings(app.SubordinateTo...)
for _, relType := range sortedRelTypes {
for _, related := range app.Relations[relType] {
relations.add(related, appName, relType, subs.Contains(related))
}
}
}
pUnit := func(name string, u unitStatus, level int) {
message := u.WorkloadStatusInfo.Message
agentDoing := agentDoing(u.JujuStatusInfo)
if agentDoing != "" {
message = fmt.Sprintf("(%s) %s", agentDoing, message)
//.........这里部分代码省略.........