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
936421a4
Commit
936421a4
authored
Mar 29, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
relax restmapper resource matching
parent
be8ce6c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
restmapper.go
pkg/api/meta/restmapper.go
+16
-6
No files found.
pkg/api/meta/restmapper.go
View file @
936421a4
...
...
@@ -69,7 +69,6 @@ var RESTScopeRoot = &restScope{
//
// TODO: Only accept plural for some operations for increased control?
// (`get pod bar` vs `get pods bar`)
// TODO these maps should be keyed based on GroupVersionKinds
type
DefaultRESTMapper
struct
{
defaultGroupVersions
[]
unversioned
.
GroupVersion
...
...
@@ -143,6 +142,8 @@ var unpluralizedSuffixes = []string{
}
// KindToResource converts Kind to a resource name.
// Broken. This method only "sort of" works when used outside of this package. It assumes that Kinds and Resources match
// and they aren't guaranteed to do so.
func
KindToResource
(
kind
unversioned
.
GroupVersionKind
)
(
/*plural*/
unversioned
.
GroupVersionResource
/*singular*/
,
unversioned
.
GroupVersionResource
)
{
kindName
:=
kind
.
Kind
if
len
(
kindName
)
==
0
{
...
...
@@ -199,7 +200,19 @@ func (m *DefaultRESTMapper) ResourceSingularizer(resourceType string) (string, e
return
singular
.
Resource
,
nil
}
func
(
m
*
DefaultRESTMapper
)
ResourcesFor
(
resource
unversioned
.
GroupVersionResource
)
([]
unversioned
.
GroupVersionResource
,
error
)
{
// coerceResourceForMatching makes the resource lower case and converts internal versions to unspecified (legacy behavior)
func
coerceResourceForMatching
(
resource
unversioned
.
GroupVersionResource
)
unversioned
.
GroupVersionResource
{
resource
.
Resource
=
strings
.
ToLower
(
resource
.
Resource
)
if
resource
.
Version
==
runtime
.
APIVersionInternal
{
resource
.
Version
=
""
}
return
resource
}
func
(
m
*
DefaultRESTMapper
)
ResourcesFor
(
input
unversioned
.
GroupVersionResource
)
([]
unversioned
.
GroupVersionResource
,
error
)
{
resource
:=
coerceResourceForMatching
(
input
)
hasResource
:=
len
(
resource
.
Resource
)
>
0
hasGroup
:=
len
(
resource
.
Group
)
>
0
hasVersion
:=
len
(
resource
.
Version
)
>
0
...
...
@@ -276,10 +289,7 @@ func (m *DefaultRESTMapper) ResourceFor(resource unversioned.GroupVersionResourc
}
func
(
m
*
DefaultRESTMapper
)
KindsFor
(
input
unversioned
.
GroupVersionResource
)
([]
unversioned
.
GroupVersionKind
,
error
)
{
resource
:=
input
.
GroupVersion
()
.
WithResource
(
strings
.
ToLower
(
input
.
Resource
))
if
resource
.
Version
==
runtime
.
APIVersionInternal
{
resource
.
Version
=
""
}
resource
:=
coerceResourceForMatching
(
input
)
hasResource
:=
len
(
resource
.
Resource
)
>
0
hasGroup
:=
len
(
resource
.
Group
)
>
0
...
...
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