Extract streams helpers from command package to their own package to remove a cyclic dependency from command to internal/containerizedengine

Aliasing old types
* streams.InStream -> streams.In
* streams.NewInStream -> streams.NewIn
* streams.OutStream -> streams.Out
* streams.NewOutStream -> streams.NewOut

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
Silvin Lubecki
2019-01-28 14:30:31 +01:00
parent 81e7426e11
commit eb0ba4f8d5
17 changed files with 136 additions and 108 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/streams"
"github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@ -59,7 +60,7 @@ func runUnlock(dockerCli command.Cli) error {
return client.SwarmUnlock(ctx, req)
}
func readKey(in *command.InStream, prompt string) (string, error) {
func readKey(in *streams.In, prompt string) (string, error) {
if in.IsTerminal() {
fmt.Print(prompt)
dt, err := terminal.ReadPassword(int(in.FD()))

View File

@ -5,7 +5,7 @@ import (
"strings"
"testing"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/streams"
"github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm"
@ -92,7 +92,7 @@ func TestSwarmUnlock(t *testing.T) {
return nil
},
})
dockerCli.SetIn(command.NewInStream(ioutil.NopCloser(strings.NewReader(input))))
dockerCli.SetIn(streams.NewIn(ioutil.NopCloser(strings.NewReader(input))))
cmd := newUnlockCommand(dockerCli)
assert.NilError(t, cmd.Execute())
}