mirror of https://github.com/docker/docs.git
Merge pull request #7507 from shykes/cleanup-tiny
Cleanup: tiny little things
This commit is contained in:
commit
57e0cbb991
|
@ -15,6 +15,19 @@ import (
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type DockerCli struct {
|
||||||
|
proto string
|
||||||
|
addr string
|
||||||
|
configFile *registry.ConfigFile
|
||||||
|
in io.ReadCloser
|
||||||
|
out io.Writer
|
||||||
|
err io.Writer
|
||||||
|
isTerminal bool
|
||||||
|
terminalFd uintptr
|
||||||
|
tlsConfig *tls.Config
|
||||||
|
scheme string
|
||||||
|
}
|
||||||
|
|
||||||
var funcMap = template.FuncMap{
|
var funcMap = template.FuncMap{
|
||||||
"json": func(v interface{}) string {
|
"json": func(v interface{}) string {
|
||||||
a, _ := json.Marshal(v)
|
a, _ := json.Marshal(v)
|
||||||
|
@ -34,7 +47,8 @@ func (cli *DockerCli) getMethod(name string) (func(...string) error, bool) {
|
||||||
return method.Interface().(func(...string) error), true
|
return method.Interface().(func(...string) error), true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *DockerCli) ParseCommands(args ...string) error {
|
// Cmd executes the specified command
|
||||||
|
func (cli *DockerCli) Cmd(args ...string) error {
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
method, exists := cli.getMethod(args[0])
|
method, exists := cli.getMethod(args[0])
|
||||||
if !exists {
|
if !exists {
|
||||||
|
@ -97,16 +111,3 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, proto, addr string, tlsC
|
||||||
scheme: scheme,
|
scheme: scheme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DockerCli struct {
|
|
||||||
proto string
|
|
||||||
addr string
|
|
||||||
configFile *registry.ConfigFile
|
|
||||||
in io.ReadCloser
|
|
||||||
out io.Writer
|
|
||||||
err io.Writer
|
|
||||||
isTerminal bool
|
|
||||||
terminalFd uintptr
|
|
||||||
tlsConfig *tls.Config
|
|
||||||
scheme string
|
|
||||||
}
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ func main() {
|
||||||
cli = client.NewDockerCli(os.Stdin, os.Stdout, os.Stderr, protoAddrParts[0], protoAddrParts[1], nil)
|
cli = client.NewDockerCli(os.Stdin, os.Stdout, os.Stderr, protoAddrParts[0], protoAddrParts[1], nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cli.ParseCommands(flag.Args()...); err != nil {
|
if err := cli.Cmd(flag.Args()...); err != nil {
|
||||||
if sterr, ok := err.(*utils.StatusError); ok {
|
if sterr, ok := err.(*utils.StatusError); ok {
|
||||||
if sterr.Status != "" {
|
if sterr.Status != "" {
|
||||||
log.Println(sterr.Status)
|
log.Println(sterr.Status)
|
||||||
|
|
Loading…
Reference in New Issue