Skip to content

Commit 45fbbc0

Browse files
Renaming and 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>
1 parent 0ef2125 commit 45fbbc0

File tree

18 files changed

+98
-75
lines changed

18 files changed

+98
-75
lines changed

cli/command/cli.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ import (
3838

3939
// Streams is an interface which exposes the standard input and output streams
4040
type Streams interface {
41-
In() *streams.InStream
42-
Out() *streams.OutStream
41+
In() *streams.In
42+
Out() *streams.Out
4343
Err() io.Writer
4444
}
4545

4646
// Cli represents the docker command line client.
4747
type Cli interface {
4848
Client() client.APIClient
49-
Out() *streams.OutStream
49+
Out() *streams.Out
5050
Err() io.Writer
51-
In() *streams.InStream
52-
SetIn(in *streams.InStream)
51+
In() *streams.In
52+
SetIn(in *streams.In)
5353
Apply(ops ...DockerCliOption) error
5454
ConfigFile() *configfile.ConfigFile
5555
ServerInfo() ServerInfo
@@ -70,8 +70,8 @@ type Cli interface {
7070
// Instances of the client can be returned from NewDockerCli.
7171
type DockerCli struct {
7272
configFile *configfile.ConfigFile
73-
in *streams.InStream
74-
out *streams.OutStream
73+
in *streams.In
74+
out *streams.Out
7575
err io.Writer
7676
client client.APIClient
7777
serverInfo ServerInfo
@@ -100,7 +100,7 @@ func (cli *DockerCli) Client() client.APIClient {
100100
}
101101

102102
// Out returns the writer used for stdout
103-
func (cli *DockerCli) Out() *streams.OutStream {
103+
func (cli *DockerCli) Out() *streams.Out {
104104
return cli.out
105105
}
106106

@@ -110,12 +110,12 @@ func (cli *DockerCli) Err() io.Writer {
110110
}
111111

112112
// SetIn sets the reader used for stdin
113-
func (cli *DockerCli) SetIn(in *streams.InStream) {
113+
func (cli *DockerCli) SetIn(in *streams.In) {
114114
cli.in = in
115115
}
116116

117117
// In returns the reader used for stdin
118-
func (cli *DockerCli) In() *streams.InStream {
118+
func (cli *DockerCli) In() *streams.In {
119119
return cli.in
120120
}
121121

cli/command/cli_options.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func WithStandardStreams() DockerCliOption {
1818
return func(cli *DockerCli) error {
1919
// Set terminal emulation based on platform as required.
2020
stdin, stdout, stderr := term.StdStreams()
21-
cli.in = streams.NewInStream(stdin)
22-
cli.out = streams.NewOutStream(stdout)
21+
cli.in = streams.NewIn(stdin)
22+
cli.out = streams.NewOut(stdout)
2323
cli.err = stderr
2424
return nil
2525
}
@@ -28,7 +28,7 @@ func WithStandardStreams() DockerCliOption {
2828
// WithCombinedStreams uses the same stream for the output and error streams.
2929
func WithCombinedStreams(combined io.Writer) DockerCliOption {
3030
return func(cli *DockerCli) error {
31-
cli.out = streams.NewOutStream(combined)
31+
cli.out = streams.NewOut(combined)
3232
cli.err = combined
3333
return nil
3434
}
@@ -37,15 +37,15 @@ func WithCombinedStreams(combined io.Writer) DockerCliOption {
3737
// WithInputStream sets a cli input stream.
3838
func WithInputStream(in io.ReadCloser) DockerCliOption {
3939
return func(cli *DockerCli) error {
40-
cli.in = streams.NewInStream(in)
40+
cli.in = streams.NewIn(in)
4141
return nil
4242
}
4343
}
4444

4545
// WithOutputStream sets a cli output stream.
4646
func WithOutputStream(out io.Writer) DockerCliOption {
4747
return func(cli *DockerCli) error {
48-
cli.out = streams.NewOutStream(out)
48+
cli.out = streams.NewOut(out)
4949
return nil
5050
}
5151
}

cli/command/context/export-import_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestExportImportPipe(t *testing.T) {
5353
dest: "-",
5454
}))
5555
assert.Equal(t, cli.ErrBuffer().String(), "")
56-
cli.SetIn(streams.NewInStream(ioutil.NopCloser(bytes.NewBuffer(cli.OutBuffer().Bytes()))))
56+
cli.SetIn(streams.NewIn(ioutil.NopCloser(bytes.NewBuffer(cli.OutBuffer().Bytes()))))
5757
cli.OutBuffer().Reset()
5858
cli.ErrBuffer().Reset()
5959
assert.NilError(t, runImport(cli, "test2", "-"))

cli/command/image/build_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestRunBuildDockerfileFromStdinWithCompress(t *testing.T) {
3939
FROM alpine:3.6
4040
COPY foo /
4141
`)
42-
cli.SetIn(streams.NewInStream(ioutil.NopCloser(dockerfile)))
42+
cli.SetIn(streams.NewIn(ioutil.NopCloser(dockerfile)))
4343

4444
dir := fs.NewDir(t, t.Name(),
4545
fs.WithFile("foo", "some content"))

cli/command/image/trust.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth tru
297297

298298
out := cli.Out()
299299
if opts.quiet {
300-
out = streams.NewOutStream(ioutil.Discard)
300+
out = streams.NewOut(ioutil.Discard)
301301
}
302302
return jsonmessage.DisplayJSONMessagesToStream(responseBody, out, nil)
303303
}

cli/command/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func GetDefaultAuthConfig(cli Cli, checkCredStore bool, serverAddress string, is
102102
func ConfigureAuth(cli Cli, flUser, flPassword string, authconfig *types.AuthConfig, isDefaultRegistry bool) error {
103103
// On Windows, force the use of the regular OS stdin stream. Fixes #14336/#14210
104104
if runtime.GOOS == "windows" {
105-
cli.SetIn(streams.NewInStream(os.Stdin))
105+
cli.SetIn(streams.NewIn(os.Stdin))
106106
}
107107

108108
// Some links documenting this:

cli/command/stack/kubernetes/deploy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func metaStateFromStatus(status serviceStatus) metaServiceState {
104104
}
105105

106106
type forwardOnlyStatusDisplay struct {
107-
o *streams.OutStream
107+
o *streams.Out
108108
states map[string]metaServiceState
109109
}
110110

@@ -117,7 +117,7 @@ func (d *forwardOnlyStatusDisplay) OnStatus(status serviceStatus) {
117117
}
118118

119119
type interactiveStatusDisplay struct {
120-
o *streams.OutStream
120+
o *streams.Out
121121
statuses []serviceStatus
122122
}
123123

@@ -150,7 +150,7 @@ func displayInteractiveServiceStatus(status serviceStatus, o io.Writer) {
150150
status.podsReady, status.podsPending, totalFailed, status.podsTotal)
151151
}
152152

153-
func newStatusDisplay(o *streams.OutStream) statusDisplay {
153+
func newStatusDisplay(o *streams.Out) statusDisplay {
154154
if !o.IsTerminal() {
155155
return &forwardOnlyStatusDisplay{o: o, states: map[string]metaServiceState{}}
156156
}

cli/command/streams.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package command
2+
3+
import (
4+
"github.com/docker/cli/cli/streams"
5+
)
6+
7+
// InStream is an input stream used by the DockerCli to read user input
8+
// Deprecated: Use github.com/docker/cli/cli/streams.In instead
9+
type InStream = streams.In
10+
11+
// OutStream is an output stream used by the DockerCli to write normal program
12+
// output.
13+
// Deprecated: Use github.com/docker/cli/cli/streams.Out instead
14+
type OutStream = streams.Out
15+
16+
var (
17+
// NewInStream returns a new InStream object from a ReadCloser
18+
// Deprecated: Use github.com/docker/cli/cli/streams.NewIn instead
19+
NewInStream = streams.NewIn
20+
// NewOutStream returns a new OutStream object from a Writer
21+
// Deprecated: Use github.com/docker/cli/cli/streams.NewOut instead
22+
NewOutStream = streams.NewOut
23+
)

cli/command/swarm/unlock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func runUnlock(dockerCli command.Cli) error {
6060
return client.SwarmUnlock(ctx, req)
6161
}
6262

63-
func readKey(in *streams.InStream, prompt string) (string, error) {
63+
func readKey(in *streams.In, prompt string) (string, error) {
6464
if in.IsTerminal() {
6565
fmt.Print(prompt)
6666
dt, err := terminal.ReadPassword(int(in.FD()))

cli/command/swarm/unlock_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestSwarmUnlock(t *testing.T) {
9292
return nil
9393
},
9494
})
95-
dockerCli.SetIn(streams.NewInStream(ioutil.NopCloser(strings.NewReader(input))))
95+
dockerCli.SetIn(streams.NewIn(ioutil.NopCloser(strings.NewReader(input))))
9696
cmd := newUnlockCommand(dockerCli)
9797
assert.NilError(t, cmd.Execute())
9898
}

0 commit comments

Comments
 (0)