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
5b11b598
Commit
5b11b598
authored
Aug 30, 2016
by
Timothy St. Clair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes to cleanup storage clients during UT.
During etcd3.clientv3 integration we had discovered we were leaking connections
parent
9f3841b4
Hide whitespace changes
Inline
Side-by-side
Showing
65 changed files
with
309 additions
and
74 deletions
+309
-74
etcd.go
pkg/registry/certificates/etcd/etcd.go
+3
-2
etcd.go
pkg/registry/clusterrole/etcd/etcd.go
+3
-2
etcd.go
pkg/registry/clusterrolebinding/etcd/etcd.go
+3
-2
etcd.go
pkg/registry/configmap/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/configmap/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/controller/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/controller/etcd/etcd_test.go
+9
-0
etcd.go
pkg/registry/daemonset/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/daemonset/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/deployment/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/deployment/etcd/etcd_test.go
+11
-3
etcd.go
pkg/registry/endpoint/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/endpoint/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/event/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/event/etcd/etcd_test.go
+3
-0
store.go
pkg/registry/generic/registry/store.go
+3
-0
store_test.go
pkg/registry/generic/registry/store_test.go
+5
-2
etcd.go
pkg/registry/horizontalpodautoscaler/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/horizontalpodautoscaler/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/ingress/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/ingress/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/job/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/job/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/limitrange/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/limitrange/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/namespace/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/namespace/etcd/etcd_test.go
+8
-0
etcd.go
pkg/registry/networkpolicy/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/networkpolicy/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/node/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/node/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/persistentvolume/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/persistentvolume/etcd/etcd_test.go
+7
-0
etcd.go
pkg/registry/persistentvolumeclaim/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/persistentvolumeclaim/etcd/etcd_test.go
+7
-0
etcd.go
pkg/registry/petset/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/petset/etcd/etcd_test.go
+6
-1
etcd.go
pkg/registry/pod/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/pod/etcd/etcd_test.go
+18
-0
etcd.go
pkg/registry/poddisruptionbudget/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/poddisruptionbudget/etcd/etcd_test.go
+6
-1
etcd.go
pkg/registry/podsecuritypolicy/etcd/etcd.go
+2
-1
etcd_test.go
pkg/registry/podsecuritypolicy/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/podtemplate/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/podtemplate/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/replicaset/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/replicaset/etcd/etcd_test.go
+10
-0
etcd.go
pkg/registry/resourcequota/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/resourcequota/etcd/etcd_test.go
+7
-0
etcd.go
pkg/registry/role/etcd/etcd.go
+3
-2
etcd.go
pkg/registry/rolebinding/etcd/etcd.go
+3
-2
etcd.go
pkg/registry/scheduledjob/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/scheduledjob/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/secret/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/secret/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/service/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/service/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/serviceaccount/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/serviceaccount/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/storageclass/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/storageclass/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/thirdpartyresource/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/thirdpartyresource/etcd/etcd_test.go
+6
-0
etcd.go
pkg/registry/thirdpartyresourcedata/etcd/etcd.go
+3
-2
etcd_test.go
pkg/registry/thirdpartyresourcedata/etcd/etcd_test.go
+6
-0
No files found.
pkg/registry/certificates/etcd/etcd.go
View file @
5b11b598
...
...
@@ -40,7 +40,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST, *ApprovalREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
certificates
.
CertificateSigningRequestList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
CertificateSigningRequests
),
&
certificates
.
CertificateSigningRequest
{},
...
...
@@ -72,7 +72,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST, *ApprovalREST) {
UpdateStrategy
:
csrregistry
.
Strategy
,
DeleteStrategy
:
csrregistry
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
// Subresources use the same store and creation strategy, which only
...
...
pkg/registry/clusterrole/etcd/etcd.go
View file @
5b11b598
...
...
@@ -37,7 +37,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
rbac
.
ClusterRoleList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
ClusterRoles
),
&
rbac
.
ClusterRole
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
clusterrole
.
Strategy
,
DeleteStrategy
:
clusterrole
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
...
...
pkg/registry/clusterrolebinding/etcd/etcd.go
View file @
5b11b598
...
...
@@ -37,7 +37,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
rbac
.
ClusterRoleBindingList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
ClusterRoleBindings
),
&
rbac
.
ClusterRoleBinding
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
clusterrolebinding
.
Strategy
,
DeleteStrategy
:
clusterrolebinding
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
...
...
pkg/registry/configmap/etcd/etcd.go
View file @
5b11b598
...
...
@@ -36,7 +36,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ConfigMapList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
ConfigMaps
),
&
api
.
ConfigMap
{},
...
...
@@ -81,7 +81,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
configmap
.
Strategy
,
DeleteStrategy
:
configmap
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/configmap/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -53,6 +53,7 @@ func validNewConfigMap() *api.ConfigMap {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
validConfigMap
:=
validNewConfigMap
()
...
...
@@ -80,6 +81,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -102,6 +104,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewConfigMap
())
}
...
...
@@ -109,6 +112,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewConfigMap
())
}
...
...
@@ -116,6 +120,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewConfigMap
())
}
...
...
@@ -123,6 +128,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewConfigMap
(),
...
...
pkg/registry/controller/etcd/etcd.go
View file @
5b11b598
...
...
@@ -62,7 +62,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ReplicationControllerList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Controllers
),
&
api
.
ReplicationController
{},
...
...
@@ -104,7 +104,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
controller
.
Strategy
,
DeleteStrategy
:
controller
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
controller
.
StatusStrategy
...
...
pkg/registry/controller/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -88,6 +88,7 @@ var validController = validNewController()
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Controller
.
Store
)
controller
:=
validNewController
()
controller
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -108,6 +109,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Controller
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -135,6 +137,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Controller
.
Store
)
test
.
TestDelete
(
validNewController
())
}
...
...
@@ -142,6 +145,7 @@ func TestDelete(t *testing.T) {
func
TestGenerationNumber
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
modifiedSno
:=
*
validNewController
()
modifiedSno
.
Generation
=
100
modifiedSno
.
Status
.
ObservedGeneration
=
10
...
...
@@ -192,6 +196,7 @@ func TestGenerationNumber(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Controller
.
Store
)
test
.
TestGet
(
validNewController
())
}
...
...
@@ -199,6 +204,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Controller
.
Store
)
test
.
TestList
(
validNewController
())
}
...
...
@@ -206,6 +212,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Controller
.
Store
)
test
.
TestWatch
(
validController
,
...
...
@@ -240,6 +247,7 @@ func TestWatch(t *testing.T) {
func
TestScaleGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
namespace
)
rc
,
err
:=
createController
(
storage
.
Controller
,
*
validController
,
t
)
...
...
@@ -276,6 +284,7 @@ func TestScaleGet(t *testing.T) {
func
TestScaleUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Controller
.
Store
.
DestroyFunc
()
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
namespace
)
rc
,
err
:=
createController
(
storage
.
Controller
,
*
validController
,
t
)
...
...
pkg/registry/daemonset/etcd/etcd.go
View file @
5b11b598
...
...
@@ -38,7 +38,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
extensions
.
DaemonSetList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Daemonsets
),
&
extensions
.
DaemonSet
{},
...
...
@@ -79,7 +79,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
daemonset
.
Strategy
,
DeleteStrategy
:
daemonset
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
daemonset
.
StatusStrategy
...
...
pkg/registry/daemonset/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -70,6 +70,7 @@ var validDaemonSet = newValidDaemonSet()
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
ds
:=
newValidDaemonSet
()
ds
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -96,6 +97,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -124,6 +126,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
newValidDaemonSet
())
}
...
...
@@ -131,6 +134,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
newValidDaemonSet
())
}
...
...
@@ -138,6 +142,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
newValidDaemonSet
())
}
...
...
@@ -145,6 +150,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validDaemonSet
,
...
...
pkg/registry/deployment/etcd/etcd.go
View file @
5b11b598
...
...
@@ -62,7 +62,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST, *RollbackREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
extensions
.
DeploymentList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Deployments
),
&
extensions
.
Deployment
{},
...
...
@@ -102,7 +102,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST, *RollbackREST) {
UpdateStrategy
:
deployment
.
Strategy
,
DeleteStrategy
:
deployment
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
deployment
.
StatusStrategy
...
...
pkg/registry/deployment/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -93,6 +93,7 @@ var validDeployment = *validNewDeployment()
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Deployment
.
Store
)
deployment
:=
validNewDeployment
()
deployment
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -112,6 +113,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Deployment
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -144,6 +146,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Deployment
.
Store
)
test
.
TestDelete
(
validNewDeployment
())
}
...
...
@@ -151,6 +154,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Deployment
.
Store
)
test
.
TestGet
(
validNewDeployment
())
}
...
...
@@ -158,6 +162,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Deployment
.
Store
)
test
.
TestList
(
validNewDeployment
())
}
...
...
@@ -165,6 +170,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Deployment
.
Store
)
test
.
TestWatch
(
validNewDeployment
(),
...
...
@@ -190,7 +196,7 @@ func TestWatch(t *testing.T) {
func
TestScaleGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
var
deployment
extensions
.
Deployment
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
namespace
)
key
:=
etcdtest
.
AddPrefix
(
"/deployments/"
+
namespace
+
"/"
+
name
)
...
...
@@ -227,7 +233,7 @@ func TestScaleGet(t *testing.T) {
func
TestScaleUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
var
deployment
extensions
.
Deployment
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
namespace
)
key
:=
etcdtest
.
AddPrefix
(
"/deployments/"
+
namespace
+
"/"
+
name
)
...
...
@@ -265,7 +271,7 @@ func TestScaleUpdate(t *testing.T) {
func
TestStatusUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
namespace
)
key
:=
etcdtest
.
AddPrefix
(
"/deployments/"
+
namespace
+
"/"
+
name
)
if
err
:=
storage
.
Deployment
.
Storage
.
Create
(
ctx
,
key
,
&
validDeployment
,
nil
,
0
);
err
!=
nil
{
...
...
@@ -348,6 +354,7 @@ func TestEtcdCreateDeploymentRollback(t *testing.T) {
t
.
Errorf
(
"%s: expected: %v, got: %v"
,
k
,
*
d
.
(
*
extensions
.
Deployment
)
.
Spec
.
RollbackTo
,
test
.
rollback
.
RollbackTo
)
}
}
storage
.
Deployment
.
Store
.
DestroyFunc
()
server
.
Terminate
(
t
)
}
}
...
...
@@ -357,6 +364,7 @@ func TestEtcdCreateDeploymentRollback(t *testing.T) {
func
TestEtcdCreateDeploymentRollbackNoDeployment
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Deployment
.
Store
.
DestroyFunc
()
rollbackStorage
:=
storage
.
Rollback
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
namespace
)
...
...
pkg/registry/endpoint/etcd/etcd.go
View file @
5b11b598
...
...
@@ -35,7 +35,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
EndpointsList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Endpoints
),
&
api
.
Endpoints
{},
...
...
@@ -65,7 +65,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
endpoint
.
Strategy
,
DeleteStrategy
:
endpoint
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/endpoint/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -60,6 +60,7 @@ func validChangedEndpoints() *api.Endpoints {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
endpoints
:=
validNewEndpoints
()
endpoints
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -76,6 +77,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
AllowCreateOnUpdate
()
test
.
TestUpdate
(
// valid
...
...
@@ -95,6 +97,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewEndpoints
())
}
...
...
@@ -102,6 +105,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewEndpoints
())
}
...
...
@@ -109,6 +113,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewEndpoints
())
}
...
...
@@ -116,6 +121,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewEndpoints
(),
...
...
pkg/registry/event/etcd/etcd.go
View file @
5b11b598
...
...
@@ -34,7 +34,7 @@ func NewREST(opts generic.RESTOptions, ttl uint64) *REST {
// We explicitly do NOT do any decoration here - switching on Cacher
// for events will lead to too high memory consumption.
storageInterface
,
_
:=
generic
.
NewRawStorage
(
opts
.
StorageConfig
)
storageInterface
,
dFunc
:=
generic
.
NewRawStorage
(
opts
.
StorageConfig
)
store
:=
&
registry
.
Store
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
Event
{}
},
...
...
@@ -59,7 +59,8 @@ func NewREST(opts generic.RESTOptions, ttl uint64) *REST {
UpdateStrategy
:
event
.
Strategy
,
DeleteStrategy
:
event
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/event/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -51,6 +51,7 @@ func validNewEvent(namespace string) *api.Event {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
event
:=
validNewEvent
(
test
.
TestNamespace
())
event
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -65,6 +66,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
AllowCreateOnUpdate
()
test
.
TestUpdate
(
// valid
...
...
@@ -87,6 +89,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewEvent
(
test
.
TestNamespace
()))
}
pkg/registry/generic/registry/store.go
View file @
5b11b598
...
...
@@ -90,6 +90,9 @@ type Store struct {
// Returns a matcher corresponding to the provided labels and fields.
PredicateFunc
func
(
label
labels
.
Selector
,
field
fields
.
Selector
)
*
generic
.
SelectionPredicate
// Called to cleanup storage clients.
DestroyFunc
func
()
// DeleteCollectionWorkers is the maximum number of workers in a single
// DeleteCollection call.
DeleteCollectionWorkers
int
...
...
pkg/registry/generic/registry/store_test.go
View file @
5b11b598
...
...
@@ -1200,11 +1200,14 @@ func newTestGenericStoreRegistry(t *testing.T, hasCacheEnabled bool) (factory.De
strategy
:=
&
testRESTStrategy
{
api
.
Scheme
,
api
.
SimpleNameGenerator
,
true
,
false
,
true
}
sc
.
Codec
=
testapi
.
Default
.
StorageCodec
()
destroyFunc
:=
func
()
{}
s
,
err
:=
factory
.
Create
(
*
sc
)
s
,
dFunc
,
err
:=
factory
.
Create
(
*
sc
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error creating storage: %v"
,
err
)
}
destroyFunc
:=
func
()
{
dFunc
()
server
.
Terminate
(
t
)
}
if
hasCacheEnabled
{
config
:=
storage
.
CacherConfig
{
CacheCapacity
:
10
,
...
...
pkg/registry/horizontalpodautoscaler/etcd/etcd.go
View file @
5b11b598
...
...
@@ -37,7 +37,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
autoscaling
.
HorizontalPodAutoscalerList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
HorizontalPodAutoscalers
),
&
autoscaling
.
HorizontalPodAutoscaler
{},
...
...
@@ -77,7 +77,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
horizontalpodautoscaler
.
Strategy
,
DeleteStrategy
:
horizontalpodautoscaler
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
horizontalpodautoscaler
.
StatusStrategy
...
...
pkg/registry/horizontalpodautoscaler/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -59,6 +59,7 @@ func validNewHorizontalPodAutoscaler(name string) *autoscaling.HorizontalPodAuto
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
autoscaler
:=
validNewHorizontalPodAutoscaler
(
"foo"
)
autoscaler
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -73,6 +74,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -89,6 +91,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewHorizontalPodAutoscaler
(
"foo"
))
}
...
...
@@ -96,6 +99,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewHorizontalPodAutoscaler
(
"foo"
))
}
...
...
@@ -103,6 +107,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewHorizontalPodAutoscaler
(
"foo"
))
}
...
...
@@ -110,6 +115,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewHorizontalPodAutoscaler
(
"foo"
),
...
...
pkg/registry/ingress/etcd/etcd.go
View file @
5b11b598
...
...
@@ -38,7 +38,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
extensions
.
IngressList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Ingress
),
&
extensions
.
Ingress
{},
...
...
@@ -79,7 +79,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
ingress
.
Strategy
,
DeleteStrategy
:
ingress
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
ingress
.
StatusStrategy
...
...
pkg/registry/ingress/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -115,6 +115,7 @@ func validIngress() *extensions.Ingress {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
ingress
:=
validIngress
()
noDefaultBackendAndRules
:=
validIngress
()
...
...
@@ -134,6 +135,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -169,6 +171,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validIngress
())
}
...
...
@@ -176,6 +179,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validIngress
())
}
...
...
@@ -183,6 +187,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validIngress
())
}
...
...
@@ -190,6 +195,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validIngress
(),
...
...
pkg/registry/job/etcd/etcd.go
View file @
5b11b598
...
...
@@ -38,7 +38,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
batch
.
JobList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Jobs
),
&
batch
.
Job
{},
...
...
@@ -79,7 +79,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
job
.
Strategy
,
DeleteStrategy
:
job
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
...
...
pkg/registry/job/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -76,6 +76,7 @@ func validNewJob() *batch.Job {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
validJob
:=
validNewJob
()
validJob
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -96,6 +97,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
two
:=
int32
(
2
)
test
.
TestUpdate
(
...
...
@@ -124,6 +126,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewJob
())
}
...
...
@@ -131,6 +134,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewJob
())
}
...
...
@@ -138,6 +142,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewJob
())
}
...
...
@@ -145,6 +150,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewJob
(),
...
...
pkg/registry/limitrange/etcd/etcd.go
View file @
5b11b598
...
...
@@ -35,7 +35,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
LimitRangeList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
LimitRanges
),
&
api
.
LimitRange
{},
...
...
@@ -66,7 +66,8 @@ func NewREST(opts generic.RESTOptions) *REST {
DeleteStrategy
:
limitrange
.
Strategy
,
ExportStrategy
:
limitrange
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/limitrange/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -62,6 +62,7 @@ func validNewLimitRange() *api.LimitRange {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
GeneratesName
()
validLimitRange
:=
validNewLimitRange
()
validLimitRange
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -78,6 +79,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
AllowCreateOnUpdate
()
test
.
TestUpdate
(
// valid
...
...
@@ -106,6 +108,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewLimitRange
())
}
...
...
@@ -113,6 +116,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewLimitRange
())
}
...
...
@@ -120,6 +124,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewLimitRange
())
}
...
...
@@ -127,6 +132,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewLimitRange
(),
...
...
pkg/registry/namespace/etcd/etcd.go
View file @
5b11b598
...
...
@@ -53,7 +53,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST, *FinalizeREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
NamespaceList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Namespaces
),
&
api
.
Namespace
{},
...
...
@@ -84,7 +84,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST, *FinalizeREST) {
DeleteStrategy
:
namespace
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
...
...
pkg/registry/namespace/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -47,6 +47,7 @@ func validNewNamespace() *api.Namespace {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
namespace
:=
validNewNamespace
()
namespace
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo"
}
...
...
@@ -63,6 +64,7 @@ func TestCreate(t *testing.T) {
func
TestCreateSetsFields
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
namespace
:=
validNewNamespace
()
ctx
:=
api
.
NewContext
()
_
,
err
:=
storage
.
Create
(
ctx
,
namespace
)
...
...
@@ -89,6 +91,7 @@ func TestCreateSetsFields(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewNamespace
())
}
...
...
@@ -96,6 +99,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestGet
(
validNewNamespace
())
}
...
...
@@ -103,6 +107,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestList
(
validNewNamespace
())
}
...
...
@@ -110,6 +115,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestWatch
(
validNewNamespace
(),
...
...
@@ -134,6 +140,7 @@ func TestWatch(t *testing.T) {
func
TestDeleteNamespaceWithIncompleteFinalizers
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
key
:=
etcdtest
.
AddPrefix
(
"namespaces/foo"
)
ctx
:=
api
.
NewContext
()
now
:=
unversioned
.
Now
()
...
...
@@ -158,6 +165,7 @@ func TestDeleteNamespaceWithIncompleteFinalizers(t *testing.T) {
func
TestDeleteNamespaceWithCompleteFinalizers
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
key
:=
etcdtest
.
AddPrefix
(
"namespaces/foo"
)
ctx
:=
api
.
NewContext
()
now
:=
unversioned
.
Now
()
...
...
pkg/registry/networkpolicy/etcd/etcd.go
View file @
5b11b598
...
...
@@ -37,7 +37,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
extensionsapi
.
NetworkPolicyList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
NetworkPolicys
),
&
extensionsapi
.
NetworkPolicy
{},
...
...
@@ -78,7 +78,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
networkpolicy
.
Strategy
,
DeleteStrategy
:
networkpolicy
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/networkpolicy/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -81,6 +81,7 @@ var validNetworkPolicy = *validNewNetworkPolicy()
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
np
:=
validNewNetworkPolicy
()
np
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -102,6 +103,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -128,6 +130,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewNetworkPolicy
())
}
...
...
@@ -135,6 +138,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewNetworkPolicy
())
}
...
...
@@ -142,6 +146,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewNetworkPolicy
())
}
...
...
@@ -149,6 +154,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewNetworkPolicy
(),
...
...
pkg/registry/node/etcd/etcd.go
View file @
5b11b598
...
...
@@ -69,7 +69,7 @@ func NewStorage(opts generic.RESTOptions, connection client.ConnectionInfoGetter
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
NodeList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Nodes
),
&
api
.
Node
{},
...
...
@@ -99,7 +99,8 @@ func NewStorage(opts generic.RESTOptions, connection client.ConnectionInfoGetter
DeleteStrategy
:
node
.
Strategy
,
ExportStrategy
:
node
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
...
...
pkg/registry/node/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -67,6 +67,7 @@ func validNewNode() *api.Node {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
node
:=
validNewNode
()
node
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo"
}
...
...
@@ -83,6 +84,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestUpdate
(
// valid
...
...
@@ -99,6 +101,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestDelete
(
validNewNode
())
}
...
...
@@ -106,6 +109,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestGet
(
validNewNode
())
}
...
...
@@ -113,6 +117,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestList
(
validNewNode
())
}
...
...
@@ -120,6 +125,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestWatch
(
validNewNode
(),
...
...
pkg/registry/persistentvolume/etcd/etcd.go
View file @
5b11b598
...
...
@@ -36,7 +36,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolumeList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
PersistentVolumes
),
&
api
.
PersistentVolume
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
DeleteStrategy
:
persistentvolume
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
...
...
pkg/registry/persistentvolume/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -71,6 +71,7 @@ func validChangedPersistentVolume() *api.PersistentVolume {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
pv
:=
validNewPersistentVolume
(
"foo"
)
pv
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo"
}
...
...
@@ -87,6 +88,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestUpdate
(
// valid
...
...
@@ -105,6 +107,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewPersistentVolume
(
"foo"
))
}
...
...
@@ -112,6 +115,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestGet
(
validNewPersistentVolume
(
"foo"
))
}
...
...
@@ -119,6 +123,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestList
(
validNewPersistentVolume
(
"foo"
))
}
...
...
@@ -126,6 +131,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestWatch
(
validNewPersistentVolume
(
"foo"
),
...
...
@@ -150,6 +156,7 @@ func TestWatch(t *testing.T) {
func
TestUpdateStatus
(
t
*
testing
.
T
)
{
storage
,
statusStorage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
key
=
etcdtest
.
AddPrefix
(
key
)
...
...
pkg/registry/persistentvolumeclaim/etcd/etcd.go
View file @
5b11b598
...
...
@@ -36,7 +36,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolumeClaimList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
PersistentVolumeClaims
),
&
api
.
PersistentVolumeClaim
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
DeleteStrategy
:
persistentvolumeclaim
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
...
...
pkg/registry/persistentvolumeclaim/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -63,6 +63,7 @@ func validNewPersistentVolumeClaim(name, ns string) *api.PersistentVolumeClaim {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
pv
:=
validNewPersistentVolumeClaim
(
"foo"
,
api
.
NamespaceDefault
)
pv
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -79,6 +80,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -95,6 +97,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewPersistentVolumeClaim
(
"foo"
,
api
.
NamespaceDefault
))
}
...
...
@@ -102,6 +105,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewPersistentVolumeClaim
(
"foo"
,
api
.
NamespaceDefault
))
}
...
...
@@ -109,6 +113,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewPersistentVolumeClaim
(
"foo"
,
api
.
NamespaceDefault
))
}
...
...
@@ -116,6 +121,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewPersistentVolumeClaim
(
"foo"
,
api
.
NamespaceDefault
),
...
...
@@ -140,6 +146,7 @@ func TestWatch(t *testing.T) {
func
TestUpdateStatus
(
t
*
testing
.
T
)
{
storage
,
statusStorage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
...
...
pkg/registry/petset/etcd/etcd.go
View file @
5b11b598
...
...
@@ -38,7 +38,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
appsapi
.
PetSetList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
PetSet
),
&
appsapi
.
PetSet
{},
...
...
@@ -79,7 +79,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
petset
.
Strategy
,
DeleteStrategy
:
petset
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
petset
.
StatusStrategy
...
...
pkg/registry/petset/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -83,6 +83,7 @@ func validNewPetSet() *apps.PetSet {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
ps
:=
validNewPetSet
()
ps
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -98,7 +99,7 @@ func TestCreate(t *testing.T) {
func
TestStatusUpdate
(
t
*
testing
.
T
)
{
storage
,
statusStorage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
api
.
NamespaceDefault
)
key
:=
etcdtest
.
AddPrefix
(
"/petsets/"
+
api
.
NamespaceDefault
+
"/foo"
)
validPetSet
:=
validNewPetSet
()
...
...
@@ -135,6 +136,7 @@ func TestStatusUpdate(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewPetSet
())
}
...
...
@@ -142,6 +144,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewPetSet
())
}
...
...
@@ -149,6 +152,7 @@ func TestList(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewPetSet
())
}
...
...
@@ -156,6 +160,7 @@ func TestDelete(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewPetSet
(),
...
...
pkg/registry/pod/etcd/etcd.go
View file @
5b11b598
...
...
@@ -63,7 +63,7 @@ func NewStorage(opts generic.RESTOptions, k client.ConnectionInfoGetter, proxyTr
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
PodList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Pods
),
&
api
.
Pod
{},
...
...
@@ -94,7 +94,8 @@ func NewStorage(opts generic.RESTOptions, k client.ConnectionInfoGetter, proxyTr
DeleteStrategy
:
pod
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
...
...
pkg/registry/pod/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -82,6 +82,7 @@ func validChangedPod() *api.Pod {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
pod
:=
validNewPod
()
pod
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -108,6 +109,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -124,6 +126,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewPod
())
...
...
@@ -156,6 +159,7 @@ func TestIgnoreDeleteNotFound(t *testing.T) {
called
:=
false
registry
,
server
:=
newFailDeleteStorage
(
t
,
&
called
)
defer
server
.
Terminate
(
t
)
defer
registry
.
Store
.
DestroyFunc
()
// should fail if pod A is not created yet.
_
,
err
:=
registry
.
Delete
(
testContext
,
pod
.
Name
,
nil
)
...
...
@@ -199,6 +203,7 @@ func TestIgnoreDeleteNotFound(t *testing.T) {
func
TestCreateSetsFields
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
pod
:=
validNewPod
()
_
,
err
:=
storage
.
Create
(
api
.
NewDefaultContext
(),
pod
)
if
err
!=
nil
{
...
...
@@ -341,6 +346,7 @@ func TestResourceLocation(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewPod
())
}
...
...
@@ -348,6 +354,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewPod
())
}
...
...
@@ -355,6 +362,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewPod
(),
...
...
@@ -378,6 +386,7 @@ func TestWatch(t *testing.T) {
func
TestEtcdCreate
(
t
*
testing
.
T
)
{
storage
,
bindingStorage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
key
=
etcdtest
.
AddPrefix
(
key
)
...
...
@@ -406,6 +415,7 @@ func TestEtcdCreate(t *testing.T) {
func
TestEtcdCreateBindingNoPod
(
t
*
testing
.
T
)
{
storage
,
bindingStorage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
...
...
@@ -437,6 +447,7 @@ func TestEtcdCreateBindingNoPod(t *testing.T) {
func
TestEtcdCreateFailsWithoutNamespace
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
pod
:=
validNewPod
()
pod
.
Namespace
=
""
_
,
err
:=
storage
.
Create
(
api
.
NewContext
(),
pod
)
...
...
@@ -449,6 +460,7 @@ func TestEtcdCreateFailsWithoutNamespace(t *testing.T) {
func
TestEtcdCreateWithContainersNotFound
(
t
*
testing
.
T
)
{
storage
,
bindingStorage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
key
=
etcdtest
.
AddPrefix
(
key
)
...
...
@@ -484,6 +496,7 @@ func TestEtcdCreateWithContainersNotFound(t *testing.T) {
func
TestEtcdCreateWithConflict
(
t
*
testing
.
T
)
{
storage
,
bindingStorage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
_
,
err
:=
storage
.
Create
(
ctx
,
validNewPod
())
...
...
@@ -514,6 +527,7 @@ func TestEtcdCreateWithConflict(t *testing.T) {
func
TestEtcdCreateWithExistingContainers
(
t
*
testing
.
T
)
{
storage
,
bindingStorage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
key
=
etcdtest
.
AddPrefix
(
key
)
...
...
@@ -592,6 +606,7 @@ func TestEtcdCreateBinding(t *testing.T) {
t
.
Errorf
(
"%s: expected: %v, got: %v"
,
k
,
pod
.
(
*
api
.
Pod
)
.
Spec
.
NodeName
,
test
.
binding
.
Target
.
Name
)
}
}
storage
.
Store
.
DestroyFunc
()
server
.
Terminate
(
t
)
}
}
...
...
@@ -599,6 +614,7 @@ func TestEtcdCreateBinding(t *testing.T) {
func
TestEtcdUpdateNotScheduled
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
...
...
@@ -626,6 +642,7 @@ func TestEtcdUpdateNotScheduled(t *testing.T) {
func
TestEtcdUpdateScheduled
(
t
*
testing
.
T
)
{
storage
,
_
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
...
...
@@ -695,6 +712,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
func
TestEtcdUpdateStatus
(
t
*
testing
.
T
)
{
storage
,
_
,
statusStorage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
...
...
pkg/registry/poddisruptionbudget/etcd/etcd.go
View file @
5b11b598
...
...
@@ -38,7 +38,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
policyapi
.
PodDisruptionBudgetList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
PodDisruptionBudget
),
&
policyapi
.
PodDisruptionBudget
{},
...
...
@@ -79,7 +79,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
poddisruptionbudget
.
Strategy
,
DeleteStrategy
:
poddisruptionbudget
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
poddisruptionbudget
.
StatusStrategy
...
...
pkg/registry/poddisruptionbudget/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -68,6 +68,7 @@ func validNewPodDisruptionBudget() *policy.PodDisruptionBudget {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
pdb
:=
validNewPodDisruptionBudget
()
pdb
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -83,7 +84,7 @@ func TestCreate(t *testing.T) {
func
TestStatusUpdate
(
t
*
testing
.
T
)
{
storage
,
statusStorage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
api
.
NamespaceDefault
)
key
:=
etcdtest
.
AddPrefix
(
"/poddisruptionbudgets/"
+
api
.
NamespaceDefault
+
"/foo"
)
validPodDisruptionBudget
:=
validNewPodDisruptionBudget
()
...
...
@@ -120,6 +121,7 @@ func TestStatusUpdate(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewPodDisruptionBudget
())
}
...
...
@@ -127,6 +129,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewPodDisruptionBudget
())
}
...
...
@@ -134,6 +137,7 @@ func TestList(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewPodDisruptionBudget
())
}
...
...
@@ -141,6 +145,7 @@ func TestDelete(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewPodDisruptionBudget
(),
...
...
pkg/registry/podsecuritypolicy/etcd/etcd.go
View file @
5b11b598
...
...
@@ -37,7 +37,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
extensions
.
PodSecurityPolicyList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
PodSecurityPolicies
),
&
extensions
.
PodSecurityPolicy
{},
...
...
@@ -68,6 +68,7 @@ func NewREST(opts generic.RESTOptions) *REST {
DeleteStrategy
:
podsecuritypolicy
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/podsecuritypolicy/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -62,6 +62,7 @@ func validNewPodSecurityPolicy() *extensions.PodSecurityPolicy {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
psp
:=
validNewPodSecurityPolicy
()
psp
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo-"
}
...
...
@@ -78,6 +79,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestUpdate
(
// valid
...
...
@@ -94,6 +96,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewPodSecurityPolicy
())
}
...
...
@@ -101,6 +104,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestGet
(
validNewPodSecurityPolicy
())
}
...
...
@@ -108,6 +112,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestList
(
validNewPodSecurityPolicy
())
}
...
...
@@ -115,6 +120,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestWatch
(
validNewPodSecurityPolicy
(),
...
...
pkg/registry/podtemplate/etcd/etcd.go
View file @
5b11b598
...
...
@@ -35,7 +35,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
PodTemplateList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
PodTemplates
),
&
api
.
PodTemplate
{},
...
...
@@ -68,7 +68,8 @@ func NewREST(opts generic.RESTOptions) *REST {
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/podtemplate/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -64,6 +64,7 @@ func validNewPodTemplate(name string) *api.PodTemplate {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
pod
:=
validNewPodTemplate
(
"foo"
)
pod
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -80,6 +81,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
//valid
...
...
@@ -96,6 +98,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewPodTemplate
(
"foo"
))
}
...
...
@@ -103,6 +106,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewPodTemplate
(
"foo"
))
}
...
...
@@ -110,6 +114,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewPodTemplate
(
"foo"
))
}
...
...
@@ -117,6 +122,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewPodTemplate
(
"foo"
),
...
...
pkg/registry/replicaset/etcd/etcd.go
View file @
5b11b598
...
...
@@ -61,7 +61,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
extensions
.
ReplicaSetList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Replicasets
),
&
extensions
.
ReplicaSet
{},
...
...
@@ -102,7 +102,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
replicaset
.
Strategy
,
DeleteStrategy
:
replicaset
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
replicaset
.
StatusStrategy
...
...
pkg/registry/replicaset/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -91,6 +91,7 @@ var validReplicaSet = *validNewReplicaSet()
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
ReplicaSet
.
Store
)
rs
:=
validNewReplicaSet
()
rs
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -111,6 +112,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
ReplicaSet
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -138,6 +140,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
ReplicaSet
.
Store
)
test
.
TestDelete
(
validNewReplicaSet
())
}
...
...
@@ -145,6 +148,7 @@ func TestDelete(t *testing.T) {
func
TestGenerationNumber
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
modifiedSno
:=
*
validNewReplicaSet
()
modifiedSno
.
Generation
=
100
modifiedSno
.
Status
.
ObservedGeneration
=
10
...
...
@@ -195,6 +199,7 @@ func TestGenerationNumber(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
ReplicaSet
.
Store
)
test
.
TestGet
(
validNewReplicaSet
())
}
...
...
@@ -202,6 +207,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
ReplicaSet
.
Store
)
test
.
TestList
(
validNewReplicaSet
())
}
...
...
@@ -209,6 +215,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
ReplicaSet
.
Store
)
test
.
TestWatch
(
validNewReplicaSet
(),
...
...
@@ -241,6 +248,7 @@ func TestWatch(t *testing.T) {
func
TestScaleGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
name
:=
"foo"
...
...
@@ -280,6 +288,7 @@ func TestScaleGet(t *testing.T) {
func
TestScaleUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
name
:=
"foo"
...
...
@@ -324,6 +333,7 @@ func TestScaleUpdate(t *testing.T) {
func
TestStatusUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
ReplicaSet
.
Store
.
DestroyFunc
()
ctx
:=
api
.
WithNamespace
(
api
.
NewContext
(),
api
.
NamespaceDefault
)
key
:=
etcdtest
.
AddPrefix
(
"/replicasets/"
+
api
.
NamespaceDefault
+
"/foo"
)
...
...
pkg/registry/resourcequota/etcd/etcd.go
View file @
5b11b598
...
...
@@ -36,7 +36,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ResourceQuotaList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
ResourceQuotas
),
&
api
.
ResourceQuota
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
DeleteStrategy
:
resourcequota
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
...
...
pkg/registry/resourcequota/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -60,6 +60,7 @@ func validNewResourceQuota() *api.ResourceQuota {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
resourcequota
:=
validNewResourceQuota
()
resourcequota
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -76,6 +77,7 @@ func TestCreate(t *testing.T) {
func
TestCreateSetsFields
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
resourcequota
:=
validNewResourceQuota
()
_
,
err
:=
storage
.
Create
(
api
.
NewDefaultContext
(),
resourcequota
)
...
...
@@ -99,6 +101,7 @@ func TestCreateSetsFields(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewResourceQuota
())
}
...
...
@@ -106,6 +109,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewResourceQuota
())
}
...
...
@@ -113,6 +117,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewResourceQuota
())
}
...
...
@@ -120,6 +125,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewResourceQuota
(),
...
...
@@ -143,6 +149,7 @@ func TestWatch(t *testing.T) {
func
TestUpdateStatus
(
t
*
testing
.
T
)
{
storage
,
status
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
ctx
:=
api
.
NewDefaultContext
()
key
,
_
:=
storage
.
KeyFunc
(
ctx
,
"foo"
)
...
...
pkg/registry/role/etcd/etcd.go
View file @
5b11b598
...
...
@@ -37,7 +37,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
rbac
.
RoleList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Roles
),
&
rbac
.
Role
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
role
.
Strategy
,
DeleteStrategy
:
role
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
...
...
pkg/registry/rolebinding/etcd/etcd.go
View file @
5b11b598
...
...
@@ -37,7 +37,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
rbac
.
RoleBindingList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
RoleBindings
),
&
rbac
.
RoleBinding
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
rolebinding
.
Strategy
,
DeleteStrategy
:
rolebinding
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
...
...
pkg/registry/scheduledjob/etcd/etcd.go
View file @
5b11b598
...
...
@@ -38,7 +38,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
batch
.
ScheduledJobList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
ScheduledJobs
),
&
batch
.
ScheduledJob
{},
...
...
@@ -79,7 +79,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
UpdateStrategy
:
scheduledjob
.
Strategy
,
DeleteStrategy
:
scheduledjob
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
...
...
pkg/registry/scheduledjob/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -70,6 +70,7 @@ func TestCreate(t *testing.T) {
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
validScheduledJob
:=
validNewScheduledJob
()
validScheduledJob
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -91,6 +92,7 @@ func TestUpdate(t *testing.T) {
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
schedule
:=
"1 1 1 1 ?"
test
.
TestUpdate
(
...
...
@@ -119,6 +121,7 @@ func TestDelete(t *testing.T) {
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewScheduledJob
())
}
...
...
@@ -131,6 +134,7 @@ func TestGet(t *testing.T) {
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewScheduledJob
())
}
...
...
@@ -143,6 +147,7 @@ func TestList(t *testing.T) {
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewScheduledJob
())
}
...
...
@@ -155,6 +160,7 @@ func TestWatch(t *testing.T) {
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewScheduledJob
(),
...
...
pkg/registry/secret/etcd/etcd.go
View file @
5b11b598
...
...
@@ -35,7 +35,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
SecretList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Secrets
),
&
api
.
Secret
{},
...
...
@@ -65,7 +65,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
secret
.
Strategy
,
DeleteStrategy
:
secret
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/secret/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -49,6 +49,7 @@ func validNewSecret(name string) *api.Secret {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
secret
:=
validNewSecret
(
"foo"
)
secret
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo-"
}
...
...
@@ -71,6 +72,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -87,6 +89,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewSecret
(
"foo"
))
}
...
...
@@ -94,6 +97,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewSecret
(
"foo"
))
}
...
...
@@ -101,6 +105,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewSecret
(
"foo"
))
}
...
...
@@ -108,6 +113,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewSecret
(
"foo"
),
...
...
pkg/registry/service/etcd/etcd.go
View file @
5b11b598
...
...
@@ -36,7 +36,7 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ServiceList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
Services
),
&
api
.
Service
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
DeleteStrategy
:
service
.
Strategy
,
ExportStrategy
:
service
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
statusStore
:=
*
store
statusStore
.
UpdateStrategy
=
service
.
StatusStrategy
...
...
pkg/registry/service/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -59,6 +59,7 @@ func validService() *api.Service {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
validService
:=
validService
()
validService
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -89,6 +90,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
AllowCreateOnUpdate
()
test
.
TestUpdate
(
// valid
...
...
@@ -114,6 +116,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
AllowCreateOnUpdate
()
test
.
TestDelete
(
validService
())
}
...
...
@@ -121,6 +124,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
AllowCreateOnUpdate
()
test
.
TestGet
(
validService
())
}
...
...
@@ -128,6 +132,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
AllowCreateOnUpdate
()
test
.
TestList
(
validService
())
}
...
...
@@ -135,6 +140,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
_
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validService
(),
...
...
pkg/registry/serviceaccount/etcd/etcd.go
View file @
5b11b598
...
...
@@ -35,7 +35,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
api
.
ServiceAccountList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
ServiceAccounts
),
&
api
.
ServiceAccount
{},
...
...
@@ -66,7 +66,8 @@ func NewREST(opts generic.RESTOptions) *REST {
DeleteStrategy
:
serviceaccount
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
}
pkg/registry/serviceaccount/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -47,6 +47,7 @@ func validNewServiceAccount(name string) *api.ServiceAccount {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
serviceAccount
:=
validNewServiceAccount
(
"foo"
)
serviceAccount
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo-"
}
...
...
@@ -64,6 +65,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -80,6 +82,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewServiceAccount
(
"foo"
))
}
...
...
@@ -87,6 +90,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewServiceAccount
(
"foo"
))
}
...
...
@@ -94,6 +98,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewServiceAccount
(
"foo"
))
}
...
...
@@ -101,6 +106,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewServiceAccount
(
"foo"
),
...
...
pkg/registry/storageclass/etcd/etcd.go
View file @
5b11b598
...
...
@@ -36,7 +36,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
newListFunc
:=
func
()
runtime
.
Object
{
return
&
storageapi
.
StorageClassList
{}
}
storageInterface
,
_
:=
opts
.
Decorator
(
storageInterface
,
dFunc
:=
opts
.
Decorator
(
opts
.
StorageConfig
,
cachesize
.
GetWatchCacheSizeByResource
(
cachesize
.
StorageClasses
),
&
storageapi
.
StorageClass
{},
...
...
@@ -67,7 +67,8 @@ func NewREST(opts generic.RESTOptions) *REST {
DeleteStrategy
:
storageclass
.
Strategy
,
ReturnDeletedObject
:
true
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
...
...
pkg/registry/storageclass/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -55,6 +55,7 @@ func validChangedStorageClass() *storageapi.StorageClass {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
storageClass
:=
validNewStorageClass
(
"foo"
)
storageClass
.
ObjectMeta
=
api
.
ObjectMeta
{
GenerateName
:
"foo"
}
...
...
@@ -71,6 +72,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestUpdate
(
// valid
...
...
@@ -94,6 +96,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
ReturnDeletedObject
()
test
.
TestDelete
(
validNewStorageClass
(
"foo"
))
}
...
...
@@ -101,6 +104,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestGet
(
validNewStorageClass
(
"foo"
))
}
...
...
@@ -108,6 +112,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestList
(
validNewStorageClass
(
"foo"
))
}
...
...
@@ -115,6 +120,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
test
.
TestWatch
(
validNewStorageClass
(
"foo"
),
...
...
pkg/registry/thirdpartyresource/etcd/etcd.go
View file @
5b11b598
...
...
@@ -35,7 +35,7 @@ func NewREST(opts generic.RESTOptions) *REST {
prefix
:=
"/"
+
opts
.
ResourcePrefix
// We explicitly do NOT do any decoration here yet.
storageInterface
,
_
:=
generic
.
NewRawStorage
(
opts
.
StorageConfig
)
storageInterface
,
dFunc
:=
generic
.
NewRawStorage
(
opts
.
StorageConfig
)
store
:=
&
registry
.
Store
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
ThirdPartyResource
{}
},
...
...
@@ -56,7 +56,8 @@ func NewREST(opts generic.RESTOptions) *REST {
UpdateStrategy
:
thirdpartyresource
.
Strategy
,
DeleteStrategy
:
thirdpartyresource
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
store
}
...
...
pkg/registry/thirdpartyresource/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -58,6 +58,7 @@ func namer(i int) string {
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
Namer
(
namer
)
.
GeneratesName
()
rsrc
:=
validNewThirdPartyResource
(
"kind.domain.tld"
)
test
.
TestCreate
(
...
...
@@ -75,6 +76,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
Namer
(
namer
)
test
.
TestUpdate
(
// valid
...
...
@@ -91,6 +93,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
Namer
(
namer
)
test
.
TestDelete
(
validNewThirdPartyResource
(
"kind.domain.tld"
))
}
...
...
@@ -98,6 +101,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
Namer
(
namer
)
test
.
TestGet
(
validNewThirdPartyResource
(
"kind.domain.tld"
))
}
...
...
@@ -105,6 +109,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
Namer
(
namer
)
test
.
TestList
(
validNewThirdPartyResource
(
"kind.domain.tld"
))
}
...
...
@@ -112,6 +117,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
.
ClusterScope
()
.
Namer
(
namer
)
test
.
TestWatch
(
validNewThirdPartyResource
(
"kind.domain.tld"
),
...
...
pkg/registry/thirdpartyresourcedata/etcd/etcd.go
View file @
5b11b598
...
...
@@ -38,7 +38,7 @@ func NewREST(opts generic.RESTOptions, group, kind string) *REST {
prefix
:=
"/ThirdPartyResourceData/"
+
group
+
"/"
+
strings
.
ToLower
(
kind
)
+
"s"
// We explicitly do NOT do any decoration here yet.
storageInterface
,
_
:=
generic
.
NewRawStorage
(
opts
.
StorageConfig
)
storageInterface
,
dFunc
:=
generic
.
NewRawStorage
(
opts
.
StorageConfig
)
store
:=
&
registry
.
Store
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
extensions
.
ThirdPartyResourceData
{}
},
...
...
@@ -59,7 +59,8 @@ func NewREST(opts generic.RESTOptions, group, kind string) *REST {
UpdateStrategy
:
thirdpartyresourcedata
.
Strategy
,
DeleteStrategy
:
thirdpartyresourcedata
.
Strategy
,
Storage
:
storageInterface
,
Storage
:
storageInterface
,
DestroyFunc
:
dFunc
,
}
return
&
REST
{
...
...
pkg/registry/thirdpartyresourcedata/etcd/etcd_test.go
View file @
5b11b598
...
...
@@ -50,6 +50,7 @@ func validNewThirdPartyResourceData(name string) *extensions.ThirdPartyResourceD
func
TestCreate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
rsrc
:=
validNewThirdPartyResourceData
(
"foo"
)
rsrc
.
ObjectMeta
=
api
.
ObjectMeta
{}
...
...
@@ -64,6 +65,7 @@ func TestCreate(t *testing.T) {
func
TestUpdate
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestUpdate
(
// valid
...
...
@@ -80,6 +82,7 @@ func TestUpdate(t *testing.T) {
func
TestDelete
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestDelete
(
validNewThirdPartyResourceData
(
"foo"
))
}
...
...
@@ -87,6 +90,7 @@ func TestDelete(t *testing.T) {
func
TestGet
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestGet
(
validNewThirdPartyResourceData
(
"foo"
))
}
...
...
@@ -94,6 +98,7 @@ func TestGet(t *testing.T) {
func
TestList
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestList
(
validNewThirdPartyResourceData
(
"foo"
))
}
...
...
@@ -101,6 +106,7 @@ func TestList(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
storage
,
server
:=
newStorage
(
t
)
defer
server
.
Terminate
(
t
)
defer
storage
.
Store
.
DestroyFunc
()
test
:=
registrytest
.
New
(
t
,
storage
.
Store
)
test
.
TestWatch
(
validNewThirdPartyResourceData
(
"foo"
),
...
...
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