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
0e9b06df
Commit
0e9b06df
authored
Oct 22, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow specifying the hub group-version for a handler
parent
870d121d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
6 deletions
+22
-6
customresource_handler.go
...ensions-apiserver/pkg/apiserver/customresource_handler.go
+3
-0
create.go
...ing/src/k8s.io/apiserver/pkg/endpoints/handlers/create.go
+1
-1
patch.go
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go
+8
-4
rest.go
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest.go
+3
-0
rest_test.go
.../src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go
+3
-0
update.go
...ing/src/k8s.io/apiserver/pkg/endpoints/handlers/update.go
+2
-1
installer.go
staging/src/k8s.io/apiserver/pkg/endpoints/installer.go
+2
-0
No files found.
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go
View file @
0e9b06df
...
...
@@ -525,6 +525,9 @@ func (r *crdHandler) getOrCreateServingInfoFor(crd *apiextensions.CustomResource
Resource
:
schema
.
GroupVersionResource
{
Group
:
crd
.
Spec
.
Group
,
Version
:
v
.
Name
,
Resource
:
crd
.
Status
.
AcceptedNames
.
Plural
},
Kind
:
kind
,
// a handler for a specific group-version of a custom resource uses that version as the in-memory representation
HubGroupVersion
:
kind
.
GroupVersion
(),
MetaGroupVersion
:
metav1
.
SchemeGroupVersion
,
TableConvertor
:
storages
[
v
.
Name
]
.
CustomResource
,
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/create.go
View file @
0e9b06df
...
...
@@ -77,7 +77,7 @@ func createHandler(r rest.NamedCreater, scope RequestScope, admit admission.Inte
scope
.
err
(
err
,
w
,
req
)
return
}
decoder
:=
scope
.
Serializer
.
DecoderToVersion
(
s
.
Serializer
,
sc
hema
.
GroupVersion
{
Group
:
gv
.
Group
,
Version
:
runtime
.
APIVersionInternal
}
)
decoder
:=
scope
.
Serializer
.
DecoderToVersion
(
s
.
Serializer
,
sc
ope
.
HubGroupVersion
)
body
,
err
:=
readBody
(
req
)
if
err
!=
nil
{
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go
View file @
0e9b06df
...
...
@@ -118,9 +118,10 @@ func PatchResource(r rest.Patcher, scope RequestScope, admit admission.Interface
return
}
gv
:=
scope
.
Kind
.
GroupVersion
()
codec
:=
runtime
.
NewCodec
(
scope
.
Serializer
.
EncoderForVersion
(
s
.
Serializer
,
gv
),
scope
.
Serializer
.
DecoderToVersion
(
s
.
Serializer
,
sc
hema
.
GroupVersion
{
Group
:
gv
.
Group
,
Version
:
runtime
.
APIVersionInternal
}
),
scope
.
Serializer
.
DecoderToVersion
(
s
.
Serializer
,
sc
ope
.
HubGroupVersion
),
)
userInfo
,
_
:=
request
.
UserFrom
(
ctx
)
...
...
@@ -163,6 +164,8 @@ func PatchResource(r rest.Patcher, scope RequestScope, admit admission.Interface
kind
:
scope
.
Kind
,
resource
:
scope
.
Resource
,
hubGroupVersion
:
scope
.
HubGroupVersion
,
createValidation
:
rest
.
AdmissionToValidateObjectFunc
(
admit
,
staticAdmissionAttributes
),
updateValidation
:
rest
.
AdmissionToValidateObjectUpdateFunc
(
admit
,
staticAdmissionAttributes
),
admissionCheck
:
admissionCheck
,
...
...
@@ -218,6 +221,8 @@ type patcher struct {
resource
schema
.
GroupVersionResource
kind
schema
.
GroupVersionKind
hubGroupVersion
schema
.
GroupVersion
// Validation functions
createValidation
rest
.
ValidateObjectFunc
updateValidation
rest
.
ValidateObjectUpdateFunc
...
...
@@ -315,9 +320,8 @@ func (p *smpPatcher) applyPatchToCurrentObject(currentObject runtime.Object) (ru
if
err
:=
strategicPatchObject
(
p
.
defaulter
,
currentVersionedObject
,
p
.
patchJS
,
versionedObjToUpdate
,
p
.
schemaReferenceObj
);
err
!=
nil
{
return
nil
,
err
}
// Convert the object back to unversioned (aka internal version).
gvk
:=
p
.
kind
.
GroupKind
()
.
WithVersion
(
runtime
.
APIVersionInternal
)
return
p
.
unsafeConvertor
.
ConvertToVersion
(
versionedObjToUpdate
,
gvk
.
GroupVersion
())
// Convert the object back to the hub version
return
p
.
unsafeConvertor
.
ConvertToVersion
(
versionedObjToUpdate
,
p
.
hubGroupVersion
)
}
// strategicPatchObject applies a strategic merge patch of <patchJS> to
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest.go
View file @
0e9b06df
...
...
@@ -65,6 +65,9 @@ type RequestScope struct {
Subresource
string
MetaGroupVersion
schema
.
GroupVersion
// HubGroupVersion indicates what version objects read from etcd or incoming requests should be converted to for in-memory handling.
HubGroupVersion
schema
.
GroupVersion
}
func
(
scope
*
RequestScope
)
err
(
err
error
,
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go
View file @
0e9b06df
...
...
@@ -367,6 +367,7 @@ func (tc *patchTestCase) Run(t *testing.T) {
kind
:=
examplev1
.
SchemeGroupVersion
.
WithKind
(
"Pod"
)
resource
:=
examplev1
.
SchemeGroupVersion
.
WithResource
(
"pods"
)
schemaReferenceObj
:=
&
examplev1
.
Pod
{}
hubVersion
:=
example
.
SchemeGroupVersion
for
_
,
patchType
:=
range
[]
types
.
PatchType
{
types
.
JSONPatchType
,
types
.
MergePatchType
,
types
.
StrategicMergePatchType
}
{
// This needs to be reset on each iteration.
...
...
@@ -439,6 +440,8 @@ func (tc *patchTestCase) Run(t *testing.T) {
kind
:
kind
,
resource
:
resource
,
hubGroupVersion
:
hubVersion
,
createValidation
:
rest
.
ValidateAllObjectFunc
,
updateValidation
:
admissionValidation
,
admissionCheck
:
admissionMutation
,
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/update.go
View file @
0e9b06df
...
...
@@ -89,8 +89,9 @@ func UpdateResource(r rest.Updater, scope RequestScope, admit admission.Interfac
}
defaultGVK
:=
scope
.
Kind
original
:=
r
.
New
()
trace
.
Step
(
"About to convert to expected version"
)
decoder
:=
scope
.
Serializer
.
DecoderToVersion
(
s
.
Serializer
,
sc
hema
.
GroupVersion
{
Group
:
defaultGVK
.
Group
,
Version
:
runtime
.
APIVersionInternal
}
)
decoder
:=
scope
.
Serializer
.
DecoderToVersion
(
s
.
Serializer
,
sc
ope
.
HubGroupVersion
)
obj
,
gvk
,
err
:=
decoder
.
Decode
(
body
,
&
defaultGVK
,
original
)
if
err
!=
nil
{
err
=
transformDecodeError
(
scope
.
Typer
,
err
,
original
,
gvk
,
body
)
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/installer.go
View file @
0e9b06df
...
...
@@ -506,6 +506,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
Subresource
:
subresource
,
Kind
:
fqKindToRegister
,
HubGroupVersion
:
schema
.
GroupVersion
{
Group
:
fqKindToRegister
.
Group
,
Version
:
runtime
.
APIVersionInternal
},
MetaGroupVersion
:
metav1
.
SchemeGroupVersion
,
}
if
a
.
group
.
MetaGroupVersion
!=
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