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

2022-03-03

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

示例1:
executor_kubernetes_test.go开发语言: Go项目名称: gitlab-ci-multi-runner代码行数: 783
122	for _, test := range tests {
123		c := client.NewOrDie(&restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: version}}})
124		fakeClient := fake.RESTClient{
519	for _, test := range tests {
520		c := client.NewOrDie(&restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: version}}})
521		fakeClient := fake.RESTClient{
示例2:
restmapper_test.go开发语言: Go项目名称: amygdala代码行数: 550
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"}},
432		{DefaultVersions: []unversioned.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []unversioned.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: "internalobjects"},
433		{DefaultVersions: []unversioned.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []unversioned.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: "internalobjects"},
434
435		{DefaultVersions: []unversioned.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []unversioned.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: "internalobjects"},
436
437		{DefaultVersions: []unversioned.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []unversioned.GroupVersion{}, Resource: "internalobjects", ExpectedGroupVersion: &unversioned.GroupVersion{Group: testGroup, Version: "test"}},
438
439		{DefaultVersions: []unversioned.GroupVersion{testGroupVersion}, Kind: "InternalObject", APIGroupVersions: []unversioned.GroupVersion{{Group: testGroup, Version: "test"}}, Resource: "internalobjects"},
440
示例3:
restmapper.go开发语言: Go项目名称: amygdala代码行数: 508
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
80	pluralToSingular     map[unversioned.GroupVersionResource]unversioned.GroupVersionResource
140// KindToResource converts Kind to a resource name.
141func KindToResource(kind unversioned.GroupVersionKind) ( /*plural*/ unversioned.GroupVersionResource /*singular*/, unversioned.GroupVersionResource) {
142	kindName := kind.Kind
260
261func (m *DefaultRESTMapper) ResourceFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionResource, error) {
262	resources, err := m.ResourcesFor(resource)
326
327func (m *DefaultRESTMapper) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error) {
328	kinds, err := m.KindsFor(resource)
示例4:
apiserver.go开发语言: Go项目名称: amygdala代码行数: 498
72	// GroupVersion is the external group version
73	GroupVersion unversioned.GroupVersion
74
82	// empty, defaults to GroupVersion.
83	OptionsExternalVersion *unversioned.GroupVersion
84
103	// match the keys in the Storage map above for subresources.
104	SubresourceGroupVersionKind map[string]unversioned.GroupVersionKind
105}
212	}
213	errorNegotiated(apierrors.NewGenericServerResponse(http.StatusInternalServerError, "", api.Resource(""), "", "", 0, false), s, unversioned.GroupVersion{}, w, &http.Request{Header: headers})
214}
222func serviceErrorHandler(s runtime.NegotiatedSerializer, requestResolver *RequestInfoResolver, apiVersions []string, serviceErr restful.ServiceError, request *restful.Request, response *restful.Response) {
223	errorNegotiated(apierrors.NewGenericServerResponse(serviceErr.Code, "", api.Resource(""), "", "", 0, false), s, unversioned.GroupVersion{}, response.ResponseWriter, request.Request)
224}
示例5:
registered.go开发语言: Go项目名称: amygdala代码行数: 284
35	// registeredGroupVersions stores all API group versions for which RegisterGroup is called.
36	registeredVersions = map[unversioned.GroupVersion]struct{}{}
37
49	// Scheme.  This list is small and order matters, so represent as a slice
50	envRequestedVersions = []unversioned.GroupVersion{}
51)
69// RegisterVersions adds the given group versions to the list of registered group versions.
70func RegisterVersions(availableVersions []unversioned.GroupVersion) {
71	for _, v := range availableVersions {
88// The caller of this function is responsible to add the versions to scheme and RESTMapper.
89func EnableVersions(versions ...unversioned.GroupVersion) error {
90	var unregisteredVersions []unversioned.GroupVersion
231// then any non-preferred version of the group second.
232func prioritiesForGroups(groups ...string) ([]unversioned.GroupVersionResource, []unversioned.GroupVersionKind) {
233	resourcePriority := []unversioned.GroupVersionResource{}
示例6:
resthandler.go开发语言: Go项目名称: amygdala代码行数: 1038
77
78	Resource    unversioned.GroupVersionResource
79	Kind        unversioned.GroupVersionKind
131				exports := unversioned.ExportOptions{}
132				if err := scope.ParameterCodec.DecodeParameters(values, unversioned.GroupVersion{Version: "v1"}, &exports); err != nil {
133					return nil, err
363		}
364		decoder := scope.Serializer.DecoderToVersion(s, unversioned.GroupVersion{Group: gv.Group, Version: runtime.APIVersionInternal})
365
487			scope.Serializer.EncoderForVersion(s, gv),
488			scope.Serializer.DecoderToVersion(s, unversioned.GroupVersion{Group: gv.Group, Version: runtime.APIVersionInternal}),
489		)
938// transformDecodeError adds additional information when a decode fails.
939func transformDecodeError(typer runtime.ObjectTyper, baseErr error, into runtime.Object, gvk *unversioned.GroupVersionKind) error {
940	objGVK, err := typer.ObjectKind(into)
示例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
202			CheckErr(err)
203			cmdApiVersion := unversioned.GroupVersion{}
204			if cfg.GroupVersion != nil {
207
208			outputRESTMapper := kubectl.OutputVersionMapper{RESTMapper: mapper, OutputVersions: []unversioned.GroupVersion{cmdApiVersion}}
209
212				Delegate: outputRESTMapper,
213				ResourcePriority: []unversioned.GroupVersionResource{
214					{Group: api.GroupName, Version: meta.AnyVersion, Resource: meta.AnyResource},
217				},
218				KindPriority: []unversioned.GroupVersionKind{
219					{Group: api.GroupName, Version: meta.AnyVersion, Kind: meta.AnyKind},
示例8:
master.go开发语言: Go项目名称: amygdala代码行数: 862
191		}
192		if autoscalingGroupVersion := (unversioned.GroupVersion{Group: "autoscaling", Version: "v1"}); registered.IsEnabledVersion(autoscalingGroupVersion) {
193			apiGroupInfo.SubresourceGroupVersionKind = map[string]unversioned.GroupVersionKind{
252
253		extensionsGVForDiscovery := unversioned.GroupVersionForDiscovery{
254			GroupVersion: extensionsGroupMeta.GroupVersion.String(),
258			Name:             extensionsGroupMeta.GroupVersion.Group,
259			Versions:         []unversioned.GroupVersionForDiscovery{extensionsGVForDiscovery},
260			PreferredVersion: extensionsGVForDiscovery,
270		// Hard code preferred group version to autoscaling/v1
271		autoscalingGroupMeta.GroupVersion = unversioned.GroupVersion{Group: "autoscaling", Version: "v1"}
272
284
285		autoscalingGVForDiscovery := unversioned.GroupVersionForDiscovery{
286			GroupVersion: autoscalingGroupMeta.GroupVersion.String(),
示例9:
scheme_test.go开发语言: Go项目名称: amygdala代码行数: 673
48func TestScheme(t *testing.T) {
49	internalGV := unversioned.GroupVersion{Group: "test.group", Version: runtime.APIVersionInternal}
50	externalGV := unversioned.GroupVersion{Group: "test.group", Version: "testExternal"}
217func TestExternalToInternalMapping(t *testing.T) {
218	internalGV := unversioned.GroupVersion{Group: "test.group", Version: runtime.APIVersionInternal}
219	externalGV := unversioned.GroupVersion{Group: "test.group", Version: "testExternal"}
247func TestExtensionMapping(t *testing.T) {
248	internalGV := unversioned.GroupVersion{Group: "test.group", Version: runtime.APIVersionInternal}
249	externalGV := unversioned.GroupVersion{Group: "test.group", Version: "testExternal"}
320func TestEncode(t *testing.T) {
321	internalGV := unversioned.GroupVersion{Group: "test.group", Version: runtime.APIVersionInternal}
322	externalGV := unversioned.GroupVersion{Group: "test.group", Version: "testExternal"}
344	}
345	if !reflect.DeepEqual(gvk, &unversioned.GroupVersionKind{Group: "test.group", Version: "testExternal", Kind: "Simple"}) {
346		t.Errorf("unexpected gvk returned by decode: %#v", gvk)
示例10:
genericapiserver.go开发语言: Go项目名称: amygdala代码行数: 884
184	// TODO: Remove this when https://github.com/kubernetes/kubernetes/issues/19018 is fixed.
185	OptionsExternalVersion *unversioned.GroupVersion
186
199	// match the keys in the Storage map above for subresources.
200	SubresourceGroupVersionKind map[string]unversioned.GroupVersionKind
201}
781		// Add a handler at /apis/<groupName> to enumerate all versions supported by this group.
782		apiVersionsForDiscovery := []unversioned.GroupVersionForDiscovery{}
783		for _, groupVersion := range apiGroupInfo.GroupMeta.GroupVersions {
784			apiVersionsForDiscovery = append(apiVersionsForDiscovery, unversioned.GroupVersionForDiscovery{
785				GroupVersion: groupVersion.String(),
788		}
789		preferedVersionForDiscovery := unversioned.GroupVersionForDiscovery{
790			GroupVersion: apiGroupInfo.GroupMeta.GroupVersion.String(),

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