mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Merge pull request #16496 from wojtek-t/switch_cacher_for_other_resources
Auto commit by PR queue bot
This commit is contained in:
commit
2842d9476b
@ -73,9 +73,9 @@ func (r *registryGetter) GetSecret(namespace, name string) (*api.Secret, error)
|
|||||||
|
|
||||||
// NewGetterFromStorageInterface returns a ServiceAccountTokenGetter that
|
// NewGetterFromStorageInterface returns a ServiceAccountTokenGetter that
|
||||||
// uses the specified storage to retrieve service accounts and secrets.
|
// uses the specified storage to retrieve service accounts and secrets.
|
||||||
func NewGetterFromStorageInterface(storage storage.Interface) ServiceAccountTokenGetter {
|
func NewGetterFromStorageInterface(s storage.Interface) ServiceAccountTokenGetter {
|
||||||
return NewGetterFromRegistries(
|
return NewGetterFromRegistries(
|
||||||
serviceaccount.NewRegistry(serviceaccountetcd.NewREST(storage)),
|
serviceaccount.NewRegistry(serviceaccountetcd.NewREST(s, storage.NoDecoration)),
|
||||||
secret.NewRegistry(secretetcd.NewREST(storage)),
|
secret.NewRegistry(secretetcd.NewREST(s, storage.NoDecoration)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -268,6 +268,13 @@ type Config struct {
|
|||||||
KubernetesServiceNodePort int
|
KubernetesServiceNodePort int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Config) storageFactory() storage.StorageFactory {
|
||||||
|
if c.EnableWatchCache {
|
||||||
|
return storage.NewCacher
|
||||||
|
}
|
||||||
|
return storage.NoDecoration
|
||||||
|
}
|
||||||
|
|
||||||
type InstallSSHKey func(user string, data []byte) error
|
type InstallSSHKey func(user string, data []byte) error
|
||||||
|
|
||||||
// Master contains state for a Kubernetes cluster master/api server.
|
// Master contains state for a Kubernetes cluster master/api server.
|
||||||
@ -535,27 +542,22 @@ func (m *Master) init(c *Config) {
|
|||||||
|
|
||||||
healthzChecks := []healthz.HealthzChecker{}
|
healthzChecks := []healthz.HealthzChecker{}
|
||||||
|
|
||||||
var storageFactory storage.StorageFactory
|
storageFactory := c.storageFactory()
|
||||||
if c.EnableWatchCache {
|
|
||||||
storageFactory = storage.NewCacher
|
|
||||||
} else {
|
|
||||||
storageFactory = storage.NoDecoration
|
|
||||||
}
|
|
||||||
dbClient := func(resource string) storage.Interface { return c.StorageDestinations.get("", resource) }
|
dbClient := func(resource string) storage.Interface { return c.StorageDestinations.get("", resource) }
|
||||||
podStorage := podetcd.NewStorage(dbClient("pods"), storageFactory, c.KubeletClient, m.proxyTransport)
|
podStorage := podetcd.NewStorage(dbClient("pods"), storageFactory, c.KubeletClient, m.proxyTransport)
|
||||||
|
|
||||||
podTemplateStorage := podtemplateetcd.NewREST(dbClient("podTemplates"))
|
podTemplateStorage := podtemplateetcd.NewREST(dbClient("podTemplates"), storageFactory)
|
||||||
|
|
||||||
eventStorage := eventetcd.NewREST(dbClient("events"), uint64(c.EventTTL.Seconds()))
|
eventStorage := eventetcd.NewREST(dbClient("events"), storageFactory, uint64(c.EventTTL.Seconds()))
|
||||||
limitRangeStorage := limitrangeetcd.NewREST(dbClient("limitRanges"))
|
limitRangeStorage := limitrangeetcd.NewREST(dbClient("limitRanges"), storageFactory)
|
||||||
|
|
||||||
resourceQuotaStorage, resourceQuotaStatusStorage := resourcequotaetcd.NewREST(dbClient("resourceQuotas"))
|
resourceQuotaStorage, resourceQuotaStatusStorage := resourcequotaetcd.NewREST(dbClient("resourceQuotas"), storageFactory)
|
||||||
secretStorage := secretetcd.NewREST(dbClient("secrets"))
|
secretStorage := secretetcd.NewREST(dbClient("secrets"), storageFactory)
|
||||||
serviceAccountStorage := serviceaccountetcd.NewREST(dbClient("serviceAccounts"))
|
serviceAccountStorage := serviceaccountetcd.NewREST(dbClient("serviceAccounts"), storageFactory)
|
||||||
persistentVolumeStorage, persistentVolumeStatusStorage := pvetcd.NewREST(dbClient("persistentVolumes"))
|
persistentVolumeStorage, persistentVolumeStatusStorage := pvetcd.NewREST(dbClient("persistentVolumes"), storageFactory)
|
||||||
persistentVolumeClaimStorage, persistentVolumeClaimStatusStorage := pvcetcd.NewREST(dbClient("persistentVolumeClaims"))
|
persistentVolumeClaimStorage, persistentVolumeClaimStatusStorage := pvcetcd.NewREST(dbClient("persistentVolumeClaims"), storageFactory)
|
||||||
|
|
||||||
namespaceStorage, namespaceStatusStorage, namespaceFinalizeStorage := namespaceetcd.NewREST(dbClient("namespaces"))
|
namespaceStorage, namespaceStatusStorage, namespaceFinalizeStorage := namespaceetcd.NewREST(dbClient("namespaces"), storageFactory)
|
||||||
m.namespaceRegistry = namespace.NewRegistry(namespaceStorage)
|
m.namespaceRegistry = namespace.NewRegistry(namespaceStorage)
|
||||||
|
|
||||||
endpointsStorage := endpointsetcd.NewREST(dbClient("endpoints"), storageFactory)
|
endpointsStorage := endpointsetcd.NewREST(dbClient("endpoints"), storageFactory)
|
||||||
@ -564,7 +566,7 @@ func (m *Master) init(c *Config) {
|
|||||||
nodeStorage, nodeStatusStorage := nodeetcd.NewREST(dbClient("nodes"), storageFactory, c.KubeletClient, m.proxyTransport)
|
nodeStorage, nodeStatusStorage := nodeetcd.NewREST(dbClient("nodes"), storageFactory, c.KubeletClient, m.proxyTransport)
|
||||||
m.nodeRegistry = node.NewRegistry(nodeStorage)
|
m.nodeRegistry = node.NewRegistry(nodeStorage)
|
||||||
|
|
||||||
serviceStorage := serviceetcd.NewREST(dbClient("services"))
|
serviceStorage := serviceetcd.NewREST(dbClient("services"), storageFactory)
|
||||||
m.serviceRegistry = service.NewRegistry(serviceStorage)
|
m.serviceRegistry = service.NewRegistry(serviceStorage)
|
||||||
|
|
||||||
var serviceClusterIPRegistry service.RangeRegistry
|
var serviceClusterIPRegistry service.RangeRegistry
|
||||||
@ -585,7 +587,7 @@ func (m *Master) init(c *Config) {
|
|||||||
})
|
})
|
||||||
m.serviceNodePortAllocator = serviceNodePortRegistry
|
m.serviceNodePortAllocator = serviceNodePortRegistry
|
||||||
|
|
||||||
controllerStorage, controllerStatusStorage := controlleretcd.NewREST(dbClient("replicationControllers"))
|
controllerStorage, controllerStatusStorage := controlleretcd.NewREST(dbClient("replicationControllers"), storageFactory)
|
||||||
|
|
||||||
// TODO: Factor out the core API registration
|
// TODO: Factor out the core API registration
|
||||||
m.storage = map[string]rest.Storage{
|
m.storage = map[string]rest.Storage{
|
||||||
@ -1005,7 +1007,7 @@ func (m *Master) InstallThirdPartyResource(rsrc *expapi.ThirdPartyResource) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupVersion {
|
func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupVersion {
|
||||||
resourceStorage := thirdpartyresourcedataetcd.NewREST(m.thirdPartyStorage, group, kind)
|
resourceStorage := thirdpartyresourcedataetcd.NewREST(m.thirdPartyStorage, storage.NoDecoration, group, kind)
|
||||||
|
|
||||||
apiRoot := makeThirdPartyPath("")
|
apiRoot := makeThirdPartyPath("")
|
||||||
|
|
||||||
@ -1047,21 +1049,22 @@ func (m *Master) experimental(c *Config) *apiserver.APIGroupVersion {
|
|||||||
}
|
}
|
||||||
return enabled
|
return enabled
|
||||||
}
|
}
|
||||||
|
storageFactory := c.storageFactory()
|
||||||
dbClient := func(resource string) storage.Interface {
|
dbClient := func(resource string) storage.Interface {
|
||||||
return c.StorageDestinations.get("extensions", resource)
|
return c.StorageDestinations.get("extensions", resource)
|
||||||
}
|
}
|
||||||
|
|
||||||
storage := map[string]rest.Storage{}
|
storage := map[string]rest.Storage{}
|
||||||
if isEnabled("horizontalpodautoscalers") {
|
if isEnabled("horizontalpodautoscalers") {
|
||||||
autoscalerStorage, autoscalerStatusStorage := horizontalpodautoscaleretcd.NewREST(dbClient("horizontalpodautoscalers"))
|
autoscalerStorage, autoscalerStatusStorage := horizontalpodautoscaleretcd.NewREST(dbClient("horizontalpodautoscalers"), storageFactory)
|
||||||
storage["horizontalpodautoscalers"] = autoscalerStorage
|
storage["horizontalpodautoscalers"] = autoscalerStorage
|
||||||
storage["horizontalpodautoscalers/status"] = autoscalerStatusStorage
|
storage["horizontalpodautoscalers/status"] = autoscalerStatusStorage
|
||||||
controllerStorage := expcontrolleretcd.NewStorage(c.StorageDestinations.get("", "replicationControllers"))
|
controllerStorage := expcontrolleretcd.NewStorage(c.StorageDestinations.get("", "replicationControllers"), storageFactory)
|
||||||
storage["replicationcontrollers"] = controllerStorage.ReplicationController
|
storage["replicationcontrollers"] = controllerStorage.ReplicationController
|
||||||
storage["replicationcontrollers/scale"] = controllerStorage.Scale
|
storage["replicationcontrollers/scale"] = controllerStorage.Scale
|
||||||
}
|
}
|
||||||
if isEnabled("thirdpartyresources") {
|
if isEnabled("thirdpartyresources") {
|
||||||
thirdPartyResourceStorage := thirdpartyresourceetcd.NewREST(dbClient("thirdpartyresources"))
|
thirdPartyResourceStorage := thirdpartyresourceetcd.NewREST(dbClient("thirdpartyresources"), storageFactory)
|
||||||
thirdPartyControl := ThirdPartyController{
|
thirdPartyControl := ThirdPartyController{
|
||||||
master: m,
|
master: m,
|
||||||
thirdPartyResourceRegistry: thirdPartyResourceStorage,
|
thirdPartyResourceRegistry: thirdPartyResourceStorage,
|
||||||
@ -1078,23 +1081,23 @@ func (m *Master) experimental(c *Config) *apiserver.APIGroupVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isEnabled("daemonsets") {
|
if isEnabled("daemonsets") {
|
||||||
daemonSetStorage, daemonSetStatusStorage := daemonetcd.NewREST(dbClient("daemonsets"))
|
daemonSetStorage, daemonSetStatusStorage := daemonetcd.NewREST(dbClient("daemonsets"), storageFactory)
|
||||||
storage["daemonsets"] = daemonSetStorage
|
storage["daemonsets"] = daemonSetStorage
|
||||||
storage["daemonsets/status"] = daemonSetStatusStorage
|
storage["daemonsets/status"] = daemonSetStatusStorage
|
||||||
}
|
}
|
||||||
if isEnabled("deployments") {
|
if isEnabled("deployments") {
|
||||||
deploymentStorage := deploymentetcd.NewStorage(dbClient("deployments"))
|
deploymentStorage := deploymentetcd.NewStorage(dbClient("deployments"), storageFactory)
|
||||||
storage["deployments"] = deploymentStorage.Deployment
|
storage["deployments"] = deploymentStorage.Deployment
|
||||||
storage["deployments/status"] = deploymentStorage.Status
|
storage["deployments/status"] = deploymentStorage.Status
|
||||||
storage["deployments/scale"] = deploymentStorage.Scale
|
storage["deployments/scale"] = deploymentStorage.Scale
|
||||||
}
|
}
|
||||||
if isEnabled("jobs") {
|
if isEnabled("jobs") {
|
||||||
jobStorage, jobStatusStorage := jobetcd.NewREST(dbClient("jobs"))
|
jobStorage, jobStatusStorage := jobetcd.NewREST(dbClient("jobs"), storageFactory)
|
||||||
storage["jobs"] = jobStorage
|
storage["jobs"] = jobStorage
|
||||||
storage["jobs/status"] = jobStatusStorage
|
storage["jobs/status"] = jobStatusStorage
|
||||||
}
|
}
|
||||||
if isEnabled("ingresses") {
|
if isEnabled("ingresses") {
|
||||||
ingressStorage, ingressStatusStorage := ingressetcd.NewREST(dbClient("ingresses"))
|
ingressStorage, ingressStatusStorage := ingressetcd.NewREST(dbClient("ingresses"), storageFactory)
|
||||||
storage["ingresses"] = ingressStorage
|
storage["ingresses"] = ingressStorage
|
||||||
storage["ingresses/status"] = ingressStatusStorage
|
storage["ingresses/status"] = ingressStatusStorage
|
||||||
}
|
}
|
||||||
|
@ -32,13 +32,18 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against replication controllers.
|
// NewREST returns a RESTStorage object that will work against replication controllers.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
prefix := "/controllers"
|
prefix := "/controllers"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.ReplicationControllerList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.ReplicationController{}, prefix, true, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.ReplicationController{} },
|
NewFunc: func() runtime.Object { return &api.ReplicationController{} },
|
||||||
|
|
||||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||||
NewListFunc: func() runtime.Object { return &api.ReplicationControllerList{} },
|
NewListFunc: newListFunc,
|
||||||
// Produces a path that etcd understands, to the root of the resource
|
// Produces a path that etcd understands, to the root of the resource
|
||||||
// by combining the namespace in the context with the given prefix
|
// by combining the namespace in the context with the given prefix
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
@ -65,7 +70,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
// Used to validate controller updates
|
// Used to validate controller updates
|
||||||
UpdateStrategy: controller.Strategy,
|
UpdateStrategy: controller.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
statusStore.UpdateStrategy = controller.StatusStrategy
|
statusStore.UpdateStrategy = controller.StatusStrategy
|
||||||
|
@ -24,13 +24,14 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
storage, statusStorage := NewREST(etcdStorage)
|
controllerStorage, statusStorage := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return storage, statusStorage, fakeClient
|
return controllerStorage, statusStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// createController is a helper function that returns a controller with the updated resource version.
|
// createController is a helper function that returns a controller with the updated resource version.
|
||||||
|
@ -33,25 +33,28 @@ type REST struct {
|
|||||||
*etcdgeneric.Etcd
|
*etcdgeneric.Etcd
|
||||||
}
|
}
|
||||||
|
|
||||||
// daemonPrefix is the location for daemons in etcd
|
|
||||||
var daemonPrefix = "/daemonsets"
|
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
|
prefix := "/daemonsets"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &extensions.DaemonSetList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &extensions.DaemonSet{}, prefix, false, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &extensions.DaemonSet{} },
|
NewFunc: func() runtime.Object { return &extensions.DaemonSet{} },
|
||||||
|
|
||||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||||
NewListFunc: func() runtime.Object { return &extensions.DaemonSetList{} },
|
NewListFunc: newListFunc,
|
||||||
// Produces a path that etcd understands, to the root of the resource
|
// Produces a path that etcd understands, to the root of the resource
|
||||||
// by combining the namespace in the context with the given prefix
|
// by combining the namespace in the context with the given prefix
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, daemonPrefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
// Produces a path that etcd understands, to the resource by combining
|
// Produces a path that etcd understands, to the resource by combining
|
||||||
// the namespace in the context with the given prefix
|
// the namespace in the context with the given prefix
|
||||||
KeyFunc: func(ctx api.Context, name string) (string, error) {
|
KeyFunc: func(ctx api.Context, name string) (string, error) {
|
||||||
return etcdgeneric.NamespaceKeyFunc(ctx, daemonPrefix, name)
|
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name)
|
||||||
},
|
},
|
||||||
// Retrieve the name field of a daemon set
|
// Retrieve the name field of a daemon set
|
||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
@ -69,7 +72,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
// Used to validate daemon set updates
|
// Used to validate daemon set updates
|
||||||
UpdateStrategy: daemonset.Strategy,
|
UpdateStrategy: daemonset.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
statusStore.UpdateStrategy = daemonset.StatusStrategy
|
statusStore.UpdateStrategy = daemonset.StatusStrategy
|
||||||
|
@ -25,13 +25,14 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
||||||
storage, statusStorage := NewREST(etcdStorage)
|
daemonSetStorage, statusStorage := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return storage, statusStorage, fakeClient
|
return daemonSetStorage, statusStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func newValidDaemonSet() *extensions.DaemonSet {
|
func newValidDaemonSet() *extensions.DaemonSet {
|
||||||
|
@ -39,8 +39,8 @@ type DeploymentStorage struct {
|
|||||||
Scale *ScaleREST
|
Scale *ScaleREST
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorage(s storage.Interface) DeploymentStorage {
|
func NewStorage(s storage.Interface, storageFactory storage.StorageFactory) DeploymentStorage {
|
||||||
deploymentRest, deploymentStatusRest := NewREST(s)
|
deploymentRest, deploymentStatusRest := NewREST(s, storageFactory)
|
||||||
deploymentRegistry := deployment.NewRegistry(deploymentRest)
|
deploymentRegistry := deployment.NewRegistry(deploymentRest)
|
||||||
|
|
||||||
return DeploymentStorage{
|
return DeploymentStorage{
|
||||||
@ -55,12 +55,17 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against deployments.
|
// NewREST returns a RESTStorage object that will work against deployments.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
prefix := "/deployments"
|
prefix := "/deployments"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &extensions.DeploymentList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &extensions.Deployment{}, prefix, false, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &extensions.Deployment{} },
|
NewFunc: func() runtime.Object { return &extensions.Deployment{} },
|
||||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||||
NewListFunc: func() runtime.Object { return &extensions.DeploymentList{} },
|
NewListFunc: newListFunc,
|
||||||
// Produces a path that etcd understands, to the root of the resource
|
// Produces a path that etcd understands, to the root of the resource
|
||||||
// by combining the namespace in the context with the given prefix.
|
// by combining the namespace in the context with the given prefix.
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
@ -87,7 +92,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
// Used to validate deployment updates.
|
// Used to validate deployment updates.
|
||||||
UpdateStrategy: deployment.Strategy,
|
UpdateStrategy: deployment.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
statusStore.UpdateStrategy = deployment.StatusStrategy
|
statusStore.UpdateStrategy = deployment.StatusStrategy
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
@ -33,7 +34,7 @@ import (
|
|||||||
|
|
||||||
func newStorage(t *testing.T) (*DeploymentStorage, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*DeploymentStorage, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
||||||
deploymentStorage := NewStorage(etcdStorage)
|
deploymentStorage := NewStorage(etcdStorage, storage.NoDecoration)
|
||||||
return &deploymentStorage, fakeClient
|
return &deploymentStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +32,13 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against events.
|
// NewREST returns a RESTStorage object that will work against events.
|
||||||
func NewREST(s storage.Interface, ttl uint64) *REST {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory, ttl uint64) *REST {
|
||||||
prefix := "/events"
|
prefix := "/events"
|
||||||
|
|
||||||
|
// We explicitly do NOT do any decoration here - switching on Cacher
|
||||||
|
// for events will lead to too high memory consumption.
|
||||||
|
storageInterface := s
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.Event{} },
|
NewFunc: func() runtime.Object { return &api.Event{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.EventList{} },
|
NewListFunc: func() runtime.Object { return &api.EventList{} },
|
||||||
@ -57,7 +62,7 @@ func NewREST(s storage.Interface, ttl uint64) *REST {
|
|||||||
CreateStrategy: event.Strategy,
|
CreateStrategy: event.Strategy,
|
||||||
UpdateStrategy: event.Strategy,
|
UpdateStrategy: event.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
return &REST{store}
|
return &REST{store}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ var testTTL uint64 = 60
|
|||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
fakeClient.HideExpires = true
|
fakeClient.HideExpires = true
|
||||||
return NewREST(etcdStorage, testTTL), fakeClient
|
return NewREST(etcdStorage, storage.NoDecoration, testTTL), fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewEvent(namespace string) *api.Event {
|
func validNewEvent(namespace string) *api.Event {
|
||||||
|
@ -37,9 +37,9 @@ type ContainerStorage struct {
|
|||||||
Scale *ScaleREST
|
Scale *ScaleREST
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorage(s storage.Interface) ContainerStorage {
|
func NewStorage(s storage.Interface, storageFactory storage.StorageFactory) ContainerStorage {
|
||||||
// scale does not set status, only updates spec so we ignore the status
|
// scale does not set status, only updates spec so we ignore the status
|
||||||
controllerREST, _ := etcd.NewREST(s)
|
controllerREST, _ := etcd.NewREST(s, storageFactory)
|
||||||
rcRegistry := controller.NewRegistry(controllerREST)
|
rcRegistry := controller.NewRegistry(controllerREST)
|
||||||
|
|
||||||
return ContainerStorage{
|
return ContainerStorage{
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
@ -31,7 +32,7 @@ import (
|
|||||||
|
|
||||||
func newStorage(t *testing.T) (*ScaleREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*ScaleREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
return NewStorage(etcdStorage).Scale, fakeClient
|
return NewStorage(etcdStorage, storage.NoDecoration).Scale, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
var validPodTemplate = api.PodTemplate{
|
var validPodTemplate = api.PodTemplate{
|
||||||
|
@ -33,12 +33,17 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
|
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
prefix := "/horizontalpodautoscalers"
|
prefix := "/horizontalpodautoscalers"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &extensions.HorizontalPodAutoscalerList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &extensions.HorizontalPodAutoscaler{}, prefix, false, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &extensions.HorizontalPodAutoscaler{} },
|
NewFunc: func() runtime.Object { return &extensions.HorizontalPodAutoscaler{} },
|
||||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||||
NewListFunc: func() runtime.Object { return &extensions.HorizontalPodAutoscalerList{} },
|
NewListFunc: newListFunc,
|
||||||
// Produces a path that etcd understands, to the root of the resource
|
// Produces a path that etcd understands, to the root of the resource
|
||||||
// by combining the namespace in the context with the given prefix
|
// by combining the namespace in the context with the given prefix
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
@ -65,7 +70,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
// Used to validate autoscaler updates
|
// Used to validate autoscaler updates
|
||||||
UpdateStrategy: horizontalpodautoscaler.Strategy,
|
UpdateStrategy: horizontalpodautoscaler.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
statusStore.UpdateStrategy = horizontalpodautoscaler.StatusStrategy
|
statusStore.UpdateStrategy = horizontalpodautoscaler.StatusStrategy
|
||||||
|
@ -27,13 +27,14 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
||||||
storage, statusStorage := NewREST(etcdStorage)
|
horizontalPodAutoscalerStorage, statusStorage := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return storage, statusStorage, fakeClient
|
return horizontalPodAutoscalerStorage, statusStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewHorizontalPodAutoscaler(name string) *extensions.HorizontalPodAutoscaler {
|
func validNewHorizontalPodAutoscaler(name string) *extensions.HorizontalPodAutoscaler {
|
||||||
|
@ -28,31 +28,33 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/storage"
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
IngressPath string = "/ingress"
|
|
||||||
)
|
|
||||||
|
|
||||||
// rest implements a RESTStorage for replication controllers against etcd
|
// rest implements a RESTStorage for replication controllers against etcd
|
||||||
type REST struct {
|
type REST struct {
|
||||||
*etcdgeneric.Etcd
|
*etcdgeneric.Etcd
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against replication controllers.
|
// NewREST returns a RESTStorage object that will work against replication controllers.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
|
prefix := "/ingress"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &extensions.IngressList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &extensions.Ingress{}, prefix, false, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &extensions.Ingress{} },
|
NewFunc: func() runtime.Object { return &extensions.Ingress{} },
|
||||||
|
|
||||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||||
NewListFunc: func() runtime.Object { return &extensions.IngressList{} },
|
NewListFunc: newListFunc,
|
||||||
// Produces a ingress that etcd understands, to the root of the resource
|
// Produces a ingress that etcd understands, to the root of the resource
|
||||||
// by combining the namespace in the context with the given prefix
|
// by combining the namespace in the context with the given prefix
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, IngressPath)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
// Produces a ingress that etcd understands, to the resource by combining
|
// Produces a ingress that etcd understands, to the resource by combining
|
||||||
// the namespace in the context with the given prefix
|
// the namespace in the context with the given prefix
|
||||||
KeyFunc: func(ctx api.Context, name string) (string, error) {
|
KeyFunc: func(ctx api.Context, name string) (string, error) {
|
||||||
return etcdgeneric.NamespaceKeyFunc(ctx, IngressPath, name)
|
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name)
|
||||||
},
|
},
|
||||||
// Retrieve the name field of a replication controller
|
// Retrieve the name field of a replication controller
|
||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
@ -70,7 +72,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
// Used to validate controller updates
|
// Used to validate controller updates
|
||||||
UpdateStrategy: ingress.Strategy,
|
UpdateStrategy: ingress.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
statusStore.UpdateStrategy = ingress.StatusStrategy
|
statusStore.UpdateStrategy = ingress.StatusStrategy
|
||||||
|
@ -25,13 +25,14 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
||||||
ingressStorage, statusStorage := NewREST(etcdStorage)
|
ingressStorage, statusStorage := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return ingressStorage, statusStorage, fakeClient
|
return ingressStorage, statusStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,26 +33,28 @@ type REST struct {
|
|||||||
*etcdgeneric.Etcd
|
*etcdgeneric.Etcd
|
||||||
}
|
}
|
||||||
|
|
||||||
// jobPrefix is the location for jobs in etcd, only exposed
|
|
||||||
// for testing
|
|
||||||
var jobPrefix = "/jobs"
|
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against Jobs.
|
// NewREST returns a RESTStorage object that will work against Jobs.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
|
prefix := "/jobs"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &extensions.JobList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &extensions.Job{}, prefix, false, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &extensions.Job{} },
|
NewFunc: func() runtime.Object { return &extensions.Job{} },
|
||||||
|
|
||||||
// NewListFunc returns an object capable of storing results of an etcd list.
|
// NewListFunc returns an object capable of storing results of an etcd list.
|
||||||
NewListFunc: func() runtime.Object { return &extensions.JobList{} },
|
NewListFunc: newListFunc,
|
||||||
// Produces a path that etcd understands, to the root of the resource
|
// Produces a path that etcd understands, to the root of the resource
|
||||||
// by combining the namespace in the context with the given prefix
|
// by combining the namespace in the context with the given prefix
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, jobPrefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
// Produces a path that etcd understands, to the resource by combining
|
// Produces a path that etcd understands, to the resource by combining
|
||||||
// the namespace in the context with the given prefix
|
// the namespace in the context with the given prefix
|
||||||
KeyFunc: func(ctx api.Context, name string) (string, error) {
|
KeyFunc: func(ctx api.Context, name string) (string, error) {
|
||||||
return etcdgeneric.NamespaceKeyFunc(ctx, jobPrefix, name)
|
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name)
|
||||||
},
|
},
|
||||||
// Retrieve the name field of a job
|
// Retrieve the name field of a job
|
||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
@ -70,7 +72,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
// Used to validate job updates
|
// Used to validate job updates
|
||||||
UpdateStrategy: job.Strategy,
|
UpdateStrategy: job.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
|
@ -27,13 +27,14 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
||||||
storage, statusStorage := NewREST(etcdStorage)
|
jobStorage, statusStorage := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return storage, statusStorage, fakeClient
|
return jobStorage, statusStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewJob() *extensions.Job {
|
func validNewJob() *extensions.Job {
|
||||||
|
@ -32,11 +32,16 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
|
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
|
||||||
func NewREST(s storage.Interface) *REST {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) *REST {
|
||||||
prefix := "/limitranges"
|
prefix := "/limitranges"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.LimitRangeList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.LimitRange{}, prefix, true, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.LimitRange{} },
|
NewFunc: func() runtime.Object { return &api.LimitRange{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.LimitRangeList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
@ -54,7 +59,7 @@ func NewREST(s storage.Interface) *REST {
|
|||||||
CreateStrategy: limitrange.Strategy,
|
CreateStrategy: limitrange.Strategy,
|
||||||
UpdateStrategy: limitrange.Strategy,
|
UpdateStrategy: limitrange.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
return &REST{store}
|
return &REST{store}
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,13 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
return NewREST(etcdStorage), fakeClient
|
return NewREST(etcdStorage, storage.NoDecoration), fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewLimitRange() *api.LimitRange {
|
func validNewLimitRange() *api.LimitRange {
|
||||||
|
@ -48,11 +48,16 @@ type FinalizeREST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against namespaces.
|
// NewREST returns a RESTStorage object that will work against namespaces.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST, *FinalizeREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST, *FinalizeREST) {
|
||||||
prefix := "/namespaces"
|
prefix := "/namespaces"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.NamespaceList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.Namespace{}, prefix, true, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.Namespace{} },
|
NewFunc: func() runtime.Object { return &api.Namespace{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.NamespaceList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return prefix
|
return prefix
|
||||||
},
|
},
|
||||||
@ -71,7 +76,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST, *FinalizeREST) {
|
|||||||
UpdateStrategy: namespace.Strategy,
|
UpdateStrategy: namespace.Strategy,
|
||||||
ReturnDeletedObject: true,
|
ReturnDeletedObject: true,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
|
@ -26,14 +26,15 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
storage, _, _ := NewREST(etcdStorage)
|
namespaceStorage, _, _ := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return storage, fakeClient
|
return namespaceStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewNamespace() *api.Namespace {
|
func validNewNamespace() *api.Namespace {
|
||||||
|
@ -32,11 +32,16 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against persistent volumes.
|
// NewREST returns a RESTStorage object that will work against persistent volumes.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
prefix := "/persistentvolumes"
|
prefix := "/persistentvolumes"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.PersistentVolumeList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.PersistentVolume{}, prefix, true, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
|
NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.PersistentVolumeList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return prefix
|
return prefix
|
||||||
},
|
},
|
||||||
@ -55,7 +60,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
UpdateStrategy: persistentvolume.Strategy,
|
UpdateStrategy: persistentvolume.Strategy,
|
||||||
ReturnDeletedObject: true,
|
ReturnDeletedObject: true,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
@ -33,8 +34,8 @@ import (
|
|||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
storage, statusStorage := NewREST(etcdStorage)
|
persistentVolumeStorage, statusStorage := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return storage, statusStorage, fakeClient
|
return persistentVolumeStorage, statusStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewPersistentVolume(name string) *api.PersistentVolume {
|
func validNewPersistentVolume(name string) *api.PersistentVolume {
|
||||||
|
@ -32,11 +32,16 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against persistent volume claims.
|
// NewREST returns a RESTStorage object that will work against persistent volume claims.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
prefix := "/persistentvolumeclaims"
|
prefix := "/persistentvolumeclaims"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.PersistentVolumeClaimList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.PersistentVolumeClaim{}, prefix, true, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
|
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.PersistentVolumeClaimList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
@ -55,7 +60,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
UpdateStrategy: persistentvolumeclaim.Strategy,
|
UpdateStrategy: persistentvolumeclaim.Strategy,
|
||||||
ReturnDeletedObject: true,
|
ReturnDeletedObject: true,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
@ -33,8 +34,8 @@ import (
|
|||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
storage, statusStorage := NewREST(etcdStorage)
|
persistentVolumeClaimStorage, statusStorage := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return storage, statusStorage, fakeClient
|
return persistentVolumeClaimStorage, statusStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewPersistentVolumeClaim(name, ns string) *api.PersistentVolumeClaim {
|
func validNewPersistentVolumeClaim(name, ns string) *api.PersistentVolumeClaim {
|
||||||
|
@ -32,11 +32,16 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against pod templates.
|
// NewREST returns a RESTStorage object that will work against pod templates.
|
||||||
func NewREST(s storage.Interface) *REST {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) *REST {
|
||||||
prefix := "/podtemplates"
|
prefix := "/podtemplates"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.PodTemplateList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.PodTemplate{}, prefix, false, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
|
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.PodTemplateList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
@ -55,7 +60,7 @@ func NewREST(s storage.Interface) *REST {
|
|||||||
UpdateStrategy: podtemplate.Strategy,
|
UpdateStrategy: podtemplate.Strategy,
|
||||||
ReturnDeletedObject: true,
|
ReturnDeletedObject: true,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
return &REST{store}
|
return &REST{store}
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,13 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
return NewREST(etcdStorage), fakeClient
|
return NewREST(etcdStorage, storage.NoDecoration), fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewPodTemplate(name string) *api.PodTemplate {
|
func validNewPodTemplate(name string) *api.PodTemplate {
|
||||||
|
@ -32,11 +32,16 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against resource quotas.
|
// NewREST returns a RESTStorage object that will work against resource quotas.
|
||||||
func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) (*REST, *StatusREST) {
|
||||||
prefix := "/resourcequotas"
|
prefix := "/resourcequotas"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.ResourceQuotaList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.ResourceQuota{}, prefix, true, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
|
NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ResourceQuotaList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
@ -55,7 +60,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
|
|||||||
UpdateStrategy: resourcequota.Strategy,
|
UpdateStrategy: resourcequota.Strategy,
|
||||||
ReturnDeletedObject: true,
|
ReturnDeletedObject: true,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
statusStore := *store
|
statusStore := *store
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
@ -34,8 +35,8 @@ import (
|
|||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
storage, statusStorage := NewREST(etcdStorage)
|
resourceQuotaStorage, statusStorage := NewREST(etcdStorage, storage.NoDecoration)
|
||||||
return storage, statusStorage, fakeClient
|
return resourceQuotaStorage, statusStorage, fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewResourceQuota() *api.ResourceQuota {
|
func validNewResourceQuota() *api.ResourceQuota {
|
||||||
|
@ -32,12 +32,16 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against secrets.
|
// NewREST returns a RESTStorage object that will work against secrets.
|
||||||
func NewREST(s storage.Interface) *REST {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) *REST {
|
||||||
prefix := "/secrets"
|
prefix := "/secrets"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.SecretList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.Secret{}, prefix, true, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.Secret{} },
|
NewFunc: func() runtime.Object { return &api.Secret{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.SecretList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
@ -55,7 +59,7 @@ func NewREST(s storage.Interface) *REST {
|
|||||||
CreateStrategy: secret.Strategy,
|
CreateStrategy: secret.Strategy,
|
||||||
UpdateStrategy: secret.Strategy,
|
UpdateStrategy: secret.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
return &REST{store}
|
return &REST{store}
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,13 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
return NewREST(etcdStorage), fakeClient
|
return NewREST(etcdStorage, storage.NoDecoration), fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewSecret(name string) *api.Secret {
|
func validNewSecret(name string) *api.Secret {
|
||||||
|
@ -32,11 +32,16 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against services.
|
// NewREST returns a RESTStorage object that will work against services.
|
||||||
func NewREST(s storage.Interface) *REST {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) *REST {
|
||||||
prefix := "/services/specs"
|
prefix := "/services/specs"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.ServiceList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.Service{}, prefix, false, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.Service{} },
|
NewFunc: func() runtime.Object { return &api.Service{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ServiceList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
@ -54,7 +59,7 @@ func NewREST(s storage.Interface) *REST {
|
|||||||
CreateStrategy: service.Strategy,
|
CreateStrategy: service.Strategy,
|
||||||
UpdateStrategy: service.Strategy,
|
UpdateStrategy: service.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
return &REST{store}
|
return &REST{store}
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,14 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
return NewREST(etcdStorage), fakeClient
|
return NewREST(etcdStorage, storage.NoDecoration), fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validService() *api.Service {
|
func validService() *api.Service {
|
||||||
|
@ -32,11 +32,16 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against service accounts.
|
// NewREST returns a RESTStorage object that will work against service accounts.
|
||||||
func NewREST(s storage.Interface) *REST {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) *REST {
|
||||||
prefix := "/serviceaccounts"
|
prefix := "/serviceaccounts"
|
||||||
|
|
||||||
|
newListFunc := func() runtime.Object { return &api.ServiceAccountList{} }
|
||||||
|
storageInterface := storageFactory(
|
||||||
|
s, 100, nil, &api.ServiceAccount{}, prefix, true, newListFunc)
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
|
NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} },
|
NewListFunc: newListFunc,
|
||||||
KeyRootFunc: func(ctx api.Context) string {
|
KeyRootFunc: func(ctx api.Context) string {
|
||||||
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
|
||||||
},
|
},
|
||||||
@ -55,7 +60,7 @@ func NewREST(s storage.Interface) *REST {
|
|||||||
UpdateStrategy: serviceaccount.Strategy,
|
UpdateStrategy: serviceaccount.Strategy,
|
||||||
ReturnDeletedObject: true,
|
ReturnDeletedObject: true,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
return &REST{store}
|
return &REST{store}
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,13 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "")
|
||||||
return NewREST(etcdStorage), fakeClient
|
return NewREST(etcdStorage, storage.NoDecoration), fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewServiceAccount(name string) *api.ServiceAccount {
|
func validNewServiceAccount(name string) *api.ServiceAccount {
|
||||||
|
@ -34,9 +34,12 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a registry which will store ThirdPartyResource in the given helper
|
// NewREST returns a registry which will store ThirdPartyResource in the given helper
|
||||||
func NewREST(s storage.Interface) *REST {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory) *REST {
|
||||||
prefix := "/thirdpartyresources"
|
prefix := "/thirdpartyresources"
|
||||||
|
|
||||||
|
// We explicitly do NOT do any decoration here yet.
|
||||||
|
storageInterface := s
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResource{} },
|
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResource{} },
|
||||||
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceList{} },
|
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceList{} },
|
||||||
@ -56,7 +59,7 @@ func NewREST(s storage.Interface) *REST {
|
|||||||
CreateStrategy: thirdpartyresource.Strategy,
|
CreateStrategy: thirdpartyresource.Strategy,
|
||||||
UpdateStrategy: thirdpartyresource.Strategy,
|
UpdateStrategy: thirdpartyresource.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &REST{store}
|
return &REST{store}
|
||||||
|
@ -27,12 +27,13 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
||||||
return NewREST(etcdStorage), fakeClient
|
return NewREST(etcdStorage, storage.NoDecoration), fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewThirdPartyResource(name string) *extensions.ThirdPartyResource {
|
func validNewThirdPartyResource(name string) *extensions.ThirdPartyResource {
|
||||||
|
@ -36,9 +36,12 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a registry which will store ThirdPartyResourceData in the given helper
|
// NewREST returns a registry which will store ThirdPartyResourceData in the given helper
|
||||||
func NewREST(s storage.Interface, group, kind string) *REST {
|
func NewREST(s storage.Interface, storageFactory storage.StorageFactory, group, kind string) *REST {
|
||||||
prefix := "/ThirdPartyResourceData/" + group + "/" + strings.ToLower(kind) + "s"
|
prefix := "/ThirdPartyResourceData/" + group + "/" + strings.ToLower(kind) + "s"
|
||||||
|
|
||||||
|
// We explicitly do NOT do any decoration here yet.
|
||||||
|
storageInterface := s
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResourceData{} },
|
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResourceData{} },
|
||||||
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceDataList{} },
|
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceDataList{} },
|
||||||
@ -58,7 +61,7 @@ func NewREST(s storage.Interface, group, kind string) *REST {
|
|||||||
CreateStrategy: thirdpartyresourcedata.Strategy,
|
CreateStrategy: thirdpartyresourcedata.Strategy,
|
||||||
UpdateStrategy: thirdpartyresourcedata.Strategy,
|
UpdateStrategy: thirdpartyresourcedata.Strategy,
|
||||||
|
|
||||||
Storage: s,
|
Storage: storageInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &REST{store}
|
return &REST{store}
|
||||||
|
@ -27,12 +27,13 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/storage"
|
||||||
"k8s.io/kubernetes/pkg/tools"
|
"k8s.io/kubernetes/pkg/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) {
|
||||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "extensions")
|
||||||
return NewREST(etcdStorage, "foo", "bar"), fakeClient
|
return NewREST(etcdStorage, storage.NoDecoration, "foo", "bar"), fakeClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewThirdPartyResourceData(name string) *extensions.ThirdPartyResourceData {
|
func validNewThirdPartyResourceData(name string) *extensions.ThirdPartyResourceData {
|
||||||
|
Loading…
Reference in New Issue
Block a user