don't try stdin mode unless a flag is passed
This commit is contained in:
parent
9863e97953
commit
bdb64a088c
4 changed files with 9 additions and 8 deletions
12
README.md
12
README.md
|
@ -189,12 +189,12 @@ Dockviz supports connecting to the Docker daemon directly. It defaults to `unix
|
|||
Dockviz also supports receiving Docker image or container json data on standard input.
|
||||
|
||||
```
|
||||
$ curl -s http://localhost:4243/images/json?all=1 | dockviz images --tree
|
||||
$ curl -s http://localhost:4243/containers/json?all=1 | dockviz containers --dot | dot -Tpng -o containers.png
|
||||
$ echo -e "GET /images/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock | sed '1,/^[[:space:]]*$/d' | dockviz images --tree
|
||||
$ echo -e "GET /containers/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock | sed '1,/^[[:space:]]*$/d' | dockviz containers --dot | dot -Tpng -o containers.png
|
||||
$ echo -e "GET /images/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock | sed '1,/^[[:space:]]*$/d' | docker run -i nate/dockviz images --tree
|
||||
$ echo -e "GET /containers/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock | sed '1,/^[[:space:]]*$/d' | docker run -i nate/dockviz containers --dot | dot -Tpng -o containers.png
|
||||
$ curl -s http://localhost:4243/images/json?all=1 | dockviz --stdin images --tree
|
||||
$ curl -s http://localhost:4243/containers/json?all=1 | dockviz --stdin containers --dot | dot -Tpng -o containers.png
|
||||
$ echo -e "GET /images/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock | sed '1,/^[[:space:]]*$/d' | dockviz --stdin images --tree
|
||||
$ echo -e "GET /containers/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock | sed '1,/^[[:space:]]*$/d' | dockviz --stdin containers --dot | dot -Tpng -o containers.png
|
||||
$ echo -e "GET /images/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock | sed '1,/^[[:space:]]*$/d' | docker run -i nate/dockviz --stdin images --tree
|
||||
$ echo -e "GET /containers/json?all=1 HTTP/1.0\r\n" | nc -U /var/run/docker.sock | sed '1,/^[[:space:]]*$/d' | docker run -i nate/dockviz --stdin containers --dot | dot -Tpng -o containers.png
|
||||
```
|
||||
|
||||
Note: GNU netcat doesn't support `-U` (UNIX socket) flag, so OpenBSD variant can be used.
|
||||
|
|
1
cli.go
1
cli.go
|
@ -14,6 +14,7 @@ type GlobalOptions struct {
|
|||
TLSVerify bool `long:"tlsverify" description:"Use TLS and verify the remote"`
|
||||
Host string `long:"host" short:"H" value-name:"unix:///var/run/docker.sock" description:"Docker host to connect to"`
|
||||
Version func() `long:"version" short:"v" description:"Display version information."`
|
||||
Stdin bool `long:"stdin" description:"Enable reading image information from stdin (pre-Docker-1.11 only)"`
|
||||
}
|
||||
|
||||
var globalOptions GlobalOptions
|
||||
|
|
|
@ -37,7 +37,7 @@ func (x *ContainersCommand) Execute(args []string) error {
|
|||
return fmt.Errorf("error reading stdin stat", err)
|
||||
}
|
||||
|
||||
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
||||
if globalOptions.Stdin && (stat.Mode()&os.ModeCharDevice) == 0 {
|
||||
// read in stdin
|
||||
stdin, err := ioutil.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
|
|
|
@ -51,7 +51,7 @@ func (x *ImagesCommand) Execute(args []string) error {
|
|||
return fmt.Errorf("error reading stdin stat", err)
|
||||
}
|
||||
|
||||
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
||||
if globalOptions.Stdin && (stat.Mode()&os.ModeCharDevice) == 0 {
|
||||
// read in stdin
|
||||
stdin, err := ioutil.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue