From 89fce5b1d35e9ee74e3d620565082b177b6149fb Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 6 Mar 2019 11:00:09 +0800 Subject: [PATCH] chore(variable): change UserName to Username Signed-off-by: Bo-Yi Wu --- main.go | 2 +- plugin.go | 4 ++-- plugin_test.go | 36 ++++++++++++++++++------------------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/main.go b/main.go index ac19934..4c3df91 100644 --- a/main.go +++ b/main.go @@ -195,7 +195,7 @@ func run(c *cli.Context) error { Config: Config{ Key: c.String("ssh-key"), KeyPath: c.String("key-path"), - UserName: c.String("user"), + Username: c.String("user"), Password: c.String("password"), Host: c.StringSlice("host"), Port: c.Int("port"), diff --git a/plugin.go b/plugin.go index 36a524c..1e29264 100644 --- a/plugin.go +++ b/plugin.go @@ -25,7 +25,7 @@ type ( Config struct { Key string KeyPath string - UserName string + Username string Password string Host []string Port int @@ -55,7 +55,7 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) { // Create MakeConfig instance with remote username, server address and path to private key. ssh := &easyssh.MakeConfig{ Server: host, - User: p.Config.UserName, + User: p.Config.Username, Password: p.Config.Password, Port: strconv.Itoa(p.Config.Port), Key: p.Config.Key, diff --git a/plugin_test.go b/plugin_test.go index 1067328..b9cb43f 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -23,7 +23,7 @@ func TestMissingKeyOrPassword(t *testing.T) { plugin := Plugin{ Config{ Host: []string{"localhost"}, - UserName: "ubuntu", + Username: "ubuntu", }, os.Stdout, } @@ -38,7 +38,7 @@ func TestSetPasswordAndKey(t *testing.T) { plugin := Plugin{ Config{ Host: []string{"localhost"}, - UserName: "ubuntu", + Username: "ubuntu", Password: "1234", Key: "1234", }, @@ -55,7 +55,7 @@ func TestIncorrectPassword(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, Password: "123456", Script: []string{"whoami"}, @@ -71,7 +71,7 @@ func TestSSHScriptFromRawKey(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, CommandTimeout: 60, Key: `-----BEGIN RSA PRIVATE KEY----- @@ -114,7 +114,7 @@ func TestSSHScriptFromKeyFile(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost", "127.0.0.1"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{"whoami", "ls -al"}, @@ -130,7 +130,7 @@ func TestStreamFromSSHCommand(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost", "127.0.0.1"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{"whoami", "for i in {1..5}; do echo ${i}; sleep 1; done", "echo 'done'"}, @@ -146,7 +146,7 @@ func TestSSHScriptWithError(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost", "127.0.0.1"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{"exit 1"}, @@ -163,7 +163,7 @@ func TestSSHCommandTimeOut(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{"sleep 5"}, @@ -179,7 +179,7 @@ func TestProxyCommand(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{"whoami"}, @@ -201,7 +201,7 @@ func TestSSHCommandError(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{"mkdir a", "mkdir a"}, @@ -217,7 +217,7 @@ func TestSSHCommandExitCodeError(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{ @@ -240,7 +240,7 @@ func TestSetENV(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Secrets: []string{"FOO"}, @@ -267,7 +267,7 @@ func TestSetExistingENV(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Secrets: []string{"FOO"}, @@ -292,7 +292,7 @@ func TestSyncMode(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost", "127.0.0.1"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{"whoami", "for i in {1..3}; do echo ${i}; sleep 1; done", "echo 'done'"}, @@ -363,7 +363,7 @@ func TestCommandOutput(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost", "127.0.0.1"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{ @@ -398,7 +398,7 @@ func TestScriptStop(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{ @@ -433,7 +433,7 @@ func TestNoneScriptStop(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Script: []string{ @@ -494,7 +494,7 @@ func TestEnvOutput(t *testing.T) { plugin := Plugin{ Config: Config{ Host: []string{"localhost"}, - UserName: "drone-scp", + Username: "drone-scp", Port: 22, KeyPath: "./tests/.ssh/id_rsa", Envs: []string{"env_1", "env_2", "env_3", "env_4", "env_5", "env_6", "env_7"},