k8s/io/kubernetes/pkg/api/testapi.Version 示例代码

2022-03-03

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

示例1:
endpoints_controller_test.go开发语言: Go项目名称: kubernetes代码行数: 492
36		pods = append(pods, api.Pod{
37			TypeMeta:   api.TypeMeta{APIVersion: testapi.Version()},
38			ObjectMeta: api.ObjectMeta{Name: fmt.Sprintf("pod%d", i)},
61	return &api.PodList{
62		TypeMeta: api.TypeMeta{APIVersion: testapi.Version(), Kind: "PodList"},
63		Items:    pods,
193	mux := http.NewServeMux()
194	mux.Handle("/api/"+testapi.Version()+"/pods", &fakePodHandler)
195	mux.Handle("/api/"+testapi.Version()+"/services", &fakeServiceHandler)
196	mux.Handle("/api/"+testapi.Version()+"/endpoints", &fakeEndpointsHandler)
197	mux.Handle("/api/"+testapi.Version()+"/endpoints/", &fakeEndpointsHandler)
210	defer testServer.Close()
211	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
212	endpoints := NewEndpointController(client)
示例2:
replication_controller_test.go开发语言: Go项目名称: kubernetes代码行数: 375
39func makeNamespaceURL(namespace, suffix string) string {
40	if !(testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2") {
41		return makeURL("/ns/" + namespace + suffix)
46func makeURL(suffix string) string {
47	return path.Join("/api", testapi.Version(), suffix)
48}
125	defer testServer.Close()
126	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
127
146	defer testServer.Close()
147	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
148
167	defer testServer.Close()
168	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
169
示例3:
factory_test.go开发语言: Go项目名称: kubernetes代码行数: 376
42	server := httptest.NewServer(&handler)
43	client := client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
44	factory := ConfigFactory{client}
55		{
56			location: "/api/" + testapi.Version() + "/minions?fields=",
57			factory:  factory.createMinionLW,
60		{
61			location: "/api/" + testapi.Version() + "/pods?fields=DesiredState.Host!%3D",
62			factory:  factory.createAssignedPodLW,
65		{
66			location: "/api/" + testapi.Version() + "/pods?fields=DesiredState.Host%3D",
67			factory:  factory.createUnassignedPodLW,
77		server := httptest.NewServer(&handler)
78		factory.Client = client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
79		// This test merely tests that the correct request is made.
示例4:
restclient_test.go开发语言: Go项目名称: kubernetes代码行数: 299
74	}
75	if _, err := RESTClientFor(&Config{Host: "127.0.0.1", Version: testapi.Version(), Codec: testapi.Codec()}); err != nil {
76		t.Errorf("unexpected error: %v", err)
128		Host:           testServer.URL,
129		Version:        testapi.Version(),
130		Codec:          testapi.Codec(),
158		Host:           testServer.URL,
159		Version:        testapi.Version(),
160		Codec:          testapi.Codec(),
184	}
185	fakeHandler.ValidateRequest(t, "/"+testapi.Version()+"/test", "GET", nil)
186}
199		Host:           testServer.URL,
200		Version:        testapi.Version(),
201		Codec:          testapi.Codec(),
示例5:
auth_test.go开发语言: Go项目名称: kubernetes代码行数: 1094
56	requireEtcd()
57	if api.PreV1Beta3(testapi.Version()) {
58		nodeResourceName = "minions"
379
380	helper, err := master.NewEtcdHelper(newEtcdClient(), testapi.Version())
381	if err != nil {
519
520	helper, err := master.NewEtcdHelper(newEtcdClient(), testapi.Version())
521	if err != nil {
586
587	helper, err := master.NewEtcdHelper(newEtcdClient(), testapi.Version())
588	if err != nil {
675
676	helper, err := master.NewEtcdHelper(newEtcdClient(), testapi.Version())
677	if err != nil {
示例6:
replication_controller_test.go开发语言: Go项目名称: kubernetes代码行数: 357
42func makeURL(suffix string) string {
43	return path.Join("/api", testapi.Version(), suffix)
44}
117	testServer := httptest.NewServer(&fakeHandler)
118	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
119
137	testServer := httptest.NewServer(&fakeHandler)
138	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
139
157	testServer := httptest.NewServer(&fakeHandler)
158	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
159
178	testServer := httptest.NewServer(&fakeHandler)
179	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
180
示例7:
endpoints_controller_test.go开发语言: Go项目名称: kubernetes代码行数: 293
38				ID:         fmt.Sprintf("pod%d", i),
39				APIVersion: testapi.Version(),
40			},
59	return api.PodList{
60		TypeMeta: api.TypeMeta{APIVersion: testapi.Version(), Kind: "PodList"},
61		Items:    pods,
144	mux := http.NewServeMux()
145	mux.Handle("/api/"+testapi.Version()+"/pods", &fakePodHandler)
146	mux.Handle("/api/"+testapi.Version()+"/services", &fakeServiceHandler)
147	mux.Handle("/api/"+testapi.Version()+"/endpoints", &fakeEndpointsHandler)
148	mux.Handle("/api/"+testapi.Version()+"/endpoints/", &fakeEndpointsHandler)
160		serverResponse{http.StatusOK, api.Endpoints{}})
161	client := client.NewOrDie(&client.Config{Host: testServer.URL, Version: testapi.Version()})
162	endpoints := NewEndpointController(client)
示例8:
factory_test.go开发语言: Go项目名称: kubernetes代码行数: 362
43	defer server.Close()
44	client := client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
45	factory := NewConfigFactory(client)
161		// FakeHandler musn't be sent requests other than the one you want to test.
162		mux.Handle("/api/"+testapi.Version()+"/minions", &handler)
163		server := httptest.NewServer(mux)
164		defer server.Close()
165		client := client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
166		cf := NewConfigFactory(client)
172		}
173		handler.ValidateRequest(t, "/api/"+testapi.Version()+"/minions", "GET", nil)
174
181func makeNamespaceURL(namespace, suffix string, isClient bool) string {
182	if !(testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2") {
183		return makeURL("/ns/" + namespace + suffix)
示例9:
listwatch_test.go开发语言: Go项目名称: kubernetes代码行数: 172
41func buildResourcePath(prefix, namespace, resource string) string {
42	base := path.Join("/api", testapi.Version(), prefix)
43	if len(namespace) > 0 {
44		if !(testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2") {
45			base = path.Join(base, "namespaces", namespace)
60	}
61	if testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2" {
62		v.Set("namespace", namespace)
107		defer server.Close()
108		client := client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
109		lw := NewListWatchFromClient(client, item.resource, item.namespace, item.fieldSelector)
164		defer server.Close()
165		client := client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
166		lw := NewListWatchFromClient(client, item.resource, item.namespace, item.fieldSelector)
示例10:
rest_test.go开发语言: Go项目名称: kubernetes代码行数: 277
168			UID:             "long uid string",
169			APIVersion:      testapi.Version(),
170			ResourceVersion: "0",
187		"involvedObject.uid":             "long uid string",
188		"involvedObject.apiVersion":      testapi.Version(),
189		"involvedObject.resourceVersion": "0",
205			UID:             "long uid string",
206			APIVersion:      testapi.Version(),
207			ResourceVersion: "0",
217			UID:             "other long uid string",
218			APIVersion:      testapi.Version(),
219			ResourceVersion: "0",
229			UID:             "yet another long uid string",
230			APIVersion:      testapi.Version(),
231			ResourceVersion: "0",

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