Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2842d947
Commit
2842d947
authored
Nov 04, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16496 from wojtek-t/switch_cacher_for_other_resources
Auto commit by PR queue bot
parents
78c8c942
030a272d
Hide whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
226 additions
and
127 deletions
+226
-127
tokengetter.go
pkg/controller/serviceaccount/tokengetter.go
+3
-3
master.go
pkg/master/master.go
+28
-25
etcd.go
pkg/registry/controller/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/controller/etcd/etcd_test.go
+3
-2
etcd.go
pkg/registry/daemonset/etcd/etcd.go
+11
-8
etcd_test.go
pkg/registry/daemonset/etcd/etcd_test.go
+3
-2
etcd.go
pkg/registry/deployment/etcd/etcd.go
+10
-5
etcd_test.go
pkg/registry/deployment/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/event/etcd/etcd.go
+7
-2
etcd_test.go
pkg/registry/event/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/experimental/controller/etcd/etcd.go
+2
-2
etcd_test.go
pkg/registry/experimental/controller/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/horizontalpodautoscaler/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/horizontalpodautoscaler/etcd/etcd_test.go
+3
-2
etcd.go
pkg/registry/ingress/etcd/etcd.go
+11
-9
etcd_test.go
pkg/registry/ingress/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/job/etcd/etcd.go
+11
-9
etcd_test.go
pkg/registry/job/etcd/etcd_test.go
+3
-2
etcd.go
pkg/registry/limitrange/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/limitrange/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/namespace/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/namespace/etcd/etcd_test.go
+3
-2
etcd.go
pkg/registry/persistentvolume/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/persistentvolume/etcd/etcd_test.go
+3
-2
etcd.go
pkg/registry/persistentvolumeclaim/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/persistentvolumeclaim/etcd/etcd_test.go
+3
-2
etcd.go
pkg/registry/podtemplate/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/podtemplate/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/resourcequota/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/resourcequota/etcd/etcd_test.go
+3
-2
etcd.go
pkg/registry/secret/etcd/etcd.go
+7
-3
etcd_test.go
pkg/registry/secret/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/service/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/service/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/serviceaccount/etcd/etcd.go
+8
-3
etcd_test.go
pkg/registry/serviceaccount/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/thirdpartyresource/etcd/etcd.go
+5
-2
etcd_test.go
pkg/registry/thirdpartyresource/etcd/etcd_test.go
+2
-1
etcd.go
pkg/registry/thirdpartyresourcedata/etcd/etcd.go
+5
-2
etcd_test.go
pkg/registry/thirdpartyresourcedata/etcd/etcd_test.go
+2
-1
No files found.
pkg/controller/serviceaccount/tokengetter.go
View file @
2842d947
...
...
@@ -73,9 +73,9 @@ func (r *registryGetter) GetSecret(namespace, name string) (*api.Secret, error)
// NewGetterFromStorageInterface returns a ServiceAccountTokenGetter that
// uses the specified storage to retrieve service accounts and secrets.
func
NewGetterFromStorageInterface
(
s
torage
storage
.
Interface
)
ServiceAccountTokenGetter
{
func
NewGetterFromStorageInterface
(
s
storage
.
Interface
)
ServiceAccountTokenGetter
{
return
NewGetterFromRegistries
(
serviceaccount
.
NewRegistry
(
serviceaccountetcd
.
NewREST
(
s
torage
)),
secret
.
NewRegistry
(
secretetcd
.
NewREST
(
s
torage
)),
serviceaccount
.
NewRegistry
(
serviceaccountetcd
.
NewREST
(
s
,
storage
.
NoDecoration
)),
secret
.
NewRegistry
(
secretetcd
.
NewREST
(
s
,
storage
.
NoDecoration
)),
)
}
pkg/master/master.go
View file @
2842d947
...
...
@@ -268,6 +268,13 @@ type Config struct {
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
// Master contains state for a Kubernetes cluster master/api server.
...
...
@@ -535,27 +542,22 @@ func (m *Master) init(c *Config) {
healthzChecks
:=
[]
healthz
.
HealthzChecker
{}
var
storageFactory
storage
.
StorageFactory
if
c
.
EnableWatchCache
{
storageFactory
=
storage
.
NewCacher
}
else
{
storageFactory
=
storage
.
NoDecoration
}
storageFactory
:=
c
.
storageFactory
()
dbClient
:=
func
(
resource
string
)
storage
.
Interface
{
return
c
.
StorageDestinations
.
get
(
""
,
resource
)
}
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
()))
limitRangeStorage
:=
limitrangeetcd
.
NewREST
(
dbClient
(
"limitRanges"
))
eventStorage
:=
eventetcd
.
NewREST
(
dbClient
(
"events"
),
storageFactory
,
uint64
(
c
.
EventTTL
.
Seconds
()))
limitRangeStorage
:=
limitrangeetcd
.
NewREST
(
dbClient
(
"limitRanges"
)
,
storageFactory
)
resourceQuotaStorage
,
resourceQuotaStatusStorage
:=
resourcequotaetcd
.
NewREST
(
dbClient
(
"resourceQuotas"
))
secretStorage
:=
secretetcd
.
NewREST
(
dbClient
(
"secrets"
))
serviceAccountStorage
:=
serviceaccountetcd
.
NewREST
(
dbClient
(
"serviceAccounts"
))
persistentVolumeStorage
,
persistentVolumeStatusStorage
:=
pvetcd
.
NewREST
(
dbClient
(
"persistentVolumes"
))
persistentVolumeClaimStorage
,
persistentVolumeClaimStatusStorage
:=
pvcetcd
.
NewREST
(
dbClient
(
"persistentVolumeClaims"
))
resourceQuotaStorage
,
resourceQuotaStatusStorage
:=
resourcequotaetcd
.
NewREST
(
dbClient
(
"resourceQuotas"
)
,
storageFactory
)
secretStorage
:=
secretetcd
.
NewREST
(
dbClient
(
"secrets"
)
,
storageFactory
)
serviceAccountStorage
:=
serviceaccountetcd
.
NewREST
(
dbClient
(
"serviceAccounts"
)
,
storageFactory
)
persistentVolumeStorage
,
persistentVolumeStatusStorage
:=
pvetcd
.
NewREST
(
dbClient
(
"persistentVolumes"
)
,
storageFactory
)
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
)
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
)
m
.
nodeRegistry
=
node
.
NewRegistry
(
nodeStorage
)
serviceStorage
:=
serviceetcd
.
NewREST
(
dbClient
(
"services"
))
serviceStorage
:=
serviceetcd
.
NewREST
(
dbClient
(
"services"
)
,
storageFactory
)
m
.
serviceRegistry
=
service
.
NewRegistry
(
serviceStorage
)
var
serviceClusterIPRegistry
service
.
RangeRegistry
...
...
@@ -585,7 +587,7 @@ func (m *Master) init(c *Config) {
})
m
.
serviceNodePortAllocator
=
serviceNodePortRegistry
controllerStorage
,
controllerStatusStorage
:=
controlleretcd
.
NewREST
(
dbClient
(
"replicationControllers"
))
controllerStorage
,
controllerStatusStorage
:=
controlleretcd
.
NewREST
(
dbClient
(
"replicationControllers"
)
,
storageFactory
)
// TODO: Factor out the core API registration
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
{
resourceStorage
:=
thirdpartyresourcedataetcd
.
NewREST
(
m
.
thirdPartyStorage
,
group
,
kind
)
resourceStorage
:=
thirdpartyresourcedataetcd
.
NewREST
(
m
.
thirdPartyStorage
,
storage
.
NoDecoration
,
group
,
kind
)
apiRoot
:=
makeThirdPartyPath
(
""
)
...
...
@@ -1047,21 +1049,22 @@ func (m *Master) experimental(c *Config) *apiserver.APIGroupVersion {
}
return
enabled
}
storageFactory
:=
c
.
storageFactory
()
dbClient
:=
func
(
resource
string
)
storage
.
Interface
{
return
c
.
StorageDestinations
.
get
(
"extensions"
,
resource
)
}
storage
:=
map
[
string
]
rest
.
Storage
{}
if
isEnabled
(
"horizontalpodautoscalers"
)
{
autoscalerStorage
,
autoscalerStatusStorage
:=
horizontalpodautoscaleretcd
.
NewREST
(
dbClient
(
"horizontalpodautoscalers"
))
autoscalerStorage
,
autoscalerStatusStorage
:=
horizontalpodautoscaleretcd
.
NewREST
(
dbClient
(
"horizontalpodautoscalers"
)
,
storageFactory
)
storage
[
"horizontalpodautoscalers"
]
=
autoscalerStorage
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/scale"
]
=
controllerStorage
.
Scale
}
if
isEnabled
(
"thirdpartyresources"
)
{
thirdPartyResourceStorage
:=
thirdpartyresourceetcd
.
NewREST
(
dbClient
(
"thirdpartyresources"
))
thirdPartyResourceStorage
:=
thirdpartyresourceetcd
.
NewREST
(
dbClient
(
"thirdpartyresources"
)
,
storageFactory
)
thirdPartyControl
:=
ThirdPartyController
{
master
:
m
,
thirdPartyResourceRegistry
:
thirdPartyResourceStorage
,
...
...
@@ -1078,23 +1081,23 @@ func (m *Master) experimental(c *Config) *apiserver.APIGroupVersion {
}
if
isEnabled
(
"daemonsets"
)
{
daemonSetStorage
,
daemonSetStatusStorage
:=
daemonetcd
.
NewREST
(
dbClient
(
"daemonsets"
))
daemonSetStorage
,
daemonSetStatusStorage
:=
daemonetcd
.
NewREST
(
dbClient
(
"daemonsets"
)
,
storageFactory
)
storage
[
"daemonsets"
]
=
daemonSetStorage
storage
[
"daemonsets/status"
]
=
daemonSetStatusStorage
}
if
isEnabled
(
"deployments"
)
{
deploymentStorage
:=
deploymentetcd
.
NewStorage
(
dbClient
(
"deployments"
))
deploymentStorage
:=
deploymentetcd
.
NewStorage
(
dbClient
(
"deployments"
)
,
storageFactory
)
storage
[
"deployments"
]
=
deploymentStorage
.
Deployment
storage
[
"deployments/status"
]
=
deploymentStorage
.
Status
storage
[
"deployments/scale"
]
=
deploymentStorage
.
Scale
}
if
isEnabled
(
"jobs"
)
{
jobStorage
,
jobStatusStorage
:=
jobetcd
.
NewREST
(
dbClient
(
"jobs"
))
jobStorage
,
jobStatusStorage
:=
jobetcd
.
NewREST
(
dbClient
(
"jobs"
)
,
storageFactory
)
storage
[
"jobs"
]
=
jobStorage
storage
[
"jobs/status"
]
=
jobStatusStorage
}
if
isEnabled
(
"ingresses"
)
{
ingressStorage
,
ingressStatusStorage
:=
ingressetcd
.
NewREST
(
dbClient
(
"ingresses"
))
ingressStorage
,
ingressStatusStorage
:=
ingressetcd
.
NewREST
(
dbClient
(
"ingresses"
)
,
storageFactory
)
storage
[
"ingresses"
]
=
ingressStorage
storage
[
"ingresses/status"
]
=
ingressStatusStorage
}
...
...
pkg/registry/controller/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,13 +32,18 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ReplicationControllerList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
ReplicationController
{},
prefix
,
true
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ReplicationController
{}
},
// 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
// by combining the namespace in the context with the given prefix
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
...
...
@@ -65,7 +70,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
// Used to validate controller updates
UpdateStrategy
:
controller
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
controller
.
StatusStrategy
...
...
pkg/registry/controller/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -24,13 +24,14 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
storage
,
statusStorage
:=
NewREST
(
etcdStorage
)
return
s
torage
,
statusStorage
,
fakeClient
controllerStorage
,
statusStorage
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
controllerS
torage
,
statusStorage
,
fakeClient
}
// createController is a helper function that returns a controller with the updated resource version.
...
...
pkg/registry/daemonset/etcd/etcd.go
View file @
2842d947
...
...
@@ -33,25 +33,28 @@ type REST struct {
*
etcdgeneric
.
Etcd
}
// daemonPrefix is the location for daemons in etcd
var
daemonPrefix
=
"/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
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
DaemonSet
{}
},
// 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
// by combining the namespace in the context with the given prefix
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
daemonP
refix
)
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
p
refix
)
},
// Produces a path that etcd understands, to the resource by combining
// the namespace in the context with the given prefix
KeyFunc
:
func
(
ctx
api
.
Context
,
name
string
)
(
string
,
error
)
{
return
etcdgeneric
.
NamespaceKeyFunc
(
ctx
,
daemonP
refix
,
name
)
return
etcdgeneric
.
NamespaceKeyFunc
(
ctx
,
p
refix
,
name
)
},
// Retrieve the name field of a daemon set
ObjectNameFunc
:
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
...
...
@@ -69,7 +72,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
// Used to validate daemon set updates
UpdateStrategy
:
daemonset
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
daemonset
.
StatusStrategy
...
...
pkg/registry/daemonset/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -25,13 +25,14 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
"extensions"
)
storage
,
statusStorage
:=
NewREST
(
etcdStorage
)
return
s
torage
,
statusStorage
,
fakeClient
daemonSetStorage
,
statusStorage
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
daemonSetS
torage
,
statusStorage
,
fakeClient
}
func
newValidDaemonSet
()
*
extensions
.
DaemonSet
{
...
...
pkg/registry/deployment/etcd/etcd.go
View file @
2842d947
...
...
@@ -39,8 +39,8 @@ type DeploymentStorage struct {
Scale
*
ScaleREST
}
func
NewStorage
(
s
storage
.
Interface
)
DeploymentStorage
{
deploymentRest
,
deploymentStatusRest
:=
NewREST
(
s
)
func
NewStorage
(
s
storage
.
Interface
,
storageFactory
storage
.
StorageFactory
)
DeploymentStorage
{
deploymentRest
,
deploymentStatusRest
:=
NewREST
(
s
,
storageFactory
)
deploymentRegistry
:=
deployment
.
NewRegistry
(
deploymentRest
)
return
DeploymentStorage
{
...
...
@@ -55,12 +55,17 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
extensions
.
DeploymentList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
extensions
.
Deployment
{},
prefix
,
false
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
Deployment
{}
},
// 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
// by combining the namespace in the context with the given prefix.
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
...
...
@@ -87,7 +92,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
// Used to validate deployment updates.
UpdateStrategy
:
deployment
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
deployment
.
StatusStrategy
...
...
pkg/registry/deployment/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -33,7 +34,7 @@ import (
func
newStorage
(
t
*
testing
.
T
)
(
*
DeploymentStorage
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
"extensions"
)
deploymentStorage
:=
NewStorage
(
etcdStorage
)
deploymentStorage
:=
NewStorage
(
etcdStorage
,
storage
.
NoDecoration
)
return
&
deploymentStorage
,
fakeClient
}
...
...
pkg/registry/event/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,8 +32,13 @@ type REST struct {
}
// 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"
// 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
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
Event
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
EventList
{}
},
...
...
@@ -57,7 +62,7 @@ func NewREST(s storage.Interface, ttl uint64) *REST {
CreateStrategy
:
event
.
Strategy
,
UpdateStrategy
:
event
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
return
&
REST
{
store
}
}
pkg/registry/event/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
...
...
@@ -30,7 +31,7 @@ var testTTL uint64 = 60
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
fakeClient
.
HideExpires
=
true
return
NewREST
(
etcdStorage
,
testTTL
),
fakeClient
return
NewREST
(
etcdStorage
,
storage
.
NoDecoration
,
testTTL
),
fakeClient
}
func
validNewEvent
(
namespace
string
)
*
api
.
Event
{
...
...
pkg/registry/experimental/controller/etcd/etcd.go
View file @
2842d947
...
...
@@ -37,9 +37,9 @@ type ContainerStorage struct {
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
controllerREST
,
_
:=
etcd
.
NewREST
(
s
)
controllerREST
,
_
:=
etcd
.
NewREST
(
s
,
storageFactory
)
rcRegistry
:=
controller
.
NewRegistry
(
controllerREST
)
return
ContainerStorage
{
...
...
pkg/registry/experimental/controller/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -31,7 +32,7 @@ import (
func
newStorage
(
t
*
testing
.
T
)
(
*
ScaleREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
return
NewStorage
(
etcdStorage
)
.
Scale
,
fakeClient
return
NewStorage
(
etcdStorage
,
storage
.
NoDecoration
)
.
Scale
,
fakeClient
}
var
validPodTemplate
=
api
.
PodTemplate
{
...
...
pkg/registry/horizontalpodautoscaler/etcd/etcd.go
View file @
2842d947
...
...
@@ -33,12 +33,17 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
extensions
.
HorizontalPodAutoscalerList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
extensions
.
HorizontalPodAutoscaler
{},
prefix
,
false
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
HorizontalPodAutoscaler
{}
},
// 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
// by combining the namespace in the context with the given prefix
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
...
...
@@ -65,7 +70,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
// Used to validate autoscaler updates
UpdateStrategy
:
horizontalpodautoscaler
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
horizontalpodautoscaler
.
StatusStrategy
...
...
pkg/registry/horizontalpodautoscaler/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -27,13 +27,14 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
"extensions"
)
storage
,
statusStorage
:=
NewREST
(
etcdStorage
)
return
s
torage
,
statusStorage
,
fakeClient
horizontalPodAutoscalerStorage
,
statusStorage
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
horizontalPodAutoscalerS
torage
,
statusStorage
,
fakeClient
}
func
validNewHorizontalPodAutoscaler
(
name
string
)
*
extensions
.
HorizontalPodAutoscaler
{
...
...
pkg/registry/ingress/etcd/etcd.go
View file @
2842d947
...
...
@@ -28,31 +28,33 @@ import (
"k8s.io/kubernetes/pkg/storage"
)
const
(
IngressPath
string
=
"/ingress"
)
// rest implements a RESTStorage for replication controllers against etcd
type
REST
struct
{
*
etcdgeneric
.
Etcd
}
// 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
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
Ingress
{}
},
// 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
// by combining the namespace in the context with the given prefix
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
// the namespace in the context with the given prefix
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
ObjectNameFunc
:
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
...
...
@@ -70,7 +72,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
// Used to validate controller updates
UpdateStrategy
:
ingress
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
ingress
.
StatusStrategy
...
...
pkg/registry/ingress/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -25,13 +25,14 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/util"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
"extensions"
)
ingressStorage
,
statusStorage
:=
NewREST
(
etcdStorage
)
ingressStorage
,
statusStorage
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
ingressStorage
,
statusStorage
,
fakeClient
}
...
...
pkg/registry/job/etcd/etcd.go
View file @
2842d947
...
...
@@ -33,26 +33,28 @@ type REST struct {
*
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.
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
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
Job
{}
},
// 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
// by combining the namespace in the context with the given prefix
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
jobP
refix
)
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
p
refix
)
},
// Produces a path that etcd understands, to the resource by combining
// the namespace in the context with the given prefix
KeyFunc
:
func
(
ctx
api
.
Context
,
name
string
)
(
string
,
error
)
{
return
etcdgeneric
.
NamespaceKeyFunc
(
ctx
,
jobP
refix
,
name
)
return
etcdgeneric
.
NamespaceKeyFunc
(
ctx
,
p
refix
,
name
)
},
// Retrieve the name field of a job
ObjectNameFunc
:
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
...
...
@@ -70,7 +72,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
// Used to validate job updates
UpdateStrategy
:
job
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
...
...
pkg/registry/job/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -27,13 +27,14 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
"extensions"
)
storage
,
statusStorage
:=
NewREST
(
etcdStorage
)
return
s
torage
,
statusStorage
,
fakeClient
jobStorage
,
statusStorage
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
jobS
torage
,
statusStorage
,
fakeClient
}
func
validNewJob
()
*
extensions
.
Job
{
...
...
pkg/registry/limitrange/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,11 +32,16 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
LimitRangeList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
LimitRange
{},
prefix
,
true
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
LimitRange
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
LimitRangeList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
prefix
)
},
...
...
@@ -54,7 +59,7 @@ func NewREST(s storage.Interface) *REST {
CreateStrategy
:
limitrange
.
Strategy
,
UpdateStrategy
:
limitrange
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
return
&
REST
{
store
}
}
pkg/registry/limitrange/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -25,12 +25,13 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
return
NewREST
(
etcdStorage
),
fakeClient
return
NewREST
(
etcdStorage
,
storage
.
NoDecoration
),
fakeClient
}
func
validNewLimitRange
()
*
api
.
LimitRange
{
...
...
pkg/registry/namespace/etcd/etcd.go
View file @
2842d947
...
...
@@ -48,11 +48,16 @@ type FinalizeREST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
NamespaceList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
Namespace
{},
prefix
,
true
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
Namespace
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
NamespaceList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
prefix
},
...
...
@@ -71,7 +76,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST, *FinalizeREST) {
UpdateStrategy
:
namespace
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
...
...
pkg/registry/namespace/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -26,14 +26,15 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools/etcdtest"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
storage
,
_
,
_
:=
NewREST
(
etcdStorage
)
return
s
torage
,
fakeClient
namespaceStorage
,
_
,
_
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
namespaceS
torage
,
fakeClient
}
func
validNewNamespace
()
*
api
.
Namespace
{
...
...
pkg/registry/persistentvolume/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,11 +32,16 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolumeList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
PersistentVolume
{},
prefix
,
true
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolume
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolumeList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
prefix
},
...
...
@@ -55,7 +60,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
UpdateStrategy
:
persistentvolume
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
...
...
pkg/registry/persistentvolume/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -33,8 +34,8 @@ import (
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
storage
,
statusStorage
:=
NewREST
(
etcdStorage
)
return
s
torage
,
statusStorage
,
fakeClient
persistentVolumeStorage
,
statusStorage
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
persistentVolumeS
torage
,
statusStorage
,
fakeClient
}
func
validNewPersistentVolume
(
name
string
)
*
api
.
PersistentVolume
{
...
...
pkg/registry/persistentvolumeclaim/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,11 +32,16 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolumeClaimList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
PersistentVolumeClaim
{},
prefix
,
true
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolumeClaim
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolumeClaimList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
prefix
)
},
...
...
@@ -55,7 +60,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
UpdateStrategy
:
persistentvolumeclaim
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
...
...
pkg/registry/persistentvolumeclaim/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -33,8 +34,8 @@ import (
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
storage
,
statusStorage
:=
NewREST
(
etcdStorage
)
return
s
torage
,
statusStorage
,
fakeClient
persistentVolumeClaimStorage
,
statusStorage
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
persistentVolumeClaimS
torage
,
statusStorage
,
fakeClient
}
func
validNewPersistentVolumeClaim
(
name
,
ns
string
)
*
api
.
PersistentVolumeClaim
{
...
...
pkg/registry/podtemplate/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,11 +32,16 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
PodTemplateList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
PodTemplate
{},
prefix
,
false
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PodTemplate
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PodTemplateList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
prefix
)
},
...
...
@@ -55,7 +60,7 @@ func NewREST(s storage.Interface) *REST {
UpdateStrategy
:
podtemplate
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
return
&
REST
{
store
}
}
pkg/registry/podtemplate/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -24,12 +24,13 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
return
NewREST
(
etcdStorage
),
fakeClient
return
NewREST
(
etcdStorage
,
storage
.
NoDecoration
),
fakeClient
}
func
validNewPodTemplate
(
name
string
)
*
api
.
PodTemplate
{
...
...
pkg/registry/resourcequota/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,11 +32,16 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ResourceQuotaList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
ResourceQuota
{},
prefix
,
true
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ResourceQuota
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ResourceQuotaList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
prefix
)
},
...
...
@@ -55,7 +60,7 @@ func NewREST(s storage.Interface) (*REST, *StatusREST) {
UpdateStrategy
:
resourcequota
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
statusStore
:=
*
store
...
...
pkg/registry/resourcequota/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -27,6 +27,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/tools/etcdtest"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -34,8 +35,8 @@ import (
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
storage
,
statusStorage
:=
NewREST
(
etcdStorage
)
return
s
torage
,
statusStorage
,
fakeClient
resourceQuotaStorage
,
statusStorage
:=
NewREST
(
etcdStorage
,
storage
.
NoDecoration
)
return
resourceQuotaS
torage
,
statusStorage
,
fakeClient
}
func
validNewResourceQuota
()
*
api
.
ResourceQuota
{
...
...
pkg/registry/secret/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,12 +32,16 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
SecretList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
Secret
{},
prefix
,
true
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
Secret
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
SecretList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
prefix
)
},
...
...
@@ -55,7 +59,7 @@ func NewREST(s storage.Interface) *REST {
CreateStrategy
:
secret
.
Strategy
,
UpdateStrategy
:
secret
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
return
&
REST
{
store
}
}
pkg/registry/secret/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -24,12 +24,13 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
return
NewREST
(
etcdStorage
),
fakeClient
return
NewREST
(
etcdStorage
,
storage
.
NoDecoration
),
fakeClient
}
func
validNewSecret
(
name
string
)
*
api
.
Secret
{
...
...
pkg/registry/service/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,11 +32,16 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ServiceList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
Service
{},
prefix
,
false
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
Service
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ServiceList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
prefix
)
},
...
...
@@ -54,7 +59,7 @@ func NewREST(s storage.Interface) *REST {
CreateStrategy
:
service
.
Strategy
,
UpdateStrategy
:
service
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
return
&
REST
{
store
}
}
pkg/registry/service/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -24,13 +24,14 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/util"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
return
NewREST
(
etcdStorage
),
fakeClient
return
NewREST
(
etcdStorage
,
storage
.
NoDecoration
),
fakeClient
}
func
validService
()
*
api
.
Service
{
...
...
pkg/registry/serviceaccount/etcd/etcd.go
View file @
2842d947
...
...
@@ -32,11 +32,16 @@ type REST struct {
}
// 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"
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ServiceAccountList
{}
}
storageInterface
:=
storageFactory
(
s
,
100
,
nil
,
&
api
.
ServiceAccount
{},
prefix
,
true
,
newListFunc
)
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ServiceAccount
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ServiceAccountList
{}
}
,
NewListFunc
:
newListFunc
,
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
prefix
)
},
...
...
@@ -55,7 +60,7 @@ func NewREST(s storage.Interface) *REST {
UpdateStrategy
:
serviceaccount
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
return
&
REST
{
store
}
}
pkg/registry/serviceaccount/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -24,12 +24,13 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
""
)
return
NewREST
(
etcdStorage
),
fakeClient
return
NewREST
(
etcdStorage
,
storage
.
NoDecoration
),
fakeClient
}
func
validNewServiceAccount
(
name
string
)
*
api
.
ServiceAccount
{
...
...
pkg/registry/thirdpartyresource/etcd/etcd.go
View file @
2842d947
...
...
@@ -34,9 +34,12 @@ type REST struct {
}
// 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"
// We explicitly do NOT do any decoration here yet.
storageInterface
:=
s
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
ThirdPartyResource
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
ThirdPartyResourceList
{}
},
...
...
@@ -56,7 +59,7 @@ func NewREST(s storage.Interface) *REST {
CreateStrategy
:
thirdpartyresource
.
Strategy
,
UpdateStrategy
:
thirdpartyresource
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
return
&
REST
{
store
}
...
...
pkg/registry/thirdpartyresource/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -27,12 +27,13 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
etcdStorage
,
fakeClient
:=
registrytest
.
NewEtcdStorage
(
t
,
"extensions"
)
return
NewREST
(
etcdStorage
),
fakeClient
return
NewREST
(
etcdStorage
,
storage
.
NoDecoration
),
fakeClient
}
func
validNewThirdPartyResource
(
name
string
)
*
extensions
.
ThirdPartyResource
{
...
...
pkg/registry/thirdpartyresourcedata/etcd/etcd.go
View file @
2842d947
...
...
@@ -36,9 +36,12 @@ type REST struct {
}
// 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"
// We explicitly do NOT do any decoration here yet.
storageInterface
:=
s
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
ThirdPartyResourceData
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
ThirdPartyResourceDataList
{}
},
...
...
@@ -58,7 +61,7 @@ func NewREST(s storage.Interface, group, kind string) *REST {
CreateStrategy
:
thirdpartyresourcedata
.
Strategy
,
UpdateStrategy
:
thirdpartyresourcedata
.
Strategy
,
Storage
:
s
,
Storage
:
s
torageInterface
,
}
return
&
REST
{
store
}
...
...
pkg/registry/thirdpartyresourcedata/etcd/etcd_test.go
View file @
2842d947
...
...
@@ -27,12 +27,13 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
"k8s.io/kubernetes/pkg/tools"
)
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
)
{
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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment