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
08d4fa5c
Commit
08d4fa5c
authored
Oct 18, 2016
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turn APIGroupPrefix into a constant
parent
c900a0ed
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
24 deletions
+15
-24
core.go
federation/cmd/federation-apiserver/app/core.go
+1
-1
config.go
pkg/genericapiserver/config.go
+8
-7
genericapiserver.go
pkg/genericapiserver/genericapiserver.go
+3
-6
genericapiserver_test.go
pkg/genericapiserver/genericapiserver_test.go
+2
-6
server_run_options.go
pkg/genericapiserver/options/server_run_options.go
+0
-2
master.go
pkg/master/master.go
+1
-1
master_test.go
pkg/master/master_test.go
+0
-1
No files found.
federation/cmd/federation-apiserver/app/core.go
View file @
08d4fa5c
...
@@ -65,7 +65,7 @@ func installCoreAPIs(s *options.ServerRunOptions, g *genericapiserver.GenericAPI
...
@@ -65,7 +65,7 @@ func installCoreAPIs(s *options.ServerRunOptions, g *genericapiserver.GenericAPI
ParameterCodec
:
core
.
ParameterCodec
,
ParameterCodec
:
core
.
ParameterCodec
,
NegotiatedSerializer
:
core
.
Codecs
,
NegotiatedSerializer
:
core
.
Codecs
,
}
}
if
err
:=
g
.
InstallLegacyAPIGroup
(
genericapiserver
.
LegacyAPIPrefix
,
&
apiGroupInfo
);
err
!=
nil
{
if
err
:=
g
.
InstallLegacyAPIGroup
(
genericapiserver
.
Default
LegacyAPIPrefix
,
&
apiGroupInfo
);
err
!=
nil
{
glog
.
Fatalf
(
"Error in registering group version: %+v.
\n
Error: %v
\n
"
,
apiGroupInfo
,
err
)
glog
.
Fatalf
(
"Error in registering group version: %+v.
\n
Error: %v
\n
"
,
apiGroupInfo
,
err
)
}
}
}
}
pkg/genericapiserver/config.go
View file @
08d4fa5c
...
@@ -59,8 +59,11 @@ import (
...
@@ -59,8 +59,11 @@ import (
)
)
const
(
const
(
// LegacyAPIPrefix is where the the legacy APIs will be located
// DefaultLegacyAPIPrefix is where the the legacy APIs will be located.
LegacyAPIPrefix
=
"/api"
DefaultLegacyAPIPrefix
=
"/api"
// APIGroupPrefix is where non-legacy API group will be located.
APIGroupPrefix
=
"/apis"
)
)
// Config is a structure used to configure a GenericAPIServer.
// Config is a structure used to configure a GenericAPIServer.
...
@@ -206,7 +209,7 @@ func NewConfig() *Config {
...
@@ -206,7 +209,7 @@ func NewConfig() *Config {
ServiceReadWritePort
:
443
,
ServiceReadWritePort
:
443
,
RequestContextMapper
:
api
.
NewRequestContextMapper
(),
RequestContextMapper
:
api
.
NewRequestContextMapper
(),
BuildHandlerChainsFunc
:
DefaultBuildHandlerChain
,
BuildHandlerChainsFunc
:
DefaultBuildHandlerChain
,
LegacyAPIGroupPrefixes
:
sets
.
NewString
(
LegacyAPIPrefix
),
LegacyAPIGroupPrefixes
:
sets
.
NewString
(
Default
LegacyAPIPrefix
),
EnableIndex
:
true
,
EnableIndex
:
true
,
EnableSwaggerSupport
:
true
,
EnableSwaggerSupport
:
true
,
...
@@ -275,7 +278,6 @@ func (c *Config) ApplyOptions(options *options.ServerRunOptions) *Config {
...
@@ -275,7 +278,6 @@ func (c *Config) ApplyOptions(options *options.ServerRunOptions) *Config {
c
.
InsecureServingInfo
=
insecureServingInfo
c
.
InsecureServingInfo
=
insecureServingInfo
}
}
c
.
APIGroupPrefix
=
options
.
APIGroupPrefix
c
.
CorsAllowedOriginList
=
options
.
CorsAllowedOriginList
c
.
CorsAllowedOriginList
=
options
.
CorsAllowedOriginList
c
.
EnableGarbageCollection
=
options
.
EnableGarbageCollection
c
.
EnableGarbageCollection
=
options
.
EnableGarbageCollection
c
.
EnableProfiling
=
options
.
EnableProfiling
c
.
EnableProfiling
=
options
.
EnableProfiling
...
@@ -373,7 +375,6 @@ func (c completedConfig) New() (*GenericAPIServer, error) {
...
@@ -373,7 +375,6 @@ func (c completedConfig) New() (*GenericAPIServer, error) {
s
:=
&
GenericAPIServer
{
s
:=
&
GenericAPIServer
{
ServiceClusterIPRange
:
c
.
ServiceClusterIPRange
,
ServiceClusterIPRange
:
c
.
ServiceClusterIPRange
,
LoopbackClientConfig
:
c
.
LoopbackClientConfig
,
LoopbackClientConfig
:
c
.
LoopbackClientConfig
,
apiPrefix
:
c
.
APIGroupPrefix
,
legacyAPIGroupPrefixes
:
c
.
LegacyAPIGroupPrefixes
,
legacyAPIGroupPrefixes
:
c
.
LegacyAPIGroupPrefixes
,
admissionControl
:
c
.
AdmissionControl
,
admissionControl
:
c
.
AdmissionControl
,
requestContextMapper
:
c
.
RequestContextMapper
,
requestContextMapper
:
c
.
RequestContextMapper
,
...
@@ -522,8 +523,8 @@ func DefaultAndValidateRunOptions(options *options.ServerRunOptions) {
...
@@ -522,8 +523,8 @@ func DefaultAndValidateRunOptions(options *options.ServerRunOptions) {
}
}
func
NewRequestInfoResolver
(
c
*
Config
)
*
request
.
RequestInfoFactory
{
func
NewRequestInfoResolver
(
c
*
Config
)
*
request
.
RequestInfoFactory
{
apiPrefixes
:=
sets
.
NewString
(
strings
.
Trim
(
c
.
APIGroupPrefix
,
"/"
))
// all possible API prefixes
apiPrefixes
:=
sets
.
NewString
(
strings
.
Trim
(
APIGroupPrefix
,
"/"
))
// all possible API prefixes
legacyAPIPrefixes
:=
sets
.
String
{}
// APIPrefixes that won't have groups (legacy)
legacyAPIPrefixes
:=
sets
.
String
{}
// APIPrefixes that won't have groups (legacy)
for
legacyAPIPrefix
:=
range
c
.
LegacyAPIGroupPrefixes
{
for
legacyAPIPrefix
:=
range
c
.
LegacyAPIGroupPrefixes
{
apiPrefixes
.
Insert
(
strings
.
Trim
(
legacyAPIPrefix
,
"/"
))
apiPrefixes
.
Insert
(
strings
.
Trim
(
legacyAPIPrefix
,
"/"
))
legacyAPIPrefixes
.
Insert
(
strings
.
Trim
(
legacyAPIPrefix
,
"/"
))
legacyAPIPrefixes
.
Insert
(
strings
.
Trim
(
legacyAPIPrefix
,
"/"
))
...
...
pkg/genericapiserver/genericapiserver.go
View file @
08d4fa5c
...
@@ -101,9 +101,6 @@ type GenericAPIServer struct {
...
@@ -101,9 +101,6 @@ type GenericAPIServer struct {
// TODO eventually we should be able to factor this out to take place during initialization.
// TODO eventually we should be able to factor this out to take place during initialization.
enableSwaggerSupport
bool
enableSwaggerSupport
bool
// apiPrefix is the prefix where API groups live, usually /apis
apiPrefix
string
// legacyAPIGroupPrefixes is used to set up URL parsing for authorization and for validating requests
// legacyAPIGroupPrefixes is used to set up URL parsing for authorization and for validating requests
// to InstallLegacyAPIGroup
// to InstallLegacyAPIGroup
legacyAPIGroupPrefixes
sets
.
String
legacyAPIGroupPrefixes
sets
.
String
...
@@ -331,7 +328,7 @@ func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
...
@@ -331,7 +328,7 @@ func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
return
fmt
.
Errorf
(
"cannot register handler with an empty version for %#v"
,
*
apiGroupInfo
)
return
fmt
.
Errorf
(
"cannot register handler with an empty version for %#v"
,
*
apiGroupInfo
)
}
}
if
err
:=
s
.
installAPIResources
(
s
.
api
Prefix
,
apiGroupInfo
);
err
!=
nil
{
if
err
:=
s
.
installAPIResources
(
APIGroup
Prefix
,
apiGroupInfo
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -360,7 +357,7 @@ func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
...
@@ -360,7 +357,7 @@ func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
}
}
s
.
AddAPIGroupForDiscovery
(
apiGroup
)
s
.
AddAPIGroupForDiscovery
(
apiGroup
)
s
.
HandlerContainer
.
Add
(
apiserver
.
NewGroupWebService
(
s
.
Serializer
,
s
.
api
Prefix
+
"/"
+
apiGroup
.
Name
,
apiGroup
))
s
.
HandlerContainer
.
Add
(
apiserver
.
NewGroupWebService
(
s
.
Serializer
,
APIGroup
Prefix
+
"/"
+
apiGroup
.
Name
,
apiGroup
))
return
nil
return
nil
}
}
...
@@ -487,7 +484,7 @@ func (s *GenericAPIServer) InstallOpenAPI() {
...
@@ -487,7 +484,7 @@ func (s *GenericAPIServer) InstallOpenAPI() {
// DynamicApisDiscovery returns a webservice serving api group discovery.
// DynamicApisDiscovery returns a webservice serving api group discovery.
// Note: during the server runtime apiGroupsForDiscovery might change.
// Note: during the server runtime apiGroupsForDiscovery might change.
func
(
s
*
GenericAPIServer
)
DynamicApisDiscovery
()
*
restful
.
WebService
{
func
(
s
*
GenericAPIServer
)
DynamicApisDiscovery
()
*
restful
.
WebService
{
return
apiserver
.
NewApisWebService
(
s
.
Serializer
,
s
.
api
Prefix
,
func
(
req
*
restful
.
Request
)
[]
unversioned
.
APIGroup
{
return
apiserver
.
NewApisWebService
(
s
.
Serializer
,
APIGroup
Prefix
,
func
(
req
*
restful
.
Request
)
[]
unversioned
.
APIGroup
{
s
.
apiGroupsForDiscoveryLock
.
RLock
()
s
.
apiGroupsForDiscoveryLock
.
RLock
()
defer
s
.
apiGroupsForDiscoveryLock
.
RUnlock
()
defer
s
.
apiGroupsForDiscoveryLock
.
RUnlock
()
...
...
pkg/genericapiserver/genericapiserver_test.go
View file @
08d4fa5c
...
@@ -57,7 +57,6 @@ func setUp(t *testing.T) (*etcdtesting.EtcdTestServer, Config, *assert.Assertion
...
@@ -57,7 +57,6 @@ func setUp(t *testing.T) (*etcdtesting.EtcdTestServer, Config, *assert.Assertion
config
.
ProxyDialer
=
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
return
nil
,
nil
}
config
.
ProxyDialer
=
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
return
nil
,
nil
}
config
.
ProxyTLSClientConfig
=
&
tls
.
Config
{}
config
.
ProxyTLSClientConfig
=
&
tls
.
Config
{}
config
.
LegacyAPIGroupPrefixes
=
sets
.
NewString
(
"/api"
)
config
.
LegacyAPIGroupPrefixes
=
sets
.
NewString
(
"/api"
)
config
.
APIGroupPrefix
=
"/apis"
return
etcdServer
,
*
config
,
assert
.
New
(
t
)
return
etcdServer
,
*
config
,
assert
.
New
(
t
)
}
}
...
@@ -81,7 +80,6 @@ func TestNew(t *testing.T) {
...
@@ -81,7 +80,6 @@ func TestNew(t *testing.T) {
// Verify many of the variables match their config counterparts
// Verify many of the variables match their config counterparts
assert
.
Equal
(
s
.
enableSwaggerSupport
,
config
.
EnableSwaggerSupport
)
assert
.
Equal
(
s
.
enableSwaggerSupport
,
config
.
EnableSwaggerSupport
)
assert
.
Equal
(
s
.
legacyAPIGroupPrefixes
,
config
.
LegacyAPIGroupPrefixes
)
assert
.
Equal
(
s
.
legacyAPIGroupPrefixes
,
config
.
LegacyAPIGroupPrefixes
)
assert
.
Equal
(
s
.
apiPrefix
,
config
.
APIGroupPrefix
)
assert
.
Equal
(
s
.
admissionControl
,
config
.
AdmissionControl
)
assert
.
Equal
(
s
.
admissionControl
,
config
.
AdmissionControl
)
assert
.
Equal
(
s
.
RequestContextMapper
(),
config
.
RequestContextMapper
)
assert
.
Equal
(
s
.
RequestContextMapper
(),
config
.
RequestContextMapper
)
...
@@ -106,7 +104,6 @@ func TestInstallAPIGroups(t *testing.T) {
...
@@ -106,7 +104,6 @@ func TestInstallAPIGroups(t *testing.T) {
defer
etcdserver
.
Terminate
(
t
)
defer
etcdserver
.
Terminate
(
t
)
config
.
LegacyAPIGroupPrefixes
=
sets
.
NewString
(
"/apiPrefix"
)
config
.
LegacyAPIGroupPrefixes
=
sets
.
NewString
(
"/apiPrefix"
)
config
.
APIGroupPrefix
=
"/apiGroupPrefix"
s
,
err
:=
config
.
SkipComplete
()
.
New
()
s
,
err
:=
config
.
SkipComplete
()
.
New
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -145,9 +142,9 @@ func TestInstallAPIGroups(t *testing.T) {
...
@@ -145,9 +142,9 @@ func TestInstallAPIGroups(t *testing.T) {
// "/api/v1"
// "/api/v1"
config
.
LegacyAPIGroupPrefixes
.
List
()[
0
]
+
"/"
+
apiGroupMeta
.
GroupVersion
.
Version
,
config
.
LegacyAPIGroupPrefixes
.
List
()[
0
]
+
"/"
+
apiGroupMeta
.
GroupVersion
.
Version
,
// "/apis/extensions"
// "/apis/extensions"
config
.
APIGroupPrefix
+
"/"
+
extensionsGroupMeta
.
GroupVersion
.
Group
,
APIGroupPrefix
+
"/"
+
extensionsGroupMeta
.
GroupVersion
.
Group
,
// "/apis/extensions/v1beta1"
// "/apis/extensions/v1beta1"
config
.
APIGroupPrefix
+
"/"
+
extensionsGroupMeta
.
GroupVersion
.
String
(),
APIGroupPrefix
+
"/"
+
extensionsGroupMeta
.
GroupVersion
.
String
(),
}
}
for
_
,
path
:=
range
validPaths
{
for
_
,
path
:=
range
validPaths
{
_
,
err
:=
http
.
Get
(
server
.
URL
+
path
)
_
,
err
:=
http
.
Get
(
server
.
URL
+
path
)
...
@@ -224,7 +221,6 @@ func TestNotRestRoutesHaveAuth(t *testing.T) {
...
@@ -224,7 +221,6 @@ func TestNotRestRoutesHaveAuth(t *testing.T) {
authz
:=
mockAuthorizer
{}
authz
:=
mockAuthorizer
{}
config
.
LegacyAPIGroupPrefixes
=
sets
.
NewString
(
"/apiPrefix"
)
config
.
LegacyAPIGroupPrefixes
=
sets
.
NewString
(
"/apiPrefix"
)
config
.
APIGroupPrefix
=
"/apiGroupPrefix"
config
.
Authorizer
=
&
authz
config
.
Authorizer
=
&
authz
config
.
EnableSwaggerUI
=
true
config
.
EnableSwaggerUI
=
true
...
...
pkg/genericapiserver/options/server_run_options.go
View file @
08d4fa5c
...
@@ -55,7 +55,6 @@ var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABA
...
@@ -55,7 +55,6 @@ var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABA
// ServerRunOptions contains the options while running a generic api server.
// ServerRunOptions contains the options while running a generic api server.
type
ServerRunOptions
struct
{
type
ServerRunOptions
struct
{
APIGroupPrefix
string
AdmissionControl
string
AdmissionControl
string
AdmissionControlConfigFile
string
AdmissionControlConfigFile
string
AdvertiseAddress
net
.
IP
AdvertiseAddress
net
.
IP
...
@@ -123,7 +122,6 @@ type ServerRunOptions struct {
...
@@ -123,7 +122,6 @@ type ServerRunOptions struct {
func
NewServerRunOptions
()
*
ServerRunOptions
{
func
NewServerRunOptions
()
*
ServerRunOptions
{
return
&
ServerRunOptions
{
return
&
ServerRunOptions
{
APIGroupPrefix
:
"/apis"
,
AdmissionControl
:
"AlwaysAdmit"
,
AdmissionControl
:
"AlwaysAdmit"
,
AnonymousAuth
:
true
,
AnonymousAuth
:
true
,
AuthorizationMode
:
"AlwaysAllow"
,
AuthorizationMode
:
"AlwaysAllow"
,
...
...
pkg/master/master.go
View file @
08d4fa5c
...
@@ -265,7 +265,7 @@ func (m *Master) InstallLegacyAPI(c *Config, restOptionsGetter genericapiserver.
...
@@ -265,7 +265,7 @@ func (m *Master) InstallLegacyAPI(c *Config, restOptionsGetter genericapiserver.
}
}
}
}
if
err
:=
m
.
GenericAPIServer
.
InstallLegacyAPIGroup
(
genericapiserver
.
LegacyAPIPrefix
,
&
apiGroupInfo
);
err
!=
nil
{
if
err
:=
m
.
GenericAPIServer
.
InstallLegacyAPIGroup
(
genericapiserver
.
Default
LegacyAPIPrefix
,
&
apiGroupInfo
);
err
!=
nil
{
glog
.
Fatalf
(
"Error in registering group versions: %v"
,
err
)
glog
.
Fatalf
(
"Error in registering group versions: %v"
,
err
)
}
}
}
}
...
...
pkg/master/master_test.go
View file @
08d4fa5c
...
@@ -90,7 +90,6 @@ func setUp(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *assert.
...
@@ -90,7 +90,6 @@ func setUp(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *assert.
config
.
GenericConfig
.
APIResourceConfigSource
=
DefaultAPIResourceConfigSource
()
config
.
GenericConfig
.
APIResourceConfigSource
=
DefaultAPIResourceConfigSource
()
config
.
GenericConfig
.
PublicAddress
=
net
.
ParseIP
(
"192.168.10.4"
)
config
.
GenericConfig
.
PublicAddress
=
net
.
ParseIP
(
"192.168.10.4"
)
config
.
GenericConfig
.
LegacyAPIGroupPrefixes
=
sets
.
NewString
(
"/api"
)
config
.
GenericConfig
.
LegacyAPIGroupPrefixes
=
sets
.
NewString
(
"/api"
)
config
.
GenericConfig
.
APIGroupPrefix
=
"/apis"
config
.
GenericConfig
.
APIResourceConfigSource
=
DefaultAPIResourceConfigSource
()
config
.
GenericConfig
.
APIResourceConfigSource
=
DefaultAPIResourceConfigSource
()
config
.
GenericConfig
.
ProxyDialer
=
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
return
nil
,
nil
}
config
.
GenericConfig
.
ProxyDialer
=
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
return
nil
,
nil
}
config
.
GenericConfig
.
ProxyTLSClientConfig
=
&
tls
.
Config
{}
config
.
GenericConfig
.
ProxyTLSClientConfig
=
&
tls
.
Config
{}
...
...
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