From e0fd83096c4d64003ba5d8d981fc2045b45f32c5 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Thu, 19 Feb 2015 00:32:08 -0800 Subject: [PATCH] Rename type Port to ContainerPort Sadly I had to do this by hand - I just could not get gorename to fix up users of it. --- cmd/integration/integration.go | 2 +- pkg/api/types.go | 10 ++++---- pkg/api/v1beta1/defaults.go | 2 +- pkg/api/v1beta1/defaults_test.go | 2 +- pkg/api/v1beta1/types.go | 6 ++--- pkg/api/v1beta2/defaults.go | 2 +- pkg/api/v1beta2/defaults_test.go | 2 +- pkg/api/v1beta2/types.go | 6 ++--- pkg/api/v1beta3/defaults.go | 2 +- pkg/api/v1beta3/defaults_test.go | 2 +- pkg/api/v1beta3/types.go | 6 ++--- pkg/api/validation/validation.go | 6 ++--- pkg/api/validation/validation_test.go | 32 ++++++++++++------------ pkg/constraint/constraint_test.go | 2 +- pkg/kubectl/run.go | 2 +- pkg/kubectl/run_test.go | 2 +- pkg/kubelet/handlers_test.go | 4 +-- pkg/kubelet/kubelet.go | 4 +-- pkg/kubelet/kubelet_test.go | 18 ++++++------- pkg/kubelet/probe_test.go | 6 ++--- pkg/registry/controller/rest_test.go | 2 +- pkg/registry/pod/etcd/etcd_test.go | 10 ++++---- pkg/scheduler/scheduler_test.go | 4 +-- pkg/service/endpoints_controller_test.go | 6 ++--- test/e2e/events.go | 2 +- test/e2e/networking.go | 2 +- test/e2e/pods.go | 6 ++--- test/e2e/rc.go | 2 +- test/e2e/service.go | 2 +- 29 files changed, 77 insertions(+), 77 deletions(-) diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 08b6eaecb02..417081fbb05 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -538,7 +538,7 @@ func runServiceTest(client *client.Client) { { Name: "c1", Image: "foo", - Ports: []api.Port{ + Ports: []api.ContainerPort{ {ContainerPort: 1234}, }, ImagePullPolicy: "PullIfNotPresent", diff --git a/pkg/api/types.go b/pkg/api/types.go index b4a7b5f609b..c1b90936eab 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -239,8 +239,8 @@ type SecretSource struct { Target ObjectReference `json:"target"` } -// Port represents a network port in a single container -type Port struct { +// ContainerPort represents a network port in a single container +type ContainerPort struct { // Optional: If specified, this must be a DNS_LABEL. Each named port // in a pod must have a unique name. Name string `json:"name,omitempty"` @@ -346,9 +346,9 @@ type Container struct { // Optional: Defaults to whatever is defined in the image. Command []string `json:"command,omitempty"` // Optional: Defaults to Docker's default. - WorkingDir string `json:"workingDir,omitempty"` - Ports []Port `json:"ports,omitempty"` - Env []EnvVar `json:"env,omitempty"` + WorkingDir string `json:"workingDir,omitempty"` + Ports []ContainerPort `json:"ports,omitempty"` + Env []EnvVar `json:"env,omitempty"` // Compute resource requirements. Resources ResourceRequirements `json:"resources,omitempty"` VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"` diff --git a/pkg/api/v1beta1/defaults.go b/pkg/api/v1beta1/defaults.go index c833f9ffb60..87e66eb7232 100644 --- a/pkg/api/v1beta1/defaults.go +++ b/pkg/api/v1beta1/defaults.go @@ -32,7 +32,7 @@ func init() { } } }, - func(obj *Port) { + func(obj *ContainerPort) { if obj.Protocol == "" { obj.Protocol = ProtocolTCP } diff --git a/pkg/api/v1beta1/defaults_test.go b/pkg/api/v1beta1/defaults_test.go index d7372045247..1a4cd66995c 100644 --- a/pkg/api/v1beta1/defaults_test.go +++ b/pkg/api/v1beta1/defaults_test.go @@ -73,7 +73,7 @@ func TestSetDefaulPodSpec(t *testing.T) { func TestSetDefaultContainer(t *testing.T) { bp := ¤t.BoundPod{} bp.Spec.Containers = []current.Container{{}} - bp.Spec.Containers[0].Ports = []current.Port{{}} + bp.Spec.Containers[0].Ports = []current.ContainerPort{{}} obj2 := roundTrip(t, runtime.Object(bp)) bp2 := obj2.(*current.BoundPod) diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index 929ec181dd9..2918aa01ffe 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -161,8 +161,8 @@ type SecretSource struct { Target ObjectReference `json:"target" description:"target is a reference to a secret"` } -// Port represents a network port in a single container -type Port struct { +// ContainerPort represents a network port in a single container +type ContainerPort struct { // Optional: If specified, this must be a DNS_LABEL. Each named port // in a pod must have a unique name. Name string `json:"name,omitempty" description:"name for the port that can be referred to by services; must be a DNS_LABEL and unique without the pod"` @@ -283,7 +283,7 @@ type Container struct { Command []string `json:"command,omitempty" description:"command argv array; not executed within a shell; defaults to entrypoint or command in the image"` // Optional: Defaults to Docker's default. WorkingDir string `json:"workingDir,omitempty" description:"container's working directory; defaults to image's default"` - Ports []Port `json:"ports,omitempty" description:"list of ports to expose from the container"` + Ports []ContainerPort `json:"ports,omitempty" description:"list of ports to expose from the container"` Env []EnvVar `json:"env,omitempty" description:"list of environment variables to set in the container"` Resources ResourceRequirements `json:"resources,omitempty" description:"Compute Resources required by this container"` // Optional: Defaults to unlimited. diff --git a/pkg/api/v1beta2/defaults.go b/pkg/api/v1beta2/defaults.go index 9242bf3a323..0d5dc090e59 100644 --- a/pkg/api/v1beta2/defaults.go +++ b/pkg/api/v1beta2/defaults.go @@ -34,7 +34,7 @@ func init() { } } }, - func(obj *Port) { + func(obj *ContainerPort) { if obj.Protocol == "" { obj.Protocol = ProtocolTCP } diff --git a/pkg/api/v1beta2/defaults_test.go b/pkg/api/v1beta2/defaults_test.go index a73c83a93e6..12cf2aef5b2 100644 --- a/pkg/api/v1beta2/defaults_test.go +++ b/pkg/api/v1beta2/defaults_test.go @@ -73,7 +73,7 @@ func TestSetDefaulPodSpec(t *testing.T) { func TestSetDefaultContainer(t *testing.T) { bp := ¤t.BoundPod{} bp.Spec.Containers = []current.Container{{}} - bp.Spec.Containers[0].Ports = []current.Port{{}} + bp.Spec.Containers[0].Ports = []current.ContainerPort{{}} obj2 := roundTrip(t, runtime.Object(bp)) bp2 := obj2.(*current.BoundPod) diff --git a/pkg/api/v1beta2/types.go b/pkg/api/v1beta2/types.go index 314aa4f9d51..4f5ed064987 100644 --- a/pkg/api/v1beta2/types.go +++ b/pkg/api/v1beta2/types.go @@ -99,8 +99,8 @@ const ( ProtocolUDP Protocol = "UDP" ) -// Port represents a network port in a single container. -type Port struct { +// ContainerPort represents a network port in a single container. +type ContainerPort struct { // Optional: If specified, this must be a DNS_LABEL. Each named port // in a pod must have a unique name. Name string `json:"name,omitempty" description:"name for the port that can be referred to by services; must be a DNS_LABEL and unique without the pod"` @@ -242,7 +242,7 @@ type Container struct { Command []string `json:"command,omitempty" description:"command argv array; not executed within a shell; defaults to entrypoint or command in the image"` // Optional: Defaults to Docker's default. WorkingDir string `json:"workingDir,omitempty" description:"container's working directory; defaults to image's default"` - Ports []Port `json:"ports,omitempty" description:"list of ports to expose from the container"` + Ports []ContainerPort `json:"ports,omitempty" description:"list of ports to expose from the container"` Env []EnvVar `json:"env,omitempty" description:"list of environment variables to set in the container"` Resources ResourceRequirements `json:"resources,omitempty" description:"Compute Resources required by this container"` // Optional: Defaults to unlimited. diff --git a/pkg/api/v1beta3/defaults.go b/pkg/api/v1beta3/defaults.go index 3149601fb64..d136fd088ff 100644 --- a/pkg/api/v1beta3/defaults.go +++ b/pkg/api/v1beta3/defaults.go @@ -32,7 +32,7 @@ func init() { } } }, - func(obj *Port) { + func(obj *ContainerPort) { if obj.Protocol == "" { obj.Protocol = ProtocolTCP } diff --git a/pkg/api/v1beta3/defaults_test.go b/pkg/api/v1beta3/defaults_test.go index e1ebf388b1e..be2e3d5aab0 100644 --- a/pkg/api/v1beta3/defaults_test.go +++ b/pkg/api/v1beta3/defaults_test.go @@ -73,7 +73,7 @@ func TestSetDefaulPodSpec(t *testing.T) { func TestSetDefaultContainer(t *testing.T) { bp := ¤t.BoundPod{} bp.Spec.Containers = []current.Container{{}} - bp.Spec.Containers[0].Ports = []current.Port{{}} + bp.Spec.Containers[0].Ports = []current.ContainerPort{{}} obj2 := roundTrip(t, runtime.Object(bp)) bp2 := obj2.(*current.BoundPod) diff --git a/pkg/api/v1beta3/types.go b/pkg/api/v1beta3/types.go index 45408842681..a09358135d7 100644 --- a/pkg/api/v1beta3/types.go +++ b/pkg/api/v1beta3/types.go @@ -254,8 +254,8 @@ type SecretSource struct { Target ObjectReference `json:"target" description:"target is a reference to a secret"` } -// Port represents a network port in a single container. -type Port struct { +// ContainerPort represents a network port in a single container. +type ContainerPort struct { // Optional: If specified, this must be a DNS_LABEL. Each named port // in a pod must have a unique name. Name string `json:"name,omitempty"` @@ -367,7 +367,7 @@ type Container struct { Command []string `json:"command,omitempty"` // Optional: Defaults to Docker's default. WorkingDir string `json:"workingDir,omitempty"` - Ports []Port `json:"ports,omitempty"` + Ports []ContainerPort `json:"ports,omitempty"` Env []EnvVar `json:"env,omitempty"` Resources ResourceRequirements `json:"resources,omitempty" description:"Compute Resources required by this container"` VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"` diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 619d6cde9bf..62bc52b66fc 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -303,7 +303,7 @@ func validateSecretSource(secretSource *api.SecretSource) errs.ValidationErrorLi var supportedPortProtocols = util.NewStringSet(string(api.ProtocolTCP), string(api.ProtocolUDP)) -func validatePorts(ports []api.Port) errs.ValidationErrorList { +func validatePorts(ports []api.ContainerPort) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allNames := util.StringSet{} @@ -388,7 +388,7 @@ func validateProbe(probe *api.Probe) errs.ValidationErrorList { // AccumulateUniquePorts runs an extraction function on each Port of each Container, // accumulating the results and returning an error if any ports conflict. -func AccumulateUniquePorts(containers []api.Container, accumulator map[int]bool, extract func(*api.Port) int) errs.ValidationErrorList { +func AccumulateUniquePorts(containers []api.Container, accumulator map[int]bool, extract func(*api.ContainerPort) int) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} for ci, ctr := range containers { @@ -413,7 +413,7 @@ func AccumulateUniquePorts(containers []api.Container, accumulator map[int]bool, // a slice of containers. func checkHostPortConflicts(containers []api.Container) errs.ValidationErrorList { allPorts := map[int]bool{} - return AccumulateUniquePorts(containers, allPorts, func(p *api.Port) int { return p.HostPort }) + return AccumulateUniquePorts(containers, allPorts, func(p *api.ContainerPort) int { return p.HostPort }) } func validateExecAction(exec *api.ExecAction) errs.ValidationErrorList { diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 9e7e3c7647c..bcba1458e8b 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -195,7 +195,7 @@ func TestValidateVolumes(t *testing.T) { } func TestValidatePorts(t *testing.T) { - successCase := []api.Port{ + successCase := []api.ContainerPort{ {Name: "abc", ContainerPort: 80, HostPort: 80, Protocol: "TCP"}, {Name: "easy", ContainerPort: 82, Protocol: "TCP"}, {Name: "as", ContainerPort: 83, Protocol: "UDP"}, @@ -207,7 +207,7 @@ func TestValidatePorts(t *testing.T) { t.Errorf("expected success: %v", errs) } - nonCanonicalCase := []api.Port{ + nonCanonicalCase := []api.ContainerPort{ {ContainerPort: 80, Protocol: "TCP"}, } if errs := validatePorts(nonCanonicalCase); len(errs) != 0 { @@ -215,22 +215,22 @@ func TestValidatePorts(t *testing.T) { } errorCases := map[string]struct { - P []api.Port + P []api.ContainerPort T errors.ValidationErrorType F string D string }{ - "name > 63 characters": {[]api.Port{{Name: strings.Repeat("a", 64), ContainerPort: 80, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].name", dnsLabelErrorMsg}, - "name not a DNS label": {[]api.Port{{Name: "a.b.c", ContainerPort: 80, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].name", dnsLabelErrorMsg}, - "name not unique": {[]api.Port{ + "name > 63 characters": {[]api.ContainerPort{{Name: strings.Repeat("a", 64), ContainerPort: 80, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].name", dnsLabelErrorMsg}, + "name not a DNS label": {[]api.ContainerPort{{Name: "a.b.c", ContainerPort: 80, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].name", dnsLabelErrorMsg}, + "name not unique": {[]api.ContainerPort{ {Name: "abc", ContainerPort: 80, Protocol: "TCP"}, {Name: "abc", ContainerPort: 81, Protocol: "TCP"}, }, errors.ValidationErrorTypeDuplicate, "[1].name", ""}, - "zero container port": {[]api.Port{{ContainerPort: 0, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].containerPort", portRangeErrorMsg}, - "invalid container port": {[]api.Port{{ContainerPort: 65536, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].containerPort", portRangeErrorMsg}, - "invalid host port": {[]api.Port{{ContainerPort: 80, HostPort: 65536, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].hostPort", portRangeErrorMsg}, - "invalid protocol": {[]api.Port{{ContainerPort: 80, Protocol: "ICMP"}}, errors.ValidationErrorTypeNotSupported, "[0].protocol", ""}, - "protocol required": {[]api.Port{{Name: "abc", ContainerPort: 80}}, errors.ValidationErrorTypeRequired, "[0].protocol", ""}, + "zero container port": {[]api.ContainerPort{{ContainerPort: 0, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].containerPort", portRangeErrorMsg}, + "invalid container port": {[]api.ContainerPort{{ContainerPort: 65536, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].containerPort", portRangeErrorMsg}, + "invalid host port": {[]api.ContainerPort{{ContainerPort: 80, HostPort: 65536, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].hostPort", portRangeErrorMsg}, + "invalid protocol": {[]api.ContainerPort{{ContainerPort: 80, Protocol: "ICMP"}}, errors.ValidationErrorTypeNotSupported, "[0].protocol", ""}, + "protocol required": {[]api.ContainerPort{{Name: "abc", ContainerPort: 80}}, errors.ValidationErrorTypeRequired, "[0].protocol", ""}, } for k, v := range errorCases { errs := validatePorts(v.P) @@ -433,9 +433,9 @@ func TestValidateContainers(t *testing.T) { }, "zero-length image": {{Name: "abc", Image: "", ImagePullPolicy: "IfNotPresent"}}, "host port not unique": { - {Name: "abc", Image: "image", Ports: []api.Port{{ContainerPort: 80, HostPort: 80, Protocol: "TCP"}}, + {Name: "abc", Image: "image", Ports: []api.ContainerPort{{ContainerPort: 80, HostPort: 80, Protocol: "TCP"}}, ImagePullPolicy: "IfNotPresent"}, - {Name: "def", Image: "image", Ports: []api.Port{{ContainerPort: 81, HostPort: 80, Protocol: "TCP"}}, + {Name: "def", Image: "image", Ports: []api.ContainerPort{{ContainerPort: 81, HostPort: 80, Protocol: "TCP"}}, ImagePullPolicy: "IfNotPresent"}, }, "invalid env var name": { @@ -587,7 +587,7 @@ func TestValidateManifest(t *testing.T) { "memory": resource.MustParse("1"), }, }, - Ports: []api.Port{ + Ports: []api.ContainerPort{ {Name: "p1", ContainerPort: 80, HostPort: 8080, Protocol: "TCP"}, {Name: "p2", ContainerPort: 81, Protocol: "TCP"}, {ContainerPort: 82, Protocol: "TCP"}, @@ -934,7 +934,7 @@ func TestValidatePodUpdate(t *testing.T) { Containers: []api.Container{ { Image: "foo:V1", - Ports: []api.Port{ + Ports: []api.ContainerPort{ {HostPort: 8080, ContainerPort: 80}, }, }, @@ -947,7 +947,7 @@ func TestValidatePodUpdate(t *testing.T) { Containers: []api.Container{ { Image: "foo:V2", - Ports: []api.Port{ + Ports: []api.ContainerPort{ {HostPort: 8000, ContainerPort: 80}, }, }, diff --git a/pkg/constraint/constraint_test.go b/pkg/constraint/constraint_test.go index eae45221270..7f76ddf196b 100644 --- a/pkg/constraint/constraint_test.go +++ b/pkg/constraint/constraint_test.go @@ -26,7 +26,7 @@ import ( func containerWithHostPorts(ports ...int) api.Container { c := api.Container{} for _, p := range ports { - c.Ports = append(c.Ports, api.Port{HostPort: p}) + c.Ports = append(c.Ports, api.ContainerPort{HostPort: p}) } return c } diff --git a/pkg/kubectl/run.go b/pkg/kubectl/run.go index 3b8e69e1cf2..4e6933be39f 100644 --- a/pkg/kubectl/run.go +++ b/pkg/kubectl/run.go @@ -82,7 +82,7 @@ func (BasicReplicationController) Generate(params map[string]string) (runtime.Ob // Don't include the port if it was not specified. if port > 0 { - controller.Spec.Template.Spec.Containers[0].Ports = []api.Port{ + controller.Spec.Template.Spec.Containers[0].Ports = []api.ContainerPort{ { ContainerPort: port, }, diff --git a/pkg/kubectl/run_test.go b/pkg/kubectl/run_test.go index f009d81c4ea..760b74ca707 100644 --- a/pkg/kubectl/run_test.go +++ b/pkg/kubectl/run_test.go @@ -84,7 +84,7 @@ func TestGenerate(t *testing.T) { { Name: "foo", Image: "someimage", - Ports: []api.Port{ + Ports: []api.ContainerPort{ { ContainerPort: 80, }, diff --git a/pkg/kubelet/handlers_test.go b/pkg/kubelet/handlers_test.go index a211f84a5a3..8f4525a4e7c 100644 --- a/pkg/kubelet/handlers_test.go +++ b/pkg/kubelet/handlers_test.go @@ -38,7 +38,7 @@ func TestResolvePortString(t *testing.T) { expected := 80 name := "foo" container := &api.Container{ - Ports: []api.Port{ + Ports: []api.ContainerPort{ {Name: name, ContainerPort: expected}, }, } @@ -55,7 +55,7 @@ func TestResolvePortStringUnknown(t *testing.T) { expected := 80 name := "foo" container := &api.Container{ - Ports: []api.Port{ + Ports: []api.ContainerPort{ {Name: "bar", ContainerPort: expected}, }, } diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index a7fcc45a956..70df616a16d 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -917,7 +917,7 @@ const ( // createPodInfraContainer starts the pod infra container for a pod. Returns the docker container ID of the newly created container. func (kl *Kubelet) createPodInfraContainer(pod *api.BoundPod) (dockertools.DockerID, error) { - var ports []api.Port + var ports []api.ContainerPort // Docker only exports ports from the pod infra container. Let's // collect all of the relevant ports and export them. for _, container := range pod.Spec.Containers { @@ -1411,7 +1411,7 @@ func updateBoundPods(changed []api.BoundPod, current []api.BoundPod) []api.Bound func filterHostPortConflicts(pods []api.BoundPod) []api.BoundPod { filtered := []api.BoundPod{} ports := map[int]bool{} - extract := func(p *api.Port) int { return p.HostPort } + extract := func(p *api.ContainerPort) int { return p.HostPort } for i := range pods { pod := &pods[i] if errs := validation.AccumulateUniquePorts(pod.Spec.Containers, ports, extract); len(errs) != 0 { diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index b1e45591e3e..46d8fa67bea 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -1136,7 +1136,7 @@ func TestMakeVolumesAndBinds(t *testing.T) { func TestMakePortsAndBindings(t *testing.T) { container := api.Container{ - Ports: []api.Port{ + Ports: []api.ContainerPort{ { ContainerPort: 80, HostPort: 8080, @@ -1200,12 +1200,12 @@ func TestMakePortsAndBindings(t *testing.T) { func TestCheckHostPortConflicts(t *testing.T) { successCaseAll := []api.BoundPod{ - {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.Port{{HostPort: 80}}}}}}, - {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}}, - {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.Port{{HostPort: 82}}}}}}, + {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 80}}}}}}, + {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 81}}}}}}, + {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 82}}}}}}, } successCaseNew := api.BoundPod{ - Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.Port{{HostPort: 83}}}}}, + Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 83}}}}}, } expected := append(successCaseAll, successCaseNew) if actual := filterHostPortConflicts(expected); !reflect.DeepEqual(actual, expected) { @@ -1213,12 +1213,12 @@ func TestCheckHostPortConflicts(t *testing.T) { } failureCaseAll := []api.BoundPod{ - {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.Port{{HostPort: 80}}}}}}, - {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}}, - {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.Port{{HostPort: 82}}}}}}, + {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 80}}}}}}, + {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 81}}}}}}, + {Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 82}}}}}}, } failureCaseNew := api.BoundPod{ - Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}, + Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 81}}}}}, } if actual := filterHostPortConflicts(append(failureCaseAll, failureCaseNew)); !reflect.DeepEqual(failureCaseAll, actual) { t.Errorf("Expected %#v, Got %#v", expected, actual) diff --git a/pkg/kubelet/probe_test.go b/pkg/kubelet/probe_test.go index 4a22e5e8a64..988ebf55cdf 100644 --- a/pkg/kubelet/probe_test.go +++ b/pkg/kubelet/probe_test.go @@ -32,7 +32,7 @@ import ( func TestFindPortByName(t *testing.T) { container := api.Container{ - Ports: []api.Port{ + Ports: []api.ContainerPort{ { Name: "foo", HostPort: 8080, @@ -71,7 +71,7 @@ func TestGetURLParts(t *testing.T) { for _, test := range testCases { state := api.PodStatus{PodIP: "127.0.0.1"} container := api.Container{ - Ports: []api.Port{{Name: "found", HostPort: 93}}, + Ports: []api.ContainerPort{{Name: "found", HostPort: 93}}, LivenessProbe: &api.Probe{ Handler: api.Handler{ HTTPGet: test.probe, @@ -114,7 +114,7 @@ func TestGetTCPAddrParts(t *testing.T) { for _, test := range testCases { host := "1.2.3.4" container := api.Container{ - Ports: []api.Port{{Name: "found", HostPort: 93}}, + Ports: []api.ContainerPort{{Name: "found", HostPort: 93}}, LivenessProbe: &api.Probe{ Handler: api.Handler{ TCPSocket: test.probe, diff --git a/pkg/registry/controller/rest_test.go b/pkg/registry/controller/rest_test.go index 9616c654210..4db4c432da9 100644 --- a/pkg/registry/controller/rest_test.go +++ b/pkg/registry/controller/rest_test.go @@ -171,7 +171,7 @@ func TestControllerParsing(t *testing.T) { Containers: []api.Container{ { Image: "dockerfile/nginx", - Ports: []api.Port{ + Ports: []api.ContainerPort{ { ContainerPort: 80, HostPort: 8080, diff --git a/pkg/registry/pod/etcd/etcd_test.go b/pkg/registry/pod/etcd/etcd_test.go index cb9d1d4b4a1..449d99d9bf0 100644 --- a/pkg/registry/pod/etcd/etcd_test.go +++ b/pkg/registry/pod/etcd/etcd_test.go @@ -592,7 +592,7 @@ func TestResourceLocation(t *testing.T) { ObjectMeta: api.ObjectMeta{Name: "foo"}, Spec: api.PodSpec{ Containers: []api.Container{ - {Name: "ctr", Ports: []api.Port{{ContainerPort: 9376}}}, + {Name: "ctr", Ports: []api.ContainerPort{{ContainerPort: 9376}}}, }, }, }, @@ -604,7 +604,7 @@ func TestResourceLocation(t *testing.T) { ObjectMeta: api.ObjectMeta{Name: "foo"}, Spec: api.PodSpec{ Containers: []api.Container{ - {Name: "ctr", Ports: []api.Port{{ContainerPort: 9376}}}, + {Name: "ctr", Ports: []api.ContainerPort{{ContainerPort: 9376}}}, }, }, }, @@ -617,7 +617,7 @@ func TestResourceLocation(t *testing.T) { Spec: api.PodSpec{ Containers: []api.Container{ {Name: "ctr1"}, - {Name: "ctr2", Ports: []api.Port{{ContainerPort: 9376}}}, + {Name: "ctr2", Ports: []api.ContainerPort{{ContainerPort: 9376}}}, }, }, }, @@ -629,8 +629,8 @@ func TestResourceLocation(t *testing.T) { ObjectMeta: api.ObjectMeta{Name: "foo"}, Spec: api.PodSpec{ Containers: []api.Container{ - {Name: "ctr1", Ports: []api.Port{{ContainerPort: 9376}}}, - {Name: "ctr2", Ports: []api.Port{{ContainerPort: 1234}}}, + {Name: "ctr1", Ports: []api.ContainerPort{{ContainerPort: 9376}}}, + {Name: "ctr2", Ports: []api.ContainerPort{{ContainerPort: 1234}}}, }, }, }, diff --git a/pkg/scheduler/scheduler_test.go b/pkg/scheduler/scheduler_test.go index 7cd296e1592..e0c652a76f2 100644 --- a/pkg/scheduler/scheduler_test.go +++ b/pkg/scheduler/scheduler_test.go @@ -60,9 +60,9 @@ func (st *schedulerTester) expectFailure(pod api.Pod) { } func newPod(host string, hostPorts ...int) api.Pod { - networkPorts := []api.Port{} + networkPorts := []api.ContainerPort{} for _, port := range hostPorts { - networkPorts = append(networkPorts, api.Port{HostPort: port}) + networkPorts = append(networkPorts, api.ContainerPort{HostPort: port}) } return api.Pod{ Status: api.PodStatus{ diff --git a/pkg/service/endpoints_controller_test.go b/pkg/service/endpoints_controller_test.go index 9476f8df5ff..40c20494c4c 100644 --- a/pkg/service/endpoints_controller_test.go +++ b/pkg/service/endpoints_controller_test.go @@ -39,7 +39,7 @@ func newPodList(count int) *api.PodList { Spec: api.PodSpec{ Containers: []api.Container{ { - Ports: []api.Port{ + Ports: []api.ContainerPort{ { ContainerPort: 8080, }, @@ -69,7 +69,7 @@ func TestFindPort(t *testing.T) { Spec: api.PodSpec{ Containers: []api.Container{ { - Ports: []api.Port{ + Ports: []api.ContainerPort{ { Name: "foo", ContainerPort: 8080, @@ -90,7 +90,7 @@ func TestFindPort(t *testing.T) { Spec: api.PodSpec{ Containers: []api.Container{ { - Ports: []api.Port{}, + Ports: []api.ContainerPort{}, }, }, }, diff --git a/test/e2e/events.go b/test/e2e/events.go index 0f7f896f2ea..90f0de3a6b8 100644 --- a/test/e2e/events.go +++ b/test/e2e/events.go @@ -64,7 +64,7 @@ var _ = Describe("Events", func() { { Name: "p", Image: "kubernetes/serve_hostname", - Ports: []api.Port{{ContainerPort: 80}}, + Ports: []api.ContainerPort{{ContainerPort: 80}}, }, }, }, diff --git a/test/e2e/networking.go b/test/e2e/networking.go index 367d7300af4..34de4720cb9 100644 --- a/test/e2e/networking.go +++ b/test/e2e/networking.go @@ -109,7 +109,7 @@ var _ = Describe("Networking", func() { Name: "webserver", Image: "kubernetes/nettest:latest", Command: []string{"-service=" + name}, - Ports: []api.Port{{ContainerPort: 8080}}, + Ports: []api.ContainerPort{{ContainerPort: 8080}}, }, }, }, diff --git a/test/e2e/pods.go b/test/e2e/pods.go index 464e7f77591..35b2e3bc02c 100644 --- a/test/e2e/pods.go +++ b/test/e2e/pods.go @@ -108,7 +108,7 @@ var _ = Describe("Pods", func() { { Name: "nginx", Image: "dockerfile/nginx", - Ports: []api.Port{{ContainerPort: 80}}, + Ports: []api.ContainerPort{{ContainerPort: 80}}, LivenessProbe: &api.Probe{ Handler: api.Handler{ HTTPGet: &api.HTTPGetAction{ @@ -167,7 +167,7 @@ var _ = Describe("Pods", func() { { Name: "nginx", Image: "dockerfile/nginx", - Ports: []api.Port{{ContainerPort: 80}}, + Ports: []api.ContainerPort{{ContainerPort: 80}}, LivenessProbe: &api.Probe{ Handler: api.Handler{ HTTPGet: &api.HTTPGetAction{ @@ -238,7 +238,7 @@ var _ = Describe("Pods", func() { { Name: "srv", Image: "kubernetes/serve_hostname", - Ports: []api.Port{{ContainerPort: 9376}}, + Ports: []api.ContainerPort{{ContainerPort: 9376}}, }, }, }, diff --git a/test/e2e/rc.go b/test/e2e/rc.go index cb9e8a3a61c..d0da049edbc 100644 --- a/test/e2e/rc.go +++ b/test/e2e/rc.go @@ -86,7 +86,7 @@ func ServeImageOrFail(c *client.Client, test string, image string) { { Name: name, Image: image, - Ports: []api.Port{{ContainerPort: 9376, HostPort: 8080}}, + Ports: []api.ContainerPort{{ContainerPort: 9376, HostPort: 8080}}, }, }, }, diff --git a/test/e2e/service.go b/test/e2e/service.go index 7a9ed995947..9a9408fca8c 100644 --- a/test/e2e/service.go +++ b/test/e2e/service.go @@ -296,7 +296,7 @@ func addEndpointPodOrFail(c *client.Client, ns, name string, labels map[string]s { Name: "test", Image: "kubernetes/pause", - Ports: []api.Port{{ContainerPort: 80}}, + Ports: []api.ContainerPort{{ContainerPort: 80}}, }, }, },