本文整理汇总了Golang中github.com/docker/docker/pkg/units.HumanSize函数的典型用法代码示例。如果您正苦于以下问题:Golang HumanSize函数的具体用法?Golang HumanSize怎么用?Golang HumanSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HumanSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Status
func (d *Driver) Status() [][2]string {
s := d.DeviceSet.Status()
status := [][2]string{
{"Pool Name", s.PoolName},
{"Pool Blocksize", fmt.Sprintf("%s", units.HumanSize(float64(s.SectorSize)))},
{"Backing Filesystem", backingFs},
{"Data file", s.DataFile},
{"Metadata file", s.MetadataFile},
{"Data Space Used", fmt.Sprintf("%s", units.HumanSize(float64(s.Data.Used)))},
{"Data Space Total", fmt.Sprintf("%s", units.HumanSize(float64(s.Data.Total)))},
{"Metadata Space Used", fmt.Sprintf("%s", units.HumanSize(float64(s.Metadata.Used)))},
{"Metadata Space Total", fmt.Sprintf("%s", units.HumanSize(float64(s.Metadata.Total)))},
{"Udev Sync Supported", fmt.Sprintf("%v", s.UdevSyncSupported)},
}
if len(s.DataLoopback) > 0 {
status = append(status, [2]string{"Data loop file", s.DataLoopback})
}
if len(s.MetadataLoopback) > 0 {
status = append(status, [2]string{"Metadata loop file", s.MetadataLoopback})
}
if vStr, err := devicemapper.GetLibraryVersion(); err == nil {
status = append(status, [2]string{"Library Version", vStr})
}
return status
}
开发者ID:hgschmie,项目名称:docker,代码行数:26,代码来源:driver.go
示例2: CommitContainer
// CommitContainer commits docker container
func (c *DockerClient) CommitContainer(s State, message string) (*docker.Image, error) {
commitOpts := docker.CommitContainerOptions{
Container: s.NoCache.ContainerID,
Message: message,
Run: &s.Config,
}
c.log.Debugf("Commit container: %# v", pretty.Formatter(commitOpts))
image, err := c.client.CommitContainer(commitOpts)
if err != nil {
return nil, err
}
// Inspect the image to get the real size
c.log.Debugf("Inspect image %s", image.ID)
if image, err = c.client.InspectImage(image.ID); err != nil {
return nil, err
}
size := fmt.Sprintf("%s (+%s)",
units.HumanSize(float64(image.VirtualSize)),
units.HumanSize(float64(image.Size)),
)
c.log.WithFields(logrus.Fields{
"size": size,
}).Infof("| Result image is %.12s", image.ID)
return image, nil
}
开发者ID:romank87,项目名称:rocker,代码行数:33,代码来源:client.go
示例3: String
func (p *JSONProgress) String() string {
var (
width = 200
pbBox string
numbersBox string
timeLeftBox string
)
ws, err := term.GetWinsize(p.terminalFd)
if err == nil {
width = int(ws.Width)
}
if p.Current <= 0 && p.Total <= 0 {
return ""
}
current := units.HumanSize(float64(p.Current))
if p.Total <= 0 {
return fmt.Sprintf("%8v", current)
}
total := units.HumanSize(float64(p.Total))
percentage := int(float64(p.Current)/float64(p.Total)*100) / 2
if percentage > 50 {
percentage = 50
}
if width > 110 {
// this number can't be negetive gh#7136
numSpaces := 0
if 50-percentage > 0 {
numSpaces = 50 - percentage - 1
}
pbBox = fmt.Sprintf("[%s%s%s] ", strings.Repeat("~", percentage), p.Animal, strings.Repeat("~", numSpaces))
}
numbersBox = fmt.Sprintf("%8v/%v", current, total)
if p.Current > p.Total {
// remove total display if the reported current is wonky.
numbersBox = fmt.Sprintf("%8v", current)
}
if p.Current > 0 && p.Start > 0 && percentage < 50 {
fromStart := time.Now().UTC().Sub(time.Unix(p.Start, 0))
perEntry := fromStart / time.Duration(p.Current)
left := time.Duration(p.Total-p.Current) * perEntry
left = (left / time.Second) * time.Second
if width > 50 {
timeLeftBox = " " + left.String()
}
}
return pbBox + numbersBox + timeLeftBox
}
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:54,代码来源:jsonmessage.go
示例4: Size
func (c *containerContext) Size() string {
c.addHeader(sizeHeader)
srw := units.HumanSize(float64(c.c.SizeRw))
sv := units.HumanSize(float64(c.c.SizeRootFs))
sf := srw
if c.c.SizeRootFs > 0 {
sf = fmt.Sprintf("%s (virtual %s)", srw, sv)
}
return sf
}
开发者ID:ranjith-shady,项目名称:docker,代码行数:11,代码来源:custom.go
示例5: probeCache
func (b *Build) probeCache(s State) (cachedState State, hit bool, err error) {
if b.cache == nil || s.NoCache.CacheBusted {
return s, false, nil
}
var s2 *State
if s2, err = b.cache.Get(s); err != nil {
return s, false, err
}
if s2 == nil {
s.NoCache.CacheBusted = true
log.Info(color.New(color.FgYellow).SprintFunc()("| Not cached"))
return s, false, nil
}
if b.cfg.ReloadCache {
defer b.cache.Del(*s2)
s.NoCache.CacheBusted = true
log.Info(color.New(color.FgYellow).SprintFunc()("| Reload cache"))
return s, false, nil
}
var img *docker.Image
if img, err = b.client.InspectImage(s2.ImageID); err != nil {
return s, true, err
}
if img == nil {
defer b.cache.Del(*s2)
s.NoCache.CacheBusted = true
log.Info(color.New(color.FgYellow).SprintFunc()("| Not cached"))
return s, false, nil
}
size := fmt.Sprintf("%s (+%s)",
units.HumanSize(float64(img.VirtualSize)),
units.HumanSize(float64(img.Size)),
)
log.WithFields(log.Fields{
"size": size,
}).Infof(color.New(color.FgGreen).SprintfFunc()("| Cached! Take image %.12s", s2.ImageID))
// Store some stuff to the build
b.ProducedSize += img.Size
b.VirtualSize = img.VirtualSize
// Keep items that should not be cached from the previous state
s2.NoCache = s.NoCache
// We don't want commits to go through the cache
s2.CleanCommits()
return *s2, true, nil
}
开发者ID:romank87,项目名称:rocker,代码行数:53,代码来源:build.go
示例6: Display
func (s *containerStats) Display(w io.Writer) error {
s.mu.RLock()
defer s.mu.RUnlock()
if s.err != nil {
return s.err
}
fmt.Fprintf(w, "%s\t%.2f%%\t%s/%s\t%.2f%%\t%s/%s\n",
s.Name,
s.CPUPercentage,
units.HumanSize(s.Memory), units.HumanSize(s.MemoryLimit),
s.MemoryPercentage,
units.HumanSize(s.NetworkRx), units.HumanSize(s.NetworkTx))
return nil
}
开发者ID:vito,项目名称:garden-linux-release,代码行数:14,代码来源:stats.go
示例7: Status
func (d *Driver) Status() [][2]string {
s := d.DeviceSet.Status()
status := [][2]string{
{"Pool Name", s.PoolName},
{"Pool Blocksize", fmt.Sprintf("%s", units.HumanSize(int64(s.SectorSize)))},
{"Data file", s.DataLoopback},
{"Metadata file", s.MetadataLoopback},
{"Data Space Used", fmt.Sprintf("%s", units.HumanSize(int64(s.Data.Used)))},
{"Data Space Total", fmt.Sprintf("%s", units.HumanSize(int64(s.Data.Total)))},
{"Metadata Space Used", fmt.Sprintf("%s", units.HumanSize(int64(s.Metadata.Used)))},
{"Metadata Space Total", fmt.Sprintf("%s", units.HumanSize(int64(s.Metadata.Total)))},
}
return status
}
开发者ID:bbinet,项目名称:docker,代码行数:15,代码来源:driver.go
示例8: serveTemplate
func (h *Handler) serveTemplate(w http.ResponseWriter, r *http.Request) {
templateDir := path.Join("/src", "templates")
lp := path.Join(templateDir, "layout.html")
// set up custom functions
funcMap := template.FuncMap{
"ext": func(name string) string {
return strings.TrimPrefix(filepath.Ext(name), ".")
},
"base": func(name string) string {
parts := strings.Split(name, "/")
return parts[len(parts)-1]
},
"size": func(s int64) string {
return units.HumanSize(float64(s))
},
}
// parse & execute the template
tmpl := template.Must(template.New("").Funcs(funcMap).ParseFiles(lp))
if err := tmpl.ExecuteTemplate(w, "layout", h.Files); err != nil {
writeError(w, fmt.Sprintf("Execute template failed: %v", err))
return
}
}
开发者ID:AgtLucas,项目名称:s3server,代码行数:25,代码来源:main.go
示例9: PrintHistory
func (e *Export) PrintHistory() {
current := e.Root()
order := []*ExportedImage{}
for {
order = append(order, current)
current = e.ChildOf(current.LayerConfig.Id)
if current == nil {
break
}
}
for i := 0; i < len(order); i++ {
stat, err := os.Stat(order[i].LayerTarPath)
size := int64(-1)
if stat != nil && err == nil {
size = stat.Size()
}
cmd := strings.Join(order[i].LayerConfig.ContainerConfig().Cmd, " ")
if len(cmd) > 60 {
cmd = cmd[0:57] + "..."
}
debug(" - ", order[i].LayerConfig.Id[0:12],
humanDuration(time.Now().UTC().Sub(order[i].LayerConfig.Created.UTC())),
cmd, units.HumanSize(float64(size)))
}
}
开发者ID:makicha,项目名称:docker-squash,代码行数:28,代码来源:export.go
示例10: printImages
// Print all the images based on SUSE. It will print in a format that is as
// close to the `docker` command as possible.
func printImages(imgs []*dockerclient.Image) {
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
fmt.Fprintf(w, "REPOSITORY\tTAG\tIMAGE ID\tCREATED\tVIRTUAL SIZE\n")
cache := getCacheFile()
for counter, img := range imgs {
fmt.Printf("Inspecting image %d/%d\r", (counter + 1), len(imgs))
if cache.isSUSE(img.Id) {
if len(img.RepoTags) < 1 {
continue
}
id := stringid.TruncateID(img.Id)
size := units.HumanSize(float64(img.VirtualSize))
for _, tag := range img.RepoTags {
t := strings.SplitN(tag, ":", 2)
fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\n", t[0], t[1], id,
timeAgo(img.Created), size)
}
}
}
fmt.Printf("\n")
_ = w.Flush()
cache.flush()
}
开发者ID:jloehel,项目名称:zypper-docker,代码行数:29,代码来源:images.go
示例11: CmdHistory
// CmdHistory shows the history of an image.
//
// Usage: docker history [OPTIONS] IMAGE
func (cli *DockerCli) CmdHistory(args ...string) error {
cmd := Cli.Subcmd("history", []string{"IMAGE"}, Cli.DockerCommands["history"].Description, true)
human := cmd.Bool([]string{"H", "-human"}, true, "Print sizes and dates in human readable format")
quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs")
noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
cmd.Require(flag.Exact, 1)
cmd.ParseFlags(args, true)
serverResp, err := cli.call("GET", "/images/"+cmd.Arg(0)+"/history", nil, nil)
if err != nil {
return err
}
defer serverResp.body.Close()
history := []types.ImageHistory{}
if err := json.NewDecoder(serverResp.body).Decode(&history); err != nil {
return err
}
w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0)
if !*quiet {
fmt.Fprintln(w, "IMAGE\tCREATED\tCREATED BY\tSIZE\tCOMMENT")
}
for _, entry := range history {
if *noTrunc {
fmt.Fprintf(w, entry.ID)
} else {
fmt.Fprintf(w, stringid.TruncateID(entry.ID))
}
if !*quiet {
if *human {
fmt.Fprintf(w, "\t%s ago\t", units.HumanDuration(time.Now().UTC().Sub(time.Unix(entry.Created, 0))))
} else {
fmt.Fprintf(w, "\t%s\t", time.Unix(entry.Created, 0).Format(time.RFC3339))
}
if *noTrunc {
fmt.Fprintf(w, "%s\t", strings.Replace(entry.CreatedBy, "\t", " ", -1))
} else {
fmt.Fprintf(w, "%s\t", stringutils.Truncate(strings.Replace(entry.CreatedBy, "\t", " ", -1), 45))
}
if *human {
fmt.Fprintf(w, "%s\t", units.HumanSize(float64(entry.Size)))
} else {
fmt.Fprintf(w, "%d\t", entry.Size)
}
fmt.Fprintf(w, "%s", entry.Comment)
}
fmt.Fprintf(w, "\n")
}
w.Flush()
return nil
}
开发者ID:previousnext,项目名称:kube-ingress,代码行数:61,代码来源:history.go
示例12: Execute
// Execute runs the command
func (c *CommandFrom) Execute(b *Build) (s State, err error) {
// TODO: for "scratch" image we may use /images/create
if len(c.cfg.args) != 1 {
return s, fmt.Errorf("FROM requires one argument")
}
var (
img *docker.Image
name = c.cfg.args[0]
)
if name == "scratch" {
s.NoBaseImage = true
return s, nil
}
if img, err = b.lookupImage(name); err != nil {
return s, fmt.Errorf("FROM error: %s", err)
}
if img == nil {
return s, fmt.Errorf("FROM: image %s not found", name)
}
// We want to say the size of the FROM image. Better to do it
// from the client, but don't know how to do it better,
// without duplicating InspectImage calls and making unnecessary functions
log.WithFields(log.Fields{
"size": units.HumanSize(float64(img.VirtualSize)),
}).Infof("| Image %.12s", img.ID)
s = b.state
s.ImageID = img.ID
s.Config = docker.Config{}
if img.Config != nil {
s.Config = *img.Config
}
b.ProducedSize = 0
b.VirtualSize = img.VirtualSize
// If we don't have OnBuild triggers, then we are done
if len(s.Config.OnBuild) == 0 {
return s, nil
}
log.Infof("| Found %d ONBUILD triggers", len(s.Config.OnBuild))
// Remove them from the config, since the config will be committed.
s.InjectCommands = s.Config.OnBuild
s.Config.OnBuild = []string{}
return s, nil
}
开发者ID:romank87,项目名称:rocker,代码行数:58,代码来源:commands.go
示例13: Status
func (d *Driver) Status() [][2]string {
s := d.DeviceSet.Status()
status := [][2]string{
{"Pool Name", s.PoolName},
{"Pool Blocksize", fmt.Sprintf("%s", units.HumanSize(int64(s.SectorSize)))},
{"Data file", s.DataLoopback},
{"Metadata file", s.MetadataLoopback},
{"Data Space Used", fmt.Sprintf("%s", units.HumanSize(int64(s.Data.Used)))},
{"Data Space Total", fmt.Sprintf("%s", units.HumanSize(int64(s.Data.Total)))},
{"Metadata Space Used", fmt.Sprintf("%s", units.HumanSize(int64(s.Metadata.Used)))},
{"Metadata Space Total", fmt.Sprintf("%s", units.HumanSize(int64(s.Metadata.Total)))},
}
if vStr, err := GetLibraryVersion(); err == nil {
status = append(status, [2]string{"Library Version", vStr})
}
return status
}
开发者ID:harshavardhana,项目名称:docker,代码行数:18,代码来源:driver.go
示例14: CmdHistory
// CmdHistory shows the history of an image.
//
// Usage: docker history [OPTIONS] IMAGE
func (cli *DockerCli) CmdHistory(args ...string) error {
cmd := Cli.Subcmd("history", []string{"IMAGE"}, Cli.DockerCommands["history"].Description, true)
human := cmd.Bool([]string{"H", "-human"}, true, "Print sizes and dates in human readable format")
quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs")
noTrunc := cmd.Bool([]string{"-no-trunc"}, false, "Don't truncate output")
cmd.Require(flag.Exact, 1)
cmd.ParseFlags(args, true)
history, err := cli.client.ImageHistory(cmd.Arg(0))
if err != nil {
return err
}
w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0)
if *quiet {
for _, entry := range history {
if *noTrunc {
fmt.Fprintf(w, "%s\n", entry.ID)
} else {
fmt.Fprintf(w, "%s\n", stringid.TruncateID(entry.ID))
}
}
w.Flush()
return nil
}
var imageID string
var createdBy string
var created string
var size string
fmt.Fprintln(w, "IMAGE\tCREATED\tCREATED BY\tSIZE\tCOMMENT")
for _, entry := range history {
imageID = entry.ID
createdBy = strings.Replace(entry.CreatedBy, "\t", " ", -1)
if *noTrunc == false {
createdBy = stringutils.Truncate(createdBy, 45)
imageID = stringid.TruncateID(entry.ID)
}
if *human {
created = units.HumanDuration(time.Now().UTC().Sub(time.Unix(entry.Created, 0))) + " ago"
size = units.HumanSize(float64(entry.Size))
} else {
created = time.Unix(entry.Created, 0).Format(time.RFC3339)
size = strconv.FormatInt(entry.Size, 10)
}
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", imageID, created, createdBy, size, entry.Comment)
}
w.Flush()
return nil
}
开发者ID:Neverous,项目名称:other-docker,代码行数:58,代码来源:history.go
示例15: housekeeping
func (c *containerData) housekeeping() {
// Long housekeeping is either 100ms or half of the housekeeping interval.
longHousekeeping := 100 * time.Millisecond
if *HousekeepingInterval/2 < longHousekeeping {
longHousekeeping = *HousekeepingInterval / 2
}
// Housekeep every second.
glog.Infof("Start housekeeping for container %q\n", c.info.Name)
lastHousekeeping := time.Now()
for {
select {
case <-c.stop:
// Stop housekeeping when signaled.
return
default:
// Perform housekeeping.
start := time.Now()
c.housekeepingTick()
// Log if housekeeping took too long.
duration := time.Since(start)
if duration >= longHousekeeping {
glog.V(2).Infof("[%s] Housekeeping took %s", c.info.Name, duration)
}
}
// Log usage if asked to do so.
if c.logUsage {
stats, err := c.storageDriver.RecentStats(c.info.Name, 2)
if err != nil {
if c.allowErrorLogging() {
glog.Infof("[%s] Failed to get recent stats for logging usage: %v", c.info.Name, err)
}
} else if len(stats) < 2 {
// Ignore, not enough stats yet.
} else {
usageCpuNs := stats[1].Cpu.Usage.Total - stats[0].Cpu.Usage.Total
usageMemory := stats[1].Memory.Usage
usageInCores := float64(usageCpuNs) / float64(stats[1].Timestamp.Sub(stats[0].Timestamp).Nanoseconds())
usageInHuman := units.HumanSize(int64(usageMemory))
glog.Infof("[%s] %.3f cores, %s of memory", c.info.Name, usageInCores, usageInHuman)
}
}
// Schedule the next housekeeping. Sleep until that time.
nextHousekeeping := c.nextHousekeeping(lastHousekeeping)
if time.Now().Before(nextHousekeeping) {
time.Sleep(nextHousekeeping.Sub(time.Now()))
}
lastHousekeeping = nextHousekeeping
}
}
开发者ID:rjnagal,项目名称:cadvisor,代码行数:54,代码来源:container.go
示例16: CommitContainer
// CommitContainer commits docker container
func (c *DockerClient) CommitContainer(s *State) (*docker.Image, error) {
commitOpts := docker.CommitContainerOptions{
Container: s.NoCache.ContainerID,
Run: &s.Config,
}
c.log.Debugf("Commit container: %# v", pretty.Formatter(commitOpts))
image, err := c.client.CommitContainer(commitOpts)
if err != nil {
return nil, err
}
// Inspect the image to get the real size
c.log.Debugf("Inspect image %s", image.ID)
if image, err = c.client.InspectImage(image.ID); err != nil {
return nil, err
}
s.ParentSize = s.Size
s.Size = image.VirtualSize
fields := logrus.Fields{}
if c.useHumanSize {
size := fmt.Sprintf("%s (+%s)",
units.HumanSize(float64(s.Size)),
units.HumanSize(float64(s.Size-s.ParentSize)),
)
fields["size"] = size
} else {
fields["size"] = s.Size
fields["delta"] = s.Size - s.ParentSize
}
c.log.WithFields(fields).Infof("| Result image is %.12s", image.ID)
return image, nil
}
开发者ID:andrewrothstein,项目名称:rocker,代码行数:40,代码来源:client.go
示例17: String
func (p *JSONProgress) String() string {
var (
width = 200
pbBox string
numbersBox string
timeLeftBox string
)
ws, err := term.GetWinsize(p.terminalFd)
if err == nil {
width = int(ws.Width)
}
if p.Current <= 0 && p.Total <= 0 {
return ""
}
current := units.HumanSize(int64(p.Current))
if p.Total <= 0 {
return fmt.Sprintf("%8v", current)
}
total := units.HumanSize(int64(p.Total))
percentage := int(float64(p.Current)/float64(p.Total)*100) / 2
if width > 110 {
pbBox = fmt.Sprintf("[%s>%s] ", strings.Repeat("=", percentage), strings.Repeat(" ", 50-percentage))
}
numbersBox = fmt.Sprintf("%8v/%v", current, total)
if p.Current > 0 && p.Start > 0 && percentage < 50 {
fromStart := time.Now().UTC().Sub(time.Unix(int64(p.Start), 0))
perEntry := fromStart / time.Duration(p.Current)
left := time.Duration(p.Total-p.Current) * perEntry
left = (left / time.Second) * time.Second
if width > 50 {
timeLeftBox = " " + left.String()
}
}
return pbBox + numbersBox + timeLeftBox
}
开发者ID:r0n22,项目名称:docker,代码行数:39,代码来源:jsonmessage.go
示例18: CmdHistory
// CmdHistory shows the history of an image.
//
// Usage: docker history [OPTIONS] IMAGE
func (cli *DockerCli) CmdHistory(args ...string) error {
cmd := cli.Subcmd("history", "IMAGE", "Show the history of an image", true)
quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs")
noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
cmd.Require(flag.Exact, 1)
utils.ParseFlags(cmd, args, true)
body, _, err := readBody(cli.call("GET", "/images/"+cmd.Arg(0)+"/history", nil, nil))
if err != nil {
return err
}
outs := engine.NewTable("Created", 0)
if _, err := outs.ReadListFrom(body); err != nil {
return err
}
w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0)
if !*quiet {
fmt.Fprintln(w, "IMAGE\tCREATED\tCREATED BY\tSIZE")
}
for _, out := range outs.Data {
outID := out.Get("Id")
if !*quiet {
if *noTrunc {
fmt.Fprintf(w, "%s\t", outID)
} else {
fmt.Fprintf(w, "%s\t", stringid.TruncateID(outID))
}
fmt.Fprintf(w, "%s ago\t", units.HumanDuration(time.Now().UTC().Sub(time.Unix(out.GetInt64("Created"), 0))))
if *noTrunc {
fmt.Fprintf(w, "%s\t", out.Get("CreatedBy"))
} else {
fmt.Fprintf(w, "%s\t", utils.Trunc(out.Get("CreatedBy"), 45))
}
fmt.Fprintf(w, "%s\n", units.HumanSize(float64(out.GetInt64("Size"))))
} else {
if *noTrunc {
fmt.Fprintln(w, outID)
} else {
fmt.Fprintln(w, stringid.TruncateID(outID))
}
}
}
w.Flush()
return nil
}
开发者ID:nicholaskh,项目名称:docker,代码行数:54,代码来源:history.go
示例19: printTreeNode
// FIXME: --viz and --tree are deprecated. Remove them in a future version.
func (cli *DockerCli) printTreeNode(noTrunc bool, image *engine.Env, prefix string) {
var imageID string
if noTrunc {
imageID = image.Get("Id")
} else {
imageID = stringid.TruncateID(image.Get("Id"))
}
fmt.Fprintf(cli.out, "%s%s Virtual Size: %s", prefix, imageID, units.HumanSize(float64(image.GetInt64("VirtualSize"))))
if image.GetList("RepoTags")[0] != "<none>:<none>" {
fmt.Fprintf(cli.out, " Tags: %s\n", strings.Join(image.GetList("RepoTags"), ", "))
} else {
fmt.Fprint(cli.out, "\n")
}
}
开发者ID:nicholaskh,项目名称:docker,代码行数:16,代码来源:images.go
示例20: printTreeNode
// FIXME: --viz and --tree are deprecated. Remove them in a future version.
func (cli *DockerCli) printTreeNode(noTrunc bool, image *types.Image, prefix string) {
var imageID string
if noTrunc {
imageID = image.ID
} else {
imageID = stringid.TruncateID(image.ID)
}
fmt.Fprintf(cli.out, "%s%s Virtual Size: %s", prefix, imageID, units.HumanSize(float64(image.VirtualSize)))
if image.RepoTags[0] != "<none>:<none>" {
fmt.Fprintf(cli.out, " Tags: %s\n", strings.Join(image.RepoTags, ", "))
} else {
fmt.Fprint(cli.out, "\n")
}
}
开发者ID:yingmsky,项目名称:docker,代码行数:16,代码来源:images.go
注:本文中的github.com/docker/docker/pkg/units.HumanSize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论