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
4d35231b
Commit
4d35231b
authored
Apr 27, 2016
by
Patrick Baxter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/hyperkube: add make-symlinks flag
parent
3d435b56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
5 deletions
+39
-5
hyperkube.go
cmd/hyperkube/hyperkube.go
+38
-5
known-flags.txt
hack/verify-flags/known-flags.txt
+1
-0
No files found.
cmd/hyperkube/hyperkube.go
View file @
4d35231b
...
@@ -41,10 +41,11 @@ type HyperKube struct {
...
@@ -41,10 +41,11 @@ type HyperKube struct {
Name
string
// The executable name, used for help and soft-link invocation
Name
string
// The executable name, used for help and soft-link invocation
Long
string
// A long description of the binary. It will be world wrapped before output.
Long
string
// A long description of the binary. It will be world wrapped before output.
servers
[]
Server
servers
[]
Server
baseFlags
*
pflag
.
FlagSet
baseFlags
*
pflag
.
FlagSet
out
io
.
Writer
out
io
.
Writer
helpFlagVal
bool
helpFlagVal
bool
makeSymlinksFlagVal
bool
}
}
// AddServer adds a server to the HyperKube object.
// AddServer adds a server to the HyperKube object.
...
@@ -75,6 +76,8 @@ func (hk *HyperKube) Flags() *pflag.FlagSet {
...
@@ -75,6 +76,8 @@ func (hk *HyperKube) Flags() *pflag.FlagSet {
hk
.
baseFlags
.
SetOutput
(
ioutil
.
Discard
)
hk
.
baseFlags
.
SetOutput
(
ioutil
.
Discard
)
hk
.
baseFlags
.
SetNormalizeFunc
(
utilflag
.
WordSepNormalizeFunc
)
hk
.
baseFlags
.
SetNormalizeFunc
(
utilflag
.
WordSepNormalizeFunc
)
hk
.
baseFlags
.
BoolVarP
(
&
hk
.
helpFlagVal
,
"help"
,
"h"
,
false
,
"help for "
+
hk
.
Name
)
hk
.
baseFlags
.
BoolVarP
(
&
hk
.
helpFlagVal
,
"help"
,
"h"
,
false
,
"help for "
+
hk
.
Name
)
hk
.
baseFlags
.
BoolVar
(
&
hk
.
makeSymlinksFlagVal
,
"make-symlinks"
,
false
,
"create a symlink for each server in current directory"
)
hk
.
baseFlags
.
MarkHidden
(
"make-symlinks"
)
// hide this flag from appearing in servers' usage output
// These will add all of the "global" flags (defined with both the
// These will add all of the "global" flags (defined with both the
// flag and pflag packages) to the new flag set we have.
// flag and pflag packages) to the new flag set we have.
...
@@ -117,7 +120,8 @@ func (hk *HyperKube) Printf(format string, i ...interface{}) {
...
@@ -117,7 +120,8 @@ func (hk *HyperKube) Printf(format string, i ...interface{}) {
func
(
hk
*
HyperKube
)
Run
(
args
[]
string
)
error
{
func
(
hk
*
HyperKube
)
Run
(
args
[]
string
)
error
{
// If we are called directly, parse all flags up to the first real
// If we are called directly, parse all flags up to the first real
// argument. That should be the server to run.
// argument. That should be the server to run.
baseCommand
:=
path
.
Base
(
args
[
0
])
command
:=
args
[
0
]
baseCommand
:=
path
.
Base
(
command
)
serverName
:=
baseCommand
serverName
:=
baseCommand
if
serverName
==
hk
.
Name
{
if
serverName
==
hk
.
Name
{
args
=
args
[
1
:
]
args
=
args
[
1
:
]
...
@@ -133,6 +137,10 @@ func (hk *HyperKube) Run(args []string) error {
...
@@ -133,6 +137,10 @@ func (hk *HyperKube) Run(args []string) error {
return
err
return
err
}
}
if
hk
.
makeSymlinksFlagVal
{
return
hk
.
MakeSymlinks
(
command
)
}
verflag
.
PrintAndExitIfRequested
()
verflag
.
PrintAndExitIfRequested
()
args
=
baseFlags
.
Args
()
args
=
baseFlags
.
Args
()
...
@@ -200,7 +208,32 @@ Servers
...
@@ -200,7 +208,32 @@ Servers
{{range .Servers}}
{{range .Servers}}
{{.Name}}
{{.Name}}
{{.Long | trim | wrap " "}}{{end}}
{{.Long | trim | wrap " "}}{{end}}
Call '{{.Name}} --make-symlinks' to create symlinks for each server in the local directory.
Call '{{.Name}} <server> --help' for help on a specific server.
Call '{{.Name}} <server> --help' for help on a specific server.
`
`
util
.
ExecuteTemplate
(
hk
.
Out
(),
tt
,
hk
)
util
.
ExecuteTemplate
(
hk
.
Out
(),
tt
,
hk
)
}
}
// MakeSymlinks will create a symlink for each registered hyperkube server in the local directory.
func
(
hk
*
HyperKube
)
MakeSymlinks
(
command
string
)
error
{
wd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
return
err
}
var
errs
bool
for
_
,
s
:=
range
hk
.
servers
{
link
:=
path
.
Join
(
wd
,
s
.
Name
())
err
:=
os
.
Symlink
(
command
,
link
)
if
err
!=
nil
{
errs
=
true
hk
.
Println
(
err
)
}
}
if
errs
{
return
errors
.
New
(
"Error creating one or more symlinks."
)
}
return
nil
}
hack/verify-flags/known-flags.txt
View file @
4d35231b
...
@@ -232,6 +232,7 @@ lock-file
...
@@ -232,6 +232,7 @@ lock-file
log-flush-frequency
log-flush-frequency
long-running-request-regexp
long-running-request-regexp
low-diskspace-threshold-mb
low-diskspace-threshold-mb
make-symlinks
manifest-url
manifest-url
manifest-url-header
manifest-url-header
masquerade-all
masquerade-all
...
...
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