Skip to content

Commit

Permalink
inttest: use variadic args for GetJoinToken
Browse files Browse the repository at this point in the history
Signed-off-by: Natanael Copa <[email protected]>
  • Loading branch information
ncopa authored and jnummelin committed Mar 29, 2021
1 parent be522d5 commit 6310751
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion inttest/byocri/byocri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 3 additions & 7 deletions inttest/common/footloosesuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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)
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion inttest/hacontrolplane/hacontrolplane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion inttest/multicontroller/multicontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 6310751

Please sign in to comment.