// NewForConfigOrDie creates a new Clientset for the given config and // panics if there is an error in the config. func NewForConfigOrDie(c *restclient.Config) *Clientset { var clientset Clientset clientset.CoreClient = unversionedcore.NewForConfigOrDie(c) clientset.ExtensionsClient = unversionedextensions.NewForConfigOrDie(c) clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &clientset }
// NewForConfigOrDie creates a new Clientset for the given config and // panics if there is an error in the config. func NewForConfigOrDie(c *restclient.Config) *Clientset { var clientset Clientset clientset.CoreClient = unversionedcore.NewForConfigOrDie(c) clientset.ExtensionsClient = unversionedextensions.NewForConfigOrDie(c) clientset.AutoscalingClient = unversionedautoscaling.NewForConfigOrDie(c) clientset.BatchClient = unversionedbatch.NewForConfigOrDie(c) clientset.RbacClient = unversionedrbac.NewForConfigOrDie(c) clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &clientset }
// NewForConfigOrDie creates a new Clientset for the given config and // panics if there is an error in the config. func NewForConfigOrDie(c *restclient.Config) *Clientset { var clientset Clientset clientset.CoreClient = unversionedcore.NewForConfigOrDie(c) clientset.AuthenticationClient = unversionedauthentication.NewForConfigOrDie(c) clientset.AuthorizationClient = unversionedauthorization.NewForConfigOrDie(c) clientset.AutoscalingClient = unversionedautoscaling.NewForConfigOrDie(c) clientset.BatchClient = unversionedbatch.NewForConfigOrDie(c) clientset.CertificatesClient = unversionedcertificates.NewForConfigOrDie(c) clientset.ExtensionsClient = unversionedextensions.NewForConfigOrDie(c) clientset.RbacClient = unversionedrbac.NewForConfigOrDie(c) clientset.StorageClient = unversionedstorage.NewForConfigOrDie(c) clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &clientset }
// 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 if c.EndpointReconcilerConfig.Interval == 0 { c.EndpointReconcilerConfig.Interval = DefaultEndpointReconcilerInterval } if c.EndpointReconcilerConfig.Reconciler == nil { // use a default endpoint reconciler if nothing is set endpointClient := coreclient.NewForConfigOrDie(c.GenericConfig.LoopbackClientConfig) c.EndpointReconcilerConfig.Reconciler = NewMasterCountEndpointReconciler(c.GenericConfig.MasterCount, endpointClient) } 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: // KubeletClientConfig func (c completedConfig) New() (*Master, error) { if reflect.DeepEqual(c.KubeletClientConfig, kubeletclient.KubeletClientConfig{}) { return nil, fmt.Errorf("Master.New() called with empty config.KubeletClientConfig") } s, err := c.Config.GenericConfig.SkipComplete().New() // completion is done in Complete, no need for a second time if err != nil { return nil, err } if c.EnableUISupport { routes.UIRedirect{}.Install(s.HandlerContainer) } if c.EnableLogsSupport { routes.Logs{}.Install(s.HandlerContainer) } m := &Master{ GenericAPIServer: s, nodeClient: coreclient.NewForConfigOrDie(c.GenericConfig.LoopbackClientConfig).Nodes(), thirdPartyResourceServer: thirdparty.NewThirdPartyResourceServer(s), } restOptionsFactory := restOptionsFactory{ deleteCollectionWorkers: c.DeleteCollectionWorkers, enableGarbageCollection: c.GenericConfig.EnableGarbageCollection, storageFactory: c.StorageFactory, } if c.EnableWatchCache { restOptionsFactory.storageDecorator = registry.StorageWithCacher } else { restOptionsFactory.storageDecorator = generic.UndecoratedStorage } // install legacy rest storage if c.GenericConfig.APIResourceConfigSource.AnyResourcesForVersionEnabled(apiv1.SchemeGroupVersion) { legacyRESTStorageProvider := corerest.LegacyRESTStorageProvider{ StorageFactory: c.StorageFactory, ProxyTransport: c.ProxyTransport, KubeletClientConfig: c.KubeletClientConfig, EventTTL: c.EventTTL, ServiceClusterIPRange: c.GenericConfig.ServiceClusterIPRange, ServiceNodePortRange: c.GenericConfig.ServiceNodePortRange, ComponentStatusServerFunc: func() map[string]apiserver.Server { return getServersToValidate(c.StorageFactory) }, LoopbackClientConfig: c.GenericConfig.LoopbackClientConfig, } m.InstallLegacyAPI(c.Config, restOptionsFactory.NewFor, legacyRESTStorageProvider) } // Add some hardcoded storage for now. Append to the map. if c.RESTStorageProviders == nil { c.RESTStorageProviders = map[string]genericapiserver.RESTStorageProvider{} } c.RESTStorageProviders[appsapi.GroupName] = appsrest.RESTStorageProvider{} 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{} c.RESTStorageProviders[extensions.GroupName] = extensionsrest.RESTStorageProvider{ResourceInterface: m.thirdPartyResourceServer} c.RESTStorageProviders[policy.GroupName] = policyrest.RESTStorageProvider{} c.RESTStorageProviders[rbac.GroupName] = &rbacrest.RESTStorageProvider{AuthorizerRBACSuperUser: c.GenericConfig.AuthorizerRBACSuperUser} c.RESTStorageProviders[storage.GroupName] = storagerest.RESTStorageProvider{} m.InstallAPIs(c.Config, restOptionsFactory.NewFor) m.InstallGeneralEndpoints(c.Config) return m, nil }