mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Review comments
This commit is contained in:
		@@ -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
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -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() {
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user