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
815fcc33
Commit
815fcc33
authored
Dec 10, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18131 from brendandburns/3rdparty
Auto commit by PR queue bot
parents
07366151
9574a4b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
codec.go
pkg/registry/thirdpartyresourcedata/codec.go
+2
-1
codec_test.go
pkg/registry/thirdpartyresourcedata/codec_test.go
+41
-0
No files found.
pkg/registry/thirdpartyresourcedata/codec.go
View file @
815fcc33
...
@@ -42,7 +42,8 @@ type thirdPartyResourceDataMapper struct {
...
@@ -42,7 +42,8 @@ type thirdPartyResourceDataMapper struct {
var
_
meta
.
RESTMapper
=
&
thirdPartyResourceDataMapper
{}
var
_
meta
.
RESTMapper
=
&
thirdPartyResourceDataMapper
{}
func
(
t
*
thirdPartyResourceDataMapper
)
isThirdPartyResource
(
resource
string
)
bool
{
func
(
t
*
thirdPartyResourceDataMapper
)
isThirdPartyResource
(
resource
string
)
bool
{
return
resource
==
strings
.
ToLower
(
t
.
kind
)
+
"s"
plural
,
_
:=
meta
.
KindToResource
(
t
.
kind
,
false
)
return
resource
==
plural
}
}
func
(
t
*
thirdPartyResourceDataMapper
)
KindFor
(
resource
string
)
(
unversioned
.
GroupVersionKind
,
error
)
{
func
(
t
*
thirdPartyResourceDataMapper
)
KindFor
(
resource
string
)
(
unversioned
.
GroupVersionKind
,
error
)
{
...
...
pkg/registry/thirdpartyresourcedata/codec_test.go
View file @
815fcc33
...
@@ -181,3 +181,44 @@ func TestCreater(t *testing.T) {
...
@@ -181,3 +181,44 @@ func TestCreater(t *testing.T) {
}
}
}
}
func
TestResourceIsValid
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
kind
string
resource
string
valid
bool
name
string
}{
{
kind
:
"Foo"
,
resource
:
"foos"
,
valid
:
true
,
name
:
"basic"
,
},
{
kind
:
"Party"
,
resource
:
"parties"
,
valid
:
true
,
name
:
"fun"
,
},
{
kind
:
"bus"
,
resource
:
"buses"
,
valid
:
true
,
name
:
"transport"
,
},
{
kind
:
"Foo"
,
resource
:
"fooies"
,
name
:
"bad"
,
},
}
for
_
,
test
:=
range
tests
{
mapper
:=
&
thirdPartyResourceDataMapper
{
kind
:
test
.
kind
}
mapper
.
mapper
=
api
.
RESTMapper
valid
:=
mapper
.
ResourceIsValid
(
test
.
resource
)
if
valid
!=
test
.
valid
{
t
.
Errorf
(
"expected: %v, saw: %v for %s"
,
test
.
valid
,
valid
,
test
.
name
)
}
}
}
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