|
@@ -20,6 +20,7 @@ import (
|
|
"path"
|
|
"path"
|
|
"path/filepath"
|
|
"path/filepath"
|
|
"reflect"
|
|
"reflect"
|
|
|
|
+ "regexp"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
"syscall"
|
|
"syscall"
|
|
@@ -727,6 +728,15 @@ func (cli *DockerCli) CmdPush(args ...string) error {
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
+ nameParts := strings.SplitN(name, "/", 2)
|
|
|
|
+ validNamespace := regexp.MustCompile(`^([a-z0-9_]{4,30})$`)
|
|
|
|
+ if !validNamespace.MatchString(nameParts[0]) {
|
|
|
|
+ return fmt.Errorf("Invalid namespace name (%s), only [a-z0-9_] are allowed, size between 4 and 30", nameParts[0])
|
|
|
|
+ }
|
|
|
|
+ validRepo := regexp.MustCompile(`^([a-zA-Z0-9-_.]+)$`)
|
|
|
|
+ if !validRepo.MatchString(nameParts[1]) {
|
|
|
|
+ return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", nameParts[1])
|
|
|
|
+ }
|
|
|
|
|
|
v := url.Values{}
|
|
v := url.Values{}
|
|
v.Set("registry", *registry)
|
|
v.Set("registry", *registry)
|
|
@@ -811,7 +821,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
|
|
|
|
|
|
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
|
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
|
if !*quiet {
|
|
if !*quiet {
|
|
- fmt.Fprintln(w, "REPOSITORY\tTAG\tID\tCREATED")
|
|
|
|
|
|
+ fmt.Fprintln(w, "REPOSITORY\tTAG\tID\tCREATED\tSIZE")
|
|
}
|
|
}
|
|
|
|
|
|
for _, out := range outs {
|
|
for _, out := range outs {
|
|
@@ -829,7 +839,12 @@ func (cli *DockerCli) CmdImages(args ...string) error {
|
|
} else {
|
|
} else {
|
|
fmt.Fprintf(w, "%s\t", utils.TruncateID(out.ID))
|
|
fmt.Fprintf(w, "%s\t", utils.TruncateID(out.ID))
|
|
}
|
|
}
|
|
- fmt.Fprintf(w, "%s ago\n", utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))))
|
|
|
|
|
|
+ fmt.Fprintf(w, "%s ago\t", utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))))
|
|
|
|
+ if out.VirtualSize > 0 {
|
|
|
|
+ fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.Size), utils.HumanSize(out.VirtualSize))
|
|
|
|
+ } else {
|
|
|
|
+ fmt.Fprintf(w, "%s\n", utils.HumanSize(out.Size))
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
if *noTrunc {
|
|
if *noTrunc {
|
|
fmt.Fprintln(w, out.ID)
|
|
fmt.Fprintln(w, out.ID)
|
|
@@ -888,15 +903,20 @@ func (cli *DockerCli) CmdPs(args ...string) error {
|
|
}
|
|
}
|
|
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
|
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
|
if !*quiet {
|
|
if !*quiet {
|
|
- fmt.Fprintln(w, "ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tPORTS")
|
|
|
|
|
|
+ fmt.Fprintln(w, "ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tPORTS\tSIZE")
|
|
}
|
|
}
|
|
|
|
|
|
for _, out := range outs {
|
|
for _, out := range outs {
|
|
if !*quiet {
|
|
if !*quiet {
|
|
if *noTrunc {
|
|
if *noTrunc {
|
|
- fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\n", out.ID, out.Image, out.Command, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, out.Ports)
|
|
|
|
|
|
+ fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\t", out.ID, out.Image, out.Command, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, out.Ports)
|
|
|
|
+ } else {
|
|
|
|
+ fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\t", utils.TruncateID(out.ID), out.Image, utils.Trunc(out.Command, 20), utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, out.Ports)
|
|
|
|
+ }
|
|
|
|
+ if out.SizeRootFs > 0 {
|
|
|
|
+ fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.SizeRw), utils.HumanSize(out.SizeRootFs))
|
|
} else {
|
|
} else {
|
|
- fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\n", utils.TruncateID(out.ID), out.Image, utils.Trunc(out.Command, 20), utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, out.Ports)
|
|
|
|
|
|
+ fmt.Fprintf(w, "%s\n", utils.HumanSize(out.SizeRw))
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if *noTrunc {
|
|
if *noTrunc {
|