diff --git a/contrib/mesos/pkg/service/endpoints_controller.go b/contrib/mesos/pkg/service/endpoints_controller.go index c8ae99f18da..ac961e16141 100644 --- a/contrib/mesos/pkg/service/endpoints_controller.go +++ b/contrib/mesos/pkg/service/endpoints_controller.go @@ -427,11 +427,11 @@ func findPort(pod *api.Pod, svcPort *api.ServicePort) (int, int, error) { // it actually maps to a host-port assigned to the pod. upstream // doesn't check this and happily returns the container port spec'd // in the service, but that doesn't align w/ mesos port mgmt. - p := portName.IntVal + p := portName.IntValue() for _, container := range pod.Spec.Containers { for _, port := range container.Ports { - if port.ContainerPort == int(p) && port.Protocol == svcPort.Protocol { - hostPort, err := findMappedPort(pod, port.Protocol, int(p)) + if port.ContainerPort == p && port.Protocol == svcPort.Protocol { + hostPort, err := findMappedPort(pod, port.Protocol, p) return hostPort, port.ContainerPort, err } } diff --git a/pkg/api/serialization_test.go b/pkg/api/serialization_test.go index 38f1d275455..bcd7bf69b21 100644 --- a/pkg/api/serialization_test.go +++ b/pkg/api/serialization_test.go @@ -110,7 +110,7 @@ func TestSpecificKind(t *testing.T) { api.Scheme.Log(t) defer api.Scheme.Log(nil) - kind := "JobList" + kind := "Pod" for i := 0; i < *fuzzIters; i++ { doRoundTripTest(kind, t) if t.Failed() { diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index 99b8ab94b2a..29e549808e2 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -375,7 +375,7 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer { c.FuzzNoCustom(s) // fuzz self without calling this function again minReplicas := int(c.Rand.Int31()) s.MinReplicas = &minReplicas - s.CPUUtilization = &extensions.CPUTargetUtilization{TargetPercentage: int(c.Int31())} + s.CPUUtilization = &extensions.CPUTargetUtilization{TargetPercentage: int(int32(c.RandUint64()))} }, ) return f diff --git a/pkg/apis/extensions/v1beta1/defaults_test.go b/pkg/apis/extensions/v1beta1/defaults_test.go index 11d9f03c384..9ad2352da2f 100644 --- a/pkg/apis/extensions/v1beta1/defaults_test.go +++ b/pkg/apis/extensions/v1beta1/defaults_test.go @@ -105,7 +105,7 @@ func TestSetDefaultDeployment(t *testing.T) { original: &Deployment{}, expected: &Deployment{ Spec: DeploymentSpec{ - Replicas: newInt(1), + Replicas: newInt32(1), Strategy: DeploymentStrategy{ Type: RollingUpdateDeploymentStrategyType, RollingUpdate: &RollingUpdateDeployment{ @@ -121,7 +121,7 @@ func TestSetDefaultDeployment(t *testing.T) { { original: &Deployment{ Spec: DeploymentSpec{ - Replicas: newInt(5), + Replicas: newInt32(5), Strategy: DeploymentStrategy{ RollingUpdate: &RollingUpdateDeployment{ MaxSurge: &differentIntOrString, @@ -131,7 +131,7 @@ func TestSetDefaultDeployment(t *testing.T) { }, expected: &Deployment{ Spec: DeploymentSpec{ - Replicas: newInt(5), + Replicas: newInt32(5), Strategy: DeploymentStrategy{ Type: RollingUpdateDeploymentStrategyType, RollingUpdate: &RollingUpdateDeployment{ @@ -147,7 +147,7 @@ func TestSetDefaultDeployment(t *testing.T) { { original: &Deployment{ Spec: DeploymentSpec{ - Replicas: newInt(5), + Replicas: newInt32(5), Strategy: DeploymentStrategy{ Type: RecreateDeploymentStrategyType, }, @@ -155,7 +155,7 @@ func TestSetDefaultDeployment(t *testing.T) { }, expected: &Deployment{ Spec: DeploymentSpec{ - Replicas: newInt(5), + Replicas: newInt32(5), Strategy: DeploymentStrategy{ Type: RecreateDeploymentStrategyType, }, @@ -167,7 +167,7 @@ func TestSetDefaultDeployment(t *testing.T) { { original: &Deployment{ Spec: DeploymentSpec{ - Replicas: newInt(5), + Replicas: newInt32(5), Strategy: DeploymentStrategy{ Type: RecreateDeploymentStrategyType, }, @@ -176,7 +176,7 @@ func TestSetDefaultDeployment(t *testing.T) { }, expected: &Deployment{ Spec: DeploymentSpec{ - Replicas: newInt(5), + Replicas: newInt32(5), Strategy: DeploymentStrategy{ Type: RecreateDeploymentStrategyType, }, @@ -208,8 +208,8 @@ func TestSetDefaultJob(t *testing.T) { Selector: &PodSelector{ MatchLabels: map[string]string{"job": "selector"}, }, - Completions: newInt(1), - Parallelism: newInt(1), + Completions: newInt32(1), + Parallelism: newInt32(1), }, } tests := []*Job{ @@ -234,7 +234,7 @@ func TestSetDefaultJob(t *testing.T) { // selector from template labels, completions set explicitly, parallelism - default { Spec: JobSpec{ - Completions: newInt(1), + Completions: newInt32(1), Template: v1.PodTemplateSpec{ ObjectMeta: v1.ObjectMeta{ Labels: map[string]string{"job": "selector"}, @@ -245,7 +245,7 @@ func TestSetDefaultJob(t *testing.T) { // selector from template labels, completions - default, parallelism set explicitly { Spec: JobSpec{ - Parallelism: newInt(1), + Parallelism: newInt32(1), Template: v1.PodTemplateSpec{ ObjectMeta: v1.ObjectMeta{ Labels: map[string]string{"job": "selector"}, @@ -294,9 +294,9 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { return obj3 } -func newInt(val int) *int32 { +func newInt32(val int32) *int32 { p := new(int32) - *p = int32(val) + *p = val return p } diff --git a/pkg/util/intstr/intstr.go b/pkg/util/intstr/intstr.go index 426375e397e..6a4eabd8a8c 100644 --- a/pkg/util/intstr/intstr.go +++ b/pkg/util/intstr/intstr.go @@ -28,6 +28,7 @@ import ( // JSON or YAML marshalling and unmarshalling, it produces or consumes the // inner type. This allows you to have, for example, a JSON field that can // accept a name or number. +// TODO: Rename to Int32OrString type IntOrString struct { Type Type IntVal int32 @@ -42,7 +43,10 @@ const ( String // The IntOrString holds a string. ) -// FromInt creates an IntOrString object with an int value. +// FromInt creates an IntOrString object with an int32 value. It is +// your responsibility not to call this method with a value greater +// than int32. +// TODO: convert to (val int32) func FromInt(val int) IntOrString { return IntOrString{Type: Int, IntVal: int32(val)} } @@ -70,7 +74,7 @@ func (intstr *IntOrString) String() string { return strconv.Itoa(intstr.IntValue()) } -// IntValue returns the IntVal cast as int32 if type Int, or if +// IntValue returns the IntVal if type Int, or if // it is a String, will attempt a conversion to int. func (intstr *IntOrString) IntValue() int { if intstr.Type == String {