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
50e12ff5
Commit
50e12ff5
authored
Sep 29, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Sep 29, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #33575 from sttts/sttts-defaulted-config
Automatic merge from submit-queue Decouple genericapiserver setDefault from New()
parents
5d218f93
6f781625
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
138 additions
and
113 deletions
+138
-113
server.go
cmd/kube-apiserver/app/server.go
+2
-2
apiserver.go
examples/apiserver/apiserver.go
+1
-1
server.go
federation/cmd/federation-apiserver/app/server.go
+1
-1
config.go
pkg/genericapiserver/config.go
+15
-7
genericapiserver_test.go
pkg/genericapiserver/genericapiserver_test.go
+3
-3
master.go
pkg/master/master.go
+32
-15
master_test.go
pkg/master/master_test.go
+23
-23
accessreview_test.go
test/integration/auth/accessreview_test.go
+12
-12
auth_test.go
test/integration/auth/auth_test.go
+20
-20
rbac_test.go
test/integration/auth/rbac_test.go
+6
-6
master_utils.go
test/integration/framework/master_utils.go
+12
-12
garbage_collector_test.go
test/integration/garbagecollector/garbage_collector_test.go
+1
-1
master_test.go
test/integration/master/master_test.go
+1
-1
openshift_test.go
test/integration/openshift/openshift_test.go
+1
-1
quota_test.go
test/integration/quota/quota_test.go
+2
-2
util.go
test/integration/scheduler_perf/util.go
+1
-1
service_account_test.go
test/integration/serviceaccount/service_account_test.go
+5
-5
No files found.
cmd/kube-apiserver/app/server.go
View file @
50e12ff5
...
...
@@ -310,7 +310,7 @@ func Run(s *options.APIServer) error {
genericConfig
.
EnableOpenAPISupport
=
true
config
:=
&
master
.
Config
{
Config
:
genericConfig
,
Generic
Config
:
genericConfig
,
StorageFactory
:
storageFactory
,
EnableWatchCache
:
s
.
EnableWatchCache
,
...
...
@@ -330,7 +330,7 @@ func Run(s *options.APIServer) error {
cachesize
.
SetWatchCacheSizes
(
s
.
WatchCacheSizes
)
}
m
,
err
:=
master
.
New
(
config
)
m
,
err
:=
config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
return
err
}
...
...
examples/apiserver/apiserver.go
View file @
50e12ff5
...
...
@@ -70,7 +70,7 @@ func Run(serverOptions *genericoptions.ServerRunOptions) error {
config
:=
genericapiserver
.
NewConfig
(
serverOptions
)
config
.
Authorizer
=
authorizer
.
NewAlwaysAllowAuthorizer
()
config
.
Serializer
=
api
.
Codecs
s
,
err
:=
config
.
New
()
s
,
err
:=
config
.
Complete
()
.
New
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error in bringing up the server: %v"
,
err
)
}
...
...
federation/cmd/federation-apiserver/app/server.go
View file @
50e12ff5
...
...
@@ -219,7 +219,7 @@ func Run(s *options.ServerRunOptions) error {
cachesize
.
SetWatchCacheSizes
(
s
.
WatchCacheSizes
)
}
m
,
err
:=
genericConfig
.
New
()
m
,
err
:=
genericConfig
.
Complete
()
.
New
()
if
err
!=
nil
{
return
err
}
...
...
pkg/genericapiserver/config.go
View file @
50e12ff5
...
...
@@ -213,8 +213,12 @@ func NewConfig(options *options.ServerRunOptions) *Config {
}
}
// setDefaults fills in any fields not set that are required to have valid data.
func
(
c
*
Config
)
setDefaults
()
{
type
completedConfig
struct
{
*
Config
}
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.
func
(
c
*
Config
)
Complete
()
completedConfig
{
if
c
.
ServiceClusterIPRange
==
nil
{
defaultNet
:=
"10.0.0.0/24"
glog
.
Warningf
(
"Network range for service cluster IPs is unspecified. Defaulting to %v."
,
defaultNet
)
...
...
@@ -267,6 +271,12 @@ func (c *Config) setDefaults() {
}
c
.
ExternalHost
=
hostAndPort
}
return
completedConfig
{
c
}
}
// SkipComplete provides a way to construct a server instance without config completion.
func
(
c
*
Config
)
SkipComplete
()
completedConfig
{
return
completedConfig
{
c
}
}
// New returns a new instance of GenericAPIServer from the given config.
...
...
@@ -291,13 +301,11 @@ func (c *Config) setDefaults() {
// If the caller wants to add additional endpoints not using the GenericAPIServer's
// auth, then the caller should create a handler for those endpoints, which delegates the
// any unhandled paths to "Handler".
func
(
c
Config
)
New
()
(
*
GenericAPIServer
,
error
)
{
func
(
c
completed
Config
)
New
()
(
*
GenericAPIServer
,
error
)
{
if
c
.
Serializer
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Genericapiserver.New() called with config.Serializer == nil"
)
}
c
.
setDefaults
()
s
:=
&
GenericAPIServer
{
ServiceClusterIPRange
:
c
.
ServiceClusterIPRange
,
ServiceNodePortRange
:
c
.
ServiceNodePortRange
,
...
...
@@ -345,8 +353,8 @@ func (c Config) New() (*GenericAPIServer, error) {
})
}
s
.
installAPI
(
&
c
)
s
.
Handler
,
s
.
InsecureHandler
=
s
.
buildHandlerChains
(
&
c
,
http
.
Handler
(
s
.
Mux
.
BaseMux
()
.
(
*
http
.
ServeMux
)))
s
.
installAPI
(
c
.
Config
)
s
.
Handler
,
s
.
InsecureHandler
=
s
.
buildHandlerChains
(
c
.
Config
,
http
.
Handler
(
s
.
Mux
.
BaseMux
()
.
(
*
http
.
ServeMux
)))
return
s
,
nil
}
...
...
pkg/genericapiserver/genericapiserver_test.go
View file @
50e12ff5
...
...
@@ -64,7 +64,7 @@ func setUp(t *testing.T) (*etcdtesting.EtcdTestServer, Config, *assert.Assertion
func
newMaster
(
t
*
testing
.
T
)
(
*
GenericAPIServer
,
*
etcdtesting
.
EtcdTestServer
,
Config
,
*
assert
.
Assertions
)
{
etcdserver
,
config
,
assert
:=
setUp
(
t
)
s
,
err
:=
config
.
New
()
s
,
err
:=
config
.
Complete
()
.
New
()
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the server: %v"
,
err
)
}
...
...
@@ -109,7 +109,7 @@ func TestInstallAPIGroups(t *testing.T) {
config
.
APIPrefix
=
"/apiPrefix"
config
.
APIGroupPrefix
=
"/apiGroupPrefix"
s
,
err
:=
config
.
New
()
s
,
err
:=
config
.
Complete
()
.
New
()
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the server: %v"
,
err
)
}
...
...
@@ -212,7 +212,7 @@ func TestNotRestRoutesHaveAuth(t *testing.T) {
config
.
EnableSwaggerSupport
=
true
config
.
EnableVersion
=
true
s
,
err
:=
config
.
New
()
s
,
err
:=
config
.
Complete
()
.
New
()
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the server: %v"
,
err
)
}
...
...
pkg/master/master.go
View file @
50e12ff5
...
...
@@ -116,7 +116,7 @@ const (
)
type
Config
struct
{
*
genericapiserver
.
Config
GenericConfig
*
genericapiserver
.
Config
StorageFactory
genericapiserver
.
StorageFactory
EnableWatchCache
bool
...
...
@@ -190,18 +190,35 @@ type RESTStorageProvider interface {
NewRESTStorage
(
apiResourceConfigSource
genericapiserver
.
APIResourceConfigSource
,
restOptionsGetter
RESTOptionsGetter
)
(
groupInfo
genericapiserver
.
APIGroupInfo
,
enabled
bool
)
}
type
completedConfig
struct
{
*
Config
}
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.
func
(
c
*
Config
)
Complete
()
completedConfig
{
c
.
GenericConfig
.
Complete
()
// enable swagger UI only if general UI support is on
c
.
GenericConfig
.
EnableSwaggerUI
=
c
.
GenericConfig
.
EnableSwaggerUI
&&
c
.
EnableUISupport
return
completedConfig
{
c
}
}
// SkipComplete provides a way to construct a server instance without config completion.
func
(
c
*
Config
)
SkipComplete
()
completedConfig
{
return
completedConfig
{
c
}
}
// New returns a new instance of Master from the given config.
// Certain config fields will be set to a default value if unset.
// Certain config fields must be specified, including:
// KubeletClient
func
New
(
c
*
Config
)
(
*
Master
,
error
)
{
func
(
c
completedConfig
)
New
(
)
(
*
Master
,
error
)
{
if
c
.
KubeletClient
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Master.New() called with config.KubeletClient == nil"
)
}
gc
:=
*
c
.
Config
// copy before mutations
gc
.
EnableSwaggerUI
=
gc
.
EnableSwaggerUI
&&
c
.
EnableUISupport
// disable swagger UI if general UI supports it
s
,
err
:=
gc
.
New
()
s
,
err
:=
c
.
Config
.
GenericConfig
.
SkipComplete
()
.
New
()
// completion is done in Complete, no need for a second time
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -223,7 +240,7 @@ func New(c *Config) (*Master, error) {
restOptionsFactory
:
restOptionsFactory
{
deleteCollectionWorkers
:
c
.
DeleteCollectionWorkers
,
enableGarbageCollection
:
c
.
EnableGarbageCollection
,
enableGarbageCollection
:
c
.
GenericConfig
.
EnableGarbageCollection
,
storageFactory
:
c
.
StorageFactory
,
},
}
...
...
@@ -239,8 +256,8 @@ func New(c *Config) (*Master, error) {
c
.
RESTStorageProviders
=
map
[
string
]
genericapiserver
.
RESTStorageProvider
{}
}
c
.
RESTStorageProviders
[
appsapi
.
GroupName
]
=
appsrest
.
RESTStorageProvider
{}
c
.
RESTStorageProviders
[
authenticationv1beta1
.
GroupName
]
=
authenticationrest
.
RESTStorageProvider
{
Authenticator
:
c
.
Authenticator
}
c
.
RESTStorageProviders
[
authorization
.
GroupName
]
=
authorizationrest
.
RESTStorageProvider
{
Authorizer
:
c
.
Authorizer
}
c
.
RESTStorageProviders
[
authenticationv1beta1
.
GroupName
]
=
authenticationrest
.
RESTStorageProvider
{
Authenticator
:
c
.
GenericConfig
.
Authenticator
}
c
.
RESTStorageProviders
[
authorization
.
GroupName
]
=
authorizationrest
.
RESTStorageProvider
{
Authorizer
:
c
.
GenericConfig
.
Authorizer
}
c
.
RESTStorageProviders
[
autoscaling
.
GroupName
]
=
autoscalingrest
.
RESTStorageProvider
{}
c
.
RESTStorageProviders
[
batch
.
GroupName
]
=
batchrest
.
RESTStorageProvider
{}
c
.
RESTStorageProviders
[
certificates
.
GroupName
]
=
certificatesrest
.
RESTStorageProvider
{}
...
...
@@ -249,9 +266,9 @@ func New(c *Config) (*Master, error) {
DisableThirdPartyControllerForTesting
:
m
.
disableThirdPartyControllerForTesting
,
}
c
.
RESTStorageProviders
[
policy
.
GroupName
]
=
policyrest
.
RESTStorageProvider
{}
c
.
RESTStorageProviders
[
rbac
.
GroupName
]
=
&
rbacrest
.
RESTStorageProvider
{
AuthorizerRBACSuperUser
:
c
.
AuthorizerRBACSuperUser
}
c
.
RESTStorageProviders
[
rbac
.
GroupName
]
=
&
rbacrest
.
RESTStorageProvider
{
AuthorizerRBACSuperUser
:
c
.
GenericConfig
.
AuthorizerRBACSuperUser
}
c
.
RESTStorageProviders
[
storage
.
GroupName
]
=
storagerest
.
RESTStorageProvider
{}
m
.
InstallAPIs
(
c
)
m
.
InstallAPIs
(
c
.
Config
)
// TODO: Attempt clean shutdown?
if
m
.
enableCoreControllers
{
...
...
@@ -265,7 +282,7 @@ func (m *Master) InstallAPIs(c *Config) {
apiGroupsInfo
:=
[]
genericapiserver
.
APIGroupInfo
{}
// Install v1 unless disabled.
if
c
.
APIResourceConfigSource
.
AnyResourcesForVersionEnabled
(
apiv1
.
SchemeGroupVersion
)
{
if
c
.
GenericConfig
.
APIResourceConfigSource
.
AnyResourcesForVersionEnabled
(
apiv1
.
SchemeGroupVersion
)
{
// Install v1 API.
m
.
initV1ResourcesStorage
(
c
)
apiGroupInfo
:=
genericapiserver
.
APIGroupInfo
{
...
...
@@ -300,7 +317,7 @@ func (m *Master) InstallAPIs(c *Config) {
}
healthz
.
InstallHandler
(
m
.
Mux
,
healthzChecks
...
)
if
c
.
EnableProfiling
{
if
c
.
GenericConfig
.
EnableProfiling
{
routes
.
MetricsWithReset
{}
.
Install
(
m
.
Mux
,
m
.
HandlerContainer
)
}
else
{
routes
.
DefaultMetrics
{}
.
Install
(
m
.
Mux
,
m
.
HandlerContainer
)
...
...
@@ -308,7 +325,7 @@ func (m *Master) InstallAPIs(c *Config) {
// Install third party resource support if requested
// TODO seems like this bit ought to be unconditional and the REST API is controlled by the config
if
c
.
APIResourceConfigSource
.
ResourceEnabled
(
extensionsapiv1beta1
.
SchemeGroupVersion
.
WithResource
(
"thirdpartyresources"
))
{
if
c
.
GenericConfig
.
APIResourceConfigSource
.
ResourceEnabled
(
extensionsapiv1beta1
.
SchemeGroupVersion
.
WithResource
(
"thirdpartyresources"
))
{
var
err
error
m
.
thirdPartyStorageConfig
,
err
=
c
.
StorageFactory
.
NewConfig
(
extensions
.
Resource
(
"thirdpartyresources"
))
if
err
!=
nil
{
...
...
@@ -324,12 +341,12 @@ func (m *Master) InstallAPIs(c *Config) {
// stabilize order.
// TODO find a better way to configure priority of groups
for
_
,
group
:=
range
sets
.
StringKeySet
(
c
.
RESTStorageProviders
)
.
List
()
{
if
!
c
.
APIResourceConfigSource
.
AnyResourcesForGroupEnabled
(
group
)
{
if
!
c
.
GenericConfig
.
APIResourceConfigSource
.
AnyResourcesForGroupEnabled
(
group
)
{
glog
.
V
(
1
)
.
Infof
(
"Skipping disabled API group %q."
,
group
)
continue
}
restStorageBuilder
:=
c
.
RESTStorageProviders
[
group
]
apiGroupInfo
,
enabled
:=
restStorageBuilder
.
NewRESTStorage
(
c
.
APIResourceConfigSource
,
restOptionsGetter
)
apiGroupInfo
,
enabled
:=
restStorageBuilder
.
NewRESTStorage
(
c
.
GenericConfig
.
APIResourceConfigSource
,
restOptionsGetter
)
if
!
enabled
{
glog
.
Warningf
(
"Problem initializing API group %q, skipping."
,
group
)
continue
...
...
pkg/master/master_test.go
View file @
50e12ff5
...
...
@@ -83,7 +83,7 @@ func setUp(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *assert.
GenericAPIServer
:
&
genericapiserver
.
GenericAPIServer
{},
}
config
:=
Config
{
Config
:
&
genericapiserver
.
Config
{},
Generic
Config
:
&
genericapiserver
.
Config
{},
}
resourceEncoding
:=
genericapiserver
.
NewDefaultResourceEncodingConfig
()
...
...
@@ -97,17 +97,17 @@ func setUp(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *assert.
storageFactory
:=
genericapiserver
.
NewDefaultStorageFactory
(
*
storageConfig
,
testapi
.
StorageMediaType
(),
api
.
Codecs
,
resourceEncoding
,
DefaultAPIResourceConfigSource
())
config
.
StorageFactory
=
storageFactory
config
.
APIResourceConfigSource
=
DefaultAPIResourceConfigSource
()
config
.
PublicAddress
=
net
.
ParseIP
(
"192.168.10.4"
)
config
.
Serializer
=
api
.
Codecs
config
.
GenericConfig
.
APIResourceConfigSource
=
DefaultAPIResourceConfigSource
()
config
.
GenericConfig
.
PublicAddress
=
net
.
ParseIP
(
"192.168.10.4"
)
config
.
GenericConfig
.
Serializer
=
api
.
Codecs
config
.
KubeletClient
=
client
.
FakeKubeletClient
{}
config
.
APIPrefix
=
"/api"
config
.
APIGroupPrefix
=
"/apis"
config
.
APIResourceConfigSource
=
DefaultAPIResourceConfigSource
()
config
.
ProxyDialer
=
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
return
nil
,
nil
}
config
.
ProxyTLSClientConfig
=
&
tls
.
Config
{}
config
.
RequestContextMapper
=
api
.
NewRequestContextMapper
()
config
.
Config
.
EnableVersion
=
true
config
.
GenericConfig
.
APIPrefix
=
"/api"
config
.
GenericConfig
.
APIGroupPrefix
=
"/apis"
config
.
GenericConfig
.
APIResourceConfigSource
=
DefaultAPIResourceConfigSource
()
config
.
GenericConfig
.
ProxyDialer
=
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
return
nil
,
nil
}
config
.
GenericConfig
.
ProxyTLSClientConfig
=
&
tls
.
Config
{}
config
.
GenericConfig
.
RequestContextMapper
=
api
.
NewRequestContextMapper
()
config
.
Generic
Config
.
EnableVersion
=
true
// TODO: this is kind of hacky. The trouble is that the sync loop
// runs in a go-routine and there is no way to validate in the test
...
...
@@ -125,7 +125,7 @@ func setUp(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *assert.
func
newMaster
(
t
*
testing
.
T
)
(
*
Master
,
*
etcdtesting
.
EtcdTestServer
,
Config
,
*
assert
.
Assertions
)
{
_
,
etcdserver
,
config
,
assert
:=
setUp
(
t
)
master
,
err
:=
New
(
&
config
)
master
,
err
:=
config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
...
...
@@ -150,8 +150,8 @@ func limitedAPIResourceConfigSource() *genericapiserver.ResourceConfig {
// newLimitedMaster only enables the core group, the extensions group, the batch group, and the autoscaling group.
func
newLimitedMaster
(
t
*
testing
.
T
)
(
*
Master
,
*
etcdtesting
.
EtcdTestServer
,
Config
,
*
assert
.
Assertions
)
{
_
,
etcdserver
,
config
,
assert
:=
setUp
(
t
)
config
.
APIResourceConfigSource
=
limitedAPIResourceConfigSource
()
master
,
err
:=
New
(
&
config
)
config
.
GenericConfig
.
APIResourceConfigSource
=
limitedAPIResourceConfigSource
()
master
,
err
:=
config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
...
...
@@ -168,8 +168,8 @@ func TestNew(t *testing.T) {
// Verify many of the variables match their config counterparts
assert
.
Equal
(
master
.
enableCoreControllers
,
config
.
EnableCoreControllers
)
assert
.
Equal
(
master
.
tunneler
,
config
.
Tunneler
)
assert
.
Equal
(
master
.
RequestContextMapper
(),
config
.
RequestContextMapper
)
assert
.
Equal
(
master
.
ClusterIP
,
config
.
PublicAddress
)
assert
.
Equal
(
master
.
RequestContextMapper
(),
config
.
GenericConfig
.
RequestContextMapper
)
assert
.
Equal
(
master
.
ClusterIP
,
config
.
GenericConfig
.
PublicAddress
)
// these values get defaulted
_
,
serviceClusterIPRange
,
_
:=
net
.
ParseCIDR
(
"10.0.0.0/24"
)
...
...
@@ -181,10 +181,10 @@ func TestNew(t *testing.T) {
// These functions should point to the same memory location
masterDialer
,
_
:=
utilnet
.
Dialer
(
master
.
ProxyTransport
)
masterDialerFunc
:=
fmt
.
Sprintf
(
"%p"
,
masterDialer
)
configDialerFunc
:=
fmt
.
Sprintf
(
"%p"
,
config
.
ProxyDialer
)
configDialerFunc
:=
fmt
.
Sprintf
(
"%p"
,
config
.
GenericConfig
.
ProxyDialer
)
assert
.
Equal
(
masterDialerFunc
,
configDialerFunc
)
assert
.
Equal
(
master
.
ProxyTransport
.
(
*
http
.
Transport
)
.
TLSClientConfig
,
config
.
ProxyTLSClientConfig
)
assert
.
Equal
(
master
.
ProxyTransport
.
(
*
http
.
Transport
)
.
TLSClientConfig
,
config
.
GenericConfig
.
ProxyTLSClientConfig
)
}
// TestNamespaceSubresources ensures the namespace subresource parsing in apiserver/handlers.go doesn't drift
...
...
@@ -1253,16 +1253,16 @@ func TestValidOpenAPISpec(t *testing.T) {
_
,
etcdserver
,
config
,
assert
:=
setUp
(
t
)
defer
etcdserver
.
Terminate
(
t
)
config
.
OpenAPIDefinitions
=
openapi
.
OpenAPIDefinitions
config
.
EnableOpenAPISupport
=
true
config
.
EnableIndex
=
true
config
.
OpenAPIInfo
=
spec
.
Info
{
config
.
GenericConfig
.
OpenAPIDefinitions
=
openapi
.
OpenAPIDefinitions
config
.
GenericConfig
.
EnableOpenAPISupport
=
true
config
.
GenericConfig
.
EnableIndex
=
true
config
.
GenericConfig
.
OpenAPIInfo
=
spec
.
Info
{
InfoProps
:
spec
.
InfoProps
{
Title
:
"Kubernetes"
,
Version
:
"unversioned"
,
},
}
master
,
err
:=
New
(
&
config
)
master
,
err
:=
config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
...
...
test/integration/auth/accessreview_test.go
View file @
50e12ff5
...
...
@@ -64,10 +64,10 @@ func TestSubjectAccessReview(t *testing.T) {
defer
s
.
Close
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
authenticator
.
RequestFunc
(
alwaysAlice
)
masterConfig
.
Authorizer
=
sarAuthorizer
{}
masterConfig
.
AdmissionControl
=
admit
.
NewAlwaysAdmit
()
m
,
err
:=
master
.
New
(
masterConfig
)
masterConfig
.
GenericConfig
.
Authenticator
=
authenticator
.
RequestFunc
(
alwaysAlice
)
masterConfig
.
GenericConfig
.
Authorizer
=
sarAuthorizer
{}
masterConfig
.
GenericConfig
.
AdmissionControl
=
admit
.
NewAlwaysAdmit
()
m
,
err
:=
master
Config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
t
.
Fatalf
(
"error in bringing up the master: %v"
,
err
)
}
...
...
@@ -164,12 +164,12 @@ func TestSelfSubjectAccessReview(t *testing.T) {
username
:=
"alice"
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
authenticator
.
RequestFunc
(
func
(
req
*
http
.
Request
)
(
user
.
Info
,
bool
,
error
)
{
masterConfig
.
GenericConfig
.
Authenticator
=
authenticator
.
RequestFunc
(
func
(
req
*
http
.
Request
)
(
user
.
Info
,
bool
,
error
)
{
return
&
user
.
DefaultInfo
{
Name
:
username
},
true
,
nil
})
masterConfig
.
Authorizer
=
sarAuthorizer
{}
masterConfig
.
AdmissionControl
=
admit
.
NewAlwaysAdmit
()
m
,
err
:=
master
.
New
(
masterConfig
)
masterConfig
.
GenericConfig
.
Authorizer
=
sarAuthorizer
{}
masterConfig
.
GenericConfig
.
AdmissionControl
=
admit
.
NewAlwaysAdmit
()
m
,
err
:=
master
Config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
t
.
Fatalf
(
"error in bringing up the master: %v"
,
err
)
}
...
...
@@ -254,10 +254,10 @@ func TestLocalSubjectAccessReview(t *testing.T) {
defer
s
.
Close
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
authenticator
.
RequestFunc
(
alwaysAlice
)
masterConfig
.
Authorizer
=
sarAuthorizer
{}
masterConfig
.
AdmissionControl
=
admit
.
NewAlwaysAdmit
()
m
,
err
:=
master
.
New
(
masterConfig
)
masterConfig
.
GenericConfig
.
Authenticator
=
authenticator
.
RequestFunc
(
alwaysAlice
)
masterConfig
.
GenericConfig
.
Authorizer
=
sarAuthorizer
{}
masterConfig
.
GenericConfig
.
AdmissionControl
=
admit
.
NewAlwaysAdmit
()
m
,
err
:=
master
Config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
t
.
Fatalf
(
"error in bringing up the master: %v"
,
err
)
}
...
...
test/integration/auth/auth_test.go
View file @
50e12ff5
...
...
@@ -500,7 +500,7 @@ func getPreviousResourceVersionKey(url, id string) string {
func
TestAuthModeAlwaysDeny
(
t
*
testing
.
T
)
{
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authorizer
=
apiserverauthorizer
.
NewAlwaysDenyAuthorizer
()
masterConfig
.
GenericConfig
.
Authorizer
=
apiserverauthorizer
.
NewAlwaysDenyAuthorizer
()
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -549,9 +549,9 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
Authorizer
=
allowAliceAuthorizer
{}
masterConfig
.
AdmissionControl
=
admit
.
NewAlwaysAdmit
()
masterConfig
.
GenericConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
GenericConfig
.
Authorizer
=
allowAliceAuthorizer
{}
masterConfig
.
GenericConfig
.
AdmissionControl
=
admit
.
NewAlwaysAdmit
()
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -619,8 +619,8 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
func
TestBobIsForbidden
(
t
*
testing
.
T
)
{
// This file has alice and bob in it.
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
Authorizer
=
allowAliceAuthorizer
{}
masterConfig
.
GenericConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
GenericConfig
.
Authorizer
=
allowAliceAuthorizer
{}
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -663,8 +663,8 @@ func TestUnknownUserIsUnauthorized(t *testing.T) {
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
Authorizer
=
allowAliceAuthorizer
{}
masterConfig
.
GenericConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
GenericConfig
.
Authorizer
=
allowAliceAuthorizer
{}
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -725,8 +725,8 @@ func (impersonateAuthorizer) Authorize(a authorizer.Attributes) (bool, string, e
func
TestImpersonateIsForbidden
(
t
*
testing
.
T
)
{
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
Authorizer
=
impersonateAuthorizer
{}
masterConfig
.
GenericConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
GenericConfig
.
Authorizer
=
impersonateAuthorizer
{}
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -872,8 +872,8 @@ func TestAuthorizationAttributeDetermination(t *testing.T) {
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
Authorizer
=
trackingAuthorizer
masterConfig
.
GenericConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
GenericConfig
.
Authorizer
=
trackingAuthorizer
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -938,8 +938,8 @@ func TestNamespaceAuthorization(t *testing.T) {
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
Authorizer
=
a
masterConfig
.
GenericConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
GenericConfig
.
Authorizer
=
a
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -1036,8 +1036,8 @@ func TestKindAuthorization(t *testing.T) {
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
Authorizer
=
a
masterConfig
.
GenericConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
GenericConfig
.
Authorizer
=
a
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -1120,8 +1120,8 @@ func TestReadOnlyAuthorization(t *testing.T) {
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
Authorizer
=
a
masterConfig
.
GenericConfig
.
Authenticator
=
getTestTokenAuth
()
masterConfig
.
GenericConfig
.
Authorizer
=
a
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -1179,8 +1179,8 @@ func TestWebhookTokenAuthenticator(t *testing.T) {
// Set up a master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authenticator
=
authenticator
masterConfig
.
Authorizer
=
allowAliceAuthorizer
{}
masterConfig
.
GenericConfig
.
Authenticator
=
authenticator
masterConfig
.
GenericConfig
.
Authorizer
=
allowAliceAuthorizer
{}
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
test/integration/auth/rbac_test.go
View file @
50e12ff5
...
...
@@ -338,9 +338,9 @@ func TestRBAC(t *testing.T) {
for
i
,
tc
:=
range
tests
{
// Create an API Server.
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authorizer
=
newRBACAuthorizer
(
t
,
superUser
,
masterConfig
)
masterConfig
.
Authenticator
=
newFakeAuthenticator
()
masterConfig
.
AuthorizerRBACSuperUser
=
superUser
masterConfig
.
GenericConfig
.
Authorizer
=
newRBACAuthorizer
(
t
,
superUser
,
masterConfig
)
masterConfig
.
GenericConfig
.
Authenticator
=
newFakeAuthenticator
()
masterConfig
.
GenericConfig
.
AuthorizerRBACSuperUser
=
superUser
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
@@ -437,9 +437,9 @@ func TestBootstrapping(t *testing.T) {
superUser
:=
"admin"
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
Authorizer
=
newRBACAuthorizer
(
t
,
superUser
,
masterConfig
)
masterConfig
.
Authenticator
=
newFakeAuthenticator
()
masterConfig
.
AuthorizerRBACSuperUser
=
superUser
masterConfig
.
GenericConfig
.
Authorizer
=
newRBACAuthorizer
(
t
,
superUser
,
masterConfig
)
masterConfig
.
GenericConfig
.
Authenticator
=
newFakeAuthenticator
()
masterConfig
.
GenericConfig
.
AuthorizerRBACSuperUser
=
superUser
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
defer
s
.
Close
()
...
...
test/integration/framework/master_utils.go
View file @
50e12ff5
...
...
@@ -134,22 +134,22 @@ func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Se
if
masterConfig
==
nil
{
masterConfig
=
NewMasterConfig
()
masterConfig
.
EnableProfiling
=
true
masterConfig
.
EnableSwaggerSupport
=
true
masterConfig
.
EnableOpenAPISupport
=
true
masterConfig
.
OpenAPIInfo
=
spec
.
Info
{
masterConfig
.
GenericConfig
.
EnableProfiling
=
true
masterConfig
.
GenericConfig
.
EnableSwaggerSupport
=
true
masterConfig
.
GenericConfig
.
EnableOpenAPISupport
=
true
masterConfig
.
GenericConfig
.
OpenAPIInfo
=
spec
.
Info
{
InfoProps
:
spec
.
InfoProps
{
Title
:
"Kubernetes"
,
Version
:
"unversioned"
,
},
}
masterConfig
.
OpenAPIDefaultResponse
=
spec
.
Response
{
masterConfig
.
GenericConfig
.
OpenAPIDefaultResponse
=
spec
.
Response
{
ResponseProps
:
spec
.
ResponseProps
{
Description
:
"Default Response."
,
},
}
}
m
,
err
:=
master
.
New
(
masterConfig
)
m
,
err
:=
master
Config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
glog
.
Fatalf
(
"error in bringing up the master: %v"
,
err
)
}
...
...
@@ -221,7 +221,7 @@ func NewMasterConfig() *master.Config {
NewSingleContentTypeSerializer
(
api
.
Scheme
,
testapi
.
Storage
.
Codec
(),
runtime
.
ContentTypeJSON
))
return
&
master
.
Config
{
Config
:
&
genericapiserver
.
Config
{
Generic
Config
:
&
genericapiserver
.
Config
{
APIResourceConfigSource
:
master
.
DefaultAPIResourceConfigSource
(),
APIPrefix
:
"/api"
,
APIGroupPrefix
:
"/apis"
,
...
...
@@ -245,10 +245,10 @@ func NewMasterConfig() *master.Config {
func
NewIntegrationTestMasterConfig
()
*
master
.
Config
{
masterConfig
:=
NewMasterConfig
()
masterConfig
.
EnableCoreControllers
=
true
masterConfig
.
EnableIndex
=
true
masterConfig
.
EnableVersion
=
true
masterConfig
.
PublicAddress
=
net
.
ParseIP
(
"192.168.10.4"
)
masterConfig
.
APIResourceConfigSource
=
master
.
DefaultAPIResourceConfigSource
()
masterConfig
.
GenericConfig
.
EnableIndex
=
true
masterConfig
.
GenericConfig
.
EnableVersion
=
true
masterConfig
.
GenericConfig
.
PublicAddress
=
net
.
ParseIP
(
"192.168.10.4"
)
masterConfig
.
GenericConfig
.
APIResourceConfigSource
=
master
.
DefaultAPIResourceConfigSource
()
return
masterConfig
}
...
...
@@ -332,7 +332,7 @@ func ScaleRC(name, ns string, replicas int32, clientset clientset.Interface) (*a
func
RunAMaster
(
masterConfig
*
master
.
Config
)
(
*
master
.
Master
,
*
httptest
.
Server
)
{
if
masterConfig
==
nil
{
masterConfig
=
NewMasterConfig
()
masterConfig
.
EnableProfiling
=
true
masterConfig
.
GenericConfig
.
EnableProfiling
=
true
}
return
startMasterOrDie
(
masterConfig
)
}
...
...
test/integration/garbagecollector/garbage_collector_test.go
View file @
50e12ff5
...
...
@@ -121,7 +121,7 @@ func newOwnerRC(name, namespace string) *v1.ReplicationController {
func
setup
(
t
*
testing
.
T
)
(
*
httptest
.
Server
,
*
garbagecollector
.
GarbageCollector
,
clientset
.
Interface
)
{
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
EnableCoreControllers
=
false
masterConfig
.
EnableGarbageCollection
=
true
masterConfig
.
GenericConfig
.
EnableGarbageCollection
=
true
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
clientSet
,
err
:=
clientset
.
NewForConfig
(
&
restclient
.
Config
{
Host
:
s
.
URL
})
...
...
test/integration/master/master_test.go
View file @
50e12ff5
...
...
@@ -424,7 +424,7 @@ func TestServiceAlloc(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"bad cidr: %v"
,
err
)
}
cfg
.
ServiceClusterIPRange
=
cidr
cfg
.
GenericConfig
.
ServiceClusterIPRange
=
cidr
_
,
s
:=
framework
.
RunAMaster
(
cfg
)
defer
s
.
Close
()
...
...
test/integration/openshift/openshift_test.go
View file @
50e12ff5
...
...
@@ -27,7 +27,7 @@ import (
// are not referenced directly by a master.
func
TestMasterExportsSymbols
(
t
*
testing
.
T
)
{
_
=
&
master
.
Config
{
Config
:
&
genericapiserver
.
Config
{
Generic
Config
:
&
genericapiserver
.
Config
{
EnableSwaggerSupport
:
false
,
RestfulContainer
:
nil
,
},
...
...
test/integration/quota/quota_test.go
View file @
50e12ff5
...
...
@@ -72,8 +72,8 @@ func TestQuota(t *testing.T) {
defer
close
(
admissionCh
)
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
.
AdmissionControl
=
admission
m
,
err
=
master
.
New
(
masterConfig
)
masterConfig
.
GenericConfig
.
AdmissionControl
=
admission
m
,
err
=
master
Config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
...
...
test/integration/scheduler_perf/util.go
View file @
50e12ff5
...
...
@@ -48,7 +48,7 @@ func mustSetupScheduler() (schedulerConfigFactory *factory.ConfigFactory, destro
var
m
*
master
.
Master
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
m
,
err
:=
master
Config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
panic
(
"error in brining up the master: "
+
err
.
Error
())
}
...
...
test/integration/serviceaccount/service_account_test.go
View file @
50e12ff5
...
...
@@ -406,13 +406,13 @@ func startServiceAccountTestServer(t *testing.T) (*clientset.Clientset, restclie
serviceAccountAdmission
:=
serviceaccountadmission
.
NewServiceAccount
(
rootClientset
)
masterConfig
:=
framework
.
NewMasterConfig
()
masterConfig
.
EnableIndex
=
true
masterConfig
.
Authenticator
=
authenticator
masterConfig
.
Authorizer
=
authorizer
masterConfig
.
AdmissionControl
=
serviceAccountAdmission
masterConfig
.
GenericConfig
.
EnableIndex
=
true
masterConfig
.
GenericConfig
.
Authenticator
=
authenticator
masterConfig
.
GenericConfig
.
Authorizer
=
authorizer
masterConfig
.
GenericConfig
.
AdmissionControl
=
serviceAccountAdmission
// Create a master and install handlers into mux.
m
,
err
:=
master
.
New
(
masterConfig
)
m
,
err
:=
master
Config
.
Complete
()
.
New
(
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
...
...
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