remove ResourceIsValid

pull/6/head
deads2k 2016-02-08 16:32:36 -05:00
parent 138cb09aea
commit 9901a386c3
6 changed files with 0 additions and 70 deletions

View File

@ -172,7 +172,4 @@ type RESTMapper interface {
AliasesForResource(resource string) ([]string, bool)
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
}

View File

@ -119,13 +119,3 @@ func (m MultiRESTMapper) AliasesForResource(alias string) (aliases []string, ok
}
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
}

View File

@ -522,9 +522,3 @@ func (m *DefaultRESTMapper) AliasesForResource(alias string) ([]string, bool) {
}
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
}

View File

@ -86,12 +86,6 @@ func (e ShortcutExpander) KindFor(resource unversioned.GroupVersionResource) (un
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.
func (e ShortcutExpander) ResourceSingularizer(resource string) (string, error) {
return e.RESTMapper.ResourceSingularizer(expandResourceShortcut(unversioned.GroupVersionResource{Resource: resource}).Resource)

View File

@ -126,10 +126,6 @@ func (t *thirdPartyResourceDataMapper) ResourceSingularizer(resource string) (si
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 {
return &thirdPartyResourceDataMapper{
mapper: mapper,

View File

@ -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)
}
}
}