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
59c305b5
Unverified
Commit
59c305b5
authored
Jan 14, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for submitting/receiving CRD objects as yaml
parent
aa504ccd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
40 deletions
+11
-40
customresource_handler.go
...ensions-apiserver/pkg/apiserver/customresource_handler.go
+9
-40
BUILD
...src/k8s.io/apiextensions-apiserver/test/integration/BUILD
+2
-0
yaml_test.go
....io/apiextensions-apiserver/test/integration/yaml_test.go
+0
-0
No files found.
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go
View file @
59c305b5
...
...
@@ -18,7 +18,6 @@ package apiserver
import
(
"fmt"
"io"
"net/http"
"path"
"sync"
...
...
@@ -475,27 +474,20 @@ func (s unstructuredNegotiatedSerializer) SupportedMediaTypes() []runtime.Serial
Framer
:
json
.
Framer
,
},
},
{
MediaType
:
"application/yaml"
,
EncodesAsText
:
true
,
Serializer
:
json
.
NewYAMLSerializer
(
json
.
DefaultMetaFactory
,
s
.
creator
,
s
.
typer
),
},
}
}
func
(
s
unstructuredNegotiatedSerializer
)
EncoderForVersion
(
serializ
er
runtime
.
Encoder
,
gv
runtime
.
GroupVersioner
)
runtime
.
Encoder
{
return
versioning
.
NewDefaultingCodecForScheme
(
Scheme
,
crEncoderInstance
,
nil
,
gv
,
nil
)
func
(
s
unstructuredNegotiatedSerializer
)
EncoderForVersion
(
encod
er
runtime
.
Encoder
,
gv
runtime
.
GroupVersioner
)
runtime
.
Encoder
{
return
versioning
.
NewDefaultingCodecForScheme
(
Scheme
,
encoder
,
nil
,
gv
,
nil
)
}
func
(
s
unstructuredNegotiatedSerializer
)
DecoderToVersion
(
serializer
runtime
.
Decoder
,
gv
runtime
.
GroupVersioner
)
runtime
.
Decoder
{
return
unstructuredDecoder
{
delegate
:
Codecs
.
DecoderToVersion
(
serializer
,
gv
)}
}
type
unstructuredDecoder
struct
{
delegate
runtime
.
Decoder
}
func
(
d
unstructuredDecoder
)
Decode
(
data
[]
byte
,
defaults
*
schema
.
GroupVersionKind
,
into
runtime
.
Object
)
(
runtime
.
Object
,
*
schema
.
GroupVersionKind
,
error
)
{
// Delegate for things other than Unstructured.
if
_
,
ok
:=
into
.
(
runtime
.
Unstructured
);
!
ok
&&
into
!=
nil
{
return
d
.
delegate
.
Decode
(
data
,
defaults
,
into
)
}
return
unstructured
.
UnstructuredJSONScheme
.
Decode
(
data
,
defaults
,
into
)
func
(
s
unstructuredNegotiatedSerializer
)
DecoderToVersion
(
decoder
runtime
.
Decoder
,
gv
runtime
.
GroupVersioner
)
runtime
.
Decoder
{
return
versioning
.
NewDefaultingCodecForScheme
(
Scheme
,
nil
,
decoder
,
nil
,
gv
)
}
type
unstructuredObjectTyper
struct
{
...
...
@@ -515,29 +507,6 @@ func (t unstructuredObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool {
return
t
.
delegate
.
Recognizes
(
gvk
)
||
t
.
unstructuredTyper
.
Recognizes
(
gvk
)
}
var
crEncoderInstance
=
crEncoder
{}
// crEncoder *usually* encodes using the unstructured.UnstructuredJSONScheme, but if the type is Status or WatchEvent
// it will serialize them out using the converting codec.
type
crEncoder
struct
{}
func
(
crEncoder
)
Encode
(
obj
runtime
.
Object
,
w
io
.
Writer
)
error
{
switch
t
:=
obj
.
(
type
)
{
case
*
metav1
.
Status
,
*
metav1
.
WatchEvent
:
for
_
,
info
:=
range
Codecs
.
SupportedMediaTypes
()
{
// we are always json
if
info
.
MediaType
==
"application/json"
{
return
info
.
Serializer
.
Encode
(
obj
,
w
)
}
}
return
fmt
.
Errorf
(
"unable to find json serializer for %T"
,
t
)
default
:
return
unstructured
.
UnstructuredJSONScheme
.
Encode
(
obj
,
w
)
}
}
type
unstructuredCreator
struct
{}
func
(
c
unstructuredCreator
)
New
(
kind
schema
.
GroupVersionKind
)
(
runtime
.
Object
,
error
)
{
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/BUILD
View file @
59c305b5
...
...
@@ -12,11 +12,13 @@ go_test(
"finalization_test.go",
"registration_test.go",
"validation_test.go",
"yaml_test.go",
],
importpath = "k8s.io/apiextensions-apiserver/test/integration",
tags = ["integration"],
deps = [
"//vendor/github.com/coreos/etcd/clientv3:go_default_library",
"//vendor/github.com/ghodss/yaml:go_default_library",
"//vendor/github.com/stretchr/testify/require:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/apiserver:go_default_library",
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/yaml_test.go
0 → 100644
View file @
59c305b5
This diff is collapsed.
Click to expand it.
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