本文整理汇总了Golang中github.com/jchauncey/kubeclient/api/unversioned.GroupVersion.WithResource方法的典型用法代码示例。如果您正苦于以下问题:Golang GroupVersion.WithResource方法的具体用法?Golang GroupVersion.WithResource怎么用?Golang GroupVersion.WithResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jchauncey/kubeclient/api/unversioned.GroupVersion
的用法示例。
在下文中一共展示了GroupVersion.WithResource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestKindToResource
func TestKindToResource(t *testing.T) {
testCases := []struct {
Kind string
MixedCase bool
Plural, Singular string
}{
{Kind: "Pod", MixedCase: true, Plural: "pods", Singular: "pod"},
{Kind: "Pod", MixedCase: true, Plural: "pods", Singular: "pod"},
{Kind: "Pod", MixedCase: false, Plural: "pods", Singular: "pod"},
{Kind: "ReplicationController", MixedCase: true, Plural: "replicationControllers", Singular: "replicationController"},
{Kind: "ReplicationController", MixedCase: true, Plural: "replicationControllers", Singular: "replicationController"},
{Kind: "ReplicationController", MixedCase: false, Plural: "replicationcontrollers", Singular: "replicationcontroller"},
// Add "ies" when ending with "y"
{Kind: "ImageRepository", MixedCase: true, Plural: "imageRepositories", Singular: "imageRepository"},
// Add "es" when ending with "s"
{Kind: "miss", MixedCase: false, Plural: "misses", Singular: "miss"},
// Add "s" otherwise
{Kind: "lowercase", MixedCase: false, Plural: "lowercases", Singular: "lowercase"},
}
for i, testCase := range testCases {
version := unversioned.GroupVersion{}
plural, singular := KindToResource(version.WithKind(testCase.Kind), testCase.MixedCase)
if singular != version.WithResource(testCase.Singular) || plural != version.WithResource(testCase.Plural) {
t.Errorf("%d: unexpected plural and singular: %v %v", i, plural, singular)
}
}
}