From 105b21d1abf0bb08c67b123118fe6e1a95379984 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 27 Jun 2017 16:31:38 +0200 Subject: [PATCH] Rename NewConfigFile to New in configfile package Signed-off-by: Vincent Demeester --- cli/command/cli.go | 1 + cli/command/image/build_session.go | 4 ++-- cli/command/image/pull_test.go | 4 ++-- cli/command/image/push_test.go | 4 ++-- cli/config/config.go | 2 +- cli/config/config_test.go | 2 +- cli/config/configfile/file.go | 4 ++-- cli/config/configfile/file_test.go | 4 ++-- cli/internal/test/cli.go | 2 -- 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index 885859abc9..e9b274f5ec 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -36,6 +36,7 @@ type Cli interface { In() *InStream SetIn(in *InStream) ConfigFile() *configfile.ConfigFile + ServerInfo() ServerInfo } // DockerCli is an instance the docker command line client. diff --git a/cli/command/image/build_session.go b/cli/command/image/build_session.go index c010c0ea0b..86fe95782e 100644 --- a/cli/command/image/build_session.go +++ b/cli/command/image/build_session.go @@ -26,11 +26,11 @@ import ( const clientSessionRemote = "client-session" -func isSessionSupported(dockerCli *command.DockerCli) bool { +func isSessionSupported(dockerCli command.Cli) bool { return dockerCli.ServerInfo().HasExperimental && versions.GreaterThanOrEqualTo(dockerCli.Client().ClientVersion(), "1.31") } -func trySession(dockerCli *command.DockerCli, contextDir string) (*session.Session, error) { +func trySession(dockerCli command.Cli, contextDir string) (*session.Session, error) { var s *session.Session if isSessionSupported(dockerCli) { sharedKey, err := getBuildSharedKey(contextDir) diff --git a/cli/command/image/pull_test.go b/cli/command/image/pull_test.go index 731c774a1c..690e6222eb 100644 --- a/cli/command/image/pull_test.go +++ b/cli/command/image/pull_test.go @@ -43,7 +43,7 @@ func TestNewPullCommandErrors(t *testing.T) { for _, tc := range testCases { buf := new(bytes.Buffer) cli := test.NewFakeCli(&fakeClient{}, buf) - cli.SetConfigfile(configfile.NewConfigFile("filename")) + cli.SetConfigfile(configfile.New("filename")) cmd := NewPullCommand(cli) cmd.SetOutput(ioutil.Discard) cmd.SetArgs(tc.args) @@ -68,7 +68,7 @@ func TestNewPullCommandSuccess(t *testing.T) { for _, tc := range testCases { buf := new(bytes.Buffer) cli := test.NewFakeCli(&fakeClient{}, buf) - cli.SetConfigfile(configfile.NewConfigFile("filename")) + cli.SetConfigfile(configfile.New("filename")) cmd := NewPullCommand(cli) cmd.SetOutput(ioutil.Discard) cmd.SetArgs(tc.args) diff --git a/cli/command/image/push_test.go b/cli/command/image/push_test.go index f02e0407d6..f2c35dee21 100644 --- a/cli/command/image/push_test.go +++ b/cli/command/image/push_test.go @@ -49,7 +49,7 @@ func TestNewPushCommandErrors(t *testing.T) { for _, tc := range testCases { buf := new(bytes.Buffer) cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc}, buf) - cli.SetConfigfile(configfile.NewConfigFile("filename")) + cli.SetConfigfile(configfile.New("filename")) cmd := NewPushCommand(cli) cmd.SetOutput(ioutil.Discard) cmd.SetArgs(tc.args) @@ -74,7 +74,7 @@ func TestNewPushCommandSuccess(t *testing.T) { return ioutil.NopCloser(strings.NewReader("")), nil }, }, buf) - cli.SetConfigfile(configfile.NewConfigFile("filename")) + cli.SetConfigfile(configfile.New("filename")) cmd := NewPushCommand(cli) cmd.SetOutput(ioutil.Discard) cmd.SetArgs(tc.args) diff --git a/cli/config/config.go b/cli/config/config.go index 5e638a519f..90529ebd4c 100644 --- a/cli/config/config.go +++ b/cli/config/config.go @@ -69,7 +69,7 @@ func Load(configDir string) (*configfile.ConfigFile, error) { } filename := filepath.Join(configDir, ConfigFileName) - configFile := configfile.NewConfigFile(filename) + configFile := configfile.New(filename) // Try happy path first - latest config file if _, err := os.Stat(filename); err == nil { diff --git a/cli/config/config_test.go b/cli/config/config_test.go index 1248913c5e..c885d3e724 100644 --- a/cli/config/config_test.go +++ b/cli/config/config_test.go @@ -540,7 +540,7 @@ func TestLoadDefaultConfigFile(t *testing.T) { configFile := LoadDefaultConfigFile(buffer) credStore := credentials.DetectDefaultStore("") - expected := configfile.NewConfigFile(filename) + expected := configfile.New(filename) expected.CredentialsStore = credStore expected.PsFormat = "format" diff --git a/cli/config/configfile/file.go b/cli/config/configfile/file.go index d599cc5aa9..babd63693b 100644 --- a/cli/config/configfile/file.go +++ b/cli/config/configfile/file.go @@ -54,8 +54,8 @@ type ProxyConfig struct { FTPProxy string `json:"ftpProxy,omitempty"` } -// NewConfigFile initializes an empty configuration file for the given filename 'fn' -func NewConfigFile(fn string) *ConfigFile { +// New initializes an empty configuration file for the given filename 'fn' +func New(fn string) *ConfigFile { return &ConfigFile{ AuthConfigs: make(map[string]types.AuthConfig), HTTPHeaders: make(map[string]string), diff --git a/cli/config/configfile/file_test.go b/cli/config/configfile/file_test.go index 4e24009777..f2a61b1794 100644 --- a/cli/config/configfile/file_test.go +++ b/cli/config/configfile/file_test.go @@ -137,13 +137,13 @@ func TestProxyConfigPerHost(t *testing.T) { func TestConfigFile(t *testing.T) { configFilename := "configFilename" - configFile := NewConfigFile(configFilename) + configFile := New(configFilename) assert.Equal(t, configFilename, configFile.Filename) } func TestGetAllCredentials(t *testing.T) { - configFile := NewConfigFile("filename") + configFile := New("filename") exampleAuth := types.AuthConfig{ Username: "user", Password: "pass", diff --git a/cli/internal/test/cli.go b/cli/internal/test/cli.go index fa77a86a31..9565ae8e2d 100644 --- a/cli/internal/test/cli.go +++ b/cli/internal/test/cli.go @@ -7,7 +7,6 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/config/configfile" - "github.com/docker/cli/cli/config/credentials" "github.com/docker/docker/client" ) @@ -19,7 +18,6 @@ type FakeCli struct { out *command.OutStream err io.Writer in *command.InStream - store credentials.Store } // NewFakeCli returns a Cli backed by the fakeCli