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
1002f805
Unverified
Commit
1002f805
authored
May 02, 2018
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decorator for Create should be called on out, not obj
obj is not what we return
parent
7d57060d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
store.go
...c/k8s.io/apiserver/pkg/registry/generic/registry/store.go
+1
-1
store_test.go
....io/apiserver/pkg/registry/generic/registry/store_test.go
+10
-0
No files found.
staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go
View file @
1002f805
...
@@ -373,7 +373,7 @@ func (e *Store) Create(ctx context.Context, obj runtime.Object, createValidation
...
@@ -373,7 +373,7 @@ func (e *Store) Create(ctx context.Context, obj runtime.Object, createValidation
}
}
}
}
if
e
.
Decorator
!=
nil
{
if
e
.
Decorator
!=
nil
{
if
err
:=
e
.
Decorator
(
o
bj
);
err
!=
nil
{
if
err
:=
e
.
Decorator
(
o
ut
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
}
...
...
staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go
View file @
1002f805
...
@@ -311,6 +311,11 @@ func TestStoreCreate(t *testing.T) {
...
@@ -311,6 +311,11 @@ func TestStoreCreate(t *testing.T) {
// re-define delete strategy to have graceful delete capability
// re-define delete strategy to have graceful delete capability
defaultDeleteStrategy
:=
testRESTStrategy
{
scheme
,
names
.
SimpleNameGenerator
,
true
,
false
,
true
}
defaultDeleteStrategy
:=
testRESTStrategy
{
scheme
,
names
.
SimpleNameGenerator
,
true
,
false
,
true
}
registry
.
DeleteStrategy
=
testGracefulStrategy
{
defaultDeleteStrategy
}
registry
.
DeleteStrategy
=
testGracefulStrategy
{
defaultDeleteStrategy
}
registry
.
Decorator
=
func
(
obj
runtime
.
Object
)
error
{
pod
:=
obj
.
(
*
example
.
Pod
)
pod
.
Status
.
Phase
=
example
.
PodPhase
(
"Testing"
)
return
nil
}
// create the object with denying admission
// create the object with denying admission
objA
,
err
:=
registry
.
Create
(
testContext
,
podA
,
denyCreateValidation
,
false
)
objA
,
err
:=
registry
.
Create
(
testContext
,
podA
,
denyCreateValidation
,
false
)
...
@@ -324,6 +329,11 @@ func TestStoreCreate(t *testing.T) {
...
@@ -324,6 +329,11 @@ func TestStoreCreate(t *testing.T) {
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
}
}
// verify the decorator was called
if
objA
.
(
*
example
.
Pod
)
.
Status
.
Phase
!=
example
.
PodPhase
(
"Testing"
)
{
t
.
Errorf
(
"Decorator was not called: %#v"
,
objA
)
}
// get the object
// get the object
checkobj
,
err
:=
registry
.
Get
(
testContext
,
podA
.
Name
,
&
metav1
.
GetOptions
{})
checkobj
,
err
:=
registry
.
Get
(
testContext
,
podA
.
Name
,
&
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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