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
e752a48a
Commit
e752a48a
authored
Feb 23, 2019
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly set GVK when sending objects to webhooks
parent
8d6f20ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
conversion.go
...server/pkg/admission/plugin/webhook/generic/conversion.go
+2
-0
conversion_test.go
...r/pkg/admission/plugin/webhook/generic/conversion_test.go
+8
-0
No files found.
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/generic/conversion.go
View file @
e752a48a
...
@@ -37,5 +37,7 @@ func ConvertToGVK(obj runtime.Object, gvk schema.GroupVersionKind, o admission.O
...
@@ -37,5 +37,7 @@ func ConvertToGVK(obj runtime.Object, gvk schema.GroupVersionKind, o admission.O
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
// Explicitly set the GVK
out
.
GetObjectKind
()
.
SetGroupVersionKind
(
gvk
)
return
out
,
nil
return
out
,
nil
}
}
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/generic/conversion_test.go
View file @
e752a48a
...
@@ -62,6 +62,10 @@ func TestConvertToGVK(t *testing.T) {
...
@@ -62,6 +62,10 @@ func TestConvertToGVK(t *testing.T) {
},
},
gvk
:
examplev1
.
SchemeGroupVersion
.
WithKind
(
"Pod"
),
gvk
:
examplev1
.
SchemeGroupVersion
.
WithKind
(
"Pod"
),
expectedObj
:
&
examplev1
.
Pod
{
expectedObj
:
&
examplev1
.
Pod
{
TypeMeta
:
metav1
.
TypeMeta
{
APIVersion
:
"example.apiserver.k8s.io/v1"
,
Kind
:
"Pod"
,
},
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod1"
,
Name
:
"pod1"
,
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
...
@@ -87,6 +91,10 @@ func TestConvertToGVK(t *testing.T) {
...
@@ -87,6 +91,10 @@ func TestConvertToGVK(t *testing.T) {
},
},
gvk
:
example2v1
.
SchemeGroupVersion
.
WithKind
(
"ReplicaSet"
),
gvk
:
example2v1
.
SchemeGroupVersion
.
WithKind
(
"ReplicaSet"
),
expectedObj
:
&
example2v1
.
ReplicaSet
{
expectedObj
:
&
example2v1
.
ReplicaSet
{
TypeMeta
:
metav1
.
TypeMeta
{
APIVersion
:
"example2.apiserver.k8s.io/v1"
,
Kind
:
"ReplicaSet"
,
},
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"rs1"
,
Name
:
"rs1"
,
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
...
...
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