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

2022-03-03

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

示例1:
zz_generated.conversion.go开发语言: Go项目名称: ddysher代码行数: 5173
877	out.WorkingDir = in.WorkingDir
878	out.Ports = *(*[]api.ContainerPort)(unsafe.Pointer(&in.Ports))
879	out.EnvFrom = *(*[]api.EnvFromSource)(unsafe.Pointer(&in.EnvFrom))
959
960func autoConvert_v1_ContainerPort_To_api_ContainerPort(in *v1.ContainerPort, out *api.ContainerPort, s conversion.Scope) error {
961	out.Name = in.Name
969// Convert_v1_ContainerPort_To_api_ContainerPort is an autogenerated conversion function.
970func Convert_v1_ContainerPort_To_api_ContainerPort(in *v1.ContainerPort, out *api.ContainerPort, s conversion.Scope) error {
971	return autoConvert_v1_ContainerPort_To_api_ContainerPort(in, out, s)
973
974func autoConvert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, out *v1.ContainerPort, s conversion.Scope) error {
975	out.Name = in.Name
983// Convert_api_ContainerPort_To_v1_ContainerPort is an autogenerated conversion function.
984func Convert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, out *v1.ContainerPort, s conversion.Scope) error {
985	return autoConvert_api_ContainerPort_To_v1_ContainerPort(in, out, s)
示例2:
zz_generated.conversion.go开发语言: Go项目名称: detiber代码行数: 5169
877	out.WorkingDir = in.WorkingDir
878	out.Ports = *(*[]api.ContainerPort)(unsafe.Pointer(&in.Ports))
879	out.EnvFrom = *(*[]api.EnvFromSource)(unsafe.Pointer(&in.EnvFrom))
959
960func autoConvert_v1_ContainerPort_To_api_ContainerPort(in *v1.ContainerPort, out *api.ContainerPort, s conversion.Scope) error {
961	out.Name = in.Name
969// Convert_v1_ContainerPort_To_api_ContainerPort is an autogenerated conversion function.
970func Convert_v1_ContainerPort_To_api_ContainerPort(in *v1.ContainerPort, out *api.ContainerPort, s conversion.Scope) error {
971	return autoConvert_v1_ContainerPort_To_api_ContainerPort(in, out, s)
973
974func autoConvert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, out *v1.ContainerPort, s conversion.Scope) error {
975	out.Name = in.Name
983// Convert_api_ContainerPort_To_v1_ContainerPort is an autogenerated conversion function.
984func Convert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, out *v1.ContainerPort, s conversion.Scope) error {
985	return autoConvert_api_ContainerPort_To_v1_ContainerPort(in, out, s)
示例3:
validation_test.go开发语言: Go项目名称: amygdala代码行数: 5291
799func TestValidatePorts(t *testing.T) {
800	successCase := []api.ContainerPort{
801		{Name: "abc", ContainerPort: 80, HostPort: 80, Protocol: "TCP"},
810
811	nonCanonicalCase := []api.ContainerPort{
812		{ContainerPort: 80, Protocol: "TCP"},
818	errorCases := map[string]struct {
819		P []api.ContainerPort
820		T field.ErrorType
824		"name > 15 characters": {
825			[]api.ContainerPort{{Name: strings.Repeat("a", 16), ContainerPort: 80, Protocol: "TCP"}},
826			field.ErrorTypeInvalid,
829		"name not a IANA svc name ": {
830			[]api.ContainerPort{{Name: "a.b.c", ContainerPort: 80, Protocol: "TCP"}},
831			field.ErrorTypeInvalid,
示例4:
pods.go开发语言: Go项目名称: kubernetes代码行数: 631
160						Image: "gcr.io/google_containers/nginx:1.7.9",
161						Ports: []api.ContainerPort{{ContainerPort: 80}},
162						LivenessProbe: &api.Probe{
260						Image: "gcr.io/google_containers/nginx:1.7.9",
261						Ports: []api.ContainerPort{{ContainerPort: 80}},
262						LivenessProbe: &api.Probe{
330						Image: "gcr.io/google_containers/serve_hostname:1.1",
331						Ports: []api.ContainerPort{{ContainerPort: 9376}},
332					},
示例5:
cache_test.go开发语言: Go项目名称: amygdala代码行数: 482
35	testPods := []*api.Pod{
36		makeBasePod(nodeName, "test", "100m", "500", []api.ContainerPort{{HostPort: 80}}),
37		makeBasePod(nodeName, "test-1", "100m", "500", []api.ContainerPort{{HostPort: 80}}),
38		makeBasePod(nodeName, "test-2", "200m", "1Ki", []api.ContainerPort{{HostPort: 8080}}),
39		makeBasePod(nodeName, "test-nonzero", "", "", []api.ContainerPort{{HostPort: 80}}),
110	testPods := []*api.Pod{
111		makeBasePod(nodeName, "test-1", "100m", "500", []api.ContainerPort{{HostPort: 80}}),
112		makeBasePod(nodeName, "test-2", "200m", "1Ki", []api.ContainerPort{{HostPort: 8080}}),
170	testPods := []*api.Pod{
171		makeBasePod(nodeName, "test-1", "100m", "500", []api.ContainerPort{{HostPort: 80}}),
172		makeBasePod(nodeName, "test-2", "200m", "1Ki", []api.ContainerPort{{HostPort: 8080}}),
219	ttl := 10 * time.Second
220	basePod := makeBasePod(nodeName, "test", "100m", "500", []api.ContainerPort{{HostPort: 80}})
221	tests := []struct {
示例6:
storage_test.go开发语言: Go项目名称: ddysher代码行数: 898
283					Containers: []api.Container{
284						{Name: "ctr", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
285					},
296					Containers: []api.Container{
297						{Name: "ctr", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
298					},
310						{Name: "ctr1"},
311						{Name: "ctr2", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
312					},
323					Containers: []api.Container{
324						{Name: "ctr1", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
325						{Name: "ctr2", Ports: []api.ContainerPort{{ContainerPort: 1234}}},
422				{Name: "ctr1"},
423				{Name: "ctr2", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
424			},
示例7:
storage_test.go开发语言: Go项目名称: detiber代码行数: 898
283					Containers: []api.Container{
284						{Name: "ctr", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
285					},
296					Containers: []api.Container{
297						{Name: "ctr", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
298					},
310						{Name: "ctr1"},
311						{Name: "ctr2", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
312					},
323					Containers: []api.Container{
324						{Name: "ctr1", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
325						{Name: "ctr2", Ports: []api.ContainerPort{{ContainerPort: 1234}}},
422				{Name: "ctr1"},
423				{Name: "ctr2", Ports: []api.ContainerPort{{ContainerPort: 9376}}},
424			},
示例8:
service.go开发语言: Go项目名称: amygdala代码行数: 1922
124
125		createPodOrFail(c, ns, name1, labels, []api.ContainerPort{{ContainerPort: 80}})
126		names[name1] = true
128
129		createPodOrFail(c, ns, name2, labels, []api.ContainerPort{{ContainerPort: 80}})
130		names[name2] = true
192
193		containerPorts1 := []api.ContainerPort{
194			{
198		}
199		containerPorts2 := []api.ContainerPort{
200			{
1068
1069func createPodOrFail(c *client.Client, ns, name string, labels map[string]string, containerPorts []api.ContainerPort) {
1070	By(fmt.Sprintf("creating pod %s in namespace %s", name, ns))
示例9:
conversion_generated.go开发语言: Go项目名称: amygdala代码行数: 6785
421
422func autoConvert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, out *ContainerPort, s conversion.Scope) error {
423	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
424		defaulting.(func(*api.ContainerPort))(in)
425	}
433
434func Convert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, out *ContainerPort, s conversion.Scope) error {
435	return autoConvert_api_ContainerPort_To_v1_ContainerPort(in, out, s)
3625	if in.Ports != nil {
3626		out.Ports = make([]api.ContainerPort, len(in.Ports))
3627		for i := range in.Ports {
3725
3726func autoConvert_v1_ContainerPort_To_api_ContainerPort(in *ContainerPort, out *api.ContainerPort, s conversion.Scope) error {
3727	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
示例10:
conversion_generated.go开发语言: Go项目名称: amygdala代码行数: 3065
276
277func autoConvert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, out *v1.ContainerPort, s conversion.Scope) error {
278	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
279		defaulting.(func(*api.ContainerPort))(in)
280	}
288
289func Convert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, out *v1.ContainerPort, s conversion.Scope) error {
290	return autoConvert_api_ContainerPort_To_v1_ContainerPort(in, out, s)
1494	if in.Ports != nil {
1495		out.Ports = make([]api.ContainerPort, len(in.Ports))
1496		for i := range in.Ports {
1574
1575func autoConvert_v1_ContainerPort_To_api_ContainerPort(in *v1.ContainerPort, out *api.ContainerPort, s conversion.Scope) error {
1576	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {

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