Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
02931187
Commit
02931187
authored
Jul 29, 2024
by
Brad Davidson
Committed by
Brad Davidson
Jul 29, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add K3S_DATA_DIR as env var for --data-dir flag
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
55211a46
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
11 deletions
+11
-11
main.go
cmd/k3s/main.go
+5
-2
agent.go
pkg/cli/cmds/agent.go
+3
-0
certs.go
pkg/cli/cmds/certs.go
+1
-5
root.go
pkg/cli/cmds/root.go
+1
-4
server.go
pkg/cli/cmds/server.go
+1
-0
No files found.
cmd/k3s/main.go
View file @
02931187
...
@@ -86,11 +86,14 @@ func main() {
...
@@ -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
// If not found, the default will be used, which varies depending on whether
// k3s is being run as root or not.
// k3s is being run as root or not.
func
findDataDir
(
args
[]
string
)
string
{
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
:=
pflag
.
NewFlagSet
(
"data-dir-set"
,
pflag
.
ContinueOnError
)
fs
.
ParseErrorsWhitelist
.
UnknownFlags
=
true
fs
.
ParseErrorsWhitelist
.
UnknownFlags
=
true
fs
.
SetOutput
(
io
.
Discard
)
fs
.
SetOutput
(
io
.
Discard
)
...
...
pkg/cli/cmds/agent.go
View file @
02931187
...
@@ -266,11 +266,14 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
...
@@ -266,11 +266,14 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
EnvVar
:
version
.
ProgramUpper
+
"_URL"
,
EnvVar
:
version
.
ProgramUpper
+
"_URL"
,
Destination
:
&
AgentConfig
.
ServerURL
,
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
{
&
cli
.
StringFlag
{
Name
:
"data-dir,d"
,
Name
:
"data-dir,d"
,
Usage
:
"(agent/data) Folder to hold state"
,
Usage
:
"(agent/data) Folder to hold state"
,
Destination
:
&
AgentConfig
.
DataDir
,
Destination
:
&
AgentConfig
.
DataDir
,
Value
:
"/var/lib/rancher/"
+
version
.
Program
+
""
,
Value
:
"/var/lib/rancher/"
+
version
.
Program
+
""
,
EnvVar
:
version
.
ProgramUpper
+
"_DATA_DIR"
,
},
},
NodeNameFlag
,
NodeNameFlag
,
WithNodeIDFlag
,
WithNodeIDFlag
,
...
...
pkg/cli/cmds/certs.go
View file @
02931187
...
@@ -28,6 +28,7 @@ var (
...
@@ -28,6 +28,7 @@ var (
},
},
}
}
CertRotateCACommandFlags
=
[]
cli
.
Flag
{
CertRotateCACommandFlags
=
[]
cli
.
Flag
{
DataDirFlag
,
cli
.
StringFlag
{
cli
.
StringFlag
{
Name
:
"server,s"
,
Name
:
"server,s"
,
Usage
:
"(cluster) Server to connect to"
,
Usage
:
"(cluster) Server to connect to"
,
...
@@ -36,11 +37,6 @@ var (
...
@@ -36,11 +37,6 @@ var (
Destination
:
&
ServerConfig
.
ServerURL
,
Destination
:
&
ServerConfig
.
ServerURL
,
},
},
cli
.
StringFlag
{
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"
,
Name
:
"path"
,
Usage
:
"Path to directory containing new CA certificates"
,
Usage
:
"Path to directory containing new CA certificates"
,
Destination
:
&
CertRotateCAConfig
.
CACertPath
,
Destination
:
&
CertRotateCAConfig
.
CACertPath
,
...
...
pkg/cli/cmds/root.go
View file @
02931187
...
@@ -41,10 +41,7 @@ func NewApp() *cli.App {
...
@@ -41,10 +41,7 @@ func NewApp() *cli.App {
}
}
app
.
Flags
=
[]
cli
.
Flag
{
app
.
Flags
=
[]
cli
.
Flag
{
DebugFlag
,
DebugFlag
,
&
cli
.
StringFlag
{
DataDirFlag
,
Name
:
"data-dir,d"
,
Usage
:
"(data) Folder to hold state (default: /var/lib/rancher/"
+
version
.
Program
+
" or ${HOME}/.rancher/"
+
version
.
Program
+
" if not root)"
,
},
}
}
return
app
return
app
...
...
pkg/cli/cmds/server.go
View file @
02931187
...
@@ -117,6 +117,7 @@ var (
...
@@ -117,6 +117,7 @@ var (
Name
:
"data-dir,d"
,
Name
:
"data-dir,d"
,
Usage
:
"(data) Folder to hold state default /var/lib/rancher/"
+
version
.
Program
+
" or ${HOME}/.rancher/"
+
version
.
Program
+
" if not root"
,
Usage
:
"(data) Folder to hold state default /var/lib/rancher/"
+
version
.
Program
+
" or ${HOME}/.rancher/"
+
version
.
Program
+
" if not root"
,
Destination
:
&
ServerConfig
.
DataDir
,
Destination
:
&
ServerConfig
.
DataDir
,
EnvVar
:
version
.
ProgramUpper
+
"_DATA_DIR"
,
}
}
ServerToken
=
&
cli
.
StringFlag
{
ServerToken
=
&
cli
.
StringFlag
{
Name
:
"token,t"
,
Name
:
"token,t"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment