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
42d533e4
Commit
42d533e4
authored
May 30, 2018
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apiserver: output flags in logical sections
parent
23111ad4
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
222 additions
and
24 deletions
+222
-24
BUILD
cmd/kube-apiserver/app/BUILD
+1
-0
BUILD
cmd/kube-apiserver/app/options/BUILD
+1
-1
options.go
cmd/kube-apiserver/app/options/options.go
+19
-18
options_test.go
cmd/kube-apiserver/app/options/options_test.go
+5
-3
server.go
cmd/kube-apiserver/app/server.go
+19
-1
testserver.go
cmd/kube-apiserver/app/testing/testserver.go
+3
-1
Godeps.json
...ing/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
+20
-0
Godeps.json
staging/src/k8s.io/apiserver/Godeps/Godeps.json
+20
-0
BUILD
staging/src/k8s.io/apiserver/pkg/util/flag/BUILD
+2
-0
sectioned.go
staging/src/k8s.io/apiserver/pkg/util/flag/sectioned.go
+92
-0
Godeps.json
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
+20
-0
Godeps.json
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
+20
-0
No files found.
cmd/kube-apiserver/app/BUILD
View file @
42d533e4
...
...
@@ -76,6 +76,7 @@ go_library(
"//staging/src/k8s.io/apiserver/pkg/server/storage:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/storage/etcd3/preflight:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/flag:go_default_library",
"//staging/src/k8s.io/client-go/discovery/cached:go_default_library",
"//staging/src/k8s.io/client-go/informers:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
...
...
cmd/kube-apiserver/app/options/BUILD
View file @
42d533e4
...
...
@@ -25,8 +25,8 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/server/options:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/storage/storagebackend:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/flag:go_default_library",
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
],
)
...
...
cmd/kube-apiserver/app/options/options.go
View file @
42d533e4
...
...
@@ -25,6 +25,7 @@ import (
utilnet
"k8s.io/apimachinery/pkg/util/net"
genericoptions
"k8s.io/apiserver/pkg/server/options"
"k8s.io/apiserver/pkg/storage/storagebackend"
apiserverflag
"k8s.io/apiserver/pkg/util/flag"
api
"k8s.io/kubernetes/pkg/apis/core"
kubeoptions
"k8s.io/kubernetes/pkg/kubeapiserver/options"
kubeletclient
"k8s.io/kubernetes/pkg/kubelet/client"
...
...
@@ -33,8 +34,6 @@ import (
// add the kubernetes feature gates
_
"k8s.io/kubernetes/pkg/features"
"github.com/spf13/pflag"
)
// ServerRunOptions runs a kubernetes api server.
...
...
@@ -122,26 +121,26 @@ func NewServerRunOptions() *ServerRunOptions {
return
&
s
}
//
AddFlags adds flags for a specific APIServer to the specified FlagSet
func
(
s
*
ServerRunOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
//
Flags returns flags for a specific APIServer by section name
func
(
s
*
ServerRunOptions
)
Flags
()
(
fss
apiserverflag
.
NamedFlagSets
)
{
// Add the generic flags.
s
.
GenericServerRunOptions
.
AddUniversalFlags
(
fs
)
s
.
Etcd
.
AddFlags
(
fs
)
s
.
SecureServing
.
AddFlags
(
fs
)
s
.
InsecureServing
.
AddFlags
(
fs
)
s
.
InsecureServing
.
AddDeprecatedFlags
(
fs
)
s
.
Audit
.
AddFlags
(
fs
)
s
.
Features
.
AddFlags
(
fs
)
s
.
Authentication
.
AddFlags
(
fs
)
s
.
Authorization
.
AddFlags
(
fs
)
s
.
CloudProvider
.
AddFlags
(
fs
)
s
.
StorageSerialization
.
AddFlags
(
fs
)
s
.
APIEnablement
.
AddFlags
(
fs
)
s
.
Admission
.
AddFlags
(
fs
)
s
.
GenericServerRunOptions
.
AddUniversalFlags
(
fs
s
.
FlagSet
(
"generic"
)
)
s
.
Etcd
.
AddFlags
(
fs
s
.
FlagSet
(
"etcd"
)
)
s
.
SecureServing
.
AddFlags
(
fs
s
.
FlagSet
(
"secure serving"
)
)
s
.
InsecureServing
.
AddFlags
(
fs
s
.
FlagSet
(
"insecure serving"
)
)
s
.
InsecureServing
.
AddDeprecatedFlags
(
fs
s
.
FlagSet
(
"insecure serving"
)
)
s
.
Audit
.
AddFlags
(
fs
s
.
FlagSet
(
"auditing"
)
)
s
.
Features
.
AddFlags
(
fs
s
.
FlagSet
(
"features"
)
)
s
.
Authentication
.
AddFlags
(
fs
s
.
FlagSet
(
"authentication"
)
)
s
.
Authorization
.
AddFlags
(
fs
s
.
FlagSet
(
"authorization"
)
)
s
.
CloudProvider
.
AddFlags
(
fs
s
.
FlagSet
(
"cloud provider"
)
)
s
.
StorageSerialization
.
AddFlags
(
fs
s
.
FlagSet
(
"storage"
)
)
s
.
APIEnablement
.
AddFlags
(
fs
s
.
FlagSet
(
"api enablement"
)
)
s
.
Admission
.
AddFlags
(
fs
s
.
FlagSet
(
"admission"
)
)
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
// arrange these text blocks sensibly. Grrr.
fs
:=
fss
.
FlagSet
(
"misc"
)
fs
.
DurationVar
(
&
s
.
EventTTL
,
"event-ttl"
,
s
.
EventTTL
,
"Amount of time to retain events."
)
...
...
@@ -235,4 +234,6 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
fs
.
StringVar
(
&
s
.
ServiceAccountSigningKeyFile
,
"service-account-signing-key-file"
,
s
.
ServiceAccountSigningKeyFile
,
""
+
"Path to the file that contains the current private key of the service account token issuer. The issuer will sign issued ID tokens with this private key. (Requires the 'TokenRequest' feature gate.)"
)
return
fss
}
cmd/kube-apiserver/app/options/options_test.go
View file @
42d533e4
...
...
@@ -40,9 +40,11 @@ import (
)
func
TestAddFlags
(
t
*
testing
.
T
)
{
f
:=
pflag
.
NewFlagSet
(
"addflagstest"
,
pflag
.
ContinueOnError
)
f
s
:=
pflag
.
NewFlagSet
(
"addflagstest"
,
pflag
.
ContinueOnError
)
s
:=
NewServerRunOptions
()
s
.
AddFlags
(
f
)
for
_
,
f
:=
range
s
.
Flags
()
.
FlagSets
{
fs
.
AddFlagSet
(
f
)
}
args
:=
[]
string
{
"--enable-admission-plugins=AlwaysDeny"
,
...
...
@@ -113,7 +115,7 @@ func TestAddFlags(t *testing.T) {
"--request-timeout=2m"
,
"--storage-backend=etcd2"
,
}
f
.
Parse
(
args
)
f
s
.
Parse
(
args
)
// This is a snapshot of expected options parsed by args.
expected
:=
&
ServerRunOptions
{
...
...
cmd/kube-apiserver/app/server.go
View file @
42d533e4
...
...
@@ -55,6 +55,7 @@ import (
serverstorage
"k8s.io/apiserver/pkg/server/storage"
"k8s.io/apiserver/pkg/storage/etcd3/preflight"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
apiserverflag
"k8s.io/apiserver/pkg/util/flag"
cacheddiscovery
"k8s.io/client-go/discovery/cached"
clientgoinformers
"k8s.io/client-go/informers"
clientgoclientset
"k8s.io/client-go/kubernetes"
...
...
@@ -134,7 +135,24 @@ cluster's shared state through which all other components interact.`,
return
Run
(
completedOptions
,
stopCh
)
},
}
s
.
AddFlags
(
cmd
.
Flags
())
fs
:=
cmd
.
Flags
()
namedFlagSets
:=
s
.
Flags
()
for
_
,
f
:=
range
namedFlagSets
.
FlagSets
{
fs
.
AddFlagSet
(
f
)
}
usageFmt
:=
"Usage:
\n
%s
\n
"
cols
,
_
,
_
:=
apiserverflag
.
TerminalSize
(
cmd
.
OutOrStdout
())
cmd
.
SetUsageFunc
(
func
(
cmd
*
cobra
.
Command
)
error
{
fmt
.
Fprintf
(
cmd
.
OutOrStderr
(),
usageFmt
,
cmd
.
UseLine
())
apiserverflag
.
PrintSections
(
cmd
.
OutOrStderr
(),
namedFlagSets
,
cols
)
return
nil
})
cmd
.
SetHelpFunc
(
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
fmt
.
Fprintf
(
cmd
.
OutOrStdout
(),
"%s
\n\n
"
+
usageFmt
,
cmd
.
Long
,
cmd
.
UseLine
())
apiserverflag
.
PrintSections
(
cmd
.
OutOrStdout
(),
namedFlagSets
,
cols
)
})
return
cmd
}
...
...
cmd/kube-apiserver/app/testing/testserver.go
View file @
42d533e4
...
...
@@ -109,7 +109,9 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
fs
:=
pflag
.
NewFlagSet
(
"test"
,
pflag
.
PanicOnError
)
s
:=
options
.
NewServerRunOptions
()
s
.
AddFlags
(
fs
)
for
_
,
f
:=
range
s
.
Flags
()
.
FlagSets
{
fs
.
AddFlagSet
(
f
)
}
s
.
InsecureServing
.
BindPort
=
0
...
...
staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
View file @
42d533e4
...
...
@@ -11,6 +11,14 @@
"Rev"
:
"75cd24fc2f2c2a2088577d12123ddee5f54e0675"
},
{
"ImportPath"
:
"github.com/Azure/go-ansiterm"
,
"Rev"
:
"19f72df4d05d31cbe1c56bfc8045c96babff6c7e"
},
{
"ImportPath"
:
"github.com/Azure/go-ansiterm/winterm"
,
"Rev"
:
"19f72df4d05d31cbe1c56bfc8045c96babff6c7e"
},
{
"ImportPath"
:
"github.com/NYTimes/gziphandler"
,
"Rev"
:
"56545f4a5d46df9a6648819d1664c3a03a13ffdb"
},
...
...
@@ -355,6 +363,14 @@
"Rev"
:
"01aeca54ebda6e0fbfafd0a524d234159c05ec20"
},
{
"ImportPath"
:
"github.com/docker/docker/pkg/term"
,
"Rev"
:
"4f3616fb1c112e206b88cb7a9922bf49067a7756"
},
{
"ImportPath"
:
"github.com/docker/docker/pkg/term/windows"
,
"Rev"
:
"4f3616fb1c112e206b88cb7a9922bf49067a7756"
},
{
"ImportPath"
:
"github.com/elazarl/go-bindata-assetfs"
,
"Rev"
:
"3dcc96556217539f50599357fb481ac0dc7439b9"
},
...
...
@@ -599,6 +615,10 @@
"Rev"
:
"65c1f6f8f0fc1e2185eb9863a3bc751496404259"
},
{
"ImportPath"
:
"github.com/sirupsen/logrus"
,
"Rev"
:
"89742aefa4b206dcf400792f3bd35b542998eb3b"
},
{
"ImportPath"
:
"github.com/spf13/cobra"
,
"Rev"
:
"c439c4fa093711d42e1b01acb1235b52004753c1"
},
...
...
staging/src/k8s.io/apiserver/Godeps/Godeps.json
View file @
42d533e4
...
...
@@ -11,6 +11,14 @@
"Rev"
:
"75cd24fc2f2c2a2088577d12123ddee5f54e0675"
},
{
"ImportPath"
:
"github.com/Azure/go-ansiterm"
,
"Rev"
:
"19f72df4d05d31cbe1c56bfc8045c96babff6c7e"
},
{
"ImportPath"
:
"github.com/Azure/go-ansiterm/winterm"
,
"Rev"
:
"19f72df4d05d31cbe1c56bfc8045c96babff6c7e"
},
{
"ImportPath"
:
"github.com/NYTimes/gziphandler"
,
"Rev"
:
"56545f4a5d46df9a6648819d1664c3a03a13ffdb"
},
...
...
@@ -355,6 +363,14 @@
"Rev"
:
"01aeca54ebda6e0fbfafd0a524d234159c05ec20"
},
{
"ImportPath"
:
"github.com/docker/docker/pkg/term"
,
"Rev"
:
"4f3616fb1c112e206b88cb7a9922bf49067a7756"
},
{
"ImportPath"
:
"github.com/docker/docker/pkg/term/windows"
,
"Rev"
:
"4f3616fb1c112e206b88cb7a9922bf49067a7756"
},
{
"ImportPath"
:
"github.com/elazarl/go-bindata-assetfs"
,
"Rev"
:
"3dcc96556217539f50599357fb481ac0dc7439b9"
},
...
...
@@ -579,6 +595,10 @@
"Rev"
:
"65c1f6f8f0fc1e2185eb9863a3bc751496404259"
},
{
"ImportPath"
:
"github.com/sirupsen/logrus"
,
"Rev"
:
"89742aefa4b206dcf400792f3bd35b542998eb3b"
},
{
"ImportPath"
:
"github.com/spf13/pflag"
,
"Rev"
:
"583c0c0531f06d5278b7d917446061adc344b5cd"
},
...
...
staging/src/k8s.io/apiserver/pkg/util/flag/BUILD
View file @
42d533e4
...
...
@@ -33,6 +33,7 @@ go_library(
"namedcertkey_flag.go",
"noop.go",
"omitempty.go",
"sectioned.go",
"string_flag.go",
"tristate.go",
],
...
...
@@ -40,6 +41,7 @@ go_library(
importpath = "k8s.io/apiserver/pkg/util/flag",
deps = [
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/github.com/docker/docker/pkg/term:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
],
...
...
staging/src/k8s.io/apiserver/pkg/util/flag/sectioned.go
0 → 100644
View file @
42d533e4
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
flag
import
(
"bytes"
"fmt"
"io"
"strings"
"github.com/docker/docker/pkg/term"
"github.com/spf13/pflag"
)
// NamedFlagSets stores named flag sets in the order of calling FlagSet.
type
NamedFlagSets
struct
{
// Order is an ordered list of flag set names.
Order
[]
string
// FlagSets stores the flag sets by name.
FlagSets
map
[
string
]
*
pflag
.
FlagSet
}
// FlagSet returns the flag set with the given name and adds it to the
// ordered name list if it is not in there yet.
func
(
nfs
*
NamedFlagSets
)
FlagSet
(
name
string
)
*
pflag
.
FlagSet
{
if
nfs
.
FlagSets
==
nil
{
nfs
.
FlagSets
=
map
[
string
]
*
pflag
.
FlagSet
{}
}
if
_
,
ok
:=
nfs
.
FlagSets
[
name
];
!
ok
{
nfs
.
FlagSets
[
name
]
=
pflag
.
NewFlagSet
(
name
,
pflag
.
ExitOnError
)
nfs
.
Order
=
append
(
nfs
.
Order
,
name
)
}
return
nfs
.
FlagSets
[
name
]
}
// PrintSections prints the given names flag sets in sections, with the maximal given column number.
// If cols is zero, lines are not wrapped.
func
PrintSections
(
w
io
.
Writer
,
fss
NamedFlagSets
,
cols
int
)
{
for
_
,
name
:=
range
fss
.
Order
{
fs
:=
fss
.
FlagSets
[
name
]
wideFS
:=
pflag
.
NewFlagSet
(
""
,
pflag
.
ExitOnError
)
wideFS
.
AddFlagSet
(
fs
)
var
zzz
string
if
cols
>
24
{
zzz
=
strings
.
Repeat
(
"z"
,
cols
-
24
)
wideFS
.
Int
(
zzz
,
0
,
strings
.
Repeat
(
"z"
,
cols
-
24
))
}
var
buf
bytes
.
Buffer
fmt
.
Fprintf
(
&
buf
,
"
\n
%s flags:
\n\n
%s"
,
strings
.
ToUpper
(
name
[
:
1
])
+
name
[
1
:
],
wideFS
.
FlagUsagesWrapped
(
cols
))
if
cols
>
24
{
i
:=
strings
.
Index
(
buf
.
String
(),
zzz
)
lines
:=
strings
.
Split
(
buf
.
String
()[
:
i
],
"
\n
"
)
fmt
.
Fprint
(
w
,
strings
.
Join
(
lines
[
:
len
(
lines
)
-
1
],
"
\n
"
))
fmt
.
Fprintln
(
w
)
}
else
{
fmt
.
Fprint
(
w
,
buf
.
String
())
}
}
}
// TerminalSize returns the current width and height of the user's terminal. If it isn't a terminal,
// nil is returned. On error, zero values are returned for width and height.
// Usually w must be the stdout of the process. Stderr won't work.
func
TerminalSize
(
w
io
.
Writer
)
(
int
,
int
,
error
)
{
outFd
,
isTerminal
:=
term
.
GetFdInfo
(
w
)
if
!
isTerminal
{
return
0
,
0
,
fmt
.
Errorf
(
"given writer is no terminal"
)
}
winsize
,
err
:=
term
.
GetWinsize
(
outFd
)
if
err
!=
nil
{
return
0
,
0
,
err
}
return
int
(
winsize
.
Width
),
int
(
winsize
.
Height
),
nil
}
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
View file @
42d533e4
...
...
@@ -11,6 +11,14 @@
"Rev"
:
"75cd24fc2f2c2a2088577d12123ddee5f54e0675"
},
{
"ImportPath"
:
"github.com/Azure/go-ansiterm"
,
"Rev"
:
"19f72df4d05d31cbe1c56bfc8045c96babff6c7e"
},
{
"ImportPath"
:
"github.com/Azure/go-ansiterm/winterm"
,
"Rev"
:
"19f72df4d05d31cbe1c56bfc8045c96babff6c7e"
},
{
"ImportPath"
:
"github.com/NYTimes/gziphandler"
,
"Rev"
:
"56545f4a5d46df9a6648819d1664c3a03a13ffdb"
},
...
...
@@ -87,6 +95,14 @@
"Rev"
:
"782f4967f2dc4564575ca782fe2d04090b5faca8"
},
{
"ImportPath"
:
"github.com/docker/docker/pkg/term"
,
"Rev"
:
"4f3616fb1c112e206b88cb7a9922bf49067a7756"
},
{
"ImportPath"
:
"github.com/docker/docker/pkg/term/windows"
,
"Rev"
:
"4f3616fb1c112e206b88cb7a9922bf49067a7756"
},
{
"ImportPath"
:
"github.com/docker/spdystream"
,
"Rev"
:
"449fdfce4d962303d702fec724ef0ad181c92528"
},
...
...
@@ -291,6 +307,10 @@
"Rev"
:
"65c1f6f8f0fc1e2185eb9863a3bc751496404259"
},
{
"ImportPath"
:
"github.com/sirupsen/logrus"
,
"Rev"
:
"89742aefa4b206dcf400792f3bd35b542998eb3b"
},
{
"ImportPath"
:
"github.com/spf13/cobra"
,
"Rev"
:
"c439c4fa093711d42e1b01acb1235b52004753c1"
},
...
...
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
View file @
42d533e4
...
...
@@ -11,6 +11,14 @@
"Rev"
:
"75cd24fc2f2c2a2088577d12123ddee5f54e0675"
},
{
"ImportPath"
:
"github.com/Azure/go-ansiterm"
,
"Rev"
:
"19f72df4d05d31cbe1c56bfc8045c96babff6c7e"
},
{
"ImportPath"
:
"github.com/Azure/go-ansiterm/winterm"
,
"Rev"
:
"19f72df4d05d31cbe1c56bfc8045c96babff6c7e"
},
{
"ImportPath"
:
"github.com/NYTimes/gziphandler"
,
"Rev"
:
"56545f4a5d46df9a6648819d1664c3a03a13ffdb"
},
...
...
@@ -87,6 +95,14 @@
"Rev"
:
"782f4967f2dc4564575ca782fe2d04090b5faca8"
},
{
"ImportPath"
:
"github.com/docker/docker/pkg/term"
,
"Rev"
:
"4f3616fb1c112e206b88cb7a9922bf49067a7756"
},
{
"ImportPath"
:
"github.com/docker/docker/pkg/term/windows"
,
"Rev"
:
"4f3616fb1c112e206b88cb7a9922bf49067a7756"
},
{
"ImportPath"
:
"github.com/elazarl/go-bindata-assetfs"
,
"Rev"
:
"3dcc96556217539f50599357fb481ac0dc7439b9"
},
...
...
@@ -275,6 +291,10 @@
"Rev"
:
"65c1f6f8f0fc1e2185eb9863a3bc751496404259"
},
{
"ImportPath"
:
"github.com/sirupsen/logrus"
,
"Rev"
:
"89742aefa4b206dcf400792f3bd35b542998eb3b"
},
{
"ImportPath"
:
"github.com/spf13/cobra"
,
"Rev"
:
"c439c4fa093711d42e1b01acb1235b52004753c1"
},
...
...
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