mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Review comments
This commit is contained in:
parent
61270f4534
commit
e9e02bdd50
@ -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
|
// it actually maps to a host-port assigned to the pod. upstream
|
||||||
// doesn't check this and happily returns the container port spec'd
|
// doesn't check this and happily returns the container port spec'd
|
||||||
// in the service, but that doesn't align w/ mesos port mgmt.
|
// 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 _, container := range pod.Spec.Containers {
|
||||||
for _, port := range container.Ports {
|
for _, port := range container.Ports {
|
||||||
if port.ContainerPort == int(p) && port.Protocol == svcPort.Protocol {
|
if port.ContainerPort == p && port.Protocol == svcPort.Protocol {
|
||||||
hostPort, err := findMappedPort(pod, port.Protocol, int(p))
|
hostPort, err := findMappedPort(pod, port.Protocol, p)
|
||||||
return hostPort, port.ContainerPort, err
|
return hostPort, port.ContainerPort, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ func TestSpecificKind(t *testing.T) {
|
|||||||
api.Scheme.Log(t)
|
api.Scheme.Log(t)
|
||||||
defer api.Scheme.Log(nil)
|
defer api.Scheme.Log(nil)
|
||||||
|
|
||||||
kind := "JobList"
|
kind := "Pod"
|
||||||
for i := 0; i < *fuzzIters; i++ {
|
for i := 0; i < *fuzzIters; i++ {
|
||||||
doRoundTripTest(kind, t)
|
doRoundTripTest(kind, t)
|
||||||
if t.Failed() {
|
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
|
c.FuzzNoCustom(s) // fuzz self without calling this function again
|
||||||
minReplicas := int(c.Rand.Int31())
|
minReplicas := int(c.Rand.Int31())
|
||||||
s.MinReplicas = &minReplicas
|
s.MinReplicas = &minReplicas
|
||||||
s.CPUUtilization = &extensions.CPUTargetUtilization{TargetPercentage: int(c.Int31())}
|
s.CPUUtilization = &extensions.CPUTargetUtilization{TargetPercentage: int(int32(c.RandUint64()))}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return f
|
return f
|
||||||
|
@ -105,7 +105,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
|||||||
original: &Deployment{},
|
original: &Deployment{},
|
||||||
expected: &Deployment{
|
expected: &Deployment{
|
||||||
Spec: DeploymentSpec{
|
Spec: DeploymentSpec{
|
||||||
Replicas: newInt(1),
|
Replicas: newInt32(1),
|
||||||
Strategy: DeploymentStrategy{
|
Strategy: DeploymentStrategy{
|
||||||
Type: RollingUpdateDeploymentStrategyType,
|
Type: RollingUpdateDeploymentStrategyType,
|
||||||
RollingUpdate: &RollingUpdateDeployment{
|
RollingUpdate: &RollingUpdateDeployment{
|
||||||
@ -121,7 +121,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
|||||||
{
|
{
|
||||||
original: &Deployment{
|
original: &Deployment{
|
||||||
Spec: DeploymentSpec{
|
Spec: DeploymentSpec{
|
||||||
Replicas: newInt(5),
|
Replicas: newInt32(5),
|
||||||
Strategy: DeploymentStrategy{
|
Strategy: DeploymentStrategy{
|
||||||
RollingUpdate: &RollingUpdateDeployment{
|
RollingUpdate: &RollingUpdateDeployment{
|
||||||
MaxSurge: &differentIntOrString,
|
MaxSurge: &differentIntOrString,
|
||||||
@ -131,7 +131,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: &Deployment{
|
expected: &Deployment{
|
||||||
Spec: DeploymentSpec{
|
Spec: DeploymentSpec{
|
||||||
Replicas: newInt(5),
|
Replicas: newInt32(5),
|
||||||
Strategy: DeploymentStrategy{
|
Strategy: DeploymentStrategy{
|
||||||
Type: RollingUpdateDeploymentStrategyType,
|
Type: RollingUpdateDeploymentStrategyType,
|
||||||
RollingUpdate: &RollingUpdateDeployment{
|
RollingUpdate: &RollingUpdateDeployment{
|
||||||
@ -147,7 +147,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
|||||||
{
|
{
|
||||||
original: &Deployment{
|
original: &Deployment{
|
||||||
Spec: DeploymentSpec{
|
Spec: DeploymentSpec{
|
||||||
Replicas: newInt(5),
|
Replicas: newInt32(5),
|
||||||
Strategy: DeploymentStrategy{
|
Strategy: DeploymentStrategy{
|
||||||
Type: RecreateDeploymentStrategyType,
|
Type: RecreateDeploymentStrategyType,
|
||||||
},
|
},
|
||||||
@ -155,7 +155,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: &Deployment{
|
expected: &Deployment{
|
||||||
Spec: DeploymentSpec{
|
Spec: DeploymentSpec{
|
||||||
Replicas: newInt(5),
|
Replicas: newInt32(5),
|
||||||
Strategy: DeploymentStrategy{
|
Strategy: DeploymentStrategy{
|
||||||
Type: RecreateDeploymentStrategyType,
|
Type: RecreateDeploymentStrategyType,
|
||||||
},
|
},
|
||||||
@ -167,7 +167,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
|||||||
{
|
{
|
||||||
original: &Deployment{
|
original: &Deployment{
|
||||||
Spec: DeploymentSpec{
|
Spec: DeploymentSpec{
|
||||||
Replicas: newInt(5),
|
Replicas: newInt32(5),
|
||||||
Strategy: DeploymentStrategy{
|
Strategy: DeploymentStrategy{
|
||||||
Type: RecreateDeploymentStrategyType,
|
Type: RecreateDeploymentStrategyType,
|
||||||
},
|
},
|
||||||
@ -176,7 +176,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: &Deployment{
|
expected: &Deployment{
|
||||||
Spec: DeploymentSpec{
|
Spec: DeploymentSpec{
|
||||||
Replicas: newInt(5),
|
Replicas: newInt32(5),
|
||||||
Strategy: DeploymentStrategy{
|
Strategy: DeploymentStrategy{
|
||||||
Type: RecreateDeploymentStrategyType,
|
Type: RecreateDeploymentStrategyType,
|
||||||
},
|
},
|
||||||
@ -208,8 +208,8 @@ func TestSetDefaultJob(t *testing.T) {
|
|||||||
Selector: &PodSelector{
|
Selector: &PodSelector{
|
||||||
MatchLabels: map[string]string{"job": "selector"},
|
MatchLabels: map[string]string{"job": "selector"},
|
||||||
},
|
},
|
||||||
Completions: newInt(1),
|
Completions: newInt32(1),
|
||||||
Parallelism: newInt(1),
|
Parallelism: newInt32(1),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
tests := []*Job{
|
tests := []*Job{
|
||||||
@ -234,7 +234,7 @@ func TestSetDefaultJob(t *testing.T) {
|
|||||||
// selector from template labels, completions set explicitly, parallelism - default
|
// selector from template labels, completions set explicitly, parallelism - default
|
||||||
{
|
{
|
||||||
Spec: JobSpec{
|
Spec: JobSpec{
|
||||||
Completions: newInt(1),
|
Completions: newInt32(1),
|
||||||
Template: v1.PodTemplateSpec{
|
Template: v1.PodTemplateSpec{
|
||||||
ObjectMeta: v1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Labels: map[string]string{"job": "selector"},
|
Labels: map[string]string{"job": "selector"},
|
||||||
@ -245,7 +245,7 @@ func TestSetDefaultJob(t *testing.T) {
|
|||||||
// selector from template labels, completions - default, parallelism set explicitly
|
// selector from template labels, completions - default, parallelism set explicitly
|
||||||
{
|
{
|
||||||
Spec: JobSpec{
|
Spec: JobSpec{
|
||||||
Parallelism: newInt(1),
|
Parallelism: newInt32(1),
|
||||||
Template: v1.PodTemplateSpec{
|
Template: v1.PodTemplateSpec{
|
||||||
ObjectMeta: v1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Labels: map[string]string{"job": "selector"},
|
Labels: map[string]string{"job": "selector"},
|
||||||
@ -294,9 +294,9 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
|||||||
return obj3
|
return obj3
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInt(val int) *int32 {
|
func newInt32(val int32) *int32 {
|
||||||
p := new(int32)
|
p := new(int32)
|
||||||
*p = int32(val)
|
*p = val
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
// JSON or YAML marshalling and unmarshalling, it produces or consumes the
|
// 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
|
// inner type. This allows you to have, for example, a JSON field that can
|
||||||
// accept a name or number.
|
// accept a name or number.
|
||||||
|
// TODO: Rename to Int32OrString
|
||||||
type IntOrString struct {
|
type IntOrString struct {
|
||||||
Type Type
|
Type Type
|
||||||
IntVal int32
|
IntVal int32
|
||||||
@ -42,7 +43,10 @@ const (
|
|||||||
String // The IntOrString holds a string.
|
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 {
|
func FromInt(val int) IntOrString {
|
||||||
return IntOrString{Type: Int, IntVal: int32(val)}
|
return IntOrString{Type: Int, IntVal: int32(val)}
|
||||||
}
|
}
|
||||||
@ -70,7 +74,7 @@ func (intstr *IntOrString) String() string {
|
|||||||
return strconv.Itoa(intstr.IntValue())
|
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.
|
// it is a String, will attempt a conversion to int.
|
||||||
func (intstr *IntOrString) IntValue() int {
|
func (intstr *IntOrString) IntValue() int {
|
||||||
if intstr.Type == String {
|
if intstr.Type == String {
|
||||||
|
Loading…
Reference in New Issue
Block a user