k8s/io/kubernetes/pkg/api/unversioned.GroupVersionKind 示例代码

2022-03-03

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

示例1:
restmapper_test.go开发语言: Go项目名称: amygdala代码行数: 550
63		GroupVersionToRegister unversioned.GroupVersion
64		ExpectedGVK            unversioned.GroupVersionKind
65		Err                    bool
97		Resource         unversioned.GroupVersionResource
98		GroupVersionKind unversioned.GroupVersionKind
99		Err              bool
100	}{
101		{Resource: unversioned.GroupVersionResource{Resource: "myObject"}, GroupVersionKind: unversioned.GroupVersionKind{Group: "testapi", Version: "test", Kind: "MyObject"}},
102		{Resource: unversioned.GroupVersionResource{Resource: "myobject"}, GroupVersionKind: unversioned.GroupVersionKind{Group: "testapi2", Version: "test", Kind: "MyObject"}},
103		{Resource: unversioned.GroupVersionResource{Resource: "myObje"}, Err: true, GroupVersionKind: unversioned.GroupVersionKind{Group: "testapi", Version: "test", Kind: "MyObject"}},
104		{Resource: unversioned.GroupVersionResource{Resource: "myobje"}, Err: true, GroupVersionKind: unversioned.GroupVersionKind{Group: "testapi", Version: "test", Kind: "MyObject"}},
126		PreferredOrder           []unversioned.GroupVersion
127		KindsToRegister          []unversioned.GroupVersionKind
128		PartialResourceToRequest unversioned.GroupVersionResource
示例2:
json_test.go开发语言: Go项目名称: amygdala代码行数: 268
33	Value int `json:"value"`
34	gvk   *unversioned.GroupVersionKind
35}
37func (d *testDecodable) GetObjectKind() unversioned.ObjectKind                 { return d }
38func (d *testDecodable) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) { d.gvk = gvk }
39func (d *testDecodable) GroupVersionKind() *unversioned.GroupVersionKind       { return d.gvk }
48		data       []byte
49		defaultGVK *unversioned.GroupVersionKind
50		into       runtime.Object
53		expectedObject runtime.Object
54		expectedGVK    *unversioned.GroupVersionKind
55	}{
58
59			expectedGVK: &unversioned.GroupVersionKind{},
60			errFn:       func(err error) bool { return strings.Contains(err.Error(), "Object 'Kind' is missing in") },
示例3:
multirestmapper_test.go开发语言: Go项目名称: amygdala代码行数: 298
148		input  unversioned.GroupVersionResource
149		result []unversioned.GroupVersionKind
150		err    error
167			name:   "accept first failure",
168			mapper: MultiRESTMapper{fixedRESTMapper{err: errors.New("fail on this")}, fixedRESTMapper{kindsFor: []unversioned.GroupVersionKind{{Kind: "unused"}}}},
169			input:  unversioned.GroupVersionResource{Resource: "foo"},
175			mapper: MultiRESTMapper{
176				fixedRESTMapper{kindsFor: []unversioned.GroupVersionKind{{Kind: "dupe"}, {Kind: "first"}}},
177				fixedRESTMapper{kindsFor: []unversioned.GroupVersionKind{{Kind: "dupe"}, {Kind: "second"}}},
179			input:  unversioned.GroupVersionResource{Resource: "foo"},
180			result: []unversioned.GroupVersionKind{{Kind: "dupe"}, {Kind: "first"}, {Kind: "second"}},
181		},
185				fixedRESTMapper{err: &NoResourceMatchError{PartialResource: unversioned.GroupVersionResource{Resource: "IGNORE_THIS"}}},
186				fixedRESTMapper{kindsFor: []unversioned.GroupVersionKind{{Kind: "first"}, {Kind: "second"}}},
187			},
示例4:
priority_test.go开发语言: Go项目名称: amygdala代码行数: 206
121		delegate     RESTMapper
122		kindPatterns []unversioned.GroupVersionKind
123		result       unversioned.GroupVersionKind
127			name:     "single hit",
128			delegate: fixedRESTMapper{kindsFor: []unversioned.GroupVersionKind{{Kind: "single-hit"}}},
129			result:   unversioned.GroupVersionKind{Kind: "single-hit"},
132			name: "ambiguous match",
133			delegate: fixedRESTMapper{kindsFor: []unversioned.GroupVersionKind{
134				{Group: "one", Version: "a", Kind: "first"},
140			name: "group selection",
141			delegate: fixedRESTMapper{kindsFor: []unversioned.GroupVersionKind{
142				{Group: "one", Version: "a", Kind: "first"},
144			}},
145			kindPatterns: []unversioned.GroupVersionKind{
146				{Group: "one", Version: AnyVersion, Kind: AnyKind},
示例5:
restmapper.go开发语言: Go项目名称: amygdala代码行数: 508
75
76	resourceToKind       map[unversioned.GroupVersionResource]unversioned.GroupVersionKind
77	kindToPluralResource map[unversioned.GroupVersionKind]unversioned.GroupVersionResource
78	kindToScope          map[unversioned.GroupVersionKind]RESTScope
79	singularToPlural     map[unversioned.GroupVersionResource]unversioned.GroupVersionResource
100func NewDefaultRESTMapper(defaultGroupVersions []unversioned.GroupVersion, f VersionInterfacesFunc) *DefaultRESTMapper {
101	resourceToKind := make(map[unversioned.GroupVersionResource]unversioned.GroupVersionKind)
102	kindToPluralResource := make(map[unversioned.GroupVersionKind]unversioned.GroupVersionResource)
103	kindToScope := make(map[unversioned.GroupVersionKind]RESTScope)
104	singularToPlural := make(map[unversioned.GroupVersionResource]unversioned.GroupVersionResource)
118
119func (m *DefaultRESTMapper) Add(kind unversioned.GroupVersionKind, scope RESTScope) {
120	plural, singular := KindToResource(kind)
示例6:
scheme.go开发语言: Go项目名称: amygdala代码行数: 541
45	// the given version and name.
46	gvkToType map[unversioned.GroupVersionKind]reflect.Type
47
49	// The reflect.Type we index by should *not* be a pointer.
50	typeToGVK map[reflect.Type][]unversioned.GroupVersionKind
51
52	// unversionedTypes are transformed without conversion in ConvertToVersion.
53	unversionedTypes map[reflect.Type]unversioned.GroupVersionKind
54
78	s := &Scheme{
79		gvkToType:        map[unversioned.GroupVersionKind]reflect.Type{},
80		typeToGVK:        map[reflect.Type][]unversioned.GroupVersionKind{},
81		unversionedTypes: map[reflect.Type]unversioned.GroupVersionKind{},
82		unversionedKinds: map[string]reflect.Type{},
示例7:
factory.go开发语言: Go项目名称: amygdala代码行数: 941
117	// SwaggerSchema returns the schema declaration for the provided group version kind.
118	SwaggerSchema func(unversioned.GroupVersionKind) (*swagger.ApiDeclaration, error)
119	// Returns the default namespace to use in cases where no
217				},
218				KindPriority: []unversioned.GroupVersionKind{
219					{Group: api.GroupName, Version: meta.AnyVersion, Kind: meta.AnyKind},
525		},
526		SwaggerSchema: func(gvk unversioned.GroupVersionKind) (*swagger.ApiDeclaration, error) {
527			version := gvk.GroupVersion()
示例8:
versioning_test.go开发语言: Go项目名称: amygdala代码行数: 300
32	Value int `json:"value"`
33	gvk   *unversioned.GroupVersionKind
34}
36func (d *testDecodable) GetObjectKind() unversioned.ObjectKind                 { return d }
37func (d *testDecodable) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) { d.gvk = gvk }
38func (d *testDecodable) GroupVersionKind() *unversioned.GroupVersionKind       { return d.gvk }
40func TestDecode(t *testing.T) {
41	gvk1 := &unversioned.GroupVersionKind{Kind: "Test", Group: "other", Version: "blah"}
42	decodable1 := &testDecodable{}
57
58		defaultGVK *unversioned.GroupVersionKind
59		into       runtime.Object
271
272func (s *mockSerializer) Decode(data []byte, defaults *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) {
273	s.defaults = defaults
示例9:
cmd_test.go开发语言: Go项目名称: amygdala代码行数: 734
73func (obj *internalType) GetObjectKind() unversioned.ObjectKind { return obj }
74func (obj *internalType) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) {
75	obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
76}
77func (obj *internalType) GroupVersionKind() *unversioned.GroupVersionKind {
78	return unversioned.FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
80func (obj *externalType) GetObjectKind() unversioned.ObjectKind { return obj }
81func (obj *externalType) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) {
82	obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
83}
84func (obj *externalType) GroupVersionKind() *unversioned.GroupVersionKind {
85	return unversioned.FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
87func (obj *ExternalType2) GetObjectKind() unversioned.ObjectKind { return obj }
88func (obj *ExternalType2) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) {
89	obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
示例10:
codec.go开发语言: Go项目名称: amygdala代码行数: 384
51
52func (t *thirdPartyResourceDataMapper) getKind() unversioned.GroupVersionKind {
53	return unversioned.GroupVersionKind{Group: t.group, Version: t.version, Kind: t.kind}
77
78func (t *thirdPartyResourceDataMapper) KindsFor(resource unversioned.GroupVersionResource) ([]unversioned.GroupVersionKind, error) {
79	if t.isThirdPartyResource(resource) {
80		return []unversioned.GroupVersionKind{t.getKind()}, nil
81	}
91
92func (t *thirdPartyResourceDataMapper) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error) {
93	if t.isThirdPartyResource(resource) {
219
220func (t *thirdPartyResourceDataCodec) Decode(data []byte, gvk *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) {
221	if into == nil {

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