mirror of https://github.com/k3s-io/k3s
Add K3S_DATA_DIR as env var for --data-dir flag
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>pull/10647/head
parent
a26a5ab1d7
commit
9111b1f77e
|
@ -86,11 +86,14 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
// findDataDir reads data-dir settings from the CLI args and config file.
|
||||
// findDataDir reads data-dir settings from the environment, CLI args, and config file.
|
||||
// If not found, the default will be used, which varies depending on whether
|
||||
// k3s is being run as root or not.
|
||||
func findDataDir(args []string) string {
|
||||
var dataDir string
|
||||
dataDir := os.Getenv(version.ProgramUpper + "_DATA_DIR")
|
||||
if dataDir != "" {
|
||||
return dataDir
|
||||
}
|
||||
fs := pflag.NewFlagSet("data-dir-set", pflag.ContinueOnError)
|
||||
fs.ParseErrorsWhitelist.UnknownFlags = true
|
||||
fs.SetOutput(io.Discard)
|
||||
|
|
|
@ -266,11 +266,14 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
|
|||
EnvVar: version.ProgramUpper + "_URL",
|
||||
Destination: &AgentConfig.ServerURL,
|
||||
},
|
||||
// Note that this is different from DataDirFlag used elswhere in the CLI,
|
||||
// as this is bound to AgentConfig instead of ServerConfig.
|
||||
&cli.StringFlag{
|
||||
Name: "data-dir,d",
|
||||
Usage: "(agent/data) Folder to hold state",
|
||||
Destination: &AgentConfig.DataDir,
|
||||
Value: "/var/lib/rancher/" + version.Program + "",
|
||||
EnvVar: version.ProgramUpper + "_DATA_DIR",
|
||||
},
|
||||
NodeNameFlag,
|
||||
WithNodeIDFlag,
|
||||
|
|
|
@ -28,6 +28,7 @@ var (
|
|||
},
|
||||
}
|
||||
CertRotateCACommandFlags = []cli.Flag{
|
||||
DataDirFlag,
|
||||
cli.StringFlag{
|
||||
Name: "server,s",
|
||||
Usage: "(cluster) Server to connect to",
|
||||
|
@ -35,11 +36,6 @@ var (
|
|||
Value: "https://127.0.0.1:6443",
|
||||
Destination: &ServerConfig.ServerURL,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "data-dir,d",
|
||||
Usage: "(data) Folder to hold state default /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root",
|
||||
Destination: &ServerConfig.DataDir,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "path",
|
||||
Usage: "Path to directory containing new CA certificates",
|
||||
|
|
|
@ -41,10 +41,7 @@ func NewApp() *cli.App {
|
|||
}
|
||||
app.Flags = []cli.Flag{
|
||||
DebugFlag,
|
||||
&cli.StringFlag{
|
||||
Name: "data-dir,d",
|
||||
Usage: "(data) Folder to hold state (default: /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root)",
|
||||
},
|
||||
DataDirFlag,
|
||||
}
|
||||
|
||||
return app
|
||||
|
|
|
@ -117,6 +117,7 @@ var (
|
|||
Name: "data-dir,d",
|
||||
Usage: "(data) Folder to hold state default /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root",
|
||||
Destination: &ServerConfig.DataDir,
|
||||
EnvVar: version.ProgramUpper + "_DATA_DIR",
|
||||
}
|
||||
ServerToken = &cli.StringFlag{
|
||||
Name: "token,t",
|
||||
|
|
Loading…
Reference in New Issue