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
f0c23d68
Commit
f0c23d68
authored
Nov 02, 2014
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add runtime.ObjectConvertor to RESTMapper
parent
dc862ae4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
3 deletions
+15
-3
latest.go
pkg/api/latest/latest.go
+2
-0
interfaces.go
pkg/api/meta/interfaces.go
+2
-0
restmapper.go
pkg/api/meta/restmapper.go
+2
-1
restmapper_test.go
pkg/api/meta/restmapper_test.go
+9
-2
No files found.
pkg/api/latest/latest.go
View file @
f0c23d68
...
@@ -71,11 +71,13 @@ func InterfacesFor(version string) (*meta.VersionInterfaces, error) {
...
@@ -71,11 +71,13 @@ func InterfacesFor(version string) (*meta.VersionInterfaces, error) {
case
"v1beta1"
:
case
"v1beta1"
:
return
&
meta
.
VersionInterfaces
{
return
&
meta
.
VersionInterfaces
{
Codec
:
v1beta1
.
Codec
,
Codec
:
v1beta1
.
Codec
,
ObjectConvertor
:
api
.
Scheme
,
MetadataAccessor
:
accessor
,
MetadataAccessor
:
accessor
,
},
nil
},
nil
case
"v1beta2"
:
case
"v1beta2"
:
return
&
meta
.
VersionInterfaces
{
return
&
meta
.
VersionInterfaces
{
Codec
:
v1beta2
.
Codec
,
Codec
:
v1beta2
.
Codec
,
ObjectConvertor
:
api
.
Scheme
,
MetadataAccessor
:
accessor
,
MetadataAccessor
:
accessor
,
},
nil
},
nil
default
:
default
:
...
...
pkg/api/meta/interfaces.go
View file @
f0c23d68
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
// VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.
// VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.
type
VersionInterfaces
struct
{
type
VersionInterfaces
struct
{
runtime
.
Codec
runtime
.
Codec
runtime
.
ObjectConvertor
MetadataAccessor
MetadataAccessor
}
}
...
@@ -86,6 +87,7 @@ type RESTMapping struct {
...
@@ -86,6 +87,7 @@ type RESTMapping struct {
Kind
string
Kind
string
runtime
.
Codec
runtime
.
Codec
runtime
.
ObjectConvertor
MetadataAccessor
MetadataAccessor
}
}
...
...
pkg/api/meta/restmapper.go
View file @
f0c23d68
...
@@ -49,7 +49,7 @@ type DefaultRESTMapper struct {
...
@@ -49,7 +49,7 @@ type DefaultRESTMapper struct {
interfacesFunc
VersionInterfacesFunc
interfacesFunc
VersionInterfacesFunc
}
}
// VersionInterfacesFunc returns the appropriate codec and metadata accessor for a
// VersionInterfacesFunc returns the appropriate codec
, typer,
and metadata accessor for a
// given api version, or false if no such api version exists.
// given api version, or false if no such api version exists.
type
VersionInterfacesFunc
func
(
apiVersion
string
)
(
*
VersionInterfaces
,
bool
)
type
VersionInterfacesFunc
func
(
apiVersion
string
)
(
*
VersionInterfaces
,
bool
)
...
@@ -162,6 +162,7 @@ func (m *DefaultRESTMapper) RESTMapping(version, kind string) (*RESTMapping, err
...
@@ -162,6 +162,7 @@ func (m *DefaultRESTMapper) RESTMapping(version, kind string) (*RESTMapping, err
Kind
:
kind
,
Kind
:
kind
,
Codec
:
interfaces
.
Codec
,
Codec
:
interfaces
.
Codec
,
ObjectConvertor
:
interfaces
.
ObjectConvertor
,
MetadataAccessor
:
interfaces
.
MetadataAccessor
,
MetadataAccessor
:
interfaces
.
MetadataAccessor
,
},
nil
},
nil
}
}
pkg/api/meta/restmapper_test.go
View file @
f0c23d68
...
@@ -36,11 +36,18 @@ func (fakeCodec) DecodeInto([]byte, runtime.Object) error {
...
@@ -36,11 +36,18 @@ func (fakeCodec) DecodeInto([]byte, runtime.Object) error {
return
nil
return
nil
}
}
type
fakeConvertor
struct
{}
func
(
fakeConvertor
)
ConvertToVersion
(
in
runtime
.
Object
,
_
string
)
(
runtime
.
Object
,
error
)
{
return
in
,
nil
}
var
validCodec
=
fakeCodec
{}
var
validCodec
=
fakeCodec
{}
var
validAccessor
=
resourceAccessor
{}
var
validAccessor
=
resourceAccessor
{}
var
validConvertor
=
fakeConvertor
{}
func
fakeInterfaces
(
version
string
)
(
*
VersionInterfaces
,
bool
)
{
func
fakeInterfaces
(
version
string
)
(
*
VersionInterfaces
,
bool
)
{
return
&
VersionInterfaces
{
Codec
:
validCodec
,
MetadataAccessor
:
validAccessor
},
true
return
&
VersionInterfaces
{
Codec
:
validCodec
,
ObjectConvertor
:
validConvertor
,
MetadataAccessor
:
validAccessor
},
true
}
}
func
unmatchedVersionInterfaces
(
version
string
)
(
*
VersionInterfaces
,
bool
)
{
func
unmatchedVersionInterfaces
(
version
string
)
(
*
VersionInterfaces
,
bool
)
{
...
@@ -155,7 +162,7 @@ func TestRESTMapperRESTMapping(t *testing.T) {
...
@@ -155,7 +162,7 @@ func TestRESTMapperRESTMapping(t *testing.T) {
if
mapping
.
APIVersion
!=
version
{
if
mapping
.
APIVersion
!=
version
{
t
.
Errorf
(
"%d: unexpected version: %#v"
,
i
,
mapping
)
t
.
Errorf
(
"%d: unexpected version: %#v"
,
i
,
mapping
)
}
}
if
mapping
.
Codec
==
nil
||
mapping
.
MetadataAccessor
==
nil
{
if
mapping
.
Codec
==
nil
||
mapping
.
MetadataAccessor
==
nil
||
mapping
.
ObjectConvertor
==
nil
{
t
.
Errorf
(
"%d: missing codec and accessor: %#v"
,
i
,
mapping
)
t
.
Errorf
(
"%d: missing codec and accessor: %#v"
,
i
,
mapping
)
}
}
}
}
...
...
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