[Release-1.21] Add --server flag to k3s secrets-encrypt (#5054)

* Add server flag to access nonlocal/nondefault k3s server (#5016)

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Update gitignore

Signed-off-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
Derek Nola
2022-02-01 10:45:00 -08:00
committed by GitHub
parent 03bba66760
commit 42bc5612ff
3 changed files with 9 additions and 4 deletions

2
.gitignore vendored
View File

@@ -3,7 +3,7 @@
/.tags
/.idea
/.trash-cache
/.vagrant
.vagrant/
/.kube
/.cache
/.docker

View File

@@ -1,6 +1,7 @@
package cmds
import (
"github.com/rancher/k3s/pkg/version"
"github.com/urfave/cli"
)
@@ -9,6 +10,13 @@ const SecretsEncryptCommand = "secrets-encrypt"
var EncryptFlags = []cli.Flag{
DataDirFlag,
ServerToken,
cli.StringFlag{
Name: "server, s",
Usage: "(cluster) Server to connect to",
EnvVar: version.ProgramUpper + "_URL",
Value: "https://127.0.0.1:6443",
Destination: &ServerConfig.ServerURL,
},
}
func NewSecretsEncryptCommand(action func(*cli.Context) error, subcommands []cli.Command) cli.Command {

View File

@@ -31,9 +31,6 @@ func commandPrep(app *cli.Context, cfg *cmds.Server) (config.Control, *clientacc
if err != nil {
return controlConfig, nil, err
}
if cfg.ServerURL == "" {
cfg.ServerURL = "https://127.0.0.1:6443"
}
if cfg.Token == "" {
fp := filepath.Join(controlConfig.DataDir, "token")