k8s/io/kubernetes/pkg/api.Kind 示例代码

2022-03-03

以下示例是关于golang中包含api.Kind用法的示例代码,想了解api.Kind的具体用法?api.Kind怎么用?api.Kind使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
describe.go开发语言: Go项目名称: ddysher代码行数: 3486
122	m := map[schema.GroupKind]printers.Describer{
123		api.Kind("Pod"):                   &PodDescriber{c},
124		api.Kind("ReplicationController"): &ReplicationControllerDescriber{c},
125		api.Kind("Secret"):                &SecretDescriber{c},
126		api.Kind("Service"):               &ServiceDescriber{c},
127		api.Kind("ServiceAccount"):        &ServiceAccountDescriber{c},
128		api.Kind("Node"):                  &NodeDescriber{c},
129		api.Kind("LimitRange"):            &LimitRangeDescriber{c},
130		api.Kind("ResourceQuota"):         &ResourceQuotaDescriber{c},
131		api.Kind("PersistentVolume"):      &PersistentVolumeDescriber{c},
132		api.Kind("PersistentVolumeClaim"): &PersistentVolumeClaimDescriber{c},
示例2:
admission_test.go开发语言: Go项目名称: ddysher代码行数: 1272
143	namespace := "default"
144	err := handler.Admit(admission.NewAttributesRecord(nil, nil, api.Kind("Pod").WithVersion("version"), namespace, "name", api.Resource("pods").WithVersion("version"), "", admission.Delete, nil))
145	if err != nil {
179	newPod := validPod("123", 1, getResourceRequirements(getResourceList("100m", "2Gi"), getResourceList("", "")))
180	err := handler.Admit(admission.NewAttributesRecord(newPod, nil, api.Kind("Pod").WithVersion("version"), newPod.Namespace, newPod.Name, api.Resource("pods").WithVersion("version"), "", admission.Create, nil))
181	if err == nil {
183	}
184	err = handler.Admit(admission.NewAttributesRecord(newPod, nil, api.Kind("Pod").WithVersion("version"), newPod.Namespace, newPod.Name, api.Resource("pods").WithVersion("version"), "subresource", admission.Create, nil))
185	if err != nil {
223	newPod := validPod("allowed-pod", 1, getResourceRequirements(getResourceList("100m", "2Gi"), getResourceList("", "")))
224	err := handler.Admit(admission.NewAttributesRecord(newPod, nil, api.Kind("Pod").WithVersion("version"), newPod.Namespace, newPod.Name, api.Resource("pods").WithVersion("version"), "", admission.Create, nil))
225	if err != nil {
318	}
319	err := handler.Admit(admission.NewAttributesRecord(newService, existingService, api.Kind("Service").WithVersion("version"), newService.Namespace, newService.Name, api.Resource("services").WithVersion("version"), "", admission.Update, nil))
320	if err != nil {
示例3:
admission_test.go开发语言: Go项目名称: ddysher代码行数: 909
39	for _, op := range []admission.Operation{admission.Update, admission.Delete, admission.Connect} {
40		attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", op, nil)
41		handler := admission.NewChainHandler(NewServiceAccount())
50	pod := &api.Pod{}
51	attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("CustomResource").WithVersion("version"), "", admission.Create, nil)
52	err := NewServiceAccount().Admit(attrs)
58func TestIgnoresNilObject(t *testing.T) {
59	attrs := admission.NewAttributesRecord(nil, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, nil)
60	err := NewServiceAccount().Admit(attrs)
67	obj := &api.Namespace{}
68	attrs := admission.NewAttributesRecord(obj, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, nil)
69	err := NewServiceAccount().Admit(attrs)
87	}
88	attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, nil)
89	err := NewServiceAccount().Admit(attrs)
示例4:
describe.go开发语言: Go项目名称: detiber代码行数: 3464
121	m := map[schema.GroupKind]printers.Describer{
122		api.Kind("Pod"):                   &PodDescriber{c},
123		api.Kind("ReplicationController"): &ReplicationControllerDescriber{c},
124		api.Kind("Secret"):                &SecretDescriber{c},
125		api.Kind("Service"):               &ServiceDescriber{c},
126		api.Kind("ServiceAccount"):        &ServiceAccountDescriber{c},
127		api.Kind("Node"):                  &NodeDescriber{c},
128		api.Kind("LimitRange"):            &LimitRangeDescriber{c},
129		api.Kind("ResourceQuota"):         &ResourceQuotaDescriber{c},
130		api.Kind("PersistentVolume"):      &PersistentVolumeDescriber{c},
131		api.Kind("PersistentVolumeClaim"): &PersistentVolumeClaimDescriber{c},
示例5:
admission_test.go开发语言: Go项目名称: detiber代码行数: 1272
143	namespace := "default"
144	err := handler.Admit(admission.NewAttributesRecord(nil, nil, api.Kind("Pod").WithVersion("version"), namespace, "name", api.Resource("pods").WithVersion("version"), "", admission.Delete, nil))
145	if err != nil {
179	newPod := validPod("123", 1, getResourceRequirements(getResourceList("100m", "2Gi"), getResourceList("", "")))
180	err := handler.Admit(admission.NewAttributesRecord(newPod, nil, api.Kind("Pod").WithVersion("version"), newPod.Namespace, newPod.Name, api.Resource("pods").WithVersion("version"), "", admission.Create, nil))
181	if err == nil {
183	}
184	err = handler.Admit(admission.NewAttributesRecord(newPod, nil, api.Kind("Pod").WithVersion("version"), newPod.Namespace, newPod.Name, api.Resource("pods").WithVersion("version"), "subresource", admission.Create, nil))
185	if err != nil {
223	newPod := validPod("allowed-pod", 1, getResourceRequirements(getResourceList("100m", "2Gi"), getResourceList("", "")))
224	err := handler.Admit(admission.NewAttributesRecord(newPod, nil, api.Kind("Pod").WithVersion("version"), newPod.Namespace, newPod.Name, api.Resource("pods").WithVersion("version"), "", admission.Create, nil))
225	if err != nil {
318	}
319	err := handler.Admit(admission.NewAttributesRecord(newService, existingService, api.Kind("Service").WithVersion("version"), newService.Namespace, newService.Name, api.Resource("services").WithVersion("version"), "", admission.Update, nil))
320	if err != nil {
示例6:
admission_test.go开发语言: Go项目名称: detiber代码行数: 909
39	for _, op := range []admission.Operation{admission.Update, admission.Delete, admission.Connect} {
40		attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", op, nil)
41		handler := admission.NewChainHandler(NewServiceAccount())
50	pod := &api.Pod{}
51	attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("CustomResource").WithVersion("version"), "", admission.Create, nil)
52	err := NewServiceAccount().Admit(attrs)
58func TestIgnoresNilObject(t *testing.T) {
59	attrs := admission.NewAttributesRecord(nil, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, nil)
60	err := NewServiceAccount().Admit(attrs)
67	obj := &api.Namespace{}
68	attrs := admission.NewAttributesRecord(obj, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, nil)
69	err := NewServiceAccount().Admit(attrs)
87	}
88	attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, nil)
89	err := NewServiceAccount().Admit(attrs)
示例7:
resource_quota_controller_test.go开发语言: Go项目名称: ddysher代码行数: 565
116		GroupKindsToReplenish: []schema.GroupKind{
117			api.Kind("Pod"),
118			api.Kind("Service"),
119			api.Kind("ReplicationController"),
120			api.Kind("PersistentVolumeClaim"),
203		GroupKindsToReplenish: []schema.GroupKind{
204			api.Kind("Pod"),
205			api.Kind("Service"),
206			api.Kind("ReplicationController"),
207			api.Kind("PersistentVolumeClaim"),
293		GroupKindsToReplenish: []schema.GroupKind{
294			api.Kind("Pod"),
295			api.Kind("Service"),
示例8:
factory_client_access.go开发语言: Go项目名称: ddysher代码行数: 625
561	switch kind {
562	case api.Kind("ReplicationController"), api.Kind("Service"), api.Kind("Pod"),
563		extensions.Kind("Deployment"), apps.Kind("Deployment"), extensions.Kind("ReplicaSet"):
572	switch kind {
573	case api.Kind("ReplicationController"), extensions.Kind("ReplicaSet"),
574		extensions.Kind("Deployment"), apps.Kind("Deployment"):
示例9:
density.go开发语言: Go项目名称: ddysher代码行数: 823
410		// TODO: Expose runLatencyTest as ginkgo flag.
411		{podsPerNode: 3, runLatencyTest: false, kind: api.Kind("ReplicationController")},
412		{podsPerNode: 30, runLatencyTest: true, kind: api.Kind("ReplicationController")},
413		{podsPerNode: 50, runLatencyTest: false, kind: api.Kind("ReplicationController")},
414		{podsPerNode: 95, runLatencyTest: true, kind: api.Kind("ReplicationController")},
415		{podsPerNode: 100, runLatencyTest: false, kind: api.Kind("ReplicationController")},
416		// Tests for other resource types:
419		// Test scheduling when daemons are preset
420		{podsPerNode: 30, runLatencyTest: true, kind: api.Kind("ReplicationController"), daemonsPerNode: 2},
421		// Test with secrets
430		case 30:
431			if testArg.kind == api.Kind("ReplicationController") && testArg.daemonsPerNode == 0 && testArg.secretsPerPod == 0 && testArg.configMapsPerPod == 0 {
432				feature = "Performance"
示例10:
resource_quota_controller_test.go开发语言: Go项目名称: detiber代码行数: 565
116		GroupKindsToReplenish: []schema.GroupKind{
117			api.Kind("Pod"),
118			api.Kind("Service"),
119			api.Kind("ReplicationController"),
120			api.Kind("PersistentVolumeClaim"),
203		GroupKindsToReplenish: []schema.GroupKind{
204			api.Kind("Pod"),
205			api.Kind("Service"),
206			api.Kind("ReplicationController"),
207			api.Kind("PersistentVolumeClaim"),
293		GroupKindsToReplenish: []schema.GroupKind{
294			api.Kind("Pod"),
295			api.Kind("Service"),

本文地址:https://www.itbaoku.cn/snippets/415608.html