From 6310751054ab6d0cf9175283c730f619863877a3 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 23 Mar 2021 13:48:38 +0100 Subject: [PATCH] inttest: use variadic args for GetJoinToken Signed-off-by: Natanael Copa --- inttest/byocri/byocri_test.go | 2 +- inttest/common/footloosesuite.go | 10 +++------- inttest/hacontrolplane/hacontrolplane_test.go | 2 +- inttest/multicontroller/multicontroller_test.go | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/inttest/byocri/byocri_test.go b/inttest/byocri/byocri_test.go index 920e940220bc..f94257b42d68 100644 --- a/inttest/byocri/byocri_test.go +++ b/inttest/byocri/byocri_test.go @@ -57,7 +57,7 @@ func (s *BYOCRISuite) TestK0sGetsUp() { } func (s *BYOCRISuite) runDockerWorker() error { - token, err := s.GetJoinToken("worker", "") + token, err := s.GetJoinToken("worker") if err != nil { return err } diff --git a/inttest/common/footloosesuite.go b/inttest/common/footloosesuite.go index 6e65a12367e8..b46ce8ed3e5d 100644 --- a/inttest/common/footloosesuite.go +++ b/inttest/common/footloosesuite.go @@ -211,10 +211,6 @@ func getDataDirOpt(args []string) string { return "" } -func getDataDir(args []string) string { - return strings.TrimPrefix(getDataDirOpt(args), "--data-dir=") -} - // InitController initializes a controller func (s *FootlooseSuite) InitController(idx int, k0sArgs ...string) error { controllerNode := s.ControllerNode(idx) @@ -235,7 +231,7 @@ func (s *FootlooseSuite) InitController(idx int, k0sArgs ...string) error { } // GetJoinToken generates join token for the asked role -func (s *FootlooseSuite) GetJoinToken(role string, dataDir string) (string, error) { +func (s *FootlooseSuite) GetJoinToken(role string, extraArgs ...string) (string, error) { // assume we have main on node 0 always controllerNode := s.ControllerNode(0) s.Contains([]string{"controller", "worker"}, role, "Bad role") @@ -244,7 +240,7 @@ func (s *FootlooseSuite) GetJoinToken(role string, dataDir string) (string, erro return "", err } defer ssh.Disconnect() - token, err := ssh.ExecWithOutput(fmt.Sprintf("k0s token create --role=%s --data-dir=%s", role, dataDir)) + token, err := ssh.ExecWithOutput(fmt.Sprintf("k0s token create --role=%s %s", role, strings.Join(extraArgs, " "))) if err != nil { return "", fmt.Errorf("can't get join token: %v", err) } @@ -262,7 +258,7 @@ func (s *FootlooseSuite) RunWorkers(args ...string) error { return err } defer ssh.Disconnect() - token, err := s.GetJoinToken("worker", getDataDir(args)) + token, err := s.GetJoinToken("worker", getDataDirOpt(args)) if err != nil { return err } diff --git a/inttest/hacontrolplane/hacontrolplane_test.go b/inttest/hacontrolplane/hacontrolplane_test.go index a26518e2189c..77311a82a2bc 100644 --- a/inttest/hacontrolplane/hacontrolplane_test.go +++ b/inttest/hacontrolplane/hacontrolplane_test.go @@ -65,7 +65,7 @@ func (s *HAControlplaneSuite) makeNodeLeave(executeOnControllerIdx int, peerAddr func (s *HAControlplaneSuite) TestDeregistration() { s.NoError(s.InitController(0)) - token, err := s.GetJoinToken("controller", "") + token, err := s.GetJoinToken("controller") s.NoError(err) s.NoError(s.InitController(1, token)) diff --git a/inttest/multicontroller/multicontroller_test.go b/inttest/multicontroller/multicontroller_test.go index ee1ff32e2f2f..592844e97eb0 100644 --- a/inttest/multicontroller/multicontroller_test.go +++ b/inttest/multicontroller/multicontroller_test.go @@ -47,7 +47,7 @@ func (s *MultiControllerSuite) TestK0sGetsUp() { s.PutFile(s.ControllerNode(0), "/tmp/k0s.yaml", fmt.Sprintf(k0sConfigWithMultiController, ipAddress)) s.NoError(s.InitController(0, "--config=/tmp/k0s.yaml")) - token, err := s.GetJoinToken("controller", "") + token, err := s.GetJoinToken("controller") s.NoError(err) s.PutFile(s.ControllerNode(1), "/tmp/k0s.yaml", fmt.Sprintf(k0sConfigWithMultiController, ipAddress)) s.NoError(s.InitController(1, "--config=/tmp/k0s.yaml", token))