mirror of https://github.com/docker/cli.git
Rename NewConfigFile to New in configfile package
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
62dfbef4d8
commit
105b21d1ab
|
@ -36,6 +36,7 @@ type Cli interface {
|
||||||
In() *InStream
|
In() *InStream
|
||||||
SetIn(in *InStream)
|
SetIn(in *InStream)
|
||||||
ConfigFile() *configfile.ConfigFile
|
ConfigFile() *configfile.ConfigFile
|
||||||
|
ServerInfo() ServerInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// DockerCli is an instance the docker command line client.
|
// DockerCli is an instance the docker command line client.
|
||||||
|
|
|
@ -26,11 +26,11 @@ import (
|
||||||
|
|
||||||
const clientSessionRemote = "client-session"
|
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")
|
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
|
var s *session.Session
|
||||||
if isSessionSupported(dockerCli) {
|
if isSessionSupported(dockerCli) {
|
||||||
sharedKey, err := getBuildSharedKey(contextDir)
|
sharedKey, err := getBuildSharedKey(contextDir)
|
||||||
|
|
|
@ -43,7 +43,7 @@ func TestNewPullCommandErrors(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
cli := test.NewFakeCli(&fakeClient{}, buf)
|
cli := test.NewFakeCli(&fakeClient{}, buf)
|
||||||
cli.SetConfigfile(configfile.NewConfigFile("filename"))
|
cli.SetConfigfile(configfile.New("filename"))
|
||||||
cmd := NewPullCommand(cli)
|
cmd := NewPullCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
@ -68,7 +68,7 @@ func TestNewPullCommandSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
cli := test.NewFakeCli(&fakeClient{}, buf)
|
cli := test.NewFakeCli(&fakeClient{}, buf)
|
||||||
cli.SetConfigfile(configfile.NewConfigFile("filename"))
|
cli.SetConfigfile(configfile.New("filename"))
|
||||||
cmd := NewPullCommand(cli)
|
cmd := NewPullCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
@ -49,7 +49,7 @@ func TestNewPushCommandErrors(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc}, buf)
|
cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc}, buf)
|
||||||
cli.SetConfigfile(configfile.NewConfigFile("filename"))
|
cli.SetConfigfile(configfile.New("filename"))
|
||||||
cmd := NewPushCommand(cli)
|
cmd := NewPushCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
@ -74,7 +74,7 @@ func TestNewPushCommandSuccess(t *testing.T) {
|
||||||
return ioutil.NopCloser(strings.NewReader("")), nil
|
return ioutil.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
}, buf)
|
}, buf)
|
||||||
cli.SetConfigfile(configfile.NewConfigFile("filename"))
|
cli.SetConfigfile(configfile.New("filename"))
|
||||||
cmd := NewPushCommand(cli)
|
cmd := NewPushCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
|
|
|
@ -69,7 +69,7 @@ func Load(configDir string) (*configfile.ConfigFile, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := filepath.Join(configDir, ConfigFileName)
|
filename := filepath.Join(configDir, ConfigFileName)
|
||||||
configFile := configfile.NewConfigFile(filename)
|
configFile := configfile.New(filename)
|
||||||
|
|
||||||
// Try happy path first - latest config file
|
// Try happy path first - latest config file
|
||||||
if _, err := os.Stat(filename); err == nil {
|
if _, err := os.Stat(filename); err == nil {
|
||||||
|
|
|
@ -540,7 +540,7 @@ func TestLoadDefaultConfigFile(t *testing.T) {
|
||||||
|
|
||||||
configFile := LoadDefaultConfigFile(buffer)
|
configFile := LoadDefaultConfigFile(buffer)
|
||||||
credStore := credentials.DetectDefaultStore("")
|
credStore := credentials.DetectDefaultStore("")
|
||||||
expected := configfile.NewConfigFile(filename)
|
expected := configfile.New(filename)
|
||||||
expected.CredentialsStore = credStore
|
expected.CredentialsStore = credStore
|
||||||
expected.PsFormat = "format"
|
expected.PsFormat = "format"
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ type ProxyConfig struct {
|
||||||
FTPProxy string `json:"ftpProxy,omitempty"`
|
FTPProxy string `json:"ftpProxy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfigFile initializes an empty configuration file for the given filename 'fn'
|
// New initializes an empty configuration file for the given filename 'fn'
|
||||||
func NewConfigFile(fn string) *ConfigFile {
|
func New(fn string) *ConfigFile {
|
||||||
return &ConfigFile{
|
return &ConfigFile{
|
||||||
AuthConfigs: make(map[string]types.AuthConfig),
|
AuthConfigs: make(map[string]types.AuthConfig),
|
||||||
HTTPHeaders: make(map[string]string),
|
HTTPHeaders: make(map[string]string),
|
||||||
|
|
|
@ -137,13 +137,13 @@ func TestProxyConfigPerHost(t *testing.T) {
|
||||||
|
|
||||||
func TestConfigFile(t *testing.T) {
|
func TestConfigFile(t *testing.T) {
|
||||||
configFilename := "configFilename"
|
configFilename := "configFilename"
|
||||||
configFile := NewConfigFile(configFilename)
|
configFile := New(configFilename)
|
||||||
|
|
||||||
assert.Equal(t, configFilename, configFile.Filename)
|
assert.Equal(t, configFilename, configFile.Filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAllCredentials(t *testing.T) {
|
func TestGetAllCredentials(t *testing.T) {
|
||||||
configFile := NewConfigFile("filename")
|
configFile := New("filename")
|
||||||
exampleAuth := types.AuthConfig{
|
exampleAuth := types.AuthConfig{
|
||||||
Username: "user",
|
Username: "user",
|
||||||
Password: "pass",
|
Password: "pass",
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
"github.com/docker/cli/cli/config/credentials"
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,7 +18,6 @@ type FakeCli struct {
|
||||||
out *command.OutStream
|
out *command.OutStream
|
||||||
err io.Writer
|
err io.Writer
|
||||||
in *command.InStream
|
in *command.InStream
|
||||||
store credentials.Store
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFakeCli returns a Cli backed by the fakeCli
|
// NewFakeCli returns a Cli backed by the fakeCli
|
||||||
|
|
Loading…
Reference in New Issue