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
1380a3e6
Commit
1380a3e6
authored
Feb 15, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20850 from deads2k/remove-resource-is-valid
Auto commit by PR queue bot
parents
134d44cf
9901a386
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
70 deletions
+0
-70
interfaces.go
pkg/api/meta/interfaces.go
+0
-3
multirestmapper.go
pkg/api/meta/multirestmapper.go
+0
-10
restmapper.go
pkg/api/meta/restmapper.go
+0
-6
kubectl.go
pkg/kubectl/kubectl.go
+0
-6
codec.go
pkg/registry/thirdpartyresourcedata/codec.go
+0
-4
codec_test.go
pkg/registry/thirdpartyresourcedata/codec_test.go
+0
-41
No files found.
pkg/api/meta/interfaces.go
View file @
1380a3e6
...
@@ -172,7 +172,4 @@ type RESTMapper interface {
...
@@ -172,7 +172,4 @@ type RESTMapper interface {
AliasesForResource
(
resource
string
)
([]
string
,
bool
)
AliasesForResource
(
resource
string
)
([]
string
,
bool
)
ResourceSingularizer
(
resource
string
)
(
singular
string
,
err
error
)
ResourceSingularizer
(
resource
string
)
(
singular
string
,
err
error
)
// ResourceIsValid takes a partial resource and returns back whether or not the resource matches at least one kind
ResourceIsValid
(
resource
unversioned
.
GroupVersionResource
)
bool
}
}
pkg/api/meta/multirestmapper.go
View file @
1380a3e6
...
@@ -119,13 +119,3 @@ func (m MultiRESTMapper) AliasesForResource(alias string) (aliases []string, ok
...
@@ -119,13 +119,3 @@ func (m MultiRESTMapper) AliasesForResource(alias string) (aliases []string, ok
}
}
return
nil
,
false
return
nil
,
false
}
}
// ResourceIsValid takes a string (either group/kind or kind) and checks if it's a valid resource
func
(
m
MultiRESTMapper
)
ResourceIsValid
(
resource
unversioned
.
GroupVersionResource
)
bool
{
for
_
,
t
:=
range
m
{
if
t
.
ResourceIsValid
(
resource
)
{
return
true
}
}
return
false
}
pkg/api/meta/restmapper.go
View file @
1380a3e6
...
@@ -522,9 +522,3 @@ func (m *DefaultRESTMapper) AliasesForResource(alias string) ([]string, bool) {
...
@@ -522,9 +522,3 @@ func (m *DefaultRESTMapper) AliasesForResource(alias string) ([]string, bool) {
}
}
return
nil
,
false
return
nil
,
false
}
}
// ResourceIsValid takes a partial resource and checks if it's valid
func
(
m
*
DefaultRESTMapper
)
ResourceIsValid
(
resource
unversioned
.
GroupVersionResource
)
bool
{
_
,
err
:=
m
.
KindFor
(
resource
)
return
err
==
nil
}
pkg/kubectl/kubectl.go
View file @
1380a3e6
...
@@ -86,12 +86,6 @@ func (e ShortcutExpander) KindFor(resource unversioned.GroupVersionResource) (un
...
@@ -86,12 +86,6 @@ func (e ShortcutExpander) KindFor(resource unversioned.GroupVersionResource) (un
return
e
.
RESTMapper
.
KindFor
(
resource
)
return
e
.
RESTMapper
.
KindFor
(
resource
)
}
}
// ResourceIsValid takes a string (kind) and checks if it's a valid resource.
// It expands the resource first, then invokes the wrapped mapper.
func
(
e
ShortcutExpander
)
ResourceIsValid
(
resource
unversioned
.
GroupVersionResource
)
bool
{
return
e
.
RESTMapper
.
ResourceIsValid
(
expandResourceShortcut
(
resource
))
}
// ResourceSingularizer expands the named resource and then singularizes it.
// ResourceSingularizer expands the named resource and then singularizes it.
func
(
e
ShortcutExpander
)
ResourceSingularizer
(
resource
string
)
(
string
,
error
)
{
func
(
e
ShortcutExpander
)
ResourceSingularizer
(
resource
string
)
(
string
,
error
)
{
return
e
.
RESTMapper
.
ResourceSingularizer
(
expandResourceShortcut
(
unversioned
.
GroupVersionResource
{
Resource
:
resource
})
.
Resource
)
return
e
.
RESTMapper
.
ResourceSingularizer
(
expandResourceShortcut
(
unversioned
.
GroupVersionResource
{
Resource
:
resource
})
.
Resource
)
...
...
pkg/registry/thirdpartyresourcedata/codec.go
View file @
1380a3e6
...
@@ -126,10 +126,6 @@ func (t *thirdPartyResourceDataMapper) ResourceSingularizer(resource string) (si
...
@@ -126,10 +126,6 @@ func (t *thirdPartyResourceDataMapper) ResourceSingularizer(resource string) (si
return
t
.
mapper
.
ResourceSingularizer
(
resource
)
return
t
.
mapper
.
ResourceSingularizer
(
resource
)
}
}
func
(
t
*
thirdPartyResourceDataMapper
)
ResourceIsValid
(
resource
unversioned
.
GroupVersionResource
)
bool
{
return
t
.
isThirdPartyResource
(
resource
)
||
t
.
mapper
.
ResourceIsValid
(
resource
)
}
func
NewMapper
(
mapper
meta
.
RESTMapper
,
kind
,
version
,
group
string
)
meta
.
RESTMapper
{
func
NewMapper
(
mapper
meta
.
RESTMapper
,
kind
,
version
,
group
string
)
meta
.
RESTMapper
{
return
&
thirdPartyResourceDataMapper
{
return
&
thirdPartyResourceDataMapper
{
mapper
:
mapper
,
mapper
:
mapper
,
...
...
pkg/registry/thirdpartyresourcedata/codec_test.go
View file @
1380a3e6
...
@@ -178,44 +178,3 @@ func TestCreater(t *testing.T) {
...
@@ -178,44 +178,3 @@ 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
(
unversioned
.
GroupVersionResource
{
Resource
:
test
.
resource
})
if
valid
!=
test
.
valid
{
t
.
Errorf
(
"%s: expected: %v, actual: %v"
,
test
.
name
,
test
.
valid
,
valid
)
}
}
}
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