mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Merge pull request #18131 from brendandburns/3rdparty
Auto commit by PR queue bot
This commit is contained in:
commit
815fcc3334
@ -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) {
|
||||||
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user