mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 11:38:15 +00:00
Turn embedding into composition: master.Config.{Config -> GenericConfig}
This commit is contained in:
parent
8391a19b57
commit
61409c821b
@ -310,7 +310,7 @@ func Run(s *options.APIServer) error {
|
|||||||
genericConfig.EnableOpenAPISupport = true
|
genericConfig.EnableOpenAPISupport = true
|
||||||
|
|
||||||
config := &master.Config{
|
config := &master.Config{
|
||||||
Config: genericConfig,
|
GenericConfig: genericConfig,
|
||||||
|
|
||||||
StorageFactory: storageFactory,
|
StorageFactory: storageFactory,
|
||||||
EnableWatchCache: s.EnableWatchCache,
|
EnableWatchCache: s.EnableWatchCache,
|
||||||
|
@ -116,7 +116,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
*genericapiserver.Config
|
GenericConfig *genericapiserver.Config
|
||||||
|
|
||||||
StorageFactory genericapiserver.StorageFactory
|
StorageFactory genericapiserver.StorageFactory
|
||||||
EnableWatchCache bool
|
EnableWatchCache bool
|
||||||
@ -231,7 +231,7 @@ func (c *Config) New() (*Master, error) {
|
|||||||
|
|
||||||
restOptionsFactory: restOptionsFactory{
|
restOptionsFactory: restOptionsFactory{
|
||||||
deleteCollectionWorkers: c.DeleteCollectionWorkers,
|
deleteCollectionWorkers: c.DeleteCollectionWorkers,
|
||||||
enableGarbageCollection: c.EnableGarbageCollection,
|
enableGarbageCollection: c.GenericConfig.EnableGarbageCollection,
|
||||||
storageFactory: c.StorageFactory,
|
storageFactory: c.StorageFactory,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -247,8 +247,8 @@ func (c *Config) New() (*Master, error) {
|
|||||||
c.RESTStorageProviders = map[string]genericapiserver.RESTStorageProvider{}
|
c.RESTStorageProviders = map[string]genericapiserver.RESTStorageProvider{}
|
||||||
}
|
}
|
||||||
c.RESTStorageProviders[appsapi.GroupName] = appsrest.RESTStorageProvider{}
|
c.RESTStorageProviders[appsapi.GroupName] = appsrest.RESTStorageProvider{}
|
||||||
c.RESTStorageProviders[authenticationv1beta1.GroupName] = authenticationrest.RESTStorageProvider{Authenticator: c.Authenticator}
|
c.RESTStorageProviders[authenticationv1beta1.GroupName] = authenticationrest.RESTStorageProvider{Authenticator: c.GenericConfig.Authenticator}
|
||||||
c.RESTStorageProviders[authorization.GroupName] = authorizationrest.RESTStorageProvider{Authorizer: c.Authorizer}
|
c.RESTStorageProviders[authorization.GroupName] = authorizationrest.RESTStorageProvider{Authorizer: c.GenericConfig.Authorizer}
|
||||||
c.RESTStorageProviders[autoscaling.GroupName] = autoscalingrest.RESTStorageProvider{}
|
c.RESTStorageProviders[autoscaling.GroupName] = autoscalingrest.RESTStorageProvider{}
|
||||||
c.RESTStorageProviders[batch.GroupName] = batchrest.RESTStorageProvider{}
|
c.RESTStorageProviders[batch.GroupName] = batchrest.RESTStorageProvider{}
|
||||||
c.RESTStorageProviders[certificates.GroupName] = certificatesrest.RESTStorageProvider{}
|
c.RESTStorageProviders[certificates.GroupName] = certificatesrest.RESTStorageProvider{}
|
||||||
@ -257,7 +257,7 @@ func (c *Config) New() (*Master, error) {
|
|||||||
DisableThirdPartyControllerForTesting: m.disableThirdPartyControllerForTesting,
|
DisableThirdPartyControllerForTesting: m.disableThirdPartyControllerForTesting,
|
||||||
}
|
}
|
||||||
c.RESTStorageProviders[policy.GroupName] = policyrest.RESTStorageProvider{}
|
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{}
|
c.RESTStorageProviders[storage.GroupName] = storagerest.RESTStorageProvider{}
|
||||||
m.InstallAPIs(c)
|
m.InstallAPIs(c)
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ func (m *Master) InstallAPIs(c *Config) {
|
|||||||
apiGroupsInfo := []genericapiserver.APIGroupInfo{}
|
apiGroupsInfo := []genericapiserver.APIGroupInfo{}
|
||||||
|
|
||||||
// Install v1 unless disabled.
|
// Install v1 unless disabled.
|
||||||
if c.APIResourceConfigSource.AnyResourcesForVersionEnabled(apiv1.SchemeGroupVersion) {
|
if c.GenericConfig.APIResourceConfigSource.AnyResourcesForVersionEnabled(apiv1.SchemeGroupVersion) {
|
||||||
// Install v1 API.
|
// Install v1 API.
|
||||||
m.initV1ResourcesStorage(c)
|
m.initV1ResourcesStorage(c)
|
||||||
apiGroupInfo := genericapiserver.APIGroupInfo{
|
apiGroupInfo := genericapiserver.APIGroupInfo{
|
||||||
@ -308,7 +308,7 @@ func (m *Master) InstallAPIs(c *Config) {
|
|||||||
}
|
}
|
||||||
healthz.InstallHandler(m.Mux, healthzChecks...)
|
healthz.InstallHandler(m.Mux, healthzChecks...)
|
||||||
|
|
||||||
if c.EnableProfiling {
|
if c.GenericConfig.EnableProfiling {
|
||||||
routes.MetricsWithReset{}.Install(m.Mux, m.HandlerContainer)
|
routes.MetricsWithReset{}.Install(m.Mux, m.HandlerContainer)
|
||||||
} else {
|
} else {
|
||||||
routes.DefaultMetrics{}.Install(m.Mux, m.HandlerContainer)
|
routes.DefaultMetrics{}.Install(m.Mux, m.HandlerContainer)
|
||||||
@ -316,7 +316,7 @@ func (m *Master) InstallAPIs(c *Config) {
|
|||||||
|
|
||||||
// Install third party resource support if requested
|
// 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
|
// 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
|
var err error
|
||||||
m.thirdPartyStorageConfig, err = c.StorageFactory.NewConfig(extensions.Resource("thirdpartyresources"))
|
m.thirdPartyStorageConfig, err = c.StorageFactory.NewConfig(extensions.Resource("thirdpartyresources"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -332,12 +332,12 @@ func (m *Master) InstallAPIs(c *Config) {
|
|||||||
// stabilize order.
|
// stabilize order.
|
||||||
// TODO find a better way to configure priority of groups
|
// TODO find a better way to configure priority of groups
|
||||||
for _, group := range sets.StringKeySet(c.RESTStorageProviders).List() {
|
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)
|
glog.V(1).Infof("Skipping disabled API group %q.", group)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
restStorageBuilder := c.RESTStorageProviders[group]
|
restStorageBuilder := c.RESTStorageProviders[group]
|
||||||
apiGroupInfo, enabled := restStorageBuilder.NewRESTStorage(c.APIResourceConfigSource, restOptionsGetter)
|
apiGroupInfo, enabled := restStorageBuilder.NewRESTStorage(c.GenericConfig.APIResourceConfigSource, restOptionsGetter)
|
||||||
if !enabled {
|
if !enabled {
|
||||||
glog.Warningf("Problem initializing API group %q, skipping.", group)
|
glog.Warningf("Problem initializing API group %q, skipping.", group)
|
||||||
continue
|
continue
|
||||||
|
@ -83,7 +83,7 @@ func setUp(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *assert.
|
|||||||
GenericAPIServer: &genericapiserver.GenericAPIServer{},
|
GenericAPIServer: &genericapiserver.GenericAPIServer{},
|
||||||
}
|
}
|
||||||
config := Config{
|
config := Config{
|
||||||
Config: &genericapiserver.Config{},
|
GenericConfig: &genericapiserver.Config{},
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceEncoding := genericapiserver.NewDefaultResourceEncodingConfig()
|
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())
|
storageFactory := genericapiserver.NewDefaultStorageFactory(*storageConfig, testapi.StorageMediaType(), api.Codecs, resourceEncoding, DefaultAPIResourceConfigSource())
|
||||||
|
|
||||||
config.StorageFactory = storageFactory
|
config.StorageFactory = storageFactory
|
||||||
config.APIResourceConfigSource = DefaultAPIResourceConfigSource()
|
config.GenericConfig.APIResourceConfigSource = DefaultAPIResourceConfigSource()
|
||||||
config.PublicAddress = net.ParseIP("192.168.10.4")
|
config.GenericConfig.PublicAddress = net.ParseIP("192.168.10.4")
|
||||||
config.Serializer = api.Codecs
|
config.GenericConfig.Serializer = api.Codecs
|
||||||
config.KubeletClient = client.FakeKubeletClient{}
|
config.KubeletClient = client.FakeKubeletClient{}
|
||||||
config.APIPrefix = "/api"
|
config.GenericConfig.APIPrefix = "/api"
|
||||||
config.APIGroupPrefix = "/apis"
|
config.GenericConfig.APIGroupPrefix = "/apis"
|
||||||
config.APIResourceConfigSource = DefaultAPIResourceConfigSource()
|
config.GenericConfig.APIResourceConfigSource = DefaultAPIResourceConfigSource()
|
||||||
config.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.ProxyTLSClientConfig = &tls.Config{}
|
config.GenericConfig.ProxyTLSClientConfig = &tls.Config{}
|
||||||
config.RequestContextMapper = api.NewRequestContextMapper()
|
config.GenericConfig.RequestContextMapper = api.NewRequestContextMapper()
|
||||||
config.Config.EnableVersion = true
|
config.GenericConfig.EnableVersion = true
|
||||||
|
|
||||||
// TODO: this is kind of hacky. The trouble is that the sync loop
|
// 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
|
// runs in a go-routine and there is no way to validate in the test
|
||||||
@ -150,7 +150,7 @@ func limitedAPIResourceConfigSource() *genericapiserver.ResourceConfig {
|
|||||||
// newLimitedMaster only enables the core group, the extensions group, the batch group, and the autoscaling group.
|
// 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) {
|
func newLimitedMaster(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *assert.Assertions) {
|
||||||
_, etcdserver, config, assert := setUp(t)
|
_, etcdserver, config, assert := setUp(t)
|
||||||
config.APIResourceConfigSource = limitedAPIResourceConfigSource()
|
config.GenericConfig.APIResourceConfigSource = limitedAPIResourceConfigSource()
|
||||||
master, err := config.Complete().New()
|
master, err := config.Complete().New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
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
|
// Verify many of the variables match their config counterparts
|
||||||
assert.Equal(master.enableCoreControllers, config.EnableCoreControllers)
|
assert.Equal(master.enableCoreControllers, config.EnableCoreControllers)
|
||||||
assert.Equal(master.tunneler, config.Tunneler)
|
assert.Equal(master.tunneler, config.Tunneler)
|
||||||
assert.Equal(master.RequestContextMapper(), config.RequestContextMapper)
|
assert.Equal(master.RequestContextMapper(), config.GenericConfig.RequestContextMapper)
|
||||||
assert.Equal(master.ClusterIP, config.PublicAddress)
|
assert.Equal(master.ClusterIP, config.GenericConfig.PublicAddress)
|
||||||
|
|
||||||
// these values get defaulted
|
// these values get defaulted
|
||||||
_, serviceClusterIPRange, _ := net.ParseCIDR("10.0.0.0/24")
|
_, 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
|
// These functions should point to the same memory location
|
||||||
masterDialer, _ := utilnet.Dialer(master.ProxyTransport)
|
masterDialer, _ := utilnet.Dialer(master.ProxyTransport)
|
||||||
masterDialerFunc := fmt.Sprintf("%p", masterDialer)
|
masterDialerFunc := fmt.Sprintf("%p", masterDialer)
|
||||||
configDialerFunc := fmt.Sprintf("%p", config.ProxyDialer)
|
configDialerFunc := fmt.Sprintf("%p", config.GenericConfig.ProxyDialer)
|
||||||
assert.Equal(masterDialerFunc, configDialerFunc)
|
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
|
// TestNamespaceSubresources ensures the namespace subresource parsing in apiserver/handlers.go doesn't drift
|
||||||
@ -1253,10 +1253,10 @@ func TestValidOpenAPISpec(t *testing.T) {
|
|||||||
_, etcdserver, config, assert := setUp(t)
|
_, etcdserver, config, assert := setUp(t)
|
||||||
defer etcdserver.Terminate(t)
|
defer etcdserver.Terminate(t)
|
||||||
|
|
||||||
config.OpenAPIDefinitions = openapi.OpenAPIDefinitions
|
config.GenericConfig.OpenAPIDefinitions = openapi.OpenAPIDefinitions
|
||||||
config.EnableOpenAPISupport = true
|
config.GenericConfig.EnableOpenAPISupport = true
|
||||||
config.EnableIndex = true
|
config.GenericConfig.EnableIndex = true
|
||||||
config.OpenAPIInfo = spec.Info{
|
config.GenericConfig.OpenAPIInfo = spec.Info{
|
||||||
InfoProps: spec.InfoProps{
|
InfoProps: spec.InfoProps{
|
||||||
Title: "Kubernetes",
|
Title: "Kubernetes",
|
||||||
Version: "unversioned",
|
Version: "unversioned",
|
||||||
|
@ -64,10 +64,10 @@ func TestSubjectAccessReview(t *testing.T) {
|
|||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = authenticator.RequestFunc(alwaysAlice)
|
masterConfig.GenericConfig.Authenticator = authenticator.RequestFunc(alwaysAlice)
|
||||||
masterConfig.Authorizer = sarAuthorizer{}
|
masterConfig.GenericConfig.Authorizer = sarAuthorizer{}
|
||||||
masterConfig.AdmissionControl = admit.NewAlwaysAdmit()
|
masterConfig.GenericConfig.AdmissionControl = admit.NewAlwaysAdmit()
|
||||||
m, err := masterConfig.New()
|
m, err := masterConfig.Complete().New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error in bringing up the master: %v", err)
|
t.Fatalf("error in bringing up the master: %v", err)
|
||||||
}
|
}
|
||||||
@ -164,12 +164,12 @@ func TestSelfSubjectAccessReview(t *testing.T) {
|
|||||||
|
|
||||||
username := "alice"
|
username := "alice"
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
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
|
return &user.DefaultInfo{Name: username}, true, nil
|
||||||
})
|
})
|
||||||
masterConfig.Authorizer = sarAuthorizer{}
|
masterConfig.GenericConfig.Authorizer = sarAuthorizer{}
|
||||||
masterConfig.AdmissionControl = admit.NewAlwaysAdmit()
|
masterConfig.GenericConfig.AdmissionControl = admit.NewAlwaysAdmit()
|
||||||
m, err := masterConfig.New()
|
m, err := masterConfig.Complete().New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error in bringing up the master: %v", err)
|
t.Fatalf("error in bringing up the master: %v", err)
|
||||||
}
|
}
|
||||||
@ -254,10 +254,10 @@ func TestLocalSubjectAccessReview(t *testing.T) {
|
|||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = authenticator.RequestFunc(alwaysAlice)
|
masterConfig.GenericConfig.Authenticator = authenticator.RequestFunc(alwaysAlice)
|
||||||
masterConfig.Authorizer = sarAuthorizer{}
|
masterConfig.GenericConfig.Authorizer = sarAuthorizer{}
|
||||||
masterConfig.AdmissionControl = admit.NewAlwaysAdmit()
|
masterConfig.GenericConfig.AdmissionControl = admit.NewAlwaysAdmit()
|
||||||
m, err := masterConfig.New()
|
m, err := masterConfig.Complete().New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error in bringing up the master: %v", err)
|
t.Fatalf("error in bringing up the master: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,7 @@ func getPreviousResourceVersionKey(url, id string) string {
|
|||||||
func TestAuthModeAlwaysDeny(t *testing.T) {
|
func TestAuthModeAlwaysDeny(t *testing.T) {
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authorizer = apiserverauthorizer.NewAlwaysDenyAuthorizer()
|
masterConfig.GenericConfig.Authorizer = apiserverauthorizer.NewAlwaysDenyAuthorizer()
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -549,9 +549,9 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
|
|||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = getTestTokenAuth()
|
masterConfig.GenericConfig.Authenticator = getTestTokenAuth()
|
||||||
masterConfig.Authorizer = allowAliceAuthorizer{}
|
masterConfig.GenericConfig.Authorizer = allowAliceAuthorizer{}
|
||||||
masterConfig.AdmissionControl = admit.NewAlwaysAdmit()
|
masterConfig.GenericConfig.AdmissionControl = admit.NewAlwaysAdmit()
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -619,8 +619,8 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
|
|||||||
func TestBobIsForbidden(t *testing.T) {
|
func TestBobIsForbidden(t *testing.T) {
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = getTestTokenAuth()
|
masterConfig.GenericConfig.Authenticator = getTestTokenAuth()
|
||||||
masterConfig.Authorizer = allowAliceAuthorizer{}
|
masterConfig.GenericConfig.Authorizer = allowAliceAuthorizer{}
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -663,8 +663,8 @@ func TestUnknownUserIsUnauthorized(t *testing.T) {
|
|||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = getTestTokenAuth()
|
masterConfig.GenericConfig.Authenticator = getTestTokenAuth()
|
||||||
masterConfig.Authorizer = allowAliceAuthorizer{}
|
masterConfig.GenericConfig.Authorizer = allowAliceAuthorizer{}
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -725,8 +725,8 @@ func (impersonateAuthorizer) Authorize(a authorizer.Attributes) (bool, string, e
|
|||||||
func TestImpersonateIsForbidden(t *testing.T) {
|
func TestImpersonateIsForbidden(t *testing.T) {
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = getTestTokenAuth()
|
masterConfig.GenericConfig.Authenticator = getTestTokenAuth()
|
||||||
masterConfig.Authorizer = impersonateAuthorizer{}
|
masterConfig.GenericConfig.Authorizer = impersonateAuthorizer{}
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -872,8 +872,8 @@ func TestAuthorizationAttributeDetermination(t *testing.T) {
|
|||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = getTestTokenAuth()
|
masterConfig.GenericConfig.Authenticator = getTestTokenAuth()
|
||||||
masterConfig.Authorizer = trackingAuthorizer
|
masterConfig.GenericConfig.Authorizer = trackingAuthorizer
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -938,8 +938,8 @@ func TestNamespaceAuthorization(t *testing.T) {
|
|||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = getTestTokenAuth()
|
masterConfig.GenericConfig.Authenticator = getTestTokenAuth()
|
||||||
masterConfig.Authorizer = a
|
masterConfig.GenericConfig.Authorizer = a
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -1036,8 +1036,8 @@ func TestKindAuthorization(t *testing.T) {
|
|||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = getTestTokenAuth()
|
masterConfig.GenericConfig.Authenticator = getTestTokenAuth()
|
||||||
masterConfig.Authorizer = a
|
masterConfig.GenericConfig.Authorizer = a
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -1120,8 +1120,8 @@ func TestReadOnlyAuthorization(t *testing.T) {
|
|||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = getTestTokenAuth()
|
masterConfig.GenericConfig.Authenticator = getTestTokenAuth()
|
||||||
masterConfig.Authorizer = a
|
masterConfig.GenericConfig.Authorizer = a
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -1179,8 +1179,8 @@ func TestWebhookTokenAuthenticator(t *testing.T) {
|
|||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authenticator = authenticator
|
masterConfig.GenericConfig.Authenticator = authenticator
|
||||||
masterConfig.Authorizer = allowAliceAuthorizer{}
|
masterConfig.GenericConfig.Authorizer = allowAliceAuthorizer{}
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
|
@ -338,9 +338,9 @@ func TestRBAC(t *testing.T) {
|
|||||||
for i, tc := range tests {
|
for i, tc := range tests {
|
||||||
// Create an API Server.
|
// Create an API Server.
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authorizer = newRBACAuthorizer(t, superUser, masterConfig)
|
masterConfig.GenericConfig.Authorizer = newRBACAuthorizer(t, superUser, masterConfig)
|
||||||
masterConfig.Authenticator = newFakeAuthenticator()
|
masterConfig.GenericConfig.Authenticator = newFakeAuthenticator()
|
||||||
masterConfig.AuthorizerRBACSuperUser = superUser
|
masterConfig.GenericConfig.AuthorizerRBACSuperUser = superUser
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -437,9 +437,9 @@ func TestBootstrapping(t *testing.T) {
|
|||||||
superUser := "admin"
|
superUser := "admin"
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.Authorizer = newRBACAuthorizer(t, superUser, masterConfig)
|
masterConfig.GenericConfig.Authorizer = newRBACAuthorizer(t, superUser, masterConfig)
|
||||||
masterConfig.Authenticator = newFakeAuthenticator()
|
masterConfig.GenericConfig.Authenticator = newFakeAuthenticator()
|
||||||
masterConfig.AuthorizerRBACSuperUser = superUser
|
masterConfig.GenericConfig.AuthorizerRBACSuperUser = superUser
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
|
@ -134,16 +134,16 @@ func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Se
|
|||||||
|
|
||||||
if masterConfig == nil {
|
if masterConfig == nil {
|
||||||
masterConfig = NewMasterConfig()
|
masterConfig = NewMasterConfig()
|
||||||
masterConfig.EnableProfiling = true
|
masterConfig.GenericConfig.EnableProfiling = true
|
||||||
masterConfig.EnableSwaggerSupport = true
|
masterConfig.GenericConfig.EnableSwaggerSupport = true
|
||||||
masterConfig.EnableOpenAPISupport = true
|
masterConfig.GenericConfig.EnableOpenAPISupport = true
|
||||||
masterConfig.OpenAPIInfo = spec.Info{
|
masterConfig.GenericConfig.OpenAPIInfo = spec.Info{
|
||||||
InfoProps: spec.InfoProps{
|
InfoProps: spec.InfoProps{
|
||||||
Title: "Kubernetes",
|
Title: "Kubernetes",
|
||||||
Version: "unversioned",
|
Version: "unversioned",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
masterConfig.OpenAPIDefaultResponse = spec.Response{
|
masterConfig.GenericConfig.OpenAPIDefaultResponse = spec.Response{
|
||||||
ResponseProps: spec.ResponseProps{
|
ResponseProps: spec.ResponseProps{
|
||||||
Description: "Default Response.",
|
Description: "Default Response.",
|
||||||
},
|
},
|
||||||
@ -221,7 +221,7 @@ func NewMasterConfig() *master.Config {
|
|||||||
NewSingleContentTypeSerializer(api.Scheme, testapi.Storage.Codec(), runtime.ContentTypeJSON))
|
NewSingleContentTypeSerializer(api.Scheme, testapi.Storage.Codec(), runtime.ContentTypeJSON))
|
||||||
|
|
||||||
return &master.Config{
|
return &master.Config{
|
||||||
Config: &genericapiserver.Config{
|
GenericConfig: &genericapiserver.Config{
|
||||||
APIResourceConfigSource: master.DefaultAPIResourceConfigSource(),
|
APIResourceConfigSource: master.DefaultAPIResourceConfigSource(),
|
||||||
APIPrefix: "/api",
|
APIPrefix: "/api",
|
||||||
APIGroupPrefix: "/apis",
|
APIGroupPrefix: "/apis",
|
||||||
@ -245,10 +245,10 @@ func NewMasterConfig() *master.Config {
|
|||||||
func NewIntegrationTestMasterConfig() *master.Config {
|
func NewIntegrationTestMasterConfig() *master.Config {
|
||||||
masterConfig := NewMasterConfig()
|
masterConfig := NewMasterConfig()
|
||||||
masterConfig.EnableCoreControllers = true
|
masterConfig.EnableCoreControllers = true
|
||||||
masterConfig.EnableIndex = true
|
masterConfig.GenericConfig.EnableIndex = true
|
||||||
masterConfig.EnableVersion = true
|
masterConfig.GenericConfig.EnableVersion = true
|
||||||
masterConfig.PublicAddress = net.ParseIP("192.168.10.4")
|
masterConfig.GenericConfig.PublicAddress = net.ParseIP("192.168.10.4")
|
||||||
masterConfig.APIResourceConfigSource = master.DefaultAPIResourceConfigSource()
|
masterConfig.GenericConfig.APIResourceConfigSource = master.DefaultAPIResourceConfigSource()
|
||||||
return masterConfig
|
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) {
|
func RunAMaster(masterConfig *master.Config) (*master.Master, *httptest.Server) {
|
||||||
if masterConfig == nil {
|
if masterConfig == nil {
|
||||||
masterConfig = NewMasterConfig()
|
masterConfig = NewMasterConfig()
|
||||||
masterConfig.EnableProfiling = true
|
masterConfig.GenericConfig.EnableProfiling = true
|
||||||
}
|
}
|
||||||
return startMasterOrDie(masterConfig)
|
return startMasterOrDie(masterConfig)
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func newOwnerRC(name, namespace string) *v1.ReplicationController {
|
|||||||
func setup(t *testing.T) (*httptest.Server, *garbagecollector.GarbageCollector, clientset.Interface) {
|
func setup(t *testing.T) (*httptest.Server, *garbagecollector.GarbageCollector, clientset.Interface) {
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.EnableCoreControllers = false
|
masterConfig.EnableCoreControllers = false
|
||||||
masterConfig.EnableGarbageCollection = true
|
masterConfig.GenericConfig.EnableGarbageCollection = true
|
||||||
_, s := framework.RunAMaster(masterConfig)
|
_, s := framework.RunAMaster(masterConfig)
|
||||||
|
|
||||||
clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL})
|
clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL})
|
||||||
|
@ -424,7 +424,7 @@ func TestServiceAlloc(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("bad cidr: %v", err)
|
t.Fatalf("bad cidr: %v", err)
|
||||||
}
|
}
|
||||||
cfg.ServiceClusterIPRange = cidr
|
cfg.GenericConfig.ServiceClusterIPRange = cidr
|
||||||
_, s := framework.RunAMaster(cfg)
|
_, s := framework.RunAMaster(cfg)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
// are not referenced directly by a master.
|
// are not referenced directly by a master.
|
||||||
func TestMasterExportsSymbols(t *testing.T) {
|
func TestMasterExportsSymbols(t *testing.T) {
|
||||||
_ = &master.Config{
|
_ = &master.Config{
|
||||||
Config: &genericapiserver.Config{
|
GenericConfig: &genericapiserver.Config{
|
||||||
EnableSwaggerSupport: false,
|
EnableSwaggerSupport: false,
|
||||||
RestfulContainer: nil,
|
RestfulContainer: nil,
|
||||||
},
|
},
|
||||||
|
@ -72,7 +72,7 @@ func TestQuota(t *testing.T) {
|
|||||||
defer close(admissionCh)
|
defer close(admissionCh)
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||||
masterConfig.AdmissionControl = admission
|
masterConfig.GenericConfig.AdmissionControl = admission
|
||||||
m, err = masterConfig.Complete().New()
|
m, err = masterConfig.Complete().New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
t.Fatalf("Error in bringing up the master: %v", err)
|
||||||
|
@ -406,10 +406,10 @@ func startServiceAccountTestServer(t *testing.T) (*clientset.Clientset, restclie
|
|||||||
serviceAccountAdmission := serviceaccountadmission.NewServiceAccount(rootClientset)
|
serviceAccountAdmission := serviceaccountadmission.NewServiceAccount(rootClientset)
|
||||||
|
|
||||||
masterConfig := framework.NewMasterConfig()
|
masterConfig := framework.NewMasterConfig()
|
||||||
masterConfig.EnableIndex = true
|
masterConfig.GenericConfig.EnableIndex = true
|
||||||
masterConfig.Authenticator = authenticator
|
masterConfig.GenericConfig.Authenticator = authenticator
|
||||||
masterConfig.Authorizer = authorizer
|
masterConfig.GenericConfig.Authorizer = authorizer
|
||||||
masterConfig.AdmissionControl = serviceAccountAdmission
|
masterConfig.GenericConfig.AdmissionControl = serviceAccountAdmission
|
||||||
|
|
||||||
// Create a master and install handlers into mux.
|
// Create a master and install handlers into mux.
|
||||||
m, err := masterConfig.Complete().New()
|
m, err := masterConfig.Complete().New()
|
||||||
|
Loading…
Reference in New Issue
Block a user