Skip to content

Commit

Permalink
Remove --config flag from token command
Browse files Browse the repository at this point in the history
This commit removes the config flag to comply with the changes in
k0sproject/k0s#1409

Signed-off-by: Karen Almog <[email protected]>
  • Loading branch information
Karen Almog committed Jan 20, 2022
1 parent bbd575c commit 99ee017
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,17 @@ func (k *K0s) SetDefaults() {

// GenerateToken runs the k0s token create command
func (k K0s) GenerateToken(h *Host, role string, expiry time.Duration) (token string, err error) {
var tokenCreateCmd string
out, err := h.ExecOutput(h.Configurer.K0sCmdf("token create --help"), exec.Sudo(h))
if err == nil && strings.Contains(out, "--config") {
tokenCreateCmd = fmt.Sprintf("token create --config %s --role %s --expiry %s", h.K0sConfigPath(), role, expiry.String())
} else {
tokenCreateCmd = fmt.Sprintf("token create --role %s --expiry %s", role, expiry.String())
}

err = retry.Do(
func() error {
output, err := h.ExecOutput(h.Configurer.K0sCmdf("token create --config %s --role %s --expiry %s", h.K0sConfigPath(), role, expiry.String()), exec.HideOutput(), exec.Sudo(h))
output, err := h.ExecOutput(h.Configurer.K0sCmdf(tokenCreateCmd), exec.HideOutput(), exec.Sudo(h))
if err != nil {
return err
}
Expand Down

0 comments on commit 99ee017

Please sign in to comment.