From 4a649cfe45de8d7aa693574ab9d32c709328953d Mon Sep 17 00:00:00 2001 From: appleboy Date: Sun, 27 Apr 2025 09:46:02 +0800 Subject: [PATCH] refactor: refactor SSH authentication handling with switch statement - Refactor if-else logic to a switch statement for handling SSH authentication methods Signed-off-by: appleboy --- plugin_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin_test.go b/plugin_test.go index f32b6b8..78e3354 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -974,9 +974,10 @@ func runSSHContainerTest(t *testing.T, cfg SSHTestConfig) { if pluginCfg.CommandTimeout == 0 { pluginCfg.CommandTimeout = 10 * time.Second } - if cfg.AuthMethod == "key" { + switch cfg.AuthMethod { + case "key": pluginCfg.KeyPath = cfg.KeyPath - } else if cfg.AuthMethod == "password" { + case "password": pluginCfg.Password = cfg.Password }