當前位置: 首頁>>代碼示例>>Golang>>正文


Golang simple.BuildQueryValues函數代碼示例

本文整理匯總了Golang中github.com/ttysteale/kubernetes-api/client/unversioned/testclient/simple.BuildQueryValues函數的典型用法代碼示例。如果您正苦於以下問題:Golang BuildQueryValues函數的具體用法?Golang BuildQueryValues怎麽用?Golang BuildQueryValues使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BuildQueryValues函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestServiceProxyGet

func TestServiceProxyGet(t *testing.T) {
	body := "OK"
	ns := api.NamespaceDefault
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   testapi.Default.ResourcePath("services", ns, "service-1") + "/proxy/foo",
			Query:  simple.BuildQueryValues(url.Values{"param-name": []string{"param-value"}}),
		},
		Response: simple.Response{StatusCode: 200, RawBody: &body},
	}
	response, err := c.Setup(t).Services(ns).ProxyGet("", "service-1", "", "foo", map[string]string{"param-name": "param-value"}).DoRaw()
	defer c.Close()
	c.ValidateRaw(t, response, err)

	// With scheme and port specified
	c = &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   testapi.Default.ResourcePath("services", ns, "https:service-1:my-port") + "/proxy/foo",
			Query:  simple.BuildQueryValues(url.Values{"param-name": []string{"param-value"}}),
		},
		Response: simple.Response{StatusCode: 200, RawBody: &body},
	}
	response, err = c.Setup(t).Services(ns).ProxyGet("https", "service-1", "my-port", "foo", map[string]string{"param-name": "param-value"}).DoRaw()
	defer c.Close()
	c.ValidateRaw(t, response, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:28,代碼來源:services_test.go

示例2: testGetJob

func testGetJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   group.ResourcePath(getJobsResourceName(), ns, "foo"),
			Query:  simple.BuildQueryValues(nil),
		},
		Response: simple.Response{
			StatusCode: 200,
			Body: &batch.Job{
				ObjectMeta: api.ObjectMeta{
					Name: "foo",
					Labels: map[string]string{
						"foo":  "bar",
						"name": "baz",
					},
				},
				Spec: batch.JobSpec{
					Template: api.PodTemplateSpec{},
				},
			},
		},
		ResourceGroup: resourceGroup,
	}
	receivedJob, err := getJobClient(t, c, ns, resourceGroup).Get("foo")
	defer c.Close()
	c.Validate(t, receivedJob, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:29,代碼來源:jobs_test.go

示例3: TestHorizontalPodAutoscalerList

func TestHorizontalPodAutoscalerList(t *testing.T) {
	ns := api.NamespaceDefault
	horizontalPodAutoscalerList := &autoscaling.HorizontalPodAutoscalerList{
		Items: []autoscaling.HorizontalPodAutoscaler{
			{
				ObjectMeta: api.ObjectMeta{
					Name:      "foo",
					Namespace: ns,
				},
			},
		},
	}
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
			Query:  simple.BuildQueryValues(nil),
			Body:   nil,
		},
		Response:      simple.Response{StatusCode: 200, Body: horizontalPodAutoscalerList},
		ResourceGroup: autoscaling.GroupName,
	}
	response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).List(api.ListOptions{})
	defer c.Close()
	c.Validate(t, response, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:26,代碼來源:horizontalpodautoscaler_test.go

示例4: TestListPodsLabels

func TestListPodsLabels(t *testing.T) {
	ns := api.NamespaceDefault
	labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   testapi.Default.ResourcePath("pods", ns, ""),
			Query:  simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
		Response: simple.Response{
			StatusCode: http.StatusOK,
			Body: &api.PodList{
				Items: []api.Pod{
					{
						Status: api.PodStatus{
							Phase: api.PodRunning,
						},
						ObjectMeta: api.ObjectMeta{
							Labels: map[string]string{
								"foo":  "bar",
								"name": "baz",
							},
						},
					},
				},
			},
		},
	}
	c.Setup(t)
	defer c.Close()
	c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels
	selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector()
	options := api.ListOptions{LabelSelector: selector}
	receivedPodList, err := c.Pods(ns).List(options)
	c.Validate(t, receivedPodList, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:35,代碼來源:pods_test.go

示例5: TestHorizontalPodAutoscalerCreate

func TestHorizontalPodAutoscalerCreate(t *testing.T) {
	ns := api.NamespaceDefault
	horizontalPodAutoscaler := autoscaling.HorizontalPodAutoscaler{
		ObjectMeta: api.ObjectMeta{
			Name:      "abc",
			Namespace: ns,
		},
	}
	c := &simple.Client{
		Request: simple.Request{
			Method: "POST",
			Path:   testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
			Query:  simple.BuildQueryValues(nil),
			Body:   &horizontalPodAutoscaler,
		},
		Response:      simple.Response{StatusCode: 200, Body: &horizontalPodAutoscaler},
		ResourceGroup: autoscaling.GroupName,
	}

	response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).Create(&horizontalPodAutoscaler)
	defer c.Close()
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	c.Validate(t, response, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:26,代碼來源:horizontalpodautoscaler_test.go

示例6: TestListServices

func TestListServices(t *testing.T) {
	ns := api.NamespaceDefault
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   testapi.Default.ResourcePath("services", ns, ""),
			Query:  simple.BuildQueryValues(nil)},
		Response: simple.Response{StatusCode: 200,
			Body: &api.ServiceList{
				Items: []api.Service{
					{
						ObjectMeta: api.ObjectMeta{
							Name: "name",
							Labels: map[string]string{
								"foo":  "bar",
								"name": "baz",
							},
						},
						Spec: api.ServiceSpec{
							Selector: map[string]string{
								"one": "two",
							},
						},
					},
				},
			},
		},
	}
	receivedServiceList, err := c.Setup(t).Services(ns).List(api.ListOptions{})
	defer c.Close()
	t.Logf("received services: %v %#v", err, receivedServiceList)
	c.Validate(t, receivedServiceList, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:33,代碼來源:services_test.go

示例7: TestGetService

func TestGetService(t *testing.T) {
	ns := api.NamespaceDefault
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   testapi.Default.ResourcePath("services", ns, "1"),
			Query:  simple.BuildQueryValues(nil)},
		Response: simple.Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
	}
	response, err := c.Setup(t).Services(ns).Get("1")
	defer c.Close()
	c.Validate(t, response, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:13,代碼來源:services_test.go

示例8: testDeleteJob

func testDeleteJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	c := &simple.Client{
		Request: simple.Request{
			Method: "DELETE",
			Path:   group.ResourcePath(getJobsResourceName(), ns, "foo"),
			Query:  simple.BuildQueryValues(nil),
		},
		Response:      simple.Response{StatusCode: 200},
		ResourceGroup: resourceGroup,
	}
	err := getJobClient(t, c, ns, resourceGroup).Delete("foo", nil)
	defer c.Close()
	c.Validate(t, nil, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:15,代碼來源:jobs_test.go

示例9: TestUpdateServiceStatus

func TestUpdateServiceStatus(t *testing.T) {
	ns := api.NamespaceDefault
	lbStatus := api.LoadBalancerStatus{
		Ingress: []api.LoadBalancerIngress{
			{IP: "127.0.0.1"},
		},
	}
	requestService := &api.Service{
		ObjectMeta: api.ObjectMeta{
			Name:            "foo",
			Namespace:       ns,
			ResourceVersion: "1",
		},
		Status: api.ServiceStatus{
			LoadBalancer: lbStatus,
		},
	}
	c := &simple.Client{
		Request: simple.Request{
			Method: "PUT",
			Path:   testapi.Default.ResourcePath("services", ns, "foo") + "/status",
			Query:  simple.BuildQueryValues(nil),
		},
		Response: simple.Response{
			StatusCode: 200,
			Body: &api.Service{
				ObjectMeta: api.ObjectMeta{
					Name: "foo",
					Labels: map[string]string{
						"foo":  "bar",
						"name": "baz",
					},
				},
				Spec: api.ServiceSpec{},
				Status: api.ServiceStatus{
					LoadBalancer: lbStatus,
				},
			},
		},
	}
	receivedService, err := c.Setup(t).Services(ns).UpdateStatus(requestService)
	defer c.Close()
	c.Validate(t, receivedService, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:44,代碼來源:services_test.go

示例10: testCreateJob

func testCreateJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	requestJob := &batch.Job{
		ObjectMeta: api.ObjectMeta{
			Name:      "foo",
			Namespace: ns,
		},
	}
	c := &simple.Client{
		Request: simple.Request{
			Method: "POST",
			Path:   group.ResourcePath(getJobsResourceName(), ns, ""),
			Body:   requestJob,
			Query:  simple.BuildQueryValues(nil),
		},
		Response: simple.Response{
			StatusCode: 200,
			Body: &batch.Job{
				ObjectMeta: api.ObjectMeta{
					Name: "foo",
					Labels: map[string]string{
						"foo":  "bar",
						"name": "baz",
					},
				},
				Spec: batch.JobSpec{
					Template: api.PodTemplateSpec{},
				},
			},
		},
		ResourceGroup: resourceGroup,
	}
	receivedJob, err := getJobClient(t, c, ns, resourceGroup).Create(requestJob)
	defer c.Close()
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	c.Validate(t, receivedJob, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:39,代碼來源:jobs_test.go

示例11: TestListServicesLabels

func TestListServicesLabels(t *testing.T) {
	ns := api.NamespaceDefault
	labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   testapi.Default.ResourcePath("services", ns, ""),
			Query:  simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
		Response: simple.Response{StatusCode: 200,
			Body: &api.ServiceList{
				Items: []api.Service{
					{
						ObjectMeta: api.ObjectMeta{
							Name: "name",
							Labels: map[string]string{
								"foo":  "bar",
								"name": "baz",
							},
						},
						Spec: api.ServiceSpec{
							Selector: map[string]string{
								"one": "two",
							},
						},
					},
				},
			},
		},
	}
	c.Setup(t)
	defer c.Close()
	c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels
	selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector()
	options := api.ListOptions{LabelSelector: selector}
	receivedServiceList, err := c.Services(ns).List(options)
	c.Validate(t, receivedServiceList, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:37,代碼來源:services_test.go

示例12: TestUpdateReplicaSet

func TestUpdateReplicaSet(t *testing.T) {
	ns := api.NamespaceDefault
	requestRS := &extensions.ReplicaSet{
		ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
	}
	c := &simple.Client{
		Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getReplicaSetResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
		Response: simple.Response{
			StatusCode: 200,
			Body: &extensions.ReplicaSet{
				ObjectMeta: api.ObjectMeta{
					Name: "foo",
					Labels: map[string]string{
						"foo":  "bar",
						"name": "baz",
					},
				},
				Spec: extensions.ReplicaSetSpec{
					Replicas: 2,
					Template: api.PodTemplateSpec{},
				},
			},
		},
	}
	receivedRS, err := c.Setup(t).Extensions().ReplicaSets(ns).Update(requestRS)
	c.Validate(t, receivedRS, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:27,代碼來源:replica_sets_test.go

示例13: TestHorizontalPodAutoscalerDelete

func TestHorizontalPodAutoscalerDelete(t *testing.T) {
	ns := api.NamespaceDefault
	c := &simple.Client{
		Request:       simple.Request{Method: "DELETE", Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
		Response:      simple.Response{StatusCode: 200},
		ResourceGroup: autoscaling.GroupName,
	}
	err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).Delete("foo", nil)
	defer c.Close()
	c.Validate(t, nil, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:11,代碼來源:horizontalpodautoscaler_test.go

示例14: TestHorizontalPodAutoscalerUpdateStatus

func TestHorizontalPodAutoscalerUpdateStatus(t *testing.T) {
	ns := api.NamespaceDefault
	horizontalPodAutoscaler := &autoscaling.HorizontalPodAutoscaler{
		ObjectMeta: api.ObjectMeta{
			Name:            "abc",
			Namespace:       ns,
			ResourceVersion: "1",
		},
	}
	c := &simple.Client{
		Request:       simple.Request{Method: "PUT", Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "abc") + "/status", Query: simple.BuildQueryValues(nil)},
		Response:      simple.Response{StatusCode: 200, Body: horizontalPodAutoscaler},
		ResourceGroup: autoscaling.GroupName,
	}
	response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).UpdateStatus(horizontalPodAutoscaler)
	defer c.Close()
	c.Validate(t, response, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:18,代碼來源:horizontalpodautoscaler_test.go

示例15: TestDeleteThirdPartyResource

func TestDeleteThirdPartyResource(t *testing.T) {
	c := &simple.Client{
		Request:  simple.Request{Method: "DELETE", Path: testapi.Extensions.ResourcePath(getThirdPartyResourceName(), "", "foo"), Query: simple.BuildQueryValues(nil)},
		Response: simple.Response{StatusCode: 200},
	}
	err := c.Setup(t).Extensions().ThirdPartyResources().Delete("foo")
	defer c.Close()
	c.Validate(t, nil, err)
}
開發者ID:ttysteale,項目名稱:kubernetes-api,代碼行數:9,代碼來源:thirdpartyresources_test.go


注:本文中的github.com/ttysteale/kubernetes-api/client/unversioned/testclient/simple.BuildQueryValues函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。