mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #79418 from yue9944882/chore/prune-aggregator-internals
Prune hub-type client/informer/lister from kube-aggregator
This commit is contained in:
commit
683e405f31
@ -66,13 +66,13 @@ go_library(
|
|||||||
"//staging/src/k8s.io/cloud-provider:go_default_library",
|
"//staging/src/k8s.io/cloud-provider:go_default_library",
|
||||||
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
|
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
|
||||||
"//staging/src/k8s.io/component-base/cli/globalflag:go_default_library",
|
"//staging/src/k8s.io/component-base/cli/globalflag:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister:go_default_library",
|
||||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||||
|
@ -41,13 +41,13 @@ import (
|
|||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
kubeexternalinformers "k8s.io/client-go/informers"
|
kubeexternalinformers "k8s.io/client-go/informers"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
|
v1helper "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
|
||||||
aggregatorapiserver "k8s.io/kube-aggregator/pkg/apiserver"
|
aggregatorapiserver "k8s.io/kube-aggregator/pkg/apiserver"
|
||||||
aggregatorscheme "k8s.io/kube-aggregator/pkg/apiserver/scheme"
|
aggregatorscheme "k8s.io/kube-aggregator/pkg/apiserver/scheme"
|
||||||
apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion"
|
apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
|
||||||
informers "k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion"
|
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1"
|
||||||
"k8s.io/kube-aggregator/pkg/controllers/autoregister"
|
"k8s.io/kube-aggregator/pkg/controllers/autoregister"
|
||||||
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
||||||
"k8s.io/kubernetes/pkg/master/controller/crdregistration"
|
"k8s.io/kubernetes/pkg/master/controller/crdregistration"
|
||||||
@ -130,7 +130,7 @@ func createAggregatorServer(aggregatorConfig *aggregatorapiserver.Config, delega
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
autoRegistrationController := autoregister.NewAutoRegisterController(aggregatorServer.APIRegistrationInformers.Apiregistration().InternalVersion().APIServices(), apiRegistrationClient)
|
autoRegistrationController := autoregister.NewAutoRegisterController(aggregatorServer.APIRegistrationInformers.Apiregistration().V1().APIServices(), apiRegistrationClient)
|
||||||
apiServices := apiServicesToRegister(delegateAPIServer, autoRegistrationController)
|
apiServices := apiServicesToRegister(delegateAPIServer, autoRegistrationController)
|
||||||
crdRegistrationController := crdregistration.NewCRDRegistrationController(
|
crdRegistrationController := crdregistration.NewCRDRegistrationController(
|
||||||
apiExtensionInformers.Apiextensions().InternalVersion().CustomResourceDefinitions(),
|
apiExtensionInformers.Apiextensions().InternalVersion().CustomResourceDefinitions(),
|
||||||
@ -157,7 +157,7 @@ func createAggregatorServer(aggregatorConfig *aggregatorapiserver.Config, delega
|
|||||||
makeAPIServiceAvailableHealthzCheck(
|
makeAPIServiceAvailableHealthzCheck(
|
||||||
"autoregister-completion",
|
"autoregister-completion",
|
||||||
apiServices,
|
apiServices,
|
||||||
aggregatorServer.APIRegistrationInformers.Apiregistration().InternalVersion().APIServices(),
|
aggregatorServer.APIRegistrationInformers.Apiregistration().V1().APIServices(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -167,7 +167,7 @@ func createAggregatorServer(aggregatorConfig *aggregatorapiserver.Config, delega
|
|||||||
return aggregatorServer, nil
|
return aggregatorServer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeAPIService(gv schema.GroupVersion) *apiregistration.APIService {
|
func makeAPIService(gv schema.GroupVersion) *v1.APIService {
|
||||||
apiServicePriority, ok := apiVersionPriorities[gv]
|
apiServicePriority, ok := apiVersionPriorities[gv]
|
||||||
if !ok {
|
if !ok {
|
||||||
// if we aren't found, then we shouldn't register ourselves because it could result in a CRD group version
|
// if we aren't found, then we shouldn't register ourselves because it could result in a CRD group version
|
||||||
@ -175,9 +175,9 @@ func makeAPIService(gv schema.GroupVersion) *apiregistration.APIService {
|
|||||||
klog.Infof("Skipping APIService creation for %v", gv)
|
klog.Infof("Skipping APIService creation for %v", gv)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &apiregistration.APIService{
|
return &v1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: gv.Version + "." + gv.Group},
|
ObjectMeta: metav1.ObjectMeta{Name: gv.Version + "." + gv.Group},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: v1.APIServiceSpec{
|
||||||
Group: gv.Group,
|
Group: gv.Group,
|
||||||
Version: gv.Version,
|
Version: gv.Version,
|
||||||
GroupPriorityMinimum: apiServicePriority.group,
|
GroupPriorityMinimum: apiServicePriority.group,
|
||||||
@ -188,7 +188,7 @@ func makeAPIService(gv schema.GroupVersion) *apiregistration.APIService {
|
|||||||
|
|
||||||
// makeAPIServiceAvailableHealthzCheck returns a healthz check that returns healthy
|
// makeAPIServiceAvailableHealthzCheck returns a healthz check that returns healthy
|
||||||
// once all of the specified services have been observed to be available at least once.
|
// once all of the specified services have been observed to be available at least once.
|
||||||
func makeAPIServiceAvailableHealthzCheck(name string, apiServices []*apiregistration.APIService, apiServiceInformer informers.APIServiceInformer) healthz.HealthzChecker {
|
func makeAPIServiceAvailableHealthzCheck(name string, apiServices []*v1.APIService, apiServiceInformer informers.APIServiceInformer) healthz.HealthzChecker {
|
||||||
// Track the auto-registered API services that have not been observed to be available yet
|
// Track the auto-registered API services that have not been observed to be available yet
|
||||||
pendingServiceNamesLock := &sync.RWMutex{}
|
pendingServiceNamesLock := &sync.RWMutex{}
|
||||||
pendingServiceNames := sets.NewString()
|
pendingServiceNames := sets.NewString()
|
||||||
@ -197,21 +197,21 @@ func makeAPIServiceAvailableHealthzCheck(name string, apiServices []*apiregistra
|
|||||||
}
|
}
|
||||||
|
|
||||||
// When an APIService in the list is seen as available, remove it from the pending list
|
// When an APIService in the list is seen as available, remove it from the pending list
|
||||||
handleAPIServiceChange := func(service *apiregistration.APIService) {
|
handleAPIServiceChange := func(service *v1.APIService) {
|
||||||
pendingServiceNamesLock.Lock()
|
pendingServiceNamesLock.Lock()
|
||||||
defer pendingServiceNamesLock.Unlock()
|
defer pendingServiceNamesLock.Unlock()
|
||||||
if !pendingServiceNames.Has(service.Name) {
|
if !pendingServiceNames.Has(service.Name) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if apiregistration.IsAPIServiceConditionTrue(service, apiregistration.Available) {
|
if v1helper.IsAPIServiceConditionTrue(service, v1.Available) {
|
||||||
pendingServiceNames.Delete(service.Name)
|
pendingServiceNames.Delete(service.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch add/update events for APIServices
|
// Watch add/update events for APIServices
|
||||||
apiServiceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
apiServiceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: func(obj interface{}) { handleAPIServiceChange(obj.(*apiregistration.APIService)) },
|
AddFunc: func(obj interface{}) { handleAPIServiceChange(obj.(*v1.APIService)) },
|
||||||
UpdateFunc: func(old, new interface{}) { handleAPIServiceChange(new.(*apiregistration.APIService)) },
|
UpdateFunc: func(old, new interface{}) { handleAPIServiceChange(new.(*v1.APIService)) },
|
||||||
})
|
})
|
||||||
|
|
||||||
// Don't return healthy until the pending list is empty
|
// Don't return healthy until the pending list is empty
|
||||||
@ -285,8 +285,8 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{
|
|||||||
// Version can be set to 9 (to have space around) for a new group.
|
// Version can be set to 9 (to have space around) for a new group.
|
||||||
}
|
}
|
||||||
|
|
||||||
func apiServicesToRegister(delegateAPIServer genericapiserver.DelegationTarget, registration autoregister.AutoAPIServiceRegistration) []*apiregistration.APIService {
|
func apiServicesToRegister(delegateAPIServer genericapiserver.DelegationTarget, registration autoregister.AutoAPIServiceRegistration) []*v1.APIService {
|
||||||
apiServices := []*apiregistration.APIService{}
|
apiServices := []*v1.APIService{}
|
||||||
|
|
||||||
for _, curr := range delegateAPIServer.ListedPaths() {
|
for _, curr := range delegateAPIServer.ListedPaths() {
|
||||||
if curr == "/api/v1" {
|
if curr == "/api/v1" {
|
||||||
|
@ -22,7 +22,7 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
"//vendor/k8s.io/klog:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -50,6 +50,6 @@ go_test(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
"k8s.io/kubernetes/pkg/controller"
|
"k8s.io/kubernetes/pkg/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ import (
|
|||||||
// adding and removing APIServices
|
// adding and removing APIServices
|
||||||
type AutoAPIServiceRegistration interface {
|
type AutoAPIServiceRegistration interface {
|
||||||
// AddAPIServiceToSync adds an API service to auto-register.
|
// AddAPIServiceToSync adds an API service to auto-register.
|
||||||
AddAPIServiceToSync(in *apiregistration.APIService)
|
AddAPIServiceToSync(in *v1.APIService)
|
||||||
// RemoveAPIServiceToSync removes an API service to auto-register.
|
// RemoveAPIServiceToSync removes an API service to auto-register.
|
||||||
RemoveAPIServiceToSync(name string)
|
RemoveAPIServiceToSync(name string)
|
||||||
}
|
}
|
||||||
@ -208,9 +208,9 @@ func (c *crdRegistrationController) handleVersionUpdate(groupVersion schema.Grou
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
c.apiServiceRegistration.AddAPIServiceToSync(&apiregistration.APIService{
|
c.apiServiceRegistration.AddAPIServiceToSync(&v1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: apiServiceName},
|
ObjectMeta: metav1.ObjectMeta{Name: apiServiceName},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: v1.APIServiceSpec{
|
||||||
Group: groupVersion.Group,
|
Group: groupVersion.Group,
|
||||||
Version: groupVersion.Version,
|
Version: groupVersion.Version,
|
||||||
GroupPriorityMinimum: 1000, // CRDs should have relatively low priority
|
GroupPriorityMinimum: 1000, // CRDs should have relatively low priority
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHandleVersionUpdate(t *testing.T) {
|
func TestHandleVersionUpdate(t *testing.T) {
|
||||||
|
@ -24,8 +24,8 @@ go_library(
|
|||||||
"//staging/src/k8s.io/component-base/logs:go_default_library",
|
"//staging/src/k8s.io/component-base/logs:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/install:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/install:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/validation:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/validation:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1beta1:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/cmd/server:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/cmd/server:go_default_library",
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
"//vendor/k8s.io/klog:go_default_library",
|
||||||
@ -47,10 +47,7 @@ filegroup(
|
|||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:all-srcs",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:all-srcs",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver:all-srcs",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver:all-srcs",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset:all-srcs",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset:all-srcs",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset:all-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/externalversions:all-srcs",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/externalversions:all-srcs",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion:all-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:all-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:all-srcs",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:all-srcs",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1beta1:all-srcs",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1beta1:all-srcs",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/openapi:all-srcs",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/openapi:all-srcs",
|
||||||
|
@ -32,7 +32,7 @@ bash "${CODEGEN_PKG}/generate-groups.sh" deepcopy,client,lister,informer \
|
|||||||
CLIENTSET_NAME_VERSIONED=clientset \
|
CLIENTSET_NAME_VERSIONED=clientset \
|
||||||
CLIENTSET_PKG_NAME=clientset_generated \
|
CLIENTSET_PKG_NAME=clientset_generated \
|
||||||
CLIENTSET_NAME_INTERNAL=internalclientset \
|
CLIENTSET_NAME_INTERNAL=internalclientset \
|
||||||
bash "${CODEGEN_PKG}/generate-internal-groups.sh" deepcopy,client,lister,informer,conversion \
|
bash "${CODEGEN_PKG}/generate-internal-groups.sh" deepcopy,conversion \
|
||||||
k8s.io/kube-aggregator/pkg/client k8s.io/kube-aggregator/pkg/apis k8s.io/kube-aggregator/pkg/apis \
|
k8s.io/kube-aggregator/pkg/client k8s.io/kube-aggregator/pkg/apis k8s.io/kube-aggregator/pkg/apis \
|
||||||
"apiregistration:v1beta1,v1" \
|
"apiregistration:v1beta1,v1" \
|
||||||
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
|
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
|
||||||
|
@ -29,8 +29,8 @@ import (
|
|||||||
// force compilation of packages we'll later rely upon
|
// force compilation of packages we'll later rely upon
|
||||||
_ "k8s.io/kube-aggregator/pkg/apis/apiregistration/install"
|
_ "k8s.io/kube-aggregator/pkg/apis/apiregistration/install"
|
||||||
_ "k8s.io/kube-aggregator/pkg/apis/apiregistration/validation"
|
_ "k8s.io/kube-aggregator/pkg/apis/apiregistration/validation"
|
||||||
_ "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset"
|
_ "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
|
||||||
_ "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
_ "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
_ "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1beta1"
|
_ "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,10 +18,8 @@ package apiregistration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -84,13 +82,6 @@ func (s ByVersionPriority) Less(i, j int) bool {
|
|||||||
return version.CompareKubeAwareVersionStrings(s[i].Spec.Version, s[j].Spec.Version) > 0
|
return version.CompareKubeAwareVersionStrings(s[i].Spec.Version, s[j].Spec.Version) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIServiceNameToGroupVersion returns the GroupVersion for a given apiServiceName. The name
|
|
||||||
// must be valid, but any object you get back from an informer will be valid.
|
|
||||||
func APIServiceNameToGroupVersion(apiServiceName string) schema.GroupVersion {
|
|
||||||
tokens := strings.SplitN(apiServiceName, ".", 2)
|
|
||||||
return schema.GroupVersion{Group: tokens[1], Version: tokens[0]}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewLocalAvailableAPIServiceCondition returns a condition for an available local APIService.
|
// NewLocalAvailableAPIServiceCondition returns a condition for an available local APIService.
|
||||||
func NewLocalAvailableAPIServiceCondition() APIServiceCondition {
|
func NewLocalAvailableAPIServiceCondition() APIServiceCondition {
|
||||||
return APIServiceCondition{
|
return APIServiceCondition{
|
||||||
|
@ -39,6 +39,9 @@ filegroup(
|
|||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "all-srcs",
|
name = "all-srcs",
|
||||||
srcs = [":package-srcs"],
|
srcs = [
|
||||||
|
":package-srcs",
|
||||||
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper:all-srcs",
|
||||||
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
)
|
)
|
||||||
|
@ -1,27 +1,26 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = ["helpers.go"],
|
||||||
"doc.go",
|
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper",
|
||||||
"register.go",
|
importpath = "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper",
|
||||||
],
|
visibility = ["//visibility:public"],
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/scheme",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/scheme",
|
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/version:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/install:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
go_test(
|
||||||
|
name = "go_default_test",
|
||||||
|
srcs = ["helpers_test.go"],
|
||||||
|
embed = [":go_default_library"],
|
||||||
|
deps = ["//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library"],
|
||||||
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "package-srcs",
|
name = "package-srcs",
|
||||||
srcs = glob(["**"]),
|
srcs = glob(["**"]),
|
||||||
@ -33,4 +32,5 @@ filegroup(
|
|||||||
name = "all-srcs",
|
name = "all-srcs",
|
||||||
srcs = [":package-srcs"],
|
srcs = [":package-srcs"],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 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 helper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
"k8s.io/apimachinery/pkg/version"
|
||||||
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SortedByGroupAndVersion sorts APIServices into their different groups, and then sorts them based on their versions.
|
||||||
|
// For example, the first element of the first array contains the APIService with the highest version number, in the
|
||||||
|
// group with the highest priority; while the last element of the last array contains the APIService with the lowest
|
||||||
|
// version number, in the group with the lowest priority.
|
||||||
|
func SortedByGroupAndVersion(servers []*v1.APIService) [][]*v1.APIService {
|
||||||
|
serversByGroupPriorityMinimum := ByGroupPriorityMinimum(servers)
|
||||||
|
sort.Sort(serversByGroupPriorityMinimum)
|
||||||
|
|
||||||
|
ret := [][]*v1.APIService{}
|
||||||
|
for _, curr := range serversByGroupPriorityMinimum {
|
||||||
|
// check to see if we already have an entry for this group
|
||||||
|
existingIndex := -1
|
||||||
|
for j, groupInReturn := range ret {
|
||||||
|
if groupInReturn[0].Spec.Group == curr.Spec.Group {
|
||||||
|
existingIndex = j
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if existingIndex >= 0 {
|
||||||
|
ret[existingIndex] = append(ret[existingIndex], curr)
|
||||||
|
sort.Sort(ByVersionPriority(ret[existingIndex]))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = append(ret, []*v1.APIService{curr})
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByGroupPriorityMinimum sorts with the highest group number first, then by name.
|
||||||
|
// This is not a simple reverse, because we want the name sorting to be alpha, not
|
||||||
|
// reverse alpha.
|
||||||
|
type ByGroupPriorityMinimum []*v1.APIService
|
||||||
|
|
||||||
|
func (s ByGroupPriorityMinimum) Len() int { return len(s) }
|
||||||
|
func (s ByGroupPriorityMinimum) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
func (s ByGroupPriorityMinimum) Less(i, j int) bool {
|
||||||
|
if s[i].Spec.GroupPriorityMinimum != s[j].Spec.GroupPriorityMinimum {
|
||||||
|
return s[i].Spec.GroupPriorityMinimum > s[j].Spec.GroupPriorityMinimum
|
||||||
|
}
|
||||||
|
return s[i].Name < s[j].Name
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByVersionPriority sorts with the highest version number first, then by name.
|
||||||
|
// This is not a simple reverse, because we want the name sorting to be alpha, not
|
||||||
|
// reverse alpha.
|
||||||
|
type ByVersionPriority []*v1.APIService
|
||||||
|
|
||||||
|
func (s ByVersionPriority) Len() int { return len(s) }
|
||||||
|
func (s ByVersionPriority) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
func (s ByVersionPriority) Less(i, j int) bool {
|
||||||
|
if s[i].Spec.VersionPriority != s[j].Spec.VersionPriority {
|
||||||
|
return s[i].Spec.VersionPriority > s[j].Spec.VersionPriority
|
||||||
|
}
|
||||||
|
return version.CompareKubeAwareVersionStrings(s[i].Spec.Version, s[j].Spec.Version) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIServiceNameToGroupVersion returns the GroupVersion for a given apiServiceName. The name
|
||||||
|
// must be valid, but any object you get back from an informer will be valid.
|
||||||
|
func APIServiceNameToGroupVersion(apiServiceName string) schema.GroupVersion {
|
||||||
|
tokens := strings.SplitN(apiServiceName, ".", 2)
|
||||||
|
return schema.GroupVersion{Group: tokens[1], Version: tokens[0]}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLocalAvailableAPIServiceCondition returns a condition for an available local APIService.
|
||||||
|
func NewLocalAvailableAPIServiceCondition() v1.APIServiceCondition {
|
||||||
|
return v1.APIServiceCondition{
|
||||||
|
Type: v1.Available,
|
||||||
|
Status: v1.ConditionTrue,
|
||||||
|
LastTransitionTime: metav1.Now(),
|
||||||
|
Reason: "Local",
|
||||||
|
Message: "Local APIServices are always available",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAPIServiceCondition sets the status condition. It either overwrites the existing one or
|
||||||
|
// creates a new one
|
||||||
|
func SetAPIServiceCondition(apiService *v1.APIService, newCondition v1.APIServiceCondition) {
|
||||||
|
existingCondition := GetAPIServiceConditionByType(apiService, newCondition.Type)
|
||||||
|
if existingCondition == nil {
|
||||||
|
apiService.Status.Conditions = append(apiService.Status.Conditions, newCondition)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if existingCondition.Status != newCondition.Status {
|
||||||
|
existingCondition.Status = newCondition.Status
|
||||||
|
existingCondition.LastTransitionTime = newCondition.LastTransitionTime
|
||||||
|
}
|
||||||
|
|
||||||
|
existingCondition.Reason = newCondition.Reason
|
||||||
|
existingCondition.Message = newCondition.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsAPIServiceConditionTrue indicates if the condition is present and strictly true
|
||||||
|
func IsAPIServiceConditionTrue(apiService *v1.APIService, conditionType v1.APIServiceConditionType) bool {
|
||||||
|
condition := GetAPIServiceConditionByType(apiService, conditionType)
|
||||||
|
return condition != nil && condition.Status == v1.ConditionTrue
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAPIServiceConditionByType gets an *APIServiceCondition by APIServiceConditionType if present
|
||||||
|
func GetAPIServiceConditionByType(apiService *v1.APIService, conditionType v1.APIServiceConditionType) *v1.APIServiceCondition {
|
||||||
|
for i := range apiService.Status.Conditions {
|
||||||
|
if apiService.Status.Conditions[i].Type == conditionType {
|
||||||
|
return &apiService.Status.Conditions[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
@ -0,0 +1,200 @@
|
|||||||
|
/*
|
||||||
|
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 helper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
a v1.APIServiceConditionType = "A"
|
||||||
|
b v1.APIServiceConditionType = "B"
|
||||||
|
c v1.APIServiceConditionType = "C"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsAPIServiceConditionTrue(t *testing.T) {
|
||||||
|
conditionATrue := makeNewAPIServiceCondition(a, "a reason", "a message", v1.ConditionTrue)
|
||||||
|
conditionAFalse := makeNewAPIServiceCondition(a, "a reason", "a message", v1.ConditionFalse)
|
||||||
|
tests := []*struct {
|
||||||
|
name string
|
||||||
|
apiService *v1.APIService
|
||||||
|
conditionType v1.APIServiceConditionType
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Should return false when condition of type is not present",
|
||||||
|
apiService: makeNewAPIService("v1", 100),
|
||||||
|
conditionType: a,
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Should return false when condition of type is present but status is not ConditionTrue",
|
||||||
|
apiService: makeNewAPIService("v1", 100, conditionAFalse),
|
||||||
|
conditionType: a,
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Should return false when condition of type is present but status is not ConditionTrue",
|
||||||
|
apiService: makeNewAPIService("v1", 100, conditionATrue),
|
||||||
|
conditionType: a,
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
if isConditionTrue := IsAPIServiceConditionTrue(tc.apiService, tc.conditionType); isConditionTrue != tc.expected {
|
||||||
|
t.Errorf("expected condition of type %v to be %v, actually was %v",
|
||||||
|
tc.conditionType, isConditionTrue, tc.expected)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSetAPIServiceCondition(t *testing.T) {
|
||||||
|
conditionA1 := makeNewAPIServiceCondition(a, "a1 reason", "a1 message", v1.ConditionTrue)
|
||||||
|
conditionA2 := makeNewAPIServiceCondition(a, "a2 reason", "a2 message", v1.ConditionTrue)
|
||||||
|
tests := []*struct {
|
||||||
|
name string
|
||||||
|
apiService *v1.APIService
|
||||||
|
conditionType v1.APIServiceConditionType
|
||||||
|
initialCondition *v1.APIServiceCondition
|
||||||
|
setCondition v1.APIServiceCondition
|
||||||
|
expectedCondition *v1.APIServiceCondition
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Should set a new condition with type where previously there was no condition of that type",
|
||||||
|
apiService: makeNewAPIService("v1", 100),
|
||||||
|
conditionType: a,
|
||||||
|
initialCondition: nil,
|
||||||
|
setCondition: conditionA1,
|
||||||
|
expectedCondition: &conditionA1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Should override a condition of type, when a condition of that type existed previously",
|
||||||
|
apiService: makeNewAPIService("v1", 100, conditionA1),
|
||||||
|
conditionType: a,
|
||||||
|
initialCondition: &conditionA1,
|
||||||
|
setCondition: conditionA2,
|
||||||
|
expectedCondition: &conditionA2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
startingCondition := GetAPIServiceConditionByType(tc.apiService, tc.conditionType)
|
||||||
|
if !reflect.DeepEqual(startingCondition, tc.initialCondition) {
|
||||||
|
t.Errorf("expected to find condition %s initially, actual was %s", tc.initialCondition, startingCondition)
|
||||||
|
|
||||||
|
}
|
||||||
|
SetAPIServiceCondition(tc.apiService, tc.setCondition)
|
||||||
|
actual := GetAPIServiceConditionByType(tc.apiService, tc.setCondition.Type)
|
||||||
|
if !reflect.DeepEqual(actual, tc.expectedCondition) {
|
||||||
|
t.Errorf("expected %s, actual %s", tc.expectedCondition, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSortedAPIServicesByVersion(t *testing.T) {
|
||||||
|
tests := []*struct {
|
||||||
|
name string
|
||||||
|
versions []string
|
||||||
|
expected []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "case1",
|
||||||
|
versions: []string{"v1", "v2"},
|
||||||
|
expected: []string{"v2", "v1"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "case2",
|
||||||
|
versions: []string{"v2", "v10"},
|
||||||
|
expected: []string{"v10", "v2"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "case3",
|
||||||
|
versions: []string{"v2", "v2beta1", "v10beta2", "v10beta1", "v10alpha1", "v1"},
|
||||||
|
expected: []string{"v2", "v1", "v10beta2", "v10beta1", "v2beta1", "v10alpha1"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "case4",
|
||||||
|
versions: []string{"v1", "v2", "test", "foo10", "final", "foo2", "foo1"},
|
||||||
|
expected: []string{"v2", "v1", "final", "foo1", "foo10", "foo2", "test"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "case5_from_documentation",
|
||||||
|
versions: []string{"v12alpha1", "v10", "v11beta2", "v10beta3", "v3beta1", "v2", "v11alpha2", "foo1", "v1", "foo10"},
|
||||||
|
expected: []string{"v10", "v2", "v1", "v11beta2", "v10beta3", "v3beta1", "v12alpha1", "v11alpha2", "foo1", "foo10"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
apiServices := []*v1.APIService{}
|
||||||
|
for _, v := range tc.versions {
|
||||||
|
apiServices = append(apiServices, makeNewAPIService(v, 100))
|
||||||
|
}
|
||||||
|
sortedServices := SortedByGroupAndVersion(apiServices)
|
||||||
|
actual := []string{}
|
||||||
|
for _, s := range sortedServices[0] {
|
||||||
|
actual = append(actual, s.Spec.Version)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(tc.expected, actual) {
|
||||||
|
t.Errorf("expected %s, actual %s", tc.expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetAPIServiceConditionByType(t *testing.T) {
|
||||||
|
conditionA := makeNewAPIServiceCondition(a, "a reason", "a message", v1.ConditionTrue)
|
||||||
|
conditionB := makeNewAPIServiceCondition(b, "b reason", "b message", v1.ConditionTrue)
|
||||||
|
tests := []*struct {
|
||||||
|
name string
|
||||||
|
apiService *v1.APIService
|
||||||
|
conditionType v1.APIServiceConditionType
|
||||||
|
expectedCondition *v1.APIServiceCondition
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Should find a matching condition from apiService",
|
||||||
|
apiService: makeNewAPIService("v1", 100, conditionA, conditionB),
|
||||||
|
conditionType: a,
|
||||||
|
expectedCondition: &conditionA,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Should not find a matching condition",
|
||||||
|
apiService: makeNewAPIService("v1", 100, conditionA),
|
||||||
|
conditionType: b,
|
||||||
|
expectedCondition: nil,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
actual := GetAPIServiceConditionByType(tc.apiService, tc.conditionType)
|
||||||
|
if !reflect.DeepEqual(tc.expectedCondition, actual) {
|
||||||
|
t.Errorf("expected %s, actual %s", tc.expectedCondition, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeNewAPIService(version string, priority int32, conditions ...v1.APIServiceCondition) *v1.APIService {
|
||||||
|
status := v1.APIServiceStatus{Conditions: conditions}
|
||||||
|
return &v1.APIService{Spec: v1.APIServiceSpec{Version: version, VersionPriority: priority}, Status: status}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeNewAPIServiceCondition(conditionType v1.APIServiceConditionType, reason string, message string, status v1.ConditionStatus) v1.APIServiceCondition {
|
||||||
|
return v1.APIServiceCondition{Type: conditionType, Reason: reason, Message: message, Status: status}
|
||||||
|
}
|
@ -22,10 +22,11 @@ go_test(
|
|||||||
"//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:go_default_library",
|
||||||
"//vendor/golang.org/x/net/websocket:go_default_library",
|
"//vendor/golang.org/x/net/websocket:go_default_library",
|
||||||
|
"//vendor/k8s.io/utils/pointer:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -69,14 +70,14 @@ go_library(
|
|||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/transport:go_default_library",
|
"//staging/src/k8s.io/client-go/transport:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver/scheme:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/externalversions:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/controllers:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/controllers:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator:go_default_library",
|
||||||
|
@ -28,13 +28,13 @@ import (
|
|||||||
"k8s.io/client-go/pkg/version"
|
"k8s.io/client-go/pkg/version"
|
||||||
openapicommon "k8s.io/kube-openapi/pkg/common"
|
openapicommon "k8s.io/kube-openapi/pkg/common"
|
||||||
|
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
|
v1helper "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
|
||||||
aggregatorscheme "k8s.io/kube-aggregator/pkg/apiserver/scheme"
|
aggregatorscheme "k8s.io/kube-aggregator/pkg/apiserver/scheme"
|
||||||
"k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset"
|
"k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
|
||||||
informers "k8s.io/kube-aggregator/pkg/client/informers/internalversion"
|
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions"
|
||||||
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
openapicontroller "k8s.io/kube-aggregator/pkg/controllers/openapi"
|
openapicontroller "k8s.io/kube-aggregator/pkg/controllers/openapi"
|
||||||
openapiaggregator "k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator"
|
openapiaggregator "k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator"
|
||||||
statuscontrollers "k8s.io/kube-aggregator/pkg/controllers/status"
|
statuscontrollers "k8s.io/kube-aggregator/pkg/controllers/status"
|
||||||
@ -162,7 +162,7 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
apiregistrationClient, err := internalclientset.NewForConfig(c.GenericConfig.LoopbackClientConfig)
|
apiregistrationClient, err := clientset.NewForConfig(c.GenericConfig.LoopbackClientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
|
|||||||
proxyTransport: c.ExtraConfig.ProxyTransport,
|
proxyTransport: c.ExtraConfig.ProxyTransport,
|
||||||
proxyHandlers: map[string]*proxyHandler{},
|
proxyHandlers: map[string]*proxyHandler{},
|
||||||
handledGroups: sets.String{},
|
handledGroups: sets.String{},
|
||||||
lister: informerFactory.Apiregistration().InternalVersion().APIServices().Lister(),
|
lister: informerFactory.Apiregistration().V1().APIServices().Lister(),
|
||||||
APIRegistrationInformers: informerFactory,
|
APIRegistrationInformers: informerFactory,
|
||||||
serviceResolver: c.ExtraConfig.ServiceResolver,
|
serviceResolver: c.ExtraConfig.ServiceResolver,
|
||||||
openAPIConfig: openAPIConfig,
|
openAPIConfig: openAPIConfig,
|
||||||
@ -197,12 +197,12 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
|
|||||||
s.GenericAPIServer.Handler.NonGoRestfulMux.Handle("/apis", apisHandler)
|
s.GenericAPIServer.Handler.NonGoRestfulMux.Handle("/apis", apisHandler)
|
||||||
s.GenericAPIServer.Handler.NonGoRestfulMux.UnlistedHandle("/apis/", apisHandler)
|
s.GenericAPIServer.Handler.NonGoRestfulMux.UnlistedHandle("/apis/", apisHandler)
|
||||||
|
|
||||||
apiserviceRegistrationController := NewAPIServiceRegistrationController(informerFactory.Apiregistration().InternalVersion().APIServices(), s)
|
apiserviceRegistrationController := NewAPIServiceRegistrationController(informerFactory.Apiregistration().V1().APIServices(), s)
|
||||||
availableController, err := statuscontrollers.NewAvailableConditionController(
|
availableController, err := statuscontrollers.NewAvailableConditionController(
|
||||||
informerFactory.Apiregistration().InternalVersion().APIServices(),
|
informerFactory.Apiregistration().V1().APIServices(),
|
||||||
c.GenericConfig.SharedInformerFactory.Core().V1().Services(),
|
c.GenericConfig.SharedInformerFactory.Core().V1().Services(),
|
||||||
c.GenericConfig.SharedInformerFactory.Core().V1().Endpoints(),
|
c.GenericConfig.SharedInformerFactory.Core().V1().Endpoints(),
|
||||||
apiregistrationClient.Apiregistration(),
|
apiregistrationClient.ApiregistrationV1(),
|
||||||
c.ExtraConfig.ProxyTransport,
|
c.ExtraConfig.ProxyTransport,
|
||||||
c.ExtraConfig.ProxyClientCert,
|
c.ExtraConfig.ProxyClientCert,
|
||||||
c.ExtraConfig.ProxyClientKey,
|
c.ExtraConfig.ProxyClientKey,
|
||||||
@ -266,8 +266,8 @@ func (s preparedAPIAggregator) Run(stopCh <-chan struct{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddAPIService adds an API service. It is not thread-safe, so only call it on one thread at a time please.
|
// AddAPIService adds an API service. It is not thread-safe, so only call it on one thread at a time please.
|
||||||
// It's a slow moving API, so it's ok to run the controller on a single thread
|
// It's a slow moving API, so its ok to run the controller on a single thread
|
||||||
func (s *APIAggregator) AddAPIService(apiService *apiregistration.APIService) error {
|
func (s *APIAggregator) AddAPIService(apiService *v1.APIService) error {
|
||||||
// if the proxyHandler already exists, it needs to be updated. The aggregation bits do not
|
// if the proxyHandler already exists, it needs to be updated. The aggregation bits do not
|
||||||
// since they are wired against listers because they require multiple resources to respond
|
// since they are wired against listers because they require multiple resources to respond
|
||||||
if proxyHandler, exists := s.proxyHandlers[apiService.Name]; exists {
|
if proxyHandler, exists := s.proxyHandlers[apiService.Name]; exists {
|
||||||
@ -328,7 +328,7 @@ func (s *APIAggregator) AddAPIService(apiService *apiregistration.APIService) er
|
|||||||
// RemoveAPIService removes the APIService from being handled. It is not thread-safe, so only call it on one thread at a time please.
|
// RemoveAPIService removes the APIService from being handled. It is not thread-safe, so only call it on one thread at a time please.
|
||||||
// It's a slow moving API, so it's ok to run the controller on a single thread.
|
// It's a slow moving API, so it's ok to run the controller on a single thread.
|
||||||
func (s *APIAggregator) RemoveAPIService(apiServiceName string) {
|
func (s *APIAggregator) RemoveAPIService(apiServiceName string) {
|
||||||
version := apiregistration.APIServiceNameToGroupVersion(apiServiceName)
|
version := v1helper.APIServiceNameToGroupVersion(apiServiceName)
|
||||||
|
|
||||||
proxyPath := "/apis/" + version.Group + "/" + version.Version
|
proxyPath := "/apis/" + version.Group + "/" + version.Version
|
||||||
// v1. is a special case for the legacy API. It proxies to a wider set of endpoints.
|
// v1. is a special case for the legacy API. It proxies to a wider set of endpoints.
|
||||||
|
@ -28,15 +28,15 @@ import (
|
|||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
|
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
informers "k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion"
|
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1"
|
||||||
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
"k8s.io/kube-aggregator/pkg/controllers"
|
"k8s.io/kube-aggregator/pkg/controllers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// APIHandlerManager defines the behaviour that an API handler should have.
|
// APIHandlerManager defines the behaviour that an API handler should have.
|
||||||
type APIHandlerManager interface {
|
type APIHandlerManager interface {
|
||||||
AddAPIService(apiService *apiregistration.APIService) error
|
AddAPIService(apiService *v1.APIService) error
|
||||||
RemoveAPIService(apiServiceName string)
|
RemoveAPIService(apiServiceName string)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ func (c *APIServiceRegistrationController) processNextWorkItem() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *APIServiceRegistrationController) enqueue(obj *apiregistration.APIService) {
|
func (c *APIServiceRegistrationController) enqueue(obj *v1.APIService) {
|
||||||
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
|
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Couldn't get key for object %#v: %v", obj, err)
|
klog.Errorf("Couldn't get key for object %#v: %v", obj, err)
|
||||||
@ -141,26 +141,26 @@ func (c *APIServiceRegistrationController) enqueue(obj *apiregistration.APIServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *APIServiceRegistrationController) addAPIService(obj interface{}) {
|
func (c *APIServiceRegistrationController) addAPIService(obj interface{}) {
|
||||||
castObj := obj.(*apiregistration.APIService)
|
castObj := obj.(*v1.APIService)
|
||||||
klog.V(4).Infof("Adding %s", castObj.Name)
|
klog.V(4).Infof("Adding %s", castObj.Name)
|
||||||
c.enqueue(castObj)
|
c.enqueue(castObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *APIServiceRegistrationController) updateAPIService(obj, _ interface{}) {
|
func (c *APIServiceRegistrationController) updateAPIService(obj, _ interface{}) {
|
||||||
castObj := obj.(*apiregistration.APIService)
|
castObj := obj.(*v1.APIService)
|
||||||
klog.V(4).Infof("Updating %s", castObj.Name)
|
klog.V(4).Infof("Updating %s", castObj.Name)
|
||||||
c.enqueue(castObj)
|
c.enqueue(castObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *APIServiceRegistrationController) deleteAPIService(obj interface{}) {
|
func (c *APIServiceRegistrationController) deleteAPIService(obj interface{}) {
|
||||||
castObj, ok := obj.(*apiregistration.APIService)
|
castObj, ok := obj.(*v1.APIService)
|
||||||
if !ok {
|
if !ok {
|
||||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||||
if !ok {
|
if !ok {
|
||||||
klog.Errorf("Couldn't get object from tombstone %#v", obj)
|
klog.Errorf("Couldn't get object from tombstone %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
castObj, ok = tombstone.Obj.(*apiregistration.APIService)
|
castObj, ok = tombstone.Obj.(*v1.APIService)
|
||||||
if !ok {
|
if !ok {
|
||||||
klog.Errorf("Tombstone contained object that is not expected %#v", obj)
|
klog.Errorf("Tombstone contained object that is not expected %#v", obj)
|
||||||
return
|
return
|
||||||
|
@ -27,10 +27,10 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
|
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
|
||||||
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
|
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
|
||||||
|
|
||||||
apiregistrationapi "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
apiregistrationv1api "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
apiregistrationv1api "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
|
apiregistrationv1apihelper "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper"
|
||||||
apiregistrationv1beta1api "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
|
apiregistrationv1beta1api "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
|
||||||
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// apisHandler serves the `/apis` endpoint.
|
// apisHandler serves the `/apis` endpoint.
|
||||||
@ -41,7 +41,7 @@ type apisHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var discoveryGroup = metav1.APIGroup{
|
var discoveryGroup = metav1.APIGroup{
|
||||||
Name: apiregistrationapi.GroupName,
|
Name: apiregistrationv1api.GroupName,
|
||||||
Versions: []metav1.GroupVersionForDiscovery{
|
Versions: []metav1.GroupVersionForDiscovery{
|
||||||
{
|
{
|
||||||
GroupVersion: apiregistrationv1api.SchemeGroupVersion.String(),
|
GroupVersion: apiregistrationv1api.SchemeGroupVersion.String(),
|
||||||
@ -70,7 +70,7 @@ func (r *apisHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
apiServicesByGroup := apiregistrationapi.SortedByGroupAndVersion(apiServices)
|
apiServicesByGroup := apiregistrationv1apihelper.SortedByGroupAndVersion(apiServices)
|
||||||
for _, apiGroupServers := range apiServicesByGroup {
|
for _, apiGroupServers := range apiServicesByGroup {
|
||||||
// skip the legacy group
|
// skip the legacy group
|
||||||
if len(apiGroupServers[0].Spec.Group) == 0 {
|
if len(apiGroupServers[0].Spec.Group) == 0 {
|
||||||
@ -87,8 +87,8 @@ func (r *apisHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
// convertToDiscoveryAPIGroup takes apiservices in a single group and returns a discovery compatible object.
|
// convertToDiscoveryAPIGroup takes apiservices in a single group and returns a discovery compatible object.
|
||||||
// if none of the services are available, it will return nil.
|
// if none of the services are available, it will return nil.
|
||||||
func convertToDiscoveryAPIGroup(apiServices []*apiregistrationapi.APIService) *metav1.APIGroup {
|
func convertToDiscoveryAPIGroup(apiServices []*apiregistrationv1api.APIService) *metav1.APIGroup {
|
||||||
apiServicesByGroup := apiregistrationapi.SortedByGroupAndVersion(apiServices)[0]
|
apiServicesByGroup := apiregistrationv1apihelper.SortedByGroupAndVersion(apiServices)[0]
|
||||||
|
|
||||||
var discoveryGroup *metav1.APIGroup
|
var discoveryGroup *metav1.APIGroup
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ func (r *apiGroupHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServicesForGroup := []*apiregistrationapi.APIService{}
|
apiServicesForGroup := []*apiregistrationv1api.APIService{}
|
||||||
for _, apiService := range apiServices {
|
for _, apiService := range apiServices {
|
||||||
if apiService.Spec.Group == r.groupName {
|
if apiService.Spec.Group == r.groupName {
|
||||||
apiServicesForGroup = append(apiServicesForGroup, apiService)
|
apiServicesForGroup = append(apiServicesForGroup, apiService)
|
||||||
|
@ -29,9 +29,9 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/diff"
|
"k8s.io/apimachinery/pkg/util/diff"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
|
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
aggregatorscheme "k8s.io/kube-aggregator/pkg/apiserver/scheme"
|
aggregatorscheme "k8s.io/kube-aggregator/pkg/apiserver/scheme"
|
||||||
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAPIs(t *testing.T) {
|
func TestAPIs(t *testing.T) {
|
||||||
|
@ -36,7 +36,8 @@ import (
|
|||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/transport"
|
"k8s.io/client-go/transport"
|
||||||
apiregistrationapi "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
apiregistrationv1api "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
|
apiregistrationv1apihelper "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper"
|
||||||
)
|
)
|
||||||
|
|
||||||
const aggregatorComponent string = "aggregator"
|
const aggregatorComponent string = "aggregator"
|
||||||
@ -209,7 +210,7 @@ func (r *responder) Error(_ http.ResponseWriter, _ *http.Request, err error) {
|
|||||||
|
|
||||||
// these methods provide locked access to fields
|
// these methods provide locked access to fields
|
||||||
|
|
||||||
func (r *proxyHandler) updateAPIService(apiService *apiregistrationapi.APIService) {
|
func (r *proxyHandler) updateAPIService(apiService *apiregistrationv1api.APIService) {
|
||||||
if apiService.Spec.Service == nil {
|
if apiService.Spec.Service == nil {
|
||||||
r.handlingInfo.Store(proxyHandlingInfo{local: true})
|
r.handlingInfo.Store(proxyHandlingInfo{local: true})
|
||||||
return
|
return
|
||||||
@ -228,8 +229,8 @@ func (r *proxyHandler) updateAPIService(apiService *apiregistrationapi.APIServic
|
|||||||
},
|
},
|
||||||
serviceName: apiService.Spec.Service.Name,
|
serviceName: apiService.Spec.Service.Name,
|
||||||
serviceNamespace: apiService.Spec.Service.Namespace,
|
serviceNamespace: apiService.Spec.Service.Namespace,
|
||||||
servicePort: apiService.Spec.Service.Port,
|
servicePort: *apiService.Spec.Service.Port,
|
||||||
serviceAvailable: apiregistrationapi.IsAPIServiceConditionTrue(apiService, apiregistrationapi.Available),
|
serviceAvailable: apiregistrationv1apihelper.IsAPIServiceConditionTrue(apiService, apiregistrationv1api.Available),
|
||||||
}
|
}
|
||||||
if r.proxyTransport != nil && r.proxyTransport.DialContext != nil {
|
if r.proxyTransport != nil && r.proxyTransport.DialContext != nil {
|
||||||
newInfo.restConfig.Dial = r.proxyTransport.DialContext
|
newInfo.restConfig.Dial = r.proxyTransport.DialContext
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"k8s.io/utils/pointer"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
@ -35,7 +36,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type targetHTTPHandler struct {
|
type targetHTTPHandler struct {
|
||||||
@ -118,7 +119,7 @@ func TestProxyHandler(t *testing.T) {
|
|||||||
apiService: &apiregistration.APIService{
|
apiService: &apiregistration.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: apiregistration.APIServiceSpec{
|
||||||
Service: &apiregistration.ServiceReference{},
|
Service: &apiregistration.ServiceReference{Port: pointer.Int32Ptr(443)},
|
||||||
Group: "foo",
|
Group: "foo",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
},
|
},
|
||||||
@ -140,7 +141,7 @@ func TestProxyHandler(t *testing.T) {
|
|||||||
apiService: &apiregistration.APIService{
|
apiService: &apiregistration.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: apiregistration.APIServiceSpec{
|
||||||
Service: &apiregistration.ServiceReference{},
|
Service: &apiregistration.ServiceReference{Port: pointer.Int32Ptr(443)},
|
||||||
Group: "foo",
|
Group: "foo",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
InsecureSkipTLSVerify: true,
|
InsecureSkipTLSVerify: true,
|
||||||
@ -172,7 +173,7 @@ func TestProxyHandler(t *testing.T) {
|
|||||||
apiService: &apiregistration.APIService{
|
apiService: &apiregistration.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: apiregistration.APIServiceSpec{
|
||||||
Service: &apiregistration.ServiceReference{Name: "test-service", Namespace: "test-ns", Port: 443},
|
Service: &apiregistration.ServiceReference{Name: "test-service", Namespace: "test-ns", Port: pointer.Int32Ptr(443)},
|
||||||
Group: "foo",
|
Group: "foo",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
CABundle: testCACrt,
|
CABundle: testCACrt,
|
||||||
@ -204,7 +205,7 @@ func TestProxyHandler(t *testing.T) {
|
|||||||
apiService: &apiregistration.APIService{
|
apiService: &apiregistration.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: apiregistration.APIServiceSpec{
|
||||||
Service: &apiregistration.ServiceReference{Name: "test-service", Namespace: "test-ns", Port: 443},
|
Service: &apiregistration.ServiceReference{Name: "test-service", Namespace: "test-ns", Port: pointer.Int32Ptr(443)},
|
||||||
Group: "foo",
|
Group: "foo",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
CABundle: testCACrt,
|
CABundle: testCACrt,
|
||||||
@ -227,7 +228,7 @@ func TestProxyHandler(t *testing.T) {
|
|||||||
apiService: &apiregistration.APIService{
|
apiService: &apiregistration.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: apiregistration.APIServiceSpec{
|
||||||
Service: &apiregistration.ServiceReference{Name: "bad-service", Namespace: "test-ns", Port: 443},
|
Service: &apiregistration.ServiceReference{Name: "bad-service", Namespace: "test-ns", Port: pointer.Int32Ptr(443)},
|
||||||
Group: "foo",
|
Group: "foo",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
CABundle: testCACrt,
|
CABundle: testCACrt,
|
||||||
@ -249,7 +250,7 @@ func TestProxyHandler(t *testing.T) {
|
|||||||
apiService: &apiregistration.APIService{
|
apiService: &apiregistration.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
ObjectMeta: metav1.ObjectMeta{Name: "v1.foo"},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: apiregistration.APIServiceSpec{
|
||||||
Service: &apiregistration.ServiceReference{},
|
Service: &apiregistration.ServiceReference{Port: pointer.Int32Ptr(443)},
|
||||||
Group: "foo",
|
Group: "foo",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
},
|
},
|
||||||
@ -336,7 +337,7 @@ func TestProxyUpgrade(t *testing.T) {
|
|||||||
CABundle: testCACrt,
|
CABundle: testCACrt,
|
||||||
Group: "mygroup",
|
Group: "mygroup",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
Service: &apiregistration.ServiceReference{Name: "test-service", Namespace: "test-ns", Port: 443},
|
Service: &apiregistration.ServiceReference{Name: "test-service", Namespace: "test-ns", Port: pointer.Int32Ptr(443)},
|
||||||
},
|
},
|
||||||
Status: apiregistration.APIServiceStatus{
|
Status: apiregistration.APIServiceStatus{
|
||||||
Conditions: []apiregistration.APIServiceCondition{
|
Conditions: []apiregistration.APIServiceCondition{
|
||||||
@ -353,7 +354,7 @@ func TestProxyUpgrade(t *testing.T) {
|
|||||||
InsecureSkipTLSVerify: true,
|
InsecureSkipTLSVerify: true,
|
||||||
Group: "mygroup",
|
Group: "mygroup",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
Service: &apiregistration.ServiceReference{Name: "invalid-service", Namespace: "invalid-ns", Port: 443},
|
Service: &apiregistration.ServiceReference{Name: "invalid-service", Namespace: "invalid-ns", Port: pointer.Int32Ptr(443)},
|
||||||
},
|
},
|
||||||
Status: apiregistration.APIServiceStatus{
|
Status: apiregistration.APIServiceStatus{
|
||||||
Conditions: []apiregistration.APIServiceCondition{
|
Conditions: []apiregistration.APIServiceCondition{
|
||||||
@ -370,7 +371,7 @@ func TestProxyUpgrade(t *testing.T) {
|
|||||||
CABundle: testCACrt,
|
CABundle: testCACrt,
|
||||||
Group: "mygroup",
|
Group: "mygroup",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
Service: &apiregistration.ServiceReference{Name: "invalid-service", Namespace: "invalid-ns", Port: 443},
|
Service: &apiregistration.ServiceReference{Name: "invalid-service", Namespace: "invalid-ns", Port: pointer.Int32Ptr(443)},
|
||||||
},
|
},
|
||||||
Status: apiregistration.APIServiceStatus{
|
Status: apiregistration.APIServiceStatus{
|
||||||
Conditions: []apiregistration.APIServiceCondition{
|
Conditions: []apiregistration.APIServiceCondition{
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"clientset.go",
|
|
||||||
"doc.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/client-go/discovery:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/util/flowcontrol:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [
|
|
||||||
":package-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/fake:all-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/scheme:all-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion:all-srcs",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalclientset
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
discovery "k8s.io/client-go/discovery"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
flowcontrol "k8s.io/client-go/util/flowcontrol"
|
|
||||||
apiregistrationinternalversion "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Interface interface {
|
|
||||||
Discovery() discovery.DiscoveryInterface
|
|
||||||
Apiregistration() apiregistrationinternalversion.ApiregistrationInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clientset contains the clients for groups. Each group has exactly one
|
|
||||||
// version included in a Clientset.
|
|
||||||
type Clientset struct {
|
|
||||||
*discovery.DiscoveryClient
|
|
||||||
apiregistration *apiregistrationinternalversion.ApiregistrationClient
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apiregistration retrieves the ApiregistrationClient
|
|
||||||
func (c *Clientset) Apiregistration() apiregistrationinternalversion.ApiregistrationInterface {
|
|
||||||
return c.apiregistration
|
|
||||||
}
|
|
||||||
|
|
||||||
// Discovery retrieves the DiscoveryClient
|
|
||||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
|
||||||
if c == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return c.DiscoveryClient
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForConfig creates a new Clientset for the given config.
|
|
||||||
// If config's RateLimiter is not set and QPS and Burst are acceptable,
|
|
||||||
// NewForConfig will generate a rate-limiter in configShallowCopy.
|
|
||||||
func NewForConfig(c *rest.Config) (*Clientset, error) {
|
|
||||||
configShallowCopy := *c
|
|
||||||
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
|
|
||||||
if configShallowCopy.Burst <= 0 {
|
|
||||||
return nil, fmt.Errorf("Burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
|
|
||||||
}
|
|
||||||
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
|
|
||||||
}
|
|
||||||
var cs Clientset
|
|
||||||
var err error
|
|
||||||
cs.apiregistration, err = apiregistrationinternalversion.NewForConfig(&configShallowCopy)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &cs, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForConfigOrDie creates a new Clientset for the given config and
|
|
||||||
// panics if there is an error in the config.
|
|
||||||
func NewForConfigOrDie(c *rest.Config) *Clientset {
|
|
||||||
var cs Clientset
|
|
||||||
cs.apiregistration = apiregistrationinternalversion.NewForConfigOrDie(c)
|
|
||||||
|
|
||||||
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
|
||||||
return &cs
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates a new Clientset for the given RESTClient.
|
|
||||||
func New(c rest.Interface) *Clientset {
|
|
||||||
var cs Clientset
|
|
||||||
cs.apiregistration = apiregistrationinternalversion.New(c)
|
|
||||||
|
|
||||||
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
|
||||||
return &cs
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
// This package has the automatically generated clientset.
|
|
||||||
package internalclientset
|
|
@ -1,45 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"clientset_generated.go",
|
|
||||||
"doc.go",
|
|
||||||
"register.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/fake",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/fake",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/discovery:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/discovery/fake:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion/fake:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package fake
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
|
||||||
"k8s.io/client-go/discovery"
|
|
||||||
fakediscovery "k8s.io/client-go/discovery/fake"
|
|
||||||
"k8s.io/client-go/testing"
|
|
||||||
clientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset"
|
|
||||||
apiregistrationinternalversion "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion"
|
|
||||||
fakeapiregistrationinternalversion "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion/fake"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewSimpleClientset returns a clientset that will respond with the provided objects.
|
|
||||||
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
|
||||||
// without applying any validations and/or defaults. It shouldn't be considered a replacement
|
|
||||||
// for a real clientset and is mostly useful in simple unit tests.
|
|
||||||
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
|
||||||
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
|
|
||||||
for _, obj := range objects {
|
|
||||||
if err := o.Add(obj); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cs := &Clientset{tracker: o}
|
|
||||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
|
||||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
|
||||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
|
||||||
gvr := action.GetResource()
|
|
||||||
ns := action.GetNamespace()
|
|
||||||
watch, err := o.Watch(gvr, ns)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
return true, watch, nil
|
|
||||||
})
|
|
||||||
|
|
||||||
return cs
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clientset implements clientset.Interface. Meant to be embedded into a
|
|
||||||
// struct to get a default implementation. This makes faking out just the method
|
|
||||||
// you want to test easier.
|
|
||||||
type Clientset struct {
|
|
||||||
testing.Fake
|
|
||||||
discovery *fakediscovery.FakeDiscovery
|
|
||||||
tracker testing.ObjectTracker
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
|
||||||
return c.discovery
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Clientset) Tracker() testing.ObjectTracker {
|
|
||||||
return c.tracker
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ clientset.Interface = &Clientset{}
|
|
||||||
|
|
||||||
// Apiregistration retrieves the ApiregistrationClient
|
|
||||||
func (c *Clientset) Apiregistration() apiregistrationinternalversion.ApiregistrationInterface {
|
|
||||||
return &fakeapiregistrationinternalversion.FakeApiregistration{Fake: &c.Fake}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
// This package has the automatically generated fake clientset.
|
|
||||||
package fake
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package fake
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
|
||||||
apiregistrationinternalversion "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
)
|
|
||||||
|
|
||||||
var scheme = runtime.NewScheme()
|
|
||||||
var codecs = serializer.NewCodecFactory(scheme)
|
|
||||||
var parameterCodec = runtime.NewParameterCodec(scheme)
|
|
||||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
|
||||||
apiregistrationinternalversion.AddToScheme,
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
|
||||||
// of clientsets, like in:
|
|
||||||
//
|
|
||||||
// import (
|
|
||||||
// "k8s.io/client-go/kubernetes"
|
|
||||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
|
||||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
|
||||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
|
||||||
//
|
|
||||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
|
||||||
// correctly.
|
|
||||||
var AddToScheme = localSchemeBuilder.AddToScheme
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
|
|
||||||
utilruntime.Must(AddToScheme(scheme))
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
// This package contains the scheme of the automatically generated clientset.
|
|
||||||
package scheme
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package scheme
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
|
||||||
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration/install"
|
|
||||||
)
|
|
||||||
|
|
||||||
var Scheme = runtime.NewScheme()
|
|
||||||
var Codecs = serializer.NewCodecFactory(Scheme)
|
|
||||||
var ParameterCodec = runtime.NewParameterCodec(Scheme)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
|
|
||||||
Install(Scheme)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Install registers the API group and adds types to a scheme
|
|
||||||
func Install(scheme *runtime.Scheme) {
|
|
||||||
apiregistration.Install(scheme)
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"apiregistration_client.go",
|
|
||||||
"apiservice.go",
|
|
||||||
"doc.go",
|
|
||||||
"generated_expansion.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/scheme:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [
|
|
||||||
":package-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion/fake:all-srcs",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
"k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/scheme"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ApiregistrationInterface interface {
|
|
||||||
RESTClient() rest.Interface
|
|
||||||
APIServicesGetter
|
|
||||||
}
|
|
||||||
|
|
||||||
// ApiregistrationClient is used to interact with features provided by the apiregistration.k8s.io group.
|
|
||||||
type ApiregistrationClient struct {
|
|
||||||
restClient rest.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ApiregistrationClient) APIServices() APIServiceInterface {
|
|
||||||
return newAPIServices(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForConfig creates a new ApiregistrationClient for the given config.
|
|
||||||
func NewForConfig(c *rest.Config) (*ApiregistrationClient, error) {
|
|
||||||
config := *c
|
|
||||||
if err := setConfigDefaults(&config); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
client, err := rest.RESTClientFor(&config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &ApiregistrationClient{client}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForConfigOrDie creates a new ApiregistrationClient for the given config and
|
|
||||||
// panics if there is an error in the config.
|
|
||||||
func NewForConfigOrDie(c *rest.Config) *ApiregistrationClient {
|
|
||||||
client, err := NewForConfig(c)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return client
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates a new ApiregistrationClient for the given RESTClient.
|
|
||||||
func New(c rest.Interface) *ApiregistrationClient {
|
|
||||||
return &ApiregistrationClient{c}
|
|
||||||
}
|
|
||||||
|
|
||||||
func setConfigDefaults(config *rest.Config) error {
|
|
||||||
config.APIPath = "/apis"
|
|
||||||
if config.UserAgent == "" {
|
|
||||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
|
||||||
}
|
|
||||||
if config.GroupVersion == nil || config.GroupVersion.Group != scheme.Scheme.PrioritizedVersionsForGroup("apiregistration.k8s.io")[0].Group {
|
|
||||||
gv := scheme.Scheme.PrioritizedVersionsForGroup("apiregistration.k8s.io")[0]
|
|
||||||
config.GroupVersion = &gv
|
|
||||||
}
|
|
||||||
config.NegotiatedSerializer = scheme.Codecs
|
|
||||||
|
|
||||||
if config.QPS == 0 {
|
|
||||||
config.QPS = 5
|
|
||||||
}
|
|
||||||
if config.Burst == 0 {
|
|
||||||
config.Burst = 10
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
|
||||||
// with API server by this client implementation.
|
|
||||||
func (c *ApiregistrationClient) RESTClient() rest.Interface {
|
|
||||||
if c == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return c.restClient
|
|
||||||
}
|
|
@ -1,180 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
scheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/scheme"
|
|
||||||
)
|
|
||||||
|
|
||||||
// APIServicesGetter has a method to return a APIServiceInterface.
|
|
||||||
// A group's client should implement this interface.
|
|
||||||
type APIServicesGetter interface {
|
|
||||||
APIServices() APIServiceInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
// APIServiceInterface has methods to work with APIService resources.
|
|
||||||
type APIServiceInterface interface {
|
|
||||||
Create(*apiregistration.APIService) (*apiregistration.APIService, error)
|
|
||||||
Update(*apiregistration.APIService) (*apiregistration.APIService, error)
|
|
||||||
UpdateStatus(*apiregistration.APIService) (*apiregistration.APIService, error)
|
|
||||||
Delete(name string, options *v1.DeleteOptions) error
|
|
||||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
|
||||||
Get(name string, options v1.GetOptions) (*apiregistration.APIService, error)
|
|
||||||
List(opts v1.ListOptions) (*apiregistration.APIServiceList, error)
|
|
||||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
|
||||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiregistration.APIService, err error)
|
|
||||||
APIServiceExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// aPIServices implements APIServiceInterface
|
|
||||||
type aPIServices struct {
|
|
||||||
client rest.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
// newAPIServices returns a APIServices
|
|
||||||
func newAPIServices(c *ApiregistrationClient) *aPIServices {
|
|
||||||
return &aPIServices{
|
|
||||||
client: c.RESTClient(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get takes name of the aPIService, and returns the corresponding aPIService object, and an error if there is any.
|
|
||||||
func (c *aPIServices) Get(name string, options v1.GetOptions) (result *apiregistration.APIService, err error) {
|
|
||||||
result = &apiregistration.APIService{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Resource("apiservices").
|
|
||||||
Name(name).
|
|
||||||
VersionedParams(&options, scheme.ParameterCodec).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of APIServices that match those selectors.
|
|
||||||
func (c *aPIServices) List(opts v1.ListOptions) (result *apiregistration.APIServiceList, err error) {
|
|
||||||
var timeout time.Duration
|
|
||||||
if opts.TimeoutSeconds != nil {
|
|
||||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
|
||||||
}
|
|
||||||
result = &apiregistration.APIServiceList{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Resource("apiservices").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested aPIServices.
|
|
||||||
func (c *aPIServices) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
var timeout time.Duration
|
|
||||||
if opts.TimeoutSeconds != nil {
|
|
||||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
|
||||||
}
|
|
||||||
opts.Watch = true
|
|
||||||
return c.client.Get().
|
|
||||||
Resource("apiservices").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Watch()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a aPIService and creates it. Returns the server's representation of the aPIService, and an error, if there is any.
|
|
||||||
func (c *aPIServices) Create(aPIService *apiregistration.APIService) (result *apiregistration.APIService, err error) {
|
|
||||||
result = &apiregistration.APIService{}
|
|
||||||
err = c.client.Post().
|
|
||||||
Resource("apiservices").
|
|
||||||
Body(aPIService).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a aPIService and updates it. Returns the server's representation of the aPIService, and an error, if there is any.
|
|
||||||
func (c *aPIServices) Update(aPIService *apiregistration.APIService) (result *apiregistration.APIService, err error) {
|
|
||||||
result = &apiregistration.APIService{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Resource("apiservices").
|
|
||||||
Name(aPIService.Name).
|
|
||||||
Body(aPIService).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateStatus was generated because the type contains a Status member.
|
|
||||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
|
||||||
|
|
||||||
func (c *aPIServices) UpdateStatus(aPIService *apiregistration.APIService) (result *apiregistration.APIService, err error) {
|
|
||||||
result = &apiregistration.APIService{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Resource("apiservices").
|
|
||||||
Name(aPIService.Name).
|
|
||||||
SubResource("status").
|
|
||||||
Body(aPIService).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the aPIService and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *aPIServices) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Resource("apiservices").
|
|
||||||
Name(name).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *aPIServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
var timeout time.Duration
|
|
||||||
if listOptions.TimeoutSeconds != nil {
|
|
||||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
|
||||||
}
|
|
||||||
return c.client.Delete().
|
|
||||||
Resource("apiservices").
|
|
||||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched aPIService.
|
|
||||||
func (c *aPIServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiregistration.APIService, err error) {
|
|
||||||
result = &apiregistration.APIService{}
|
|
||||||
err = c.client.Patch(pt).
|
|
||||||
Resource("apiservices").
|
|
||||||
SubResource(subresources...).
|
|
||||||
Name(name).
|
|
||||||
Body(data).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
// This package has the automatically generated typed clients.
|
|
||||||
package internalversion
|
|
@ -1,41 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"doc.go",
|
|
||||||
"fake_apiregistration_client.go",
|
|
||||||
"fake_apiservice.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion/fake",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion/fake",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
// Package fake has the automatically generated clients.
|
|
||||||
package fake
|
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package fake
|
|
||||||
|
|
||||||
import (
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
testing "k8s.io/client-go/testing"
|
|
||||||
internalversion "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion"
|
|
||||||
)
|
|
||||||
|
|
||||||
type FakeApiregistration struct {
|
|
||||||
*testing.Fake
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeApiregistration) APIServices() internalversion.APIServiceInterface {
|
|
||||||
return &FakeAPIServices{c}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
|
||||||
// with API server by this client implementation.
|
|
||||||
func (c *FakeApiregistration) RESTClient() rest.Interface {
|
|
||||||
var ret *rest.RESTClient
|
|
||||||
return ret
|
|
||||||
}
|
|
@ -1,131 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package fake
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
labels "k8s.io/apimachinery/pkg/labels"
|
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
testing "k8s.io/client-go/testing"
|
|
||||||
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FakeAPIServices implements APIServiceInterface
|
|
||||||
type FakeAPIServices struct {
|
|
||||||
Fake *FakeApiregistration
|
|
||||||
}
|
|
||||||
|
|
||||||
var apiservicesResource = schema.GroupVersionResource{Group: "apiregistration.k8s.io", Version: "", Resource: "apiservices"}
|
|
||||||
|
|
||||||
var apiservicesKind = schema.GroupVersionKind{Group: "apiregistration.k8s.io", Version: "", Kind: "APIService"}
|
|
||||||
|
|
||||||
// Get takes name of the aPIService, and returns the corresponding aPIService object, and an error if there is any.
|
|
||||||
func (c *FakeAPIServices) Get(name string, options v1.GetOptions) (result *apiregistration.APIService, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootGetAction(apiservicesResource, name), &apiregistration.APIService{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiregistration.APIService), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of APIServices that match those selectors.
|
|
||||||
func (c *FakeAPIServices) List(opts v1.ListOptions) (result *apiregistration.APIServiceList, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootListAction(apiservicesResource, apiservicesKind, opts), &apiregistration.APIServiceList{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
|
||||||
if label == nil {
|
|
||||||
label = labels.Everything()
|
|
||||||
}
|
|
||||||
list := &apiregistration.APIServiceList{ListMeta: obj.(*apiregistration.APIServiceList).ListMeta}
|
|
||||||
for _, item := range obj.(*apiregistration.APIServiceList).Items {
|
|
||||||
if label.Matches(labels.Set(item.Labels)) {
|
|
||||||
list.Items = append(list.Items, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested aPIServices.
|
|
||||||
func (c *FakeAPIServices) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
return c.Fake.
|
|
||||||
InvokesWatch(testing.NewRootWatchAction(apiservicesResource, opts))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a aPIService and creates it. Returns the server's representation of the aPIService, and an error, if there is any.
|
|
||||||
func (c *FakeAPIServices) Create(aPIService *apiregistration.APIService) (result *apiregistration.APIService, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootCreateAction(apiservicesResource, aPIService), &apiregistration.APIService{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiregistration.APIService), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a aPIService and updates it. Returns the server's representation of the aPIService, and an error, if there is any.
|
|
||||||
func (c *FakeAPIServices) Update(aPIService *apiregistration.APIService) (result *apiregistration.APIService, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootUpdateAction(apiservicesResource, aPIService), &apiregistration.APIService{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiregistration.APIService), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateStatus was generated because the type contains a Status member.
|
|
||||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
|
||||||
func (c *FakeAPIServices) UpdateStatus(aPIService *apiregistration.APIService) (*apiregistration.APIService, error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootUpdateSubresourceAction(apiservicesResource, "status", aPIService), &apiregistration.APIService{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiregistration.APIService), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the aPIService and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *FakeAPIServices) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
_, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootDeleteAction(apiservicesResource, name), &apiregistration.APIService{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *FakeAPIServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
action := testing.NewRootDeleteCollectionAction(apiservicesResource, listOptions)
|
|
||||||
|
|
||||||
_, err := c.Fake.Invokes(action, &apiregistration.APIServiceList{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched aPIService.
|
|
||||||
func (c *FakeAPIServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiregistration.APIService, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootPatchSubresourceAction(apiservicesResource, name, pt, data, subresources...), &apiregistration.APIService{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiregistration.APIService), err
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
type APIServiceExpansion interface{}
|
|
@ -1,43 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"factory.go",
|
|
||||||
"generic.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/informers/internalversion",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/informers/internalversion",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [
|
|
||||||
":package-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration:all-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces:all-srcs",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,33 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["interface.go"],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [
|
|
||||||
":package-srcs",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion:all-srcs",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by informer-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package apiregistration
|
|
||||||
|
|
||||||
import (
|
|
||||||
internalversion "k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion"
|
|
||||||
internalinterfaces "k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Interface provides access to each of this group's versions.
|
|
||||||
type Interface interface {
|
|
||||||
// InternalVersion provides access to shared informers for resources in InternalVersion.
|
|
||||||
InternalVersion() internalversion.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
type group struct {
|
|
||||||
factory internalinterfaces.SharedInformerFactory
|
|
||||||
namespace string
|
|
||||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a new Interface.
|
|
||||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
|
||||||
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
|
||||||
}
|
|
||||||
|
|
||||||
// InternalVersion returns a new internalversion.Interface.
|
|
||||||
func (g *group) InternalVersion() internalversion.Interface {
|
|
||||||
return internalversion.New(g.factory, g.namespace, g.tweakListOptions)
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"apiservice.go",
|
|
||||||
"interface.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by informer-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
time "time"
|
|
||||||
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
cache "k8s.io/client-go/tools/cache"
|
|
||||||
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
internalclientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset"
|
|
||||||
internalinterfaces "k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces"
|
|
||||||
internalversion "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
|
||||||
)
|
|
||||||
|
|
||||||
// APIServiceInformer provides access to a shared informer and lister for
|
|
||||||
// APIServices.
|
|
||||||
type APIServiceInformer interface {
|
|
||||||
Informer() cache.SharedIndexInformer
|
|
||||||
Lister() internalversion.APIServiceLister
|
|
||||||
}
|
|
||||||
|
|
||||||
type aPIServiceInformer struct {
|
|
||||||
factory internalinterfaces.SharedInformerFactory
|
|
||||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAPIServiceInformer constructs a new informer for APIService type.
|
|
||||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
|
||||||
// one. This reduces memory footprint and number of connections to the server.
|
|
||||||
func NewAPIServiceInformer(client internalclientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
|
||||||
return NewFilteredAPIServiceInformer(client, resyncPeriod, indexers, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewFilteredAPIServiceInformer constructs a new informer for APIService type.
|
|
||||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
|
||||||
// one. This reduces memory footprint and number of connections to the server.
|
|
||||||
func NewFilteredAPIServiceInformer(client internalclientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
|
||||||
return cache.NewSharedIndexInformer(
|
|
||||||
&cache.ListWatch{
|
|
||||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
|
||||||
if tweakListOptions != nil {
|
|
||||||
tweakListOptions(&options)
|
|
||||||
}
|
|
||||||
return client.Apiregistration().APIServices().List(options)
|
|
||||||
},
|
|
||||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
|
||||||
if tweakListOptions != nil {
|
|
||||||
tweakListOptions(&options)
|
|
||||||
}
|
|
||||||
return client.Apiregistration().APIServices().Watch(options)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
&apiregistration.APIService{},
|
|
||||||
resyncPeriod,
|
|
||||||
indexers,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *aPIServiceInformer) defaultInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
|
||||||
return NewFilteredAPIServiceInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *aPIServiceInformer) Informer() cache.SharedIndexInformer {
|
|
||||||
return f.factory.InformerFor(&apiregistration.APIService{}, f.defaultInformer)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *aPIServiceInformer) Lister() internalversion.APIServiceLister {
|
|
||||||
return internalversion.NewAPIServiceLister(f.Informer().GetIndexer())
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by informer-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
internalinterfaces "k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Interface provides access to all the informers in this group version.
|
|
||||||
type Interface interface {
|
|
||||||
// APIServices returns a APIServiceInformer.
|
|
||||||
APIServices() APIServiceInformer
|
|
||||||
}
|
|
||||||
|
|
||||||
type version struct {
|
|
||||||
factory internalinterfaces.SharedInformerFactory
|
|
||||||
namespace string
|
|
||||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a new Interface.
|
|
||||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
|
||||||
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
|
||||||
}
|
|
||||||
|
|
||||||
// APIServices returns a APIServiceInformer.
|
|
||||||
func (v *version) APIServices() APIServiceInformer {
|
|
||||||
return &aPIServiceInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
|
|
||||||
}
|
|
@ -1,180 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by informer-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
time "time"
|
|
||||||
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
cache "k8s.io/client-go/tools/cache"
|
|
||||||
internalclientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset"
|
|
||||||
apiregistration "k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration"
|
|
||||||
internalinterfaces "k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SharedInformerOption defines the functional option type for SharedInformerFactory.
|
|
||||||
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory
|
|
||||||
|
|
||||||
type sharedInformerFactory struct {
|
|
||||||
client internalclientset.Interface
|
|
||||||
namespace string
|
|
||||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
|
||||||
lock sync.Mutex
|
|
||||||
defaultResync time.Duration
|
|
||||||
customResync map[reflect.Type]time.Duration
|
|
||||||
|
|
||||||
informers map[reflect.Type]cache.SharedIndexInformer
|
|
||||||
// startedInformers is used for tracking which informers have been started.
|
|
||||||
// This allows Start() to be called multiple times safely.
|
|
||||||
startedInformers map[reflect.Type]bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
|
|
||||||
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
|
|
||||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
|
||||||
for k, v := range resyncConfig {
|
|
||||||
factory.customResync[reflect.TypeOf(k)] = v
|
|
||||||
}
|
|
||||||
return factory
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
|
|
||||||
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
|
|
||||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
|
||||||
factory.tweakListOptions = tweakListOptions
|
|
||||||
return factory
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithNamespace limits the SharedInformerFactory to the specified namespace.
|
|
||||||
func WithNamespace(namespace string) SharedInformerOption {
|
|
||||||
return func(factory *sharedInformerFactory) *sharedInformerFactory {
|
|
||||||
factory.namespace = namespace
|
|
||||||
return factory
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
|
|
||||||
func NewSharedInformerFactory(client internalclientset.Interface, defaultResync time.Duration) SharedInformerFactory {
|
|
||||||
return NewSharedInformerFactoryWithOptions(client, defaultResync)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
|
|
||||||
// Listers obtained via this SharedInformerFactory will be subject to the same filters
|
|
||||||
// as specified here.
|
|
||||||
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
|
|
||||||
func NewFilteredSharedInformerFactory(client internalclientset.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
|
|
||||||
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
|
|
||||||
func NewSharedInformerFactoryWithOptions(client internalclientset.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
|
|
||||||
factory := &sharedInformerFactory{
|
|
||||||
client: client,
|
|
||||||
namespace: v1.NamespaceAll,
|
|
||||||
defaultResync: defaultResync,
|
|
||||||
informers: make(map[reflect.Type]cache.SharedIndexInformer),
|
|
||||||
startedInformers: make(map[reflect.Type]bool),
|
|
||||||
customResync: make(map[reflect.Type]time.Duration),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply all options
|
|
||||||
for _, opt := range options {
|
|
||||||
factory = opt(factory)
|
|
||||||
}
|
|
||||||
|
|
||||||
return factory
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start initializes all requested informers.
|
|
||||||
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
|
|
||||||
f.lock.Lock()
|
|
||||||
defer f.lock.Unlock()
|
|
||||||
|
|
||||||
for informerType, informer := range f.informers {
|
|
||||||
if !f.startedInformers[informerType] {
|
|
||||||
go informer.Run(stopCh)
|
|
||||||
f.startedInformers[informerType] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WaitForCacheSync waits for all started informers' cache were synced.
|
|
||||||
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
|
|
||||||
informers := func() map[reflect.Type]cache.SharedIndexInformer {
|
|
||||||
f.lock.Lock()
|
|
||||||
defer f.lock.Unlock()
|
|
||||||
|
|
||||||
informers := map[reflect.Type]cache.SharedIndexInformer{}
|
|
||||||
for informerType, informer := range f.informers {
|
|
||||||
if f.startedInformers[informerType] {
|
|
||||||
informers[informerType] = informer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return informers
|
|
||||||
}()
|
|
||||||
|
|
||||||
res := map[reflect.Type]bool{}
|
|
||||||
for informType, informer := range informers {
|
|
||||||
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
|
|
||||||
// client.
|
|
||||||
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
|
|
||||||
f.lock.Lock()
|
|
||||||
defer f.lock.Unlock()
|
|
||||||
|
|
||||||
informerType := reflect.TypeOf(obj)
|
|
||||||
informer, exists := f.informers[informerType]
|
|
||||||
if exists {
|
|
||||||
return informer
|
|
||||||
}
|
|
||||||
|
|
||||||
resyncPeriod, exists := f.customResync[informerType]
|
|
||||||
if !exists {
|
|
||||||
resyncPeriod = f.defaultResync
|
|
||||||
}
|
|
||||||
|
|
||||||
informer = newFunc(f.client, resyncPeriod)
|
|
||||||
f.informers[informerType] = informer
|
|
||||||
|
|
||||||
return informer
|
|
||||||
}
|
|
||||||
|
|
||||||
// SharedInformerFactory provides shared informers for resources in all known
|
|
||||||
// API group versions.
|
|
||||||
type SharedInformerFactory interface {
|
|
||||||
internalinterfaces.SharedInformerFactory
|
|
||||||
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
|
|
||||||
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
|
|
||||||
|
|
||||||
Apiregistration() apiregistration.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *sharedInformerFactory) Apiregistration() apiregistration.Interface {
|
|
||||||
return apiregistration.New(f, f.namespace, f.tweakListOptions)
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by informer-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
cache "k8s.io/client-go/tools/cache"
|
|
||||||
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
|
|
||||||
// sharedInformers based on type
|
|
||||||
type GenericInformer interface {
|
|
||||||
Informer() cache.SharedIndexInformer
|
|
||||||
Lister() cache.GenericLister
|
|
||||||
}
|
|
||||||
|
|
||||||
type genericInformer struct {
|
|
||||||
informer cache.SharedIndexInformer
|
|
||||||
resource schema.GroupResource
|
|
||||||
}
|
|
||||||
|
|
||||||
// Informer returns the SharedIndexInformer.
|
|
||||||
func (f *genericInformer) Informer() cache.SharedIndexInformer {
|
|
||||||
return f.informer
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lister returns the GenericLister.
|
|
||||||
func (f *genericInformer) Lister() cache.GenericLister {
|
|
||||||
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ForResource gives generic access to a shared informer of the matching type
|
|
||||||
// TODO extend this to unknown resources with a client pool
|
|
||||||
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
|
|
||||||
switch resource {
|
|
||||||
// Group=apiregistration.k8s.io, Version=internalVersion
|
|
||||||
case apiregistration.SchemeGroupVersion.WithResource("apiservices"):
|
|
||||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Apiregistration().InternalVersion().APIServices().Informer()}, nil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, fmt.Errorf("no informer found for %v", resource)
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["factory_interfaces.go"],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by informer-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalinterfaces
|
|
||||||
|
|
||||||
import (
|
|
||||||
time "time"
|
|
||||||
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
cache "k8s.io/client-go/tools/cache"
|
|
||||||
internalclientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewInformerFunc takes internalclientset.Interface and time.Duration to return a SharedIndexInformer.
|
|
||||||
type NewInformerFunc func(internalclientset.Interface, time.Duration) cache.SharedIndexInformer
|
|
||||||
|
|
||||||
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
|
|
||||||
type SharedInformerFactory interface {
|
|
||||||
Start(stopCh <-chan struct{})
|
|
||||||
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
|
|
||||||
}
|
|
||||||
|
|
||||||
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
|
|
||||||
type TweakListOptionsFunc func(*v1.ListOptions)
|
|
@ -1,35 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"apiservice.go",
|
|
||||||
"expansion_generated.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion",
|
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by lister-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
|
||||||
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
|
||||||
)
|
|
||||||
|
|
||||||
// APIServiceLister helps list APIServices.
|
|
||||||
type APIServiceLister interface {
|
|
||||||
// List lists all APIServices in the indexer.
|
|
||||||
List(selector labels.Selector) (ret []*apiregistration.APIService, err error)
|
|
||||||
// Get retrieves the APIService from the index for a given name.
|
|
||||||
Get(name string) (*apiregistration.APIService, error)
|
|
||||||
APIServiceListerExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// aPIServiceLister implements the APIServiceLister interface.
|
|
||||||
type aPIServiceLister struct {
|
|
||||||
indexer cache.Indexer
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAPIServiceLister returns a new APIServiceLister.
|
|
||||||
func NewAPIServiceLister(indexer cache.Indexer) APIServiceLister {
|
|
||||||
return &aPIServiceLister{indexer: indexer}
|
|
||||||
}
|
|
||||||
|
|
||||||
// List lists all APIServices in the indexer.
|
|
||||||
func (s *aPIServiceLister) List(selector labels.Selector) (ret []*apiregistration.APIService, err error) {
|
|
||||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
|
||||||
ret = append(ret, m.(*apiregistration.APIService))
|
|
||||||
})
|
|
||||||
return ret, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get retrieves the APIService from the index for a given name.
|
|
||||||
func (s *aPIServiceLister) Get(name string) (*apiregistration.APIService, error) {
|
|
||||||
obj, exists, err := s.indexer.GetByKey(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !exists {
|
|
||||||
return nil, errors.NewNotFound(apiregistration.Resource("apiservice"), name)
|
|
||||||
}
|
|
||||||
return obj.(*apiregistration.APIService), nil
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by lister-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
// APIServiceListerExpansion allows custom methods to be added to
|
|
||||||
// APIServiceLister.
|
|
||||||
type APIServiceListerExpansion interface{}
|
|
@ -15,9 +15,9 @@ go_test(
|
|||||||
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/fake:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,10 +34,10 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/controllers:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/controllers:go_default_library",
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
"//vendor/k8s.io/klog:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -32,10 +32,10 @@ import (
|
|||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
|
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion"
|
apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
|
||||||
informers "k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion"
|
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1"
|
||||||
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
"k8s.io/kube-aggregator/pkg/controllers"
|
"k8s.io/kube-aggregator/pkg/controllers"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,9 +53,9 @@ const (
|
|||||||
// adding and removing APIServices
|
// adding and removing APIServices
|
||||||
type AutoAPIServiceRegistration interface {
|
type AutoAPIServiceRegistration interface {
|
||||||
// AddAPIServiceToSyncOnStart adds an API service to sync on start.
|
// AddAPIServiceToSyncOnStart adds an API service to sync on start.
|
||||||
AddAPIServiceToSyncOnStart(in *apiregistration.APIService)
|
AddAPIServiceToSyncOnStart(in *v1.APIService)
|
||||||
// AddAPIServiceToSync adds an API service to sync continuously.
|
// AddAPIServiceToSync adds an API service to sync continuously.
|
||||||
AddAPIServiceToSync(in *apiregistration.APIService)
|
AddAPIServiceToSync(in *v1.APIService)
|
||||||
// RemoveAPIServiceToSync removes an API service to auto-register.
|
// RemoveAPIServiceToSync removes an API service to auto-register.
|
||||||
RemoveAPIServiceToSync(name string)
|
RemoveAPIServiceToSync(name string)
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ type autoRegisterController struct {
|
|||||||
apiServiceClient apiregistrationclient.APIServicesGetter
|
apiServiceClient apiregistrationclient.APIServicesGetter
|
||||||
|
|
||||||
apiServicesToSyncLock sync.RWMutex
|
apiServicesToSyncLock sync.RWMutex
|
||||||
apiServicesToSync map[string]*apiregistration.APIService
|
apiServicesToSync map[string]*v1.APIService
|
||||||
|
|
||||||
syncHandler func(apiServiceName string) error
|
syncHandler func(apiServiceName string) error
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ func NewAutoRegisterController(apiServiceInformer informers.APIServiceInformer,
|
|||||||
apiServiceLister: apiServiceInformer.Lister(),
|
apiServiceLister: apiServiceInformer.Lister(),
|
||||||
apiServiceSynced: apiServiceInformer.Informer().HasSynced,
|
apiServiceSynced: apiServiceInformer.Informer().HasSynced,
|
||||||
apiServiceClient: apiServiceClient,
|
apiServiceClient: apiServiceClient,
|
||||||
apiServicesToSync: map[string]*apiregistration.APIService{},
|
apiServicesToSync: map[string]*v1.APIService{},
|
||||||
|
|
||||||
apiServicesAtStart: map[string]bool{},
|
apiServicesAtStart: map[string]bool{},
|
||||||
|
|
||||||
@ -102,22 +102,22 @@ func NewAutoRegisterController(apiServiceInformer informers.APIServiceInformer,
|
|||||||
|
|
||||||
apiServiceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
apiServiceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: func(obj interface{}) {
|
AddFunc: func(obj interface{}) {
|
||||||
cast := obj.(*apiregistration.APIService)
|
cast := obj.(*v1.APIService)
|
||||||
c.queue.Add(cast.Name)
|
c.queue.Add(cast.Name)
|
||||||
},
|
},
|
||||||
UpdateFunc: func(_, obj interface{}) {
|
UpdateFunc: func(_, obj interface{}) {
|
||||||
cast := obj.(*apiregistration.APIService)
|
cast := obj.(*v1.APIService)
|
||||||
c.queue.Add(cast.Name)
|
c.queue.Add(cast.Name)
|
||||||
},
|
},
|
||||||
DeleteFunc: func(obj interface{}) {
|
DeleteFunc: func(obj interface{}) {
|
||||||
cast, ok := obj.(*apiregistration.APIService)
|
cast, ok := obj.(*v1.APIService)
|
||||||
if !ok {
|
if !ok {
|
||||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||||
if !ok {
|
if !ok {
|
||||||
klog.V(2).Infof("Couldn't get object from tombstone %#v", obj)
|
klog.V(2).Infof("Couldn't get object from tombstone %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cast, ok = tombstone.Obj.(*apiregistration.APIService)
|
cast, ok = tombstone.Obj.(*v1.APIService)
|
||||||
if !ok {
|
if !ok {
|
||||||
klog.V(2).Infof("Tombstone contained unexpected object: %#v", obj)
|
klog.V(2).Infof("Tombstone contained unexpected object: %#v", obj)
|
||||||
return
|
return
|
||||||
@ -286,7 +286,7 @@ func (c *autoRegisterController) checkAPIService(name string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetAPIServiceToSync gets a single API service to sync.
|
// GetAPIServiceToSync gets a single API service to sync.
|
||||||
func (c *autoRegisterController) GetAPIServiceToSync(name string) *apiregistration.APIService {
|
func (c *autoRegisterController) GetAPIServiceToSync(name string) *v1.APIService {
|
||||||
c.apiServicesToSyncLock.RLock()
|
c.apiServicesToSyncLock.RLock()
|
||||||
defer c.apiServicesToSyncLock.RUnlock()
|
defer c.apiServicesToSyncLock.RUnlock()
|
||||||
|
|
||||||
@ -294,16 +294,16 @@ func (c *autoRegisterController) GetAPIServiceToSync(name string) *apiregistrati
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddAPIServiceToSyncOnStart registers an API service to sync only when the controller starts.
|
// AddAPIServiceToSyncOnStart registers an API service to sync only when the controller starts.
|
||||||
func (c *autoRegisterController) AddAPIServiceToSyncOnStart(in *apiregistration.APIService) {
|
func (c *autoRegisterController) AddAPIServiceToSyncOnStart(in *v1.APIService) {
|
||||||
c.addAPIServiceToSync(in, manageOnStart)
|
c.addAPIServiceToSync(in, manageOnStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddAPIServiceToSync registers an API service to sync continuously.
|
// AddAPIServiceToSync registers an API service to sync continuously.
|
||||||
func (c *autoRegisterController) AddAPIServiceToSync(in *apiregistration.APIService) {
|
func (c *autoRegisterController) AddAPIServiceToSync(in *v1.APIService) {
|
||||||
c.addAPIServiceToSync(in, manageContinuously)
|
c.addAPIServiceToSync(in, manageContinuously)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *autoRegisterController) addAPIServiceToSync(in *apiregistration.APIService, syncType string) {
|
func (c *autoRegisterController) addAPIServiceToSync(in *v1.APIService, syncType string) {
|
||||||
c.apiServicesToSyncLock.Lock()
|
c.apiServicesToSyncLock.Lock()
|
||||||
defer c.apiServicesToSyncLock.Unlock()
|
defer c.apiServicesToSyncLock.Unlock()
|
||||||
|
|
||||||
@ -338,18 +338,18 @@ func (c *autoRegisterController) setSyncedSuccessfully(name string) {
|
|||||||
c.syncedSuccessfully[name] = true
|
c.syncedSuccessfully[name] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func automanagedType(service *apiregistration.APIService) string {
|
func automanagedType(service *v1.APIService) string {
|
||||||
if service == nil {
|
if service == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return service.Labels[AutoRegisterManagedLabel]
|
return service.Labels[AutoRegisterManagedLabel]
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAutomanagedOnStart(service *apiregistration.APIService) bool {
|
func isAutomanagedOnStart(service *v1.APIService) bool {
|
||||||
return automanagedType(service) == manageOnStart
|
return automanagedType(service) == manageOnStart
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAutomanaged(service *apiregistration.APIService) bool {
|
func isAutomanaged(service *v1.APIService) bool {
|
||||||
managedType := automanagedType(service)
|
managedType := automanagedType(service)
|
||||||
return managedType == manageOnStart || managedType == manageContinuously
|
return managedType == manageOnStart || managedType == manageContinuously
|
||||||
}
|
}
|
||||||
|
@ -25,43 +25,43 @@ import (
|
|||||||
clienttesting "k8s.io/client-go/testing"
|
clienttesting "k8s.io/client-go/testing"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
"k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/fake"
|
"k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake"
|
||||||
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newAutoRegisterManagedAPIService(name string) *apiregistration.APIService {
|
func newAutoRegisterManagedAPIService(name string) *apiregistrationv1.APIService {
|
||||||
return &apiregistration.APIService{
|
return &apiregistrationv1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{AutoRegisterManagedLabel: string("true")}},
|
ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{AutoRegisterManagedLabel: string("true")}},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAutoRegisterManagedOnStartAPIService(name string) *apiregistration.APIService {
|
func newAutoRegisterManagedOnStartAPIService(name string) *apiregistrationv1.APIService {
|
||||||
return &apiregistration.APIService{
|
return &apiregistrationv1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{AutoRegisterManagedLabel: string("onstart")}},
|
ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{AutoRegisterManagedLabel: string("onstart")}},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAutoRegisterManagedModifiedAPIService(name string) *apiregistration.APIService {
|
func newAutoRegisterManagedModifiedAPIService(name string) *apiregistrationv1.APIService {
|
||||||
return &apiregistration.APIService{
|
return &apiregistrationv1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{AutoRegisterManagedLabel: string("true")}},
|
ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{AutoRegisterManagedLabel: string("true")}},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: apiregistrationv1.APIServiceSpec{
|
||||||
Group: "something",
|
Group: "something",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAutoRegisterManagedOnStartModifiedAPIService(name string) *apiregistration.APIService {
|
func newAutoRegisterManagedOnStartModifiedAPIService(name string) *apiregistrationv1.APIService {
|
||||||
return &apiregistration.APIService{
|
return &apiregistrationv1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{AutoRegisterManagedLabel: string("onstart")}},
|
ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{AutoRegisterManagedLabel: string("onstart")}},
|
||||||
Spec: apiregistration.APIServiceSpec{
|
Spec: apiregistrationv1.APIServiceSpec{
|
||||||
Group: "something",
|
Group: "something",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAPIService(name string) *apiregistration.APIService {
|
func newAPIService(name string) *apiregistrationv1.APIService {
|
||||||
return &apiregistration.APIService{
|
return &apiregistrationv1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ func checkForCreate(name string, client *fake.Clientset) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unexpected action: %v", client.Actions())
|
return fmt.Errorf("unexpected action: %v", client.Actions())
|
||||||
}
|
}
|
||||||
apiService := createAction.GetObject().(*apiregistration.APIService)
|
apiService := createAction.GetObject().(*apiregistrationv1.APIService)
|
||||||
if apiService.Name != name || apiService.Labels[AutoRegisterManagedLabel] != "true" {
|
if apiService.Name != name || apiService.Labels[AutoRegisterManagedLabel] != "true" {
|
||||||
return fmt.Errorf("bad name or label %v", createAction)
|
return fmt.Errorf("bad name or label %v", createAction)
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ func checkForCreateOnStart(name string, client *fake.Clientset) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unexpected action: %v", client.Actions())
|
return fmt.Errorf("unexpected action: %v", client.Actions())
|
||||||
}
|
}
|
||||||
apiService := createAction.GetObject().(*apiregistration.APIService)
|
apiService := createAction.GetObject().(*apiregistrationv1.APIService)
|
||||||
if apiService.Name != name || apiService.Labels[AutoRegisterManagedLabel] != "onstart" {
|
if apiService.Name != name || apiService.Labels[AutoRegisterManagedLabel] != "onstart" {
|
||||||
return fmt.Errorf("bad name or label %v", createAction)
|
return fmt.Errorf("bad name or label %v", createAction)
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ func checkForUpdate(name string, client *fake.Clientset) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unexpected action: %v", client.Actions())
|
return fmt.Errorf("unexpected action: %v", client.Actions())
|
||||||
}
|
}
|
||||||
apiService := updateAction.GetObject().(*apiregistration.APIService)
|
apiService := updateAction.GetObject().(*apiregistrationv1.APIService)
|
||||||
if apiService.Name != name || apiService.Labels[AutoRegisterManagedLabel] != "true" || apiService.Spec.Group != "" {
|
if apiService.Name != name || apiService.Labels[AutoRegisterManagedLabel] != "true" || apiService.Spec.Group != "" {
|
||||||
return fmt.Errorf("bad name, label, or group %v", updateAction)
|
return fmt.Errorf("bad name, label, or group %v", updateAction)
|
||||||
}
|
}
|
||||||
@ -161,10 +161,10 @@ func TestSync(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
apiServiceName string
|
apiServiceName string
|
||||||
addAPIServices []*apiregistration.APIService
|
addAPIServices []*apiregistrationv1.APIService
|
||||||
updateAPIServices []*apiregistration.APIService
|
updateAPIServices []*apiregistrationv1.APIService
|
||||||
addSyncAPIServices []*apiregistration.APIService
|
addSyncAPIServices []*apiregistrationv1.APIService
|
||||||
addSyncOnStartAPIServices []*apiregistration.APIService
|
addSyncOnStartAPIServices []*apiregistrationv1.APIService
|
||||||
delSyncAPIServices []string
|
delSyncAPIServices []string
|
||||||
alreadySynced map[string]bool
|
alreadySynced map[string]bool
|
||||||
presentAtStart map[string]bool
|
presentAtStart map[string]bool
|
||||||
@ -173,63 +173,63 @@ func TestSync(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "adding an API service which isn't auto-managed does nothing",
|
name: "adding an API service which isn't auto-managed does nothing",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
addAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
updateAPIServices: []*apiregistration.APIService{},
|
updateAPIServices: []*apiregistrationv1.APIService{},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{},
|
addSyncAPIServices: []*apiregistrationv1.APIService{},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
expectedResults: checkForNothing,
|
expectedResults: checkForNothing,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "adding one to auto-register should create",
|
name: "adding one to auto-register should create",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{},
|
addAPIServices: []*apiregistrationv1.APIService{},
|
||||||
updateAPIServices: []*apiregistration.APIService{},
|
updateAPIServices: []*apiregistrationv1.APIService{},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
addSyncAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
expectedResults: checkForCreate,
|
expectedResults: checkForCreate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "duplicate AddAPIServiceToSync don't panic",
|
name: "duplicate AddAPIServiceToSync don't panic",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{newAutoRegisterManagedAPIService("foo")},
|
addAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedAPIService("foo")},
|
||||||
updateAPIServices: []*apiregistration.APIService{},
|
updateAPIServices: []*apiregistrationv1.APIService{},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{newAutoRegisterManagedAPIService("foo"), newAutoRegisterManagedAPIService("foo")},
|
addSyncAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedAPIService("foo"), newAutoRegisterManagedAPIService("foo")},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
expectedResults: checkForNothing,
|
expectedResults: checkForNothing,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "duplicate RemoveAPIServiceToSync don't panic",
|
name: "duplicate RemoveAPIServiceToSync don't panic",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{newAutoRegisterManagedAPIService("foo")},
|
addAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedAPIService("foo")},
|
||||||
updateAPIServices: []*apiregistration.APIService{},
|
updateAPIServices: []*apiregistrationv1.APIService{},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{},
|
addSyncAPIServices: []*apiregistrationv1.APIService{},
|
||||||
delSyncAPIServices: []string{"foo", "foo"},
|
delSyncAPIServices: []string{"foo", "foo"},
|
||||||
expectedResults: checkForDelete,
|
expectedResults: checkForDelete,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "removing auto-managed then RemoveAPIService should not touch APIService",
|
name: "removing auto-managed then RemoveAPIService should not touch APIService",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{},
|
addAPIServices: []*apiregistrationv1.APIService{},
|
||||||
updateAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
updateAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{},
|
addSyncAPIServices: []*apiregistrationv1.APIService{},
|
||||||
delSyncAPIServices: []string{"foo"},
|
delSyncAPIServices: []string{"foo"},
|
||||||
expectedResults: checkForNothing,
|
expectedResults: checkForNothing,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "create managed apiservice without a matching request",
|
name: "create managed apiservice without a matching request",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
addAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
updateAPIServices: []*apiregistration.APIService{newAutoRegisterManagedAPIService("foo")},
|
updateAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedAPIService("foo")},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{},
|
addSyncAPIServices: []*apiregistrationv1.APIService{},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
expectedResults: checkForDelete,
|
expectedResults: checkForDelete,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "modifying it should result in stomping",
|
name: "modifying it should result in stomping",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{},
|
addAPIServices: []*apiregistrationv1.APIService{},
|
||||||
updateAPIServices: []*apiregistration.APIService{newAutoRegisterManagedModifiedAPIService("foo")},
|
updateAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedModifiedAPIService("foo")},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{newAutoRegisterManagedAPIService("foo")},
|
addSyncAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedAPIService("foo")},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
expectedResults: checkForUpdate,
|
expectedResults: checkForUpdate,
|
||||||
},
|
},
|
||||||
@ -237,18 +237,18 @@ func TestSync(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "adding one to auto-register on start should create",
|
name: "adding one to auto-register on start should create",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{},
|
addAPIServices: []*apiregistrationv1.APIService{},
|
||||||
updateAPIServices: []*apiregistration.APIService{},
|
updateAPIServices: []*apiregistrationv1.APIService{},
|
||||||
addSyncOnStartAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
addSyncOnStartAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
expectedResults: checkForCreateOnStart,
|
expectedResults: checkForCreateOnStart,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "adding one to auto-register on start already synced should do nothing",
|
name: "adding one to auto-register on start already synced should do nothing",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{},
|
addAPIServices: []*apiregistrationv1.APIService{},
|
||||||
updateAPIServices: []*apiregistration.APIService{},
|
updateAPIServices: []*apiregistrationv1.APIService{},
|
||||||
addSyncOnStartAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
addSyncOnStartAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
alreadySynced: map[string]bool{"foo": true},
|
alreadySynced: map[string]bool{"foo": true},
|
||||||
expectedResults: checkForNothing,
|
expectedResults: checkForNothing,
|
||||||
@ -256,9 +256,9 @@ func TestSync(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "managed onstart apiservice present at start without a matching request should delete",
|
name: "managed onstart apiservice present at start without a matching request should delete",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
addAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
updateAPIServices: []*apiregistration.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
updateAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{},
|
addSyncAPIServices: []*apiregistrationv1.APIService{},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
presentAtStart: map[string]bool{"foo": true},
|
presentAtStart: map[string]bool{"foo": true},
|
||||||
alreadySynced: map[string]bool{},
|
alreadySynced: map[string]bool{},
|
||||||
@ -267,9 +267,9 @@ func TestSync(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "managed onstart apiservice present at start without a matching request already synced once should no-op",
|
name: "managed onstart apiservice present at start without a matching request already synced once should no-op",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
addAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
updateAPIServices: []*apiregistration.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
updateAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{},
|
addSyncAPIServices: []*apiregistrationv1.APIService{},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
presentAtStart: map[string]bool{"foo": true},
|
presentAtStart: map[string]bool{"foo": true},
|
||||||
alreadySynced: map[string]bool{"foo": true},
|
alreadySynced: map[string]bool{"foo": true},
|
||||||
@ -278,9 +278,9 @@ func TestSync(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "managed onstart apiservice not present at start without a matching request should no-op",
|
name: "managed onstart apiservice not present at start without a matching request should no-op",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{newAPIService("foo")},
|
addAPIServices: []*apiregistrationv1.APIService{newAPIService("foo")},
|
||||||
updateAPIServices: []*apiregistration.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
updateAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
||||||
addSyncAPIServices: []*apiregistration.APIService{},
|
addSyncAPIServices: []*apiregistrationv1.APIService{},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
presentAtStart: map[string]bool{},
|
presentAtStart: map[string]bool{},
|
||||||
alreadySynced: map[string]bool{},
|
alreadySynced: map[string]bool{},
|
||||||
@ -289,18 +289,18 @@ func TestSync(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "modifying onstart it should result in stomping",
|
name: "modifying onstart it should result in stomping",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{},
|
addAPIServices: []*apiregistrationv1.APIService{},
|
||||||
updateAPIServices: []*apiregistration.APIService{newAutoRegisterManagedModifiedAPIService("foo")},
|
updateAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedModifiedAPIService("foo")},
|
||||||
addSyncOnStartAPIServices: []*apiregistration.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
addSyncOnStartAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
expectedResults: checkForUpdate,
|
expectedResults: checkForUpdate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "modifying onstart already synced should no-op",
|
name: "modifying onstart already synced should no-op",
|
||||||
apiServiceName: "foo",
|
apiServiceName: "foo",
|
||||||
addAPIServices: []*apiregistration.APIService{},
|
addAPIServices: []*apiregistrationv1.APIService{},
|
||||||
updateAPIServices: []*apiregistration.APIService{newAutoRegisterManagedModifiedAPIService("foo")},
|
updateAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedModifiedAPIService("foo")},
|
||||||
addSyncOnStartAPIServices: []*apiregistration.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
addSyncOnStartAPIServices: []*apiregistrationv1.APIService{newAutoRegisterManagedOnStartAPIService("foo")},
|
||||||
delSyncAPIServices: []string{},
|
delSyncAPIServices: []string{},
|
||||||
alreadySynced: map[string]bool{"foo": true},
|
alreadySynced: map[string]bool{"foo": true},
|
||||||
expectedResults: checkForNothing,
|
expectedResults: checkForNothing,
|
||||||
@ -322,9 +322,9 @@ func TestSync(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c := &autoRegisterController{
|
c := &autoRegisterController{
|
||||||
apiServiceClient: fakeClient.Apiregistration(),
|
apiServiceClient: fakeClient.ApiregistrationV1(),
|
||||||
apiServiceLister: listers.NewAPIServiceLister(apiServiceIndexer),
|
apiServiceLister: listers.NewAPIServiceLister(apiServiceIndexer),
|
||||||
apiServicesToSync: map[string]*apiregistration.APIService{},
|
apiServicesToSync: map[string]*apiregistrationv1.APIService{},
|
||||||
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "autoregister"),
|
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "autoregister"),
|
||||||
|
|
||||||
syncedSuccessfullyLock: &sync.RWMutex{},
|
syncedSuccessfullyLock: &sync.RWMutex{},
|
||||||
|
@ -10,7 +10,7 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator:go_default_library",
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
"//vendor/k8s.io/klog:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -14,7 +14,7 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/server:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/server:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//vendor/github.com/emicklei/go-restful:go_default_library",
|
"//vendor/github.com/emicklei/go-restful:go_default_library",
|
||||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||||
"//vendor/k8s.io/kube-openapi/pkg/aggregator:go_default_library",
|
"//vendor/k8s.io/kube-openapi/pkg/aggregator:go_default_library",
|
||||||
@ -32,7 +32,7 @@ go_test(
|
|||||||
],
|
],
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"github.com/go-openapi/spec"
|
"github.com/go-openapi/spec"
|
||||||
|
|
||||||
"k8s.io/apiserver/pkg/server"
|
"k8s.io/apiserver/pkg/server"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
"k8s.io/kube-openapi/pkg/aggregator"
|
"k8s.io/kube-openapi/pkg/aggregator"
|
||||||
"k8s.io/kube-openapi/pkg/builder"
|
"k8s.io/kube-openapi/pkg/builder"
|
||||||
"k8s.io/kube-openapi/pkg/common"
|
"k8s.io/kube-openapi/pkg/common"
|
||||||
@ -37,7 +37,7 @@ import (
|
|||||||
// SpecAggregator calls out to http handlers of APIServices and merges specs. It keeps state of the last
|
// SpecAggregator calls out to http handlers of APIServices and merges specs. It keeps state of the last
|
||||||
// known specs including the http etag.
|
// known specs including the http etag.
|
||||||
type SpecAggregator interface {
|
type SpecAggregator interface {
|
||||||
AddUpdateAPIService(handler http.Handler, apiService *apiregistration.APIService) error
|
AddUpdateAPIService(handler http.Handler, apiService *v1.APIService) error
|
||||||
UpdateAPIServiceSpec(apiServiceName string, spec *spec.Swagger, etag string) error
|
UpdateAPIServiceSpec(apiServiceName string, spec *spec.Swagger, etag string) error
|
||||||
RemoveAPIServiceSpec(apiServiceName string) error
|
RemoveAPIServiceSpec(apiServiceName string) error
|
||||||
GetAPIServiceInfo(apiServiceName string) (handler http.Handler, etag string, exists bool)
|
GetAPIServiceInfo(apiServiceName string) (handler http.Handler, etag string, exists bool)
|
||||||
@ -134,7 +134,7 @@ var _ SpecAggregator = &specAggregator{}
|
|||||||
|
|
||||||
// This function is not thread safe as it only being called on startup.
|
// This function is not thread safe as it only being called on startup.
|
||||||
func (s *specAggregator) addLocalSpec(spec *spec.Swagger, localHandler http.Handler, name, etag string) {
|
func (s *specAggregator) addLocalSpec(spec *spec.Swagger, localHandler http.Handler, name, etag string) {
|
||||||
localAPIService := apiregistration.APIService{}
|
localAPIService := v1.APIService{}
|
||||||
localAPIService.Name = name
|
localAPIService.Name = name
|
||||||
s.openAPISpecs[name] = &openAPISpecInfo{
|
s.openAPISpecs[name] = &openAPISpecInfo{
|
||||||
etag: etag,
|
etag: etag,
|
||||||
@ -147,7 +147,7 @@ func (s *specAggregator) addLocalSpec(spec *spec.Swagger, localHandler http.Hand
|
|||||||
// openAPISpecInfo is used to store OpenAPI spec with its priority.
|
// openAPISpecInfo is used to store OpenAPI spec with its priority.
|
||||||
// It can be used to sort specs with their priorities.
|
// It can be used to sort specs with their priorities.
|
||||||
type openAPISpecInfo struct {
|
type openAPISpecInfo struct {
|
||||||
apiService apiregistration.APIService
|
apiService v1.APIService
|
||||||
|
|
||||||
// Specification of this API Service. If null then the spec is not loaded yet.
|
// Specification of this API Service. If null then the spec is not loaded yet.
|
||||||
spec *spec.Swagger
|
spec *spec.Swagger
|
||||||
@ -260,7 +260,7 @@ func (s *specAggregator) UpdateAPIServiceSpec(apiServiceName string, spec *spec.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddUpdateAPIService adds or updates the api service. It is thread safe.
|
// AddUpdateAPIService adds or updates the api service. It is thread safe.
|
||||||
func (s *specAggregator) AddUpdateAPIService(handler http.Handler, apiService *apiregistration.APIService) error {
|
func (s *specAggregator) AddUpdateAPIService(handler http.Handler, apiService *v1.APIService) error {
|
||||||
s.rwMutex.Lock()
|
s.rwMutex.Lock()
|
||||||
defer s.rwMutex.Unlock()
|
defer s.rwMutex.Unlock()
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ import (
|
|||||||
|
|
||||||
"github.com/go-openapi/spec"
|
"github.com/go-openapi/spec"
|
||||||
|
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newAPIServiceForTest(name, group string, minGroupPriority, versionPriority int32, svc *apiregistration.ServiceReference) apiregistration.APIService {
|
func newAPIServiceForTest(name, group string, minGroupPriority, versionPriority int32, svc *apiregistrationv1.ServiceReference) apiregistrationv1.APIService {
|
||||||
r := apiregistration.APIService{}
|
r := apiregistrationv1.APIService{}
|
||||||
r.Spec.Group = group
|
r.Spec.Group = group
|
||||||
r.Spec.GroupPriorityMinimum = minGroupPriority
|
r.Spec.GroupPriorityMinimum = minGroupPriority
|
||||||
r.Spec.VersionPriority = versionPriority
|
r.Spec.VersionPriority = versionPriority
|
||||||
@ -48,19 +48,19 @@ func assertSortedServices(t *testing.T, actual []openAPISpecInfo, expectedNames
|
|||||||
func TestAPIServiceSort(t *testing.T) {
|
func TestAPIServiceSort(t *testing.T) {
|
||||||
list := []openAPISpecInfo{
|
list := []openAPISpecInfo{
|
||||||
{
|
{
|
||||||
apiService: newAPIServiceForTest("FirstService", "Group1", 10, 5, &apiregistration.ServiceReference{}),
|
apiService: newAPIServiceForTest("FirstService", "Group1", 10, 5, &apiregistrationv1.ServiceReference{}),
|
||||||
spec: &spec.Swagger{},
|
spec: &spec.Swagger{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
apiService: newAPIServiceForTest("SecondService", "Group2", 15, 3, &apiregistration.ServiceReference{}),
|
apiService: newAPIServiceForTest("SecondService", "Group2", 15, 3, &apiregistrationv1.ServiceReference{}),
|
||||||
spec: &spec.Swagger{},
|
spec: &spec.Swagger{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
apiService: newAPIServiceForTest("FirstServiceInternal", "Group1", 16, 3, &apiregistration.ServiceReference{}),
|
apiService: newAPIServiceForTest("FirstServiceInternal", "Group1", 16, 3, &apiregistrationv1.ServiceReference{}),
|
||||||
spec: &spec.Swagger{},
|
spec: &spec.Swagger{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
apiService: newAPIServiceForTest("ThirdService", "Group3", 15, 3, &apiregistration.ServiceReference{}),
|
apiService: newAPIServiceForTest("ThirdService", "Group3", 15, 3, &apiregistrationv1.ServiceReference{}),
|
||||||
spec: &spec.Swagger{},
|
spec: &spec.Swagger{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
"k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator"
|
"k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ func (c *AggregationController) sync(key string) (syncAction, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddAPIService adds a new API Service to OpenAPI Aggregation.
|
// AddAPIService adds a new API Service to OpenAPI Aggregation.
|
||||||
func (c *AggregationController) AddAPIService(handler http.Handler, apiService *apiregistration.APIService) {
|
func (c *AggregationController) AddAPIService(handler http.Handler, apiService *v1.APIService) {
|
||||||
if apiService.Spec.Service == nil {
|
if apiService.Spec.Service == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ func (c *AggregationController) AddAPIService(handler http.Handler, apiService *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateAPIService updates API Service's info and handler.
|
// UpdateAPIService updates API Service's info and handler.
|
||||||
func (c *AggregationController) UpdateAPIService(handler http.Handler, apiService *apiregistration.APIService) {
|
func (c *AggregationController) UpdateAPIService(handler http.Handler, apiService *v1.APIService) {
|
||||||
if apiService.Spec.Service == nil {
|
if apiService.Spec.Service == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
"go_test",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
@ -14,6 +8,7 @@ go_library(
|
|||||||
],
|
],
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/controllers/status",
|
importmap = "k8s.io/kubernetes/vendor/k8s.io/kube-aggregator/pkg/controllers/status",
|
||||||
importpath = "k8s.io/kube-aggregator/pkg/controllers/status",
|
importpath = "k8s.io/kube-aggregator/pkg/controllers/status",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||||
@ -30,10 +25,11 @@ go_library(
|
|||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/transport:go_default_library",
|
"//staging/src/k8s.io/client-go/transport:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1:go_default_library",
|
||||||
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/controllers:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/controllers:go_default_library",
|
||||||
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
|
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
"//vendor/k8s.io/klog:go_default_library",
|
||||||
@ -50,10 +46,12 @@ go_test(
|
|||||||
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
|
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/fake:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1:go_default_library",
|
||||||
|
"//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1:go_default_library",
|
||||||
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
|
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
|
||||||
|
"//vendor/k8s.io/utils/pointer:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,4 +66,5 @@ filegroup(
|
|||||||
name = "all-srcs",
|
name = "all-srcs",
|
||||||
srcs = [":package-srcs"],
|
srcs = [":package-srcs"],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
@ -38,10 +38,11 @@ import (
|
|||||||
"k8s.io/client-go/transport"
|
"k8s.io/client-go/transport"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion"
|
apiregistrationv1apihelper "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper"
|
||||||
informers "k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion"
|
apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
|
||||||
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1"
|
||||||
|
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
"k8s.io/kube-aggregator/pkg/controllers"
|
"k8s.io/kube-aggregator/pkg/controllers"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -164,32 +165,32 @@ func (c *AvailableConditionController) sync(key string) error {
|
|||||||
|
|
||||||
apiService := originalAPIService.DeepCopy()
|
apiService := originalAPIService.DeepCopy()
|
||||||
|
|
||||||
availableCondition := apiregistration.APIServiceCondition{
|
availableCondition := apiregistrationv1.APIServiceCondition{
|
||||||
Type: apiregistration.Available,
|
Type: apiregistrationv1.Available,
|
||||||
Status: apiregistration.ConditionTrue,
|
Status: apiregistrationv1.ConditionTrue,
|
||||||
LastTransitionTime: metav1.Now(),
|
LastTransitionTime: metav1.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// local API services are always considered available
|
// local API services are always considered available
|
||||||
if apiService.Spec.Service == nil {
|
if apiService.Spec.Service == nil {
|
||||||
apiregistration.SetAPIServiceCondition(apiService, apiregistration.NewLocalAvailableAPIServiceCondition())
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, apiregistrationv1apihelper.NewLocalAvailableAPIServiceCondition())
|
||||||
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
service, err := c.serviceLister.Services(apiService.Spec.Service.Namespace).Get(apiService.Spec.Service.Name)
|
service, err := c.serviceLister.Services(apiService.Spec.Service.Namespace).Get(apiService.Spec.Service.Name)
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
availableCondition.Status = apiregistration.ConditionFalse
|
availableCondition.Status = apiregistrationv1.ConditionFalse
|
||||||
availableCondition.Reason = "ServiceNotFound"
|
availableCondition.Reason = "ServiceNotFound"
|
||||||
availableCondition.Message = fmt.Sprintf("service/%s in %q is not present", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace)
|
availableCondition.Message = fmt.Sprintf("service/%s in %q is not present", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace)
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, availableCondition)
|
||||||
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
return err
|
return err
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
availableCondition.Status = apiregistration.ConditionUnknown
|
availableCondition.Status = apiregistrationv1.ConditionUnknown
|
||||||
availableCondition.Reason = "ServiceAccessError"
|
availableCondition.Reason = "ServiceAccessError"
|
||||||
availableCondition.Message = fmt.Sprintf("service/%s in %q cannot be checked due to: %v", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace, err)
|
availableCondition.Message = fmt.Sprintf("service/%s in %q cannot be checked due to: %v", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace, err)
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, availableCondition)
|
||||||
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -200,33 +201,33 @@ func (c *AvailableConditionController) sync(key string) error {
|
|||||||
portName := ""
|
portName := ""
|
||||||
foundPort := false
|
foundPort := false
|
||||||
for _, port := range service.Spec.Ports {
|
for _, port := range service.Spec.Ports {
|
||||||
if port.Port == servicePort {
|
if port.Port == *servicePort {
|
||||||
foundPort = true
|
foundPort = true
|
||||||
portName = port.Name
|
portName = port.Name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !foundPort {
|
if !foundPort {
|
||||||
availableCondition.Status = apiregistration.ConditionFalse
|
availableCondition.Status = apiregistrationv1.ConditionFalse
|
||||||
availableCondition.Reason = "ServicePortError"
|
availableCondition.Reason = "ServicePortError"
|
||||||
availableCondition.Message = fmt.Sprintf("service/%s in %q is not listening on port %d", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace, apiService.Spec.Service.Port)
|
availableCondition.Message = fmt.Sprintf("service/%s in %q is not listening on port %d", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace, *apiService.Spec.Service.Port)
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, availableCondition)
|
||||||
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoints, err := c.endpointsLister.Endpoints(apiService.Spec.Service.Namespace).Get(apiService.Spec.Service.Name)
|
endpoints, err := c.endpointsLister.Endpoints(apiService.Spec.Service.Namespace).Get(apiService.Spec.Service.Name)
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
availableCondition.Status = apiregistration.ConditionFalse
|
availableCondition.Status = apiregistrationv1.ConditionFalse
|
||||||
availableCondition.Reason = "EndpointsNotFound"
|
availableCondition.Reason = "EndpointsNotFound"
|
||||||
availableCondition.Message = fmt.Sprintf("cannot find endpoints for service/%s in %q", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace)
|
availableCondition.Message = fmt.Sprintf("cannot find endpoints for service/%s in %q", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace)
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, availableCondition)
|
||||||
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
return err
|
return err
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
availableCondition.Status = apiregistration.ConditionUnknown
|
availableCondition.Status = apiregistrationv1.ConditionUnknown
|
||||||
availableCondition.Reason = "EndpointsAccessError"
|
availableCondition.Reason = "EndpointsAccessError"
|
||||||
availableCondition.Message = fmt.Sprintf("service/%s in %q cannot be checked due to: %v", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace, err)
|
availableCondition.Message = fmt.Sprintf("service/%s in %q cannot be checked due to: %v", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace, err)
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, availableCondition)
|
||||||
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -242,10 +243,10 @@ func (c *AvailableConditionController) sync(key string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !hasActiveEndpoints {
|
if !hasActiveEndpoints {
|
||||||
availableCondition.Status = apiregistration.ConditionFalse
|
availableCondition.Status = apiregistrationv1.ConditionFalse
|
||||||
availableCondition.Reason = "MissingEndpoints"
|
availableCondition.Reason = "MissingEndpoints"
|
||||||
availableCondition.Message = fmt.Sprintf("endpoints for service/%s in %q have no addresses with port name %q", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace, portName)
|
availableCondition.Message = fmt.Sprintf("endpoints for service/%s in %q have no addresses with port name %q", apiService.Spec.Service.Name, apiService.Spec.Service.Namespace, portName)
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, availableCondition)
|
||||||
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, err := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -256,7 +257,7 @@ func (c *AvailableConditionController) sync(key string) error {
|
|||||||
results := make(chan error, attempts)
|
results := make(chan error, attempts)
|
||||||
for i := 0; i < attempts; i++ {
|
for i := 0; i < attempts; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
discoveryURL, err := c.serviceResolver.ResolveEndpoint(apiService.Spec.Service.Namespace, apiService.Spec.Service.Name, apiService.Spec.Service.Port)
|
discoveryURL, err := c.serviceResolver.ResolveEndpoint(apiService.Spec.Service.Namespace, apiService.Spec.Service.Name, *apiService.Spec.Service.Port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
results <- err
|
results <- err
|
||||||
return
|
return
|
||||||
@ -315,10 +316,10 @@ func (c *AvailableConditionController) sync(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if lastError != nil {
|
if lastError != nil {
|
||||||
availableCondition.Status = apiregistration.ConditionFalse
|
availableCondition.Status = apiregistrationv1.ConditionFalse
|
||||||
availableCondition.Reason = "FailedDiscoveryCheck"
|
availableCondition.Reason = "FailedDiscoveryCheck"
|
||||||
availableCondition.Message = lastError.Error()
|
availableCondition.Message = lastError.Error()
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, availableCondition)
|
||||||
_, updateErr := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, updateErr := updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
if updateErr != nil {
|
if updateErr != nil {
|
||||||
return updateErr
|
return updateErr
|
||||||
@ -331,14 +332,14 @@ func (c *AvailableConditionController) sync(key string) error {
|
|||||||
|
|
||||||
availableCondition.Reason = "Passed"
|
availableCondition.Reason = "Passed"
|
||||||
availableCondition.Message = "all checks passed"
|
availableCondition.Message = "all checks passed"
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
apiregistrationv1apihelper.SetAPIServiceCondition(apiService, availableCondition)
|
||||||
_, err = updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
_, err = updateAPIServiceStatus(c.apiServiceClient, originalAPIService, apiService)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateAPIServiceStatus only issues an update if a change is detected. We have a tight resync loop to quickly detect dead
|
// updateAPIServiceStatus only issues an update if a change is detected. We have a tight resync loop to quickly detect dead
|
||||||
// apiservices. Doing that means we don't want to quickly issue no-op updates.
|
// apiservices. Doing that means we don't want to quickly issue no-op updates.
|
||||||
func updateAPIServiceStatus(client apiregistrationclient.APIServicesGetter, originalAPIService, newAPIService *apiregistration.APIService) (*apiregistration.APIService, error) {
|
func updateAPIServiceStatus(client apiregistrationclient.APIServicesGetter, originalAPIService, newAPIService *apiregistrationv1.APIService) (*apiregistrationv1.APIService, error) {
|
||||||
if equality.Semantic.DeepEqual(originalAPIService.Status, newAPIService.Status) {
|
if equality.Semantic.DeepEqual(originalAPIService.Status, newAPIService.Status) {
|
||||||
return newAPIService, nil
|
return newAPIService, nil
|
||||||
}
|
}
|
||||||
@ -349,8 +350,8 @@ func updateAPIServiceStatus(client apiregistrationclient.APIServicesGetter, orig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update metrics
|
// update metrics
|
||||||
wasAvailable := apiregistration.IsAPIServiceConditionTrue(originalAPIService, apiregistration.Available)
|
wasAvailable := apiregistrationv1apihelper.IsAPIServiceConditionTrue(originalAPIService, apiregistrationv1.Available)
|
||||||
isAvailable := apiregistration.IsAPIServiceConditionTrue(newAPIService, apiregistration.Available)
|
isAvailable := apiregistrationv1apihelper.IsAPIServiceConditionTrue(newAPIService, apiregistrationv1.Available)
|
||||||
if isAvailable != wasAvailable {
|
if isAvailable != wasAvailable {
|
||||||
if isAvailable {
|
if isAvailable {
|
||||||
unavailableGauge.WithLabelValues(newAPIService.Name).Set(0.0)
|
unavailableGauge.WithLabelValues(newAPIService.Name).Set(0.0)
|
||||||
@ -358,7 +359,7 @@ func updateAPIServiceStatus(client apiregistrationclient.APIServicesGetter, orig
|
|||||||
unavailableGauge.WithLabelValues(newAPIService.Name).Set(1.0)
|
unavailableGauge.WithLabelValues(newAPIService.Name).Set(1.0)
|
||||||
|
|
||||||
reason := "UnknownReason"
|
reason := "UnknownReason"
|
||||||
if newCondition := apiregistration.GetAPIServiceConditionByType(newAPIService, apiregistration.Available); newCondition != nil {
|
if newCondition := apiregistrationv1apihelper.GetAPIServiceConditionByType(newAPIService, apiregistrationv1.Available); newCondition != nil {
|
||||||
reason = newCondition.Reason
|
reason = newCondition.Reason
|
||||||
}
|
}
|
||||||
unavailableCounter.WithLabelValues(newAPIService.Name, reason).Inc()
|
unavailableCounter.WithLabelValues(newAPIService.Name, reason).Inc()
|
||||||
@ -412,7 +413,7 @@ func (c *AvailableConditionController) processNextWorkItem() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AvailableConditionController) enqueue(obj *apiregistration.APIService) {
|
func (c *AvailableConditionController) enqueue(obj *apiregistrationv1.APIService) {
|
||||||
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
|
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Couldn't get key for object %#v: %v", obj, err)
|
klog.Errorf("Couldn't get key for object %#v: %v", obj, err)
|
||||||
@ -423,26 +424,26 @@ func (c *AvailableConditionController) enqueue(obj *apiregistration.APIService)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *AvailableConditionController) addAPIService(obj interface{}) {
|
func (c *AvailableConditionController) addAPIService(obj interface{}) {
|
||||||
castObj := obj.(*apiregistration.APIService)
|
castObj := obj.(*apiregistrationv1.APIService)
|
||||||
klog.V(4).Infof("Adding %s", castObj.Name)
|
klog.V(4).Infof("Adding %s", castObj.Name)
|
||||||
c.enqueue(castObj)
|
c.enqueue(castObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AvailableConditionController) updateAPIService(obj, _ interface{}) {
|
func (c *AvailableConditionController) updateAPIService(obj, _ interface{}) {
|
||||||
castObj := obj.(*apiregistration.APIService)
|
castObj := obj.(*apiregistrationv1.APIService)
|
||||||
klog.V(4).Infof("Updating %s", castObj.Name)
|
klog.V(4).Infof("Updating %s", castObj.Name)
|
||||||
c.enqueue(castObj)
|
c.enqueue(castObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AvailableConditionController) deleteAPIService(obj interface{}) {
|
func (c *AvailableConditionController) deleteAPIService(obj interface{}) {
|
||||||
castObj, ok := obj.(*apiregistration.APIService)
|
castObj, ok := obj.(*apiregistrationv1.APIService)
|
||||||
if !ok {
|
if !ok {
|
||||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||||
if !ok {
|
if !ok {
|
||||||
klog.Errorf("Couldn't get object from tombstone %#v", obj)
|
klog.Errorf("Couldn't get object from tombstone %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
castObj, ok = tombstone.Obj.(*apiregistration.APIService)
|
castObj, ok = tombstone.Obj.(*apiregistrationv1.APIService)
|
||||||
if !ok {
|
if !ok {
|
||||||
klog.Errorf("Tombstone contained object that is not expected %#v", obj)
|
klog.Errorf("Tombstone contained object that is not expected %#v", obj)
|
||||||
return
|
return
|
||||||
@ -453,14 +454,14 @@ func (c *AvailableConditionController) deleteAPIService(obj interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// there aren't very many apiservices, just check them all.
|
// there aren't very many apiservices, just check them all.
|
||||||
func (c *AvailableConditionController) getAPIServicesFor(obj runtime.Object) []*apiregistration.APIService {
|
func (c *AvailableConditionController) getAPIServicesFor(obj runtime.Object) []*apiregistrationv1.APIService {
|
||||||
metadata, err := meta.Accessor(obj)
|
metadata, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utilruntime.HandleError(err)
|
utilruntime.HandleError(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret []*apiregistration.APIService
|
var ret []*apiregistrationv1.APIService
|
||||||
apiServiceList, _ := c.apiServiceLister.List(labels.Everything())
|
apiServiceList, _ := c.apiServiceLister.List(labels.Everything())
|
||||||
for _, apiService := range apiServiceList {
|
for _, apiService := range apiServiceList {
|
||||||
if apiService.Spec.Service == nil {
|
if apiService.Spec.Service == nil {
|
||||||
|
@ -18,6 +18,7 @@ package apiserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"k8s.io/utils/pointer"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -31,9 +32,10 @@ import (
|
|||||||
v1listers "k8s.io/client-go/listers/core/v1"
|
v1listers "k8s.io/client-go/listers/core/v1"
|
||||||
clienttesting "k8s.io/client-go/testing"
|
clienttesting "k8s.io/client-go/testing"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
apiregistration "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||||
"k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/fake"
|
"k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake"
|
||||||
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion"
|
apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
|
||||||
|
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -95,7 +97,7 @@ func newRemoteAPIService(name string) *apiregistration.APIService {
|
|||||||
Service: &apiregistration.ServiceReference{
|
Service: &apiregistration.ServiceReference{
|
||||||
Namespace: "foo",
|
Namespace: "foo",
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Port: testServicePort,
|
Port: pointer.Int32Ptr(testServicePort),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -249,7 +251,7 @@ func TestSync(t *testing.T) {
|
|||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
c := AvailableConditionController{
|
c := AvailableConditionController{
|
||||||
apiServiceClient: fakeClient.Apiregistration(),
|
apiServiceClient: fakeClient.ApiregistrationV1(),
|
||||||
apiServiceLister: listers.NewAPIServiceLister(apiServiceIndexer),
|
apiServiceLister: listers.NewAPIServiceLister(apiServiceIndexer),
|
||||||
serviceLister: v1listers.NewServiceLister(serviceIndexer),
|
serviceLister: v1listers.NewServiceLister(serviceIndexer),
|
||||||
endpointsLister: v1listers.NewEndpointsLister(endpointsIndexer),
|
endpointsLister: v1listers.NewEndpointsLister(endpointsIndexer),
|
||||||
@ -304,13 +306,13 @@ func TestUpdateAPIServiceStatus(t *testing.T) {
|
|||||||
bar := &apiregistration.APIService{Status: apiregistration.APIServiceStatus{Conditions: []apiregistration.APIServiceCondition{{Type: "bar"}}}}
|
bar := &apiregistration.APIService{Status: apiregistration.APIServiceStatus{Conditions: []apiregistration.APIServiceCondition{{Type: "bar"}}}}
|
||||||
|
|
||||||
fakeClient := fake.NewSimpleClientset()
|
fakeClient := fake.NewSimpleClientset()
|
||||||
updateAPIServiceStatus(fakeClient.Apiregistration(), foo, foo)
|
updateAPIServiceStatus(fakeClient.ApiregistrationV1().(apiregistrationclient.APIServicesGetter), foo, foo)
|
||||||
if e, a := 0, len(fakeClient.Actions()); e != a {
|
if e, a := 0, len(fakeClient.Actions()); e != a {
|
||||||
t.Error(spew.Sdump(fakeClient.Actions()))
|
t.Error(spew.Sdump(fakeClient.Actions()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeClient.ClearActions()
|
fakeClient.ClearActions()
|
||||||
updateAPIServiceStatus(fakeClient.Apiregistration(), foo, bar)
|
updateAPIServiceStatus(fakeClient.ApiregistrationV1().(apiregistrationclient.APIServicesGetter), foo, bar)
|
||||||
if e, a := 1, len(fakeClient.Actions()); e != a {
|
if e, a := 1, len(fakeClient.Actions()); e != a {
|
||||||
t.Error(spew.Sdump(fakeClient.Actions()))
|
t.Error(spew.Sdump(fakeClient.Actions()))
|
||||||
}
|
}
|
||||||
|
16
vendor/modules.txt
vendored
16
vendor/modules.txt
vendored
@ -1591,6 +1591,7 @@ k8s.io/klog
|
|||||||
k8s.io/kube-aggregator/pkg/apis/apiregistration
|
k8s.io/kube-aggregator/pkg/apis/apiregistration
|
||||||
k8s.io/kube-aggregator/pkg/apis/apiregistration/install
|
k8s.io/kube-aggregator/pkg/apis/apiregistration/install
|
||||||
k8s.io/kube-aggregator/pkg/apis/apiregistration/v1
|
k8s.io/kube-aggregator/pkg/apis/apiregistration/v1
|
||||||
|
k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/helper
|
||||||
k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1
|
k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1
|
||||||
k8s.io/kube-aggregator/pkg/apis/apiregistration/validation
|
k8s.io/kube-aggregator/pkg/apis/apiregistration/validation
|
||||||
k8s.io/kube-aggregator/pkg/apiserver
|
k8s.io/kube-aggregator/pkg/apiserver
|
||||||
@ -1599,14 +1600,13 @@ k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset
|
|||||||
k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme
|
k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme
|
||||||
k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1
|
k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1
|
||||||
k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1
|
k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1
|
||||||
k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset
|
k8s.io/kube-aggregator/pkg/client/informers/externalversions
|
||||||
k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/scheme
|
k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration
|
||||||
k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion
|
k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1
|
||||||
k8s.io/kube-aggregator/pkg/client/informers/internalversion
|
k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1beta1
|
||||||
k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration
|
k8s.io/kube-aggregator/pkg/client/informers/externalversions/internalinterfaces
|
||||||
k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion
|
k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1
|
||||||
k8s.io/kube-aggregator/pkg/client/informers/internalversion/internalinterfaces
|
k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1beta1
|
||||||
k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion
|
|
||||||
k8s.io/kube-aggregator/pkg/cmd/server
|
k8s.io/kube-aggregator/pkg/cmd/server
|
||||||
k8s.io/kube-aggregator/pkg/controllers
|
k8s.io/kube-aggregator/pkg/controllers
|
||||||
k8s.io/kube-aggregator/pkg/controllers/autoregister
|
k8s.io/kube-aggregator/pkg/controllers/autoregister
|
||||||
|
Loading…
Reference in New Issue
Block a user