Commit 56897b3c authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #17353 from smarterclayton/remove_ambiguous_int

Auto commit by PR queue bot
parents 284b2e41 e9e02bdd
......@@ -13544,17 +13544,17 @@
},
"initialDelaySeconds": {
"type": "integer",
"format": "int64",
"format": "int32",
"description": "Number of seconds after the container has started before liveness probes are initiated. More info: http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes"
},
"timeoutSeconds": {
"type": "integer",
"format": "int64",
"format": "int32",
"description": "Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes"
},
"periodSeconds": {
"type": "integer",
"format": "int64",
"format": "int32",
"description": "How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1."
},
"successThreshold": {
......
......@@ -3784,17 +3784,17 @@
},
"initialDelaySeconds": {
"type": "integer",
"format": "int64",
"format": "int32",
"description": "Number of seconds after the container has started before liveness probes are initiated. More info: http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes"
},
"timeoutSeconds": {
"type": "integer",
"format": "int64",
"format": "int32",
"description": "Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes"
},
"periodSeconds": {
"type": "integer",
"format": "int64",
"format": "int32",
"description": "How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1."
},
"successThreshold": {
......
......@@ -427,7 +427,7 @@ 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 == p && port.Protocol == svcPort.Protocol {
......
......@@ -3302,21 +3302,21 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
<td class="tableblock halign-left valign-top"><p class="tableblock">initialDelaySeconds</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Number of seconds after the container has started before liveness probes are initiated. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes">http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int64)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">timeoutSeconds</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes">http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int64)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">periodSeconds</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int64)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
......
......@@ -3068,21 +3068,21 @@ The resulting set of endpoints can be viewed as:<br>
<td class="tableblock halign-left valign-top"><p class="tableblock">initialDelaySeconds</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Number of seconds after the container has started before liveness probes are initiated. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes">http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int64)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">timeoutSeconds</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes">http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int64)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">periodSeconds</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int64)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
......
......@@ -224,7 +224,7 @@ func NewServerTimeout(kind, operation string, retryAfterSeconds int) error {
Details: &unversioned.StatusDetails{
Kind: kind,
Name: operation,
RetryAfterSeconds: retryAfterSeconds,
RetryAfterSeconds: int32(retryAfterSeconds),
},
Message: fmt.Sprintf("The %s operation against %s could not be completed at this time, please try again.", operation, kind),
}}
......@@ -252,7 +252,7 @@ func NewTimeoutError(message string, retryAfterSeconds int) error {
Reason: unversioned.StatusReasonTimeout,
Message: fmt.Sprintf("Timeout: %s", message),
Details: &unversioned.StatusDetails{
RetryAfterSeconds: retryAfterSeconds,
RetryAfterSeconds: int32(retryAfterSeconds),
},
}}
}
......@@ -318,14 +318,14 @@ func NewGenericServerResponse(code int, verb, kind, name, serverMessage string,
}
return &StatusError{unversioned.Status{
Status: unversioned.StatusFailure,
Code: code,
Code: int32(code),
Reason: reason,
Details: &unversioned.StatusDetails{
Kind: kind,
Name: name,
Causes: causes,
RetryAfterSeconds: retryAfterSeconds,
RetryAfterSeconds: int32(retryAfterSeconds),
},
Message: message,
}}
......@@ -410,7 +410,7 @@ func SuggestsClientDelay(err error) (int, bool) {
if t.Status().Details != nil {
switch t.Status().Reason {
case unversioned.StatusReasonServerTimeout, unversioned.StatusReasonTimeout:
return t.Status().Details.RetryAfterSeconds, true
return int(t.Status().Details.RetryAfterSeconds), true
}
}
}
......
......@@ -111,7 +111,12 @@ func TestSpecificKind(t *testing.T) {
defer api.Scheme.Log(nil)
kind := "Pod"
doRoundTripTest(kind, t)
for i := 0; i < *fuzzIters; i++ {
doRoundTripTest(kind, t)
if t.Failed() {
break
}
}
}
func TestList(t *testing.T) {
......@@ -142,6 +147,9 @@ func TestRoundTripTypes(t *testing.T) {
// Try a few times, since runTest uses random values.
for i := 0; i < *fuzzIters; i++ {
doRoundTripTest(kind, t)
if t.Failed() {
break
}
}
}
}
......
......@@ -45,6 +45,17 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
f.RandSource(src)
}
f.Funcs(
func(j *int, c fuzz.Continue) {
*j = int(c.Int31())
},
func(j **int, c fuzz.Continue) {
if c.RandBool() {
i := int(c.Int31())
*j = &i
} else {
*j = nil
}
},
func(j *runtime.PluginBase, c fuzz.Continue) {
// Do nothing; this struct has only a Kind field and it must stay blank in memory.
},
......@@ -140,8 +151,8 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
},
func(j *extensions.JobSpec, c fuzz.Continue) {
c.FuzzNoCustom(j) // fuzz self without calling this function again
completions := c.Rand.Int()
parallelism := c.Rand.Int()
completions := int(c.Rand.Int31())
parallelism := int(c.Rand.Int31())
j.Completions = &completions
j.Parallelism = &parallelism
},
......@@ -227,24 +238,23 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
policies := []api.RestartPolicy{api.RestartPolicyAlways, api.RestartPolicyNever, api.RestartPolicyOnFailure}
*rp = policies[c.Rand.Intn(len(policies))]
},
// Only api.DownwardAPIVolumeFile needs to have a specific func since FieldRef has to be
// defaulted to a version otherwise roundtrip will fail
// For the remaining volume plugins the default fuzzer is enough.
func(m *api.DownwardAPIVolumeFile, c fuzz.Continue) {
m.Path = c.RandString()
versions := []string{"v1"}
m.FieldRef.APIVersion = versions[c.Rand.Intn(len(versions))]
m.FieldRef.FieldPath = c.RandString()
},
func(vs *api.VolumeSource, c fuzz.Continue) {
// Exactly one of the fields must be set.
v := reflect.ValueOf(vs).Elem()
i := int(c.RandUint64() % uint64(v.NumField()))
v = v.Field(i).Addr()
// Use a new fuzzer which cannot populate nil to ensure one field will be set.
f := fuzz.New().NilChance(0).NumElements(1, 1)
f.Funcs(
// Only api.DownwardAPIVolumeFile needs to have a specific func since FieldRef has to be
// defaulted to a version otherwise roundtrip will fail
// For the remaining volume plugins the default fuzzer is enough.
func(m *api.DownwardAPIVolumeFile, c fuzz.Continue) {
m.Path = c.RandString()
versions := []string{"v1"}
m.FieldRef.APIVersion = versions[c.Rand.Intn(len(versions))]
m.FieldRef.FieldPath = c.RandString()
},
).Fuzz(v.Interface())
t := v.Field(i).Addr()
for v.Field(i).IsNil() {
c.Fuzz(t.Interface())
}
},
func(d *api.DNSPolicy, c fuzz.Continue) {
policies := []api.DNSPolicy{api.DNSClusterFirst, api.DNSDefault}
......@@ -363,9 +373,9 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
},
func(s *extensions.HorizontalPodAutoscalerSpec, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
minReplicas := c.Rand.Int()
minReplicas := int(c.Rand.Int31())
s.MinReplicas = &minReplicas
s.CPUUtilization = &extensions.CPUTargetUtilization{TargetPercentage: int(c.RandUint64())}
s.CPUUtilization = &extensions.CPUTargetUtilization{TargetPercentage: int(int32(c.RandUint64()))}
},
)
return f
......
......@@ -14302,19 +14302,19 @@ func (x *Probe) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.InitialDelaySeconds = 0
} else {
x.InitialDelaySeconds = int64(r.DecodeInt(64))
x.InitialDelaySeconds = int(r.DecodeInt(codecSelferBitsize1234))
}
case "timeoutSeconds":
if r.TryDecodeAsNil() {
x.TimeoutSeconds = 0
} else {
x.TimeoutSeconds = int64(r.DecodeInt(64))
x.TimeoutSeconds = int(r.DecodeInt(codecSelferBitsize1234))
}
case "periodSeconds":
if r.TryDecodeAsNil() {
x.PeriodSeconds = 0
} else {
x.PeriodSeconds = int64(r.DecodeInt(64))
x.PeriodSeconds = int(r.DecodeInt(codecSelferBitsize1234))
}
case "successThreshold":
if r.TryDecodeAsNil() {
......@@ -14428,7 +14428,7 @@ func (x *Probe) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.InitialDelaySeconds = 0
} else {
x.InitialDelaySeconds = int64(r.DecodeInt(64))
x.InitialDelaySeconds = int(r.DecodeInt(codecSelferBitsize1234))
}
yyj1028++
if yyhl1028 {
......@@ -14444,7 +14444,7 @@ func (x *Probe) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.TimeoutSeconds = 0
} else {
x.TimeoutSeconds = int64(r.DecodeInt(64))
x.TimeoutSeconds = int(r.DecodeInt(codecSelferBitsize1234))
}
yyj1028++
if yyhl1028 {
......@@ -14460,7 +14460,7 @@ func (x *Probe) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.PeriodSeconds = 0
} else {
x.PeriodSeconds = int64(r.DecodeInt(64))
x.PeriodSeconds = int(r.DecodeInt(codecSelferBitsize1234))
}
yyj1028++
if yyhl1028 {
......@@ -719,11 +719,11 @@ type Probe struct {
// The action taken to determine the health of a container
Handler `json:",inline"`
// Length of time before health checking is activated. In seconds.
InitialDelaySeconds int64 `json:"initialDelaySeconds,omitempty"`
InitialDelaySeconds int `json:"initialDelaySeconds,omitempty"`
// Length of time before health checking times out. In seconds.
TimeoutSeconds int64 `json:"timeoutSeconds,omitempty"`
TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
// How often (in seconds) to perform the probe.
PeriodSeconds int64 `json:"periodSeconds,omitempty"`
PeriodSeconds int `json:"periodSeconds,omitempty"`
// Minimum consecutive successes for the probe to be considered successful after having failed.
// Must be 1 for liveness.
SuccessThreshold int `json:"successThreshold,omitempty"`
......
......@@ -99,7 +99,7 @@ type Status struct {
// the reason type.
Details *StatusDetails `json:"details,omitempty"`
// Suggested HTTP return code for this status, 0 if not set.
Code int `json:"code,omitempty"`
Code int32 `json:"code,omitempty"`
}
// StatusDetails is a set of additional properties that MAY be set by the
......@@ -120,7 +120,7 @@ type StatusDetails struct {
// failure. Not all StatusReasons may provide detailed causes.
Causes []StatusCause `json:"causes,omitempty"`
// If specified, the time in seconds before the operation should be retried.
RetryAfterSeconds int `json:"retryAfterSeconds,omitempty"`
RetryAfterSeconds int32 `json:"retryAfterSeconds,omitempty"`
}
// Values of Status.Status
......@@ -204,7 +204,7 @@ const (
// Details (optional):
// "kind" string - the kind attribute of the resource being acted on.
// "id" string - the operation that is being attempted.
// "retryAfterSeconds" int - the number of seconds before the operation should be retried
// "retryAfterSeconds" int32 - the number of seconds before the operation should be retried
// Status code 500
StatusReasonServerTimeout StatusReason = "ServerTimeout"
......@@ -214,7 +214,7 @@ const (
// The request might succeed with an increased value of timeout param. The client *should*
// wait at least the number of seconds specified by the retryAfterSeconds field.
// Details (optional):
// "retryAfterSeconds" int - the number of seconds before the operation should be retried
// "retryAfterSeconds" int32 - the number of seconds before the operation should be retried
// Status code 504
StatusReasonTimeout StatusReason = "Timeout"
......
......@@ -180,8 +180,8 @@ func convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *a
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.ReplicationControllerSpec))(in)
}
out.Replicas = new(int)
*out.Replicas = in.Replicas
out.Replicas = new(int32)
*out.Replicas = int32(in.Replicas)
if in.Selector != nil {
out.Selector = make(map[string]string)
for key, val := range in.Selector {
......@@ -213,7 +213,7 @@ func convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *R
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*ReplicationControllerSpec))(in)
}
out.Replicas = *in.Replicas
out.Replicas = int(*in.Replicas)
if in.Selector != nil {
out.Selector = make(map[string]string)
for key, val := range in.Selector {
......
......@@ -33,7 +33,7 @@ func autoconvert_api_AWSElasticBlockStoreVolumeSource_To_v1_AWSElasticBlockStore
}
out.VolumeID = in.VolumeID
out.FSType = in.FSType
out.Partition = in.Partition
out.Partition = int32(in.Partition)
out.ReadOnly = in.ReadOnly
return nil
}
......@@ -307,8 +307,8 @@ func autoconvert_api_ContainerPort_To_v1_ContainerPort(in *api.ContainerPort, ou
defaulting.(func(*api.ContainerPort))(in)
}
out.Name = in.Name
out.HostPort = in.HostPort
out.ContainerPort = in.ContainerPort
out.HostPort = int32(in.HostPort)
out.ContainerPort = int32(in.ContainerPort)
out.Protocol = Protocol(in.Protocol)
out.HostIP = in.HostIP
return nil
......@@ -371,8 +371,8 @@ func autoconvert_api_ContainerStateTerminated_To_v1_ContainerStateTerminated(in
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.ContainerStateTerminated))(in)
}
out.ExitCode = in.ExitCode
out.Signal = in.Signal
out.ExitCode = int32(in.ExitCode)
out.Signal = int32(in.Signal)
out.Reason = in.Reason
out.Message = in.Message
if err := s.Convert(&in.StartedAt, &out.StartedAt, 0); err != nil {
......@@ -414,7 +414,7 @@ func autoconvert_api_ContainerStatus_To_v1_ContainerStatus(in *api.ContainerStat
return err
}
out.Ready = in.Ready
out.RestartCount = in.RestartCount
out.RestartCount = int32(in.RestartCount)
out.Image = in.Image
out.ImageID = in.ImageID
out.ContainerID = in.ContainerID
......@@ -429,7 +429,7 @@ func autoconvert_api_DaemonEndpoint_To_v1_DaemonEndpoint(in *api.DaemonEndpoint,
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.DaemonEndpoint))(in)
}
out.Port = in.Port
out.Port = int32(in.Port)
return nil
}
......@@ -530,7 +530,7 @@ func autoconvert_api_EndpointPort_To_v1_EndpointPort(in *api.EndpointPort, out *
defaulting.(func(*api.EndpointPort))(in)
}
out.Name = in.Name
out.Port = in.Port
out.Port = int32(in.Port)
out.Protocol = Protocol(in.Protocol)
return nil
}
......@@ -698,7 +698,7 @@ func autoconvert_api_Event_To_v1_Event(in *api.Event, out *Event, s conversion.S
if err := s.Convert(&in.LastTimestamp, &out.LastTimestamp, 0); err != nil {
return err
}
out.Count = in.Count
out.Count = int32(in.Count)
out.Type = in.Type
return nil
}
......@@ -779,8 +779,8 @@ func autoconvert_api_FCVolumeSource_To_v1_FCVolumeSource(in *api.FCVolumeSource,
out.TargetWWNs = nil
}
if in.Lun != nil {
out.Lun = new(int)
*out.Lun = *in.Lun
out.Lun = new(int32)
*out.Lun = int32(*in.Lun)
} else {
out.Lun = nil
}
......@@ -811,7 +811,7 @@ func autoconvert_api_GCEPersistentDiskVolumeSource_To_v1_GCEPersistentDiskVolume
}
out.PDName = in.PDName
out.FSType = in.FSType
out.Partition = in.Partition
out.Partition = int32(in.Partition)
out.ReadOnly = in.ReadOnly
return nil
}
......@@ -917,7 +917,7 @@ func autoconvert_api_ISCSIVolumeSource_To_v1_ISCSIVolumeSource(in *api.ISCSIVolu
}
out.TargetPortal = in.TargetPortal
out.IQN = in.IQN
out.Lun = in.Lun
out.Lun = int32(in.Lun)
out.FSType = in.FSType
out.ReadOnly = in.ReadOnly
return nil
......@@ -2215,11 +2215,11 @@ func autoconvert_api_Probe_To_v1_Probe(in *api.Probe, out *Probe, s conversion.S
if err := convert_api_Handler_To_v1_Handler(&in.Handler, &out.Handler, s); err != nil {
return err
}
out.InitialDelaySeconds = in.InitialDelaySeconds
out.TimeoutSeconds = in.TimeoutSeconds
out.PeriodSeconds = in.PeriodSeconds
out.SuccessThreshold = in.SuccessThreshold
out.FailureThreshold = in.FailureThreshold
out.InitialDelaySeconds = int32(in.InitialDelaySeconds)
out.TimeoutSeconds = int32(in.TimeoutSeconds)
out.PeriodSeconds = int32(in.PeriodSeconds)
out.SuccessThreshold = int32(in.SuccessThreshold)
out.FailureThreshold = int32(in.FailureThreshold)
return nil
}
......@@ -2361,7 +2361,7 @@ func autoconvert_api_ReplicationControllerStatus_To_v1_ReplicationControllerStat
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.ReplicationControllerStatus))(in)
}
out.Replicas = in.Replicas
out.Replicas = int32(in.Replicas)
out.ObservedGeneration = in.ObservedGeneration
return nil
}
......@@ -2779,11 +2779,11 @@ func autoconvert_api_ServicePort_To_v1_ServicePort(in *api.ServicePort, out *Ser
}
out.Name = in.Name
out.Protocol = Protocol(in.Protocol)
out.Port = in.Port
out.Port = int32(in.Port)
if err := s.Convert(&in.TargetPort, &out.TargetPort, 0); err != nil {
return err
}
out.NodePort = in.NodePort
out.NodePort = int32(in.NodePort)
return nil
}
......@@ -3058,7 +3058,7 @@ func autoconvert_v1_AWSElasticBlockStoreVolumeSource_To_api_AWSElasticBlockStore
}
out.VolumeID = in.VolumeID
out.FSType = in.FSType
out.Partition = in.Partition
out.Partition = int(in.Partition)
out.ReadOnly = in.ReadOnly
return nil
}
......@@ -3332,8 +3332,8 @@ func autoconvert_v1_ContainerPort_To_api_ContainerPort(in *ContainerPort, out *a
defaulting.(func(*ContainerPort))(in)
}
out.Name = in.Name
out.HostPort = in.HostPort
out.ContainerPort = in.ContainerPort
out.HostPort = int(in.HostPort)
out.ContainerPort = int(in.ContainerPort)
out.Protocol = api.Protocol(in.Protocol)
out.HostIP = in.HostIP
return nil
......@@ -3396,8 +3396,8 @@ func autoconvert_v1_ContainerStateTerminated_To_api_ContainerStateTerminated(in
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*ContainerStateTerminated))(in)
}
out.ExitCode = in.ExitCode
out.Signal = in.Signal
out.ExitCode = int(in.ExitCode)
out.Signal = int(in.Signal)
out.Reason = in.Reason
out.Message = in.Message
if err := s.Convert(&in.StartedAt, &out.StartedAt, 0); err != nil {
......@@ -3439,7 +3439,7 @@ func autoconvert_v1_ContainerStatus_To_api_ContainerStatus(in *ContainerStatus,
return err
}
out.Ready = in.Ready
out.RestartCount = in.RestartCount
out.RestartCount = int(in.RestartCount)
out.Image = in.Image
out.ImageID = in.ImageID
out.ContainerID = in.ContainerID
......@@ -3454,7 +3454,7 @@ func autoconvert_v1_DaemonEndpoint_To_api_DaemonEndpoint(in *DaemonEndpoint, out
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*DaemonEndpoint))(in)
}
out.Port = in.Port
out.Port = int(in.Port)
return nil
}
......@@ -3555,7 +3555,7 @@ func autoconvert_v1_EndpointPort_To_api_EndpointPort(in *EndpointPort, out *api.
defaulting.(func(*EndpointPort))(in)
}
out.Name = in.Name
out.Port = in.Port
out.Port = int(in.Port)
out.Protocol = api.Protocol(in.Protocol)
return nil
}
......@@ -3723,7 +3723,7 @@ func autoconvert_v1_Event_To_api_Event(in *Event, out *api.Event, s conversion.S
if err := s.Convert(&in.LastTimestamp, &out.LastTimestamp, 0); err != nil {
return err
}
out.Count = in.Count
out.Count = int(in.Count)
out.Type = in.Type
return nil
}
......@@ -3805,7 +3805,7 @@ func autoconvert_v1_FCVolumeSource_To_api_FCVolumeSource(in *FCVolumeSource, out
}
if in.Lun != nil {
out.Lun = new(int)
*out.Lun = *in.Lun
*out.Lun = int(*in.Lun)
} else {
out.Lun = nil
}
......@@ -3836,7 +3836,7 @@ func autoconvert_v1_GCEPersistentDiskVolumeSource_To_api_GCEPersistentDiskVolume
}
out.PDName = in.PDName
out.FSType = in.FSType
out.Partition = in.Partition
out.Partition = int(in.Partition)
out.ReadOnly = in.ReadOnly
return nil
}
......@@ -3942,7 +3942,7 @@ func autoconvert_v1_ISCSIVolumeSource_To_api_ISCSIVolumeSource(in *ISCSIVolumeSo
}
out.TargetPortal = in.TargetPortal
out.IQN = in.IQN
out.Lun = in.Lun
out.Lun = int(in.Lun)
out.FSType = in.FSType
out.ReadOnly = in.ReadOnly
return nil
......@@ -5272,11 +5272,11 @@ func autoconvert_v1_Probe_To_api_Probe(in *Probe, out *api.Probe, s conversion.S
if err := convert_v1_Handler_To_api_Handler(&in.Handler, &out.Handler, s); err != nil {
return err
}
out.InitialDelaySeconds = in.InitialDelaySeconds
out.TimeoutSeconds = in.TimeoutSeconds
out.PeriodSeconds = in.PeriodSeconds
out.SuccessThreshold = in.SuccessThreshold
out.FailureThreshold = in.FailureThreshold
out.InitialDelaySeconds = int(in.InitialDelaySeconds)
out.TimeoutSeconds = int(in.TimeoutSeconds)
out.PeriodSeconds = int(in.PeriodSeconds)
out.SuccessThreshold = int(in.SuccessThreshold)
out.FailureThreshold = int(in.FailureThreshold)
return nil
}
......@@ -5416,7 +5416,7 @@ func autoconvert_v1_ReplicationControllerStatus_To_api_ReplicationControllerStat
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*ReplicationControllerStatus))(in)
}
out.Replicas = in.Replicas
out.Replicas = int(in.Replicas)
out.ObservedGeneration = in.ObservedGeneration
return nil
}
......@@ -5834,11 +5834,11 @@ func autoconvert_v1_ServicePort_To_api_ServicePort(in *ServicePort, out *api.Ser
}
out.Name = in.Name
out.Protocol = api.Protocol(in.Protocol)
out.Port = in.Port
out.Port = int(in.Port)
if err := s.Convert(&in.TargetPort, &out.TargetPort, 0); err != nil {
return err
}
out.NodePort = in.NodePort
out.NodePort = int(in.NodePort)
return nil
}
......
......@@ -597,7 +597,7 @@ func deepCopy_v1_FCVolumeSource(in FCVolumeSource, out *FCVolumeSource, c *conve
out.TargetWWNs = nil
}
if in.Lun != nil {
out.Lun = new(int)
out.Lun = new(int32)
*out.Lun = *in.Lun
} else {
out.Lun = nil
......@@ -1803,7 +1803,7 @@ func deepCopy_v1_ReplicationControllerList(in ReplicationControllerList, out *Re
func deepCopy_v1_ReplicationControllerSpec(in ReplicationControllerSpec, out *ReplicationControllerSpec, c *conversion.Cloner) error {
if in.Replicas != nil {
out.Replicas = new(int)
out.Replicas = new(int32)
*out.Replicas = *in.Replicas
} else {
out.Replicas = nil
......
......@@ -41,7 +41,7 @@ func addDefaultingFuncs() {
}
}
if obj.Spec.Replicas == nil {
obj.Spec.Replicas = new(int)
obj.Spec.Replicas = new(int32)
*obj.Spec.Replicas = 1
}
},
......@@ -85,7 +85,7 @@ func addDefaultingFuncs() {
sp.Protocol = ProtocolTCP
}
if sp.TargetPort == intstr.FromInt(0) || sp.TargetPort == intstr.FromString("") {
sp.TargetPort = intstr.FromInt(sp.Port)
sp.TargetPort = intstr.FromInt(int(sp.Port))
}
}
},
......
......@@ -156,8 +156,8 @@ func TestSetDefaultReplicationController(t *testing.T) {
}
}
func newInt(val int) *int {
p := new(int)
func newInt(val int32) *int32 {
p := new(int32)
*p = val
return p
}
......@@ -165,7 +165,7 @@ func newInt(val int) *int {
func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
tests := []struct {
rc versioned.ReplicationController
expectReplicas int
expectReplicas int32
}{
{
rc: versioned.ReplicationController{
......@@ -345,13 +345,13 @@ func TestSetDefaultServicePort(t *testing.T) {
if out.Spec.Ports[0].Protocol != versioned.ProtocolTCP {
t.Errorf("Expected protocol %s, got %s", versioned.ProtocolTCP, out.Spec.Ports[0].Protocol)
}
if out.Spec.Ports[0].TargetPort != intstr.FromInt(in.Spec.Ports[0].Port) {
if out.Spec.Ports[0].TargetPort != intstr.FromInt(int(in.Spec.Ports[0].Port)) {
t.Errorf("Expected port %v, got %v", in.Spec.Ports[0].Port, out.Spec.Ports[0].TargetPort)
}
if out.Spec.Ports[1].Protocol != versioned.ProtocolTCP {
t.Errorf("Expected protocol %s, got %s", versioned.ProtocolTCP, out.Spec.Ports[1].Protocol)
}
if out.Spec.Ports[1].TargetPort != intstr.FromInt(in.Spec.Ports[1].Port) {
if out.Spec.Ports[1].TargetPort != intstr.FromInt(int(in.Spec.Ports[1].Port)) {
t.Errorf("Expected port %v, got %v", in.Spec.Ports[1].Port, out.Spec.Ports[1].TargetPort)
}
}
......@@ -367,7 +367,7 @@ func TestSetDefaultNamespace(t *testing.T) {
}
func TestSetDefaultPodSpecHostNetwork(t *testing.T) {
portNum := 8080
portNum := int32(8080)
s := versioned.PodSpec{}
s.HostNetwork = true
s.Containers = []versioned.Container{
......
......@@ -635,7 +635,7 @@ type GCEPersistentDiskVolumeSource struct {
// Examples: For volume /dev/sda1, you specify the partition as "1".
// Similarly, the volume partition for /dev/sda is "0" (or you can leave the property empty).
// More info: http://releases.k8s.io/HEAD/docs/user-guide/volumes.md#gcepersistentdisk
Partition int `json:"partition,omitempty"`
Partition int32 `json:"partition,omitempty"`
// ReadOnly here will force the ReadOnly setting in VolumeMounts.
// Defaults to false.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/volumes.md#gcepersistentdisk
......@@ -661,7 +661,7 @@ type AWSElasticBlockStoreVolumeSource struct {
// If omitted, the default is to mount by volume name.
// Examples: For volume /dev/sda1, you specify the partition as "1".
// Similarly, the volume partition for /dev/sda is "0" (or you can leave the property empty).
Partition int `json:"partition,omitempty"`
Partition int32 `json:"partition,omitempty"`
// Specify "true" to force and set the ReadOnly property in VolumeMounts to "true".
// If omitted, the default is "false".
// More info: http://releases.k8s.io/HEAD/docs/user-guide/volumes.md#awselasticblockstore
......@@ -709,7 +709,7 @@ type ISCSIVolumeSource struct {
// Target iSCSI Qualified Name.
IQN string `json:"iqn"`
// iSCSI target lun number.
Lun int `json:"lun"`
Lun int32 `json:"lun"`
// Filesystem type of the volume that you want to mount.
// Tip: Ensure that the filesystem type is supported by the host operating system.
// Examples: "ext4", "xfs", "ntfs".
......@@ -726,7 +726,7 @@ type FCVolumeSource struct {
// Required: FC target world wide names (WWNs)
TargetWWNs []string `json:"targetWWNs"`
// Required: FC target lun number
Lun *int `json:"lun"`
Lun *int32 `json:"lun"`
// Required: Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs"
......@@ -747,10 +747,10 @@ type ContainerPort struct {
// If specified, this must be a valid port number, 0 < x < 65536.
// If HostNetwork is specified, this must match ContainerPort.
// Most containers do not need this.
HostPort int `json:"hostPort,omitempty"`
HostPort int32 `json:"hostPort,omitempty"`
// Number of port to expose on the pod's IP address.
// This must be a valid port number, 0 < x < 65536.
ContainerPort int `json:"containerPort"`
ContainerPort int32 `json:"containerPort"`
// Protocol for port. Must be UDP or TCP.
// Defaults to "TCP".
Protocol Protocol `json:"protocol,omitempty"`
......@@ -853,20 +853,20 @@ type Probe struct {
Handler `json:",inline"`
// Number of seconds after the container has started before liveness probes are initiated.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes
InitialDelaySeconds int64 `json:"initialDelaySeconds,omitempty"`
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"`
// Number of seconds after which the probe times out.
// Defaults to 1 second. Minimum value is 1.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/pod-states.md#container-probes
TimeoutSeconds int64 `json:"timeoutSeconds,omitempty"`
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
// How often (in seconds) to perform the probe.
// Default to 10 seconds. Minimum value is 1.
PeriodSeconds int64 `json:"periodSeconds,omitempty"`
PeriodSeconds int32 `json:"periodSeconds,omitempty"`
// Minimum consecutive successes for the probe to be considered successful after having failed.
// Defaults to 1. Must be 1 for liveness. Minimum value is 1.
SuccessThreshold int `json:"successThreshold,omitempty"`
SuccessThreshold int32 `json:"successThreshold,omitempty"`
// Minimum consecutive failures for the probe to be considered failed after having succeeded.
// Defaults to 3. Minimum value is 1.
FailureThreshold int `json:"failureThreshold,omitempty"`
FailureThreshold int32 `json:"failureThreshold,omitempty"`
}
// PullPolicy describes a policy for if/when to pull a container image
......@@ -1064,9 +1064,9 @@ type ContainerStateRunning struct {
// ContainerStateTerminated is a terminated state of a container.
type ContainerStateTerminated struct {
// Exit status from the last termination of the container
ExitCode int `json:"exitCode"`
ExitCode int32 `json:"exitCode"`
// Signal from the last termination of the container
Signal int `json:"signal,omitempty"`
Signal int32 `json:"signal,omitempty"`
// (brief) reason from the last termination of the container
Reason string `json:"reason,omitempty"`
// Message regarding the last termination of the container
......@@ -1106,7 +1106,7 @@ type ContainerStatus struct {
// the number of dead containers that have not yet been removed.
// Note that this is calculated from dead containers. But those containers are subject to
// garbage collection. This value will get capped at 5 by GC.
RestartCount int `json:"restartCount"`
RestartCount int32 `json:"restartCount"`
// The image the container is running.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/images.md
// TODO(dchen1107): Which image the container is running with?
......@@ -1423,7 +1423,7 @@ type ReplicationControllerSpec struct {
// This is a pointer to distinguish between explicit zero and unspecified.
// Defaults to 1.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/replication-controller.md#what-is-a-replication-controller
Replicas *int `json:"replicas,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
// Selector is a label query over pods that should match the Replicas count.
// If Selector is empty, it is defaulted to the labels present on the Pod template.
......@@ -1448,7 +1448,7 @@ type ReplicationControllerSpec struct {
type ReplicationControllerStatus struct {
// Replicas is the most recently oberved number of replicas.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/replication-controller.md#what-is-a-replication-controller
Replicas int `json:"replicas"`
Replicas int32 `json:"replicas"`
// ObservedGeneration reflects the generation of the most recently observed replication controller.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
......@@ -1612,7 +1612,7 @@ type ServicePort struct {
Protocol Protocol `json:"protocol,omitempty"`
// The port that will be exposed by this service.
Port int `json:"port"`
Port int32 `json:"port"`
// Number or name of the port to access on the pods targeted by the service.
// Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.
......@@ -1628,7 +1628,7 @@ type ServicePort struct {
// if unused or else creation of the service will fail.
// Default is to auto-allocate a port if the ServiceType of this Service requires one.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#type--nodeport
NodePort int `json:"nodePort,omitempty"`
NodePort int32 `json:"nodePort,omitempty"`
}
// Service is a named abstraction of software service (for example, mysql) consisting of local port
......@@ -1771,7 +1771,7 @@ type EndpointPort struct {
Name string `json:"name,omitempty"`
// The port number of the endpoint.
Port int `json:"port"`
Port int32 `json:"port"`
// The IP protocol for this port.
// Must be UDP or TCP.
......@@ -1807,7 +1807,7 @@ type NodeSpec struct {
// DaemonEndpoint contains information about a single Daemon endpoint.
type DaemonEndpoint struct {
// Port number of the given endpoint.
Port int `json:port`
Port int32 `json:port`
}
// NodeDaemonEndpoints lists ports opened by daemons running on the Node.
......@@ -2258,7 +2258,7 @@ type Event struct {
LastTimestamp unversioned.Time `json:"lastTimestamp,omitempty"`
// The number of times this event has occurred.
Count int `json:"count,omitempty"`
Count int32 `json:"count,omitempty"`
// Type of this event (Normal, Warning), new types could be added in the future
Type string `json:"type,omitempty"`
......
......@@ -880,8 +880,9 @@ func validateProbe(probe *api.Probe) validation.ErrorList {
return allErrs
}
allErrs = append(allErrs, validateHandler(&probe.Handler)...)
allErrs = append(allErrs, ValidatePositiveField(probe.InitialDelaySeconds, "initialDelaySeconds")...)
allErrs = append(allErrs, ValidatePositiveField(probe.TimeoutSeconds, "timeoutSeconds")...)
allErrs = append(allErrs, ValidatePositiveField(int64(probe.InitialDelaySeconds), "initialDelaySeconds")...)
allErrs = append(allErrs, ValidatePositiveField(int64(probe.TimeoutSeconds), "timeoutSeconds")...)
allErrs = append(allErrs, ValidatePositiveField(int64(probe.PeriodSeconds), "periodSeconds")...)
allErrs = append(allErrs, ValidatePositiveField(int64(probe.SuccessThreshold), "successThreshold")...)
allErrs = append(allErrs, ValidatePositiveField(int64(probe.FailureThreshold), "failureThreshold")...)
......@@ -932,7 +933,7 @@ func validateHTTPGetAction(http *api.HTTPGetAction) validation.ErrorList {
if len(http.Path) == 0 {
allErrors = append(allErrors, validation.NewRequiredError("path"))
}
if http.Port.Type == intstr.Int && !validation.IsValidPortNum(http.Port.IntVal) {
if http.Port.Type == intstr.Int && !validation.IsValidPortNum(http.Port.IntValue()) {
allErrors = append(allErrors, validation.NewInvalidError("port", http.Port, PortRangeErrorMsg))
} else if http.Port.Type == intstr.String && !validation.IsValidPortName(http.Port.StrVal) {
allErrors = append(allErrors, validation.NewInvalidError("port", http.Port.StrVal, PortNameErrorMsg))
......@@ -946,7 +947,7 @@ func validateHTTPGetAction(http *api.HTTPGetAction) validation.ErrorList {
func validateTCPSocketAction(tcp *api.TCPSocketAction) validation.ErrorList {
allErrors := validation.ErrorList{}
if tcp.Port.Type == intstr.Int && !validation.IsValidPortNum(tcp.Port.IntVal) {
if tcp.Port.Type == intstr.Int && !validation.IsValidPortNum(tcp.Port.IntValue()) {
allErrors = append(allErrors, validation.NewInvalidError("port", tcp.Port, PortRangeErrorMsg))
} else if tcp.Port.Type == intstr.String && !validation.IsValidPortName(tcp.Port.StrVal) {
allErrors = append(allErrors, validation.NewInvalidError("port", tcp.Port.StrVal, PortNameErrorMsg))
......@@ -1333,7 +1334,7 @@ func validateServicePort(sp *api.ServicePort, requireName bool, allNames *sets.S
allErrs = append(allErrs, validation.NewNotSupportedError("protocol", sp.Protocol, supportedPortProtocols.List()))
}
if sp.TargetPort.Type == intstr.Int && !validation.IsValidPortNum(sp.TargetPort.IntVal) {
if sp.TargetPort.Type == intstr.Int && !validation.IsValidPortNum(sp.TargetPort.IntValue()) {
allErrs = append(allErrs, validation.NewInvalidError("targetPort", sp.TargetPort, PortRangeErrorMsg))
}
if sp.TargetPort.Type == intstr.String && !validation.IsValidPortName(sp.TargetPort.StrVal) {
......
......@@ -36,24 +36,24 @@ func autoconvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyCon
out.BindAddress = in.BindAddress
out.CleanupIPTables = in.CleanupIPTables
out.HealthzBindAddress = in.HealthzBindAddress
out.HealthzPort = in.HealthzPort
out.HealthzPort = int32(in.HealthzPort)
out.HostnameOverride = in.HostnameOverride
out.IPTablesSyncePeriodSeconds = in.IPTablesSyncePeriodSeconds
out.KubeAPIBurst = in.KubeAPIBurst
out.KubeAPIQPS = in.KubeAPIQPS
out.IPTablesSyncePeriodSeconds = int32(in.IPTablesSyncePeriodSeconds)
out.KubeAPIBurst = int32(in.KubeAPIBurst)
out.KubeAPIQPS = int32(in.KubeAPIQPS)
out.KubeconfigPath = in.KubeconfigPath
out.MasqueradeAll = in.MasqueradeAll
out.Master = in.Master
if in.OOMScoreAdj != nil {
out.OOMScoreAdj = new(int)
*out.OOMScoreAdj = *in.OOMScoreAdj
out.OOMScoreAdj = new(int32)
*out.OOMScoreAdj = int32(*in.OOMScoreAdj)
} else {
out.OOMScoreAdj = nil
}
out.Mode = ProxyMode(in.Mode)
out.PortRange = in.PortRange
out.ResourceContainer = in.ResourceContainer
out.UDPTimeoutMilliseconds = in.UDPTimeoutMilliseconds
out.UDPTimeoutMilliseconds = int32(in.UDPTimeoutMilliseconds)
return nil
}
......@@ -71,24 +71,24 @@ func autoconvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyCon
out.BindAddress = in.BindAddress
out.CleanupIPTables = in.CleanupIPTables
out.HealthzBindAddress = in.HealthzBindAddress
out.HealthzPort = in.HealthzPort
out.HealthzPort = int(in.HealthzPort)
out.HostnameOverride = in.HostnameOverride
out.IPTablesSyncePeriodSeconds = in.IPTablesSyncePeriodSeconds
out.KubeAPIBurst = in.KubeAPIBurst
out.KubeAPIQPS = in.KubeAPIQPS
out.IPTablesSyncePeriodSeconds = int(in.IPTablesSyncePeriodSeconds)
out.KubeAPIBurst = int(in.KubeAPIBurst)
out.KubeAPIQPS = int(in.KubeAPIQPS)
out.KubeconfigPath = in.KubeconfigPath
out.MasqueradeAll = in.MasqueradeAll
out.Master = in.Master
if in.OOMScoreAdj != nil {
out.OOMScoreAdj = new(int)
*out.OOMScoreAdj = *in.OOMScoreAdj
*out.OOMScoreAdj = int(*in.OOMScoreAdj)
} else {
out.OOMScoreAdj = nil
}
out.Mode = componentconfig.ProxyMode(in.Mode)
out.PortRange = in.PortRange
out.ResourceContainer = in.ResourceContainer
out.UDPTimeoutMilliseconds = in.UDPTimeoutMilliseconds
out.UDPTimeoutMilliseconds = int(in.UDPTimeoutMilliseconds)
return nil
}
......
......@@ -46,7 +46,7 @@ func deepCopy_v1alpha1_KubeProxyConfiguration(in KubeProxyConfiguration, out *Ku
out.MasqueradeAll = in.MasqueradeAll
out.Master = in.Master
if in.OOMScoreAdj != nil {
out.OOMScoreAdj = new(int)
out.OOMScoreAdj = new(int32)
*out.OOMScoreAdj = *in.OOMScoreAdj
} else {
out.OOMScoreAdj = nil
......
......@@ -34,7 +34,7 @@ func addDefaultingFuncs() {
obj.HealthzBindAddress = "127.0.0.1"
}
if obj.OOMScoreAdj == nil {
temp := qos.KubeProxyOOMScoreAdj
temp := int32(qos.KubeProxyOOMScoreAdj)
obj.OOMScoreAdj = &temp
}
if obj.IPTablesSyncePeriodSeconds == 0 {
......
......@@ -546,7 +546,7 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Deco
if r.TryDecodeAsNil() {
x.HealthzPort = 0
} else {
x.HealthzPort = int(r.DecodeInt(codecSelferBitsize1234))
x.HealthzPort = int32(r.DecodeInt(32))
}
case "hostnameOverride":
if r.TryDecodeAsNil() {
......@@ -558,19 +558,19 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Deco
if r.TryDecodeAsNil() {
x.IPTablesSyncePeriodSeconds = 0
} else {
x.IPTablesSyncePeriodSeconds = int(r.DecodeInt(codecSelferBitsize1234))
x.IPTablesSyncePeriodSeconds = int32(r.DecodeInt(32))
}
case "kubeAPIBurst":
if r.TryDecodeAsNil() {
x.KubeAPIBurst = 0
} else {
x.KubeAPIBurst = int(r.DecodeInt(codecSelferBitsize1234))
x.KubeAPIBurst = int32(r.DecodeInt(32))
}
case "kubeAPIQPS":
if r.TryDecodeAsNil() {
x.KubeAPIQPS = 0
} else {
x.KubeAPIQPS = int(r.DecodeInt(codecSelferBitsize1234))
x.KubeAPIQPS = int32(r.DecodeInt(32))
}
case "kubeconfigPath":
if r.TryDecodeAsNil() {
......@@ -597,13 +597,13 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Deco
}
} else {
if x.OOMScoreAdj == nil {
x.OOMScoreAdj = new(int)
x.OOMScoreAdj = new(int32)
}
yym74 := z.DecBinary()
_ = yym74
if false {
} else {
*((*int)(x.OOMScoreAdj)) = int(r.DecodeInt(codecSelferBitsize1234))
*((*int32)(x.OOMScoreAdj)) = int32(r.DecodeInt(32))
}
}
case "mode":
......@@ -628,7 +628,7 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Deco
if r.TryDecodeAsNil() {
x.UDPTimeoutMilliseconds = 0
} else {
x.UDPTimeoutMilliseconds = int(r.DecodeInt(codecSelferBitsize1234))
x.UDPTimeoutMilliseconds = int32(r.DecodeInt(32))
}
default:
z.DecStructFieldNotFound(-1, yys59)
......@@ -738,7 +738,7 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.De
if r.TryDecodeAsNil() {
x.HealthzPort = 0
} else {
x.HealthzPort = int(r.DecodeInt(codecSelferBitsize1234))
x.HealthzPort = int32(r.DecodeInt(32))
}
yyj79++
if yyhl79 {
......@@ -770,7 +770,7 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.De
if r.TryDecodeAsNil() {
x.IPTablesSyncePeriodSeconds = 0
} else {
x.IPTablesSyncePeriodSeconds = int(r.DecodeInt(codecSelferBitsize1234))
x.IPTablesSyncePeriodSeconds = int32(r.DecodeInt(32))
}
yyj79++
if yyhl79 {
......@@ -786,7 +786,7 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.De
if r.TryDecodeAsNil() {
x.KubeAPIBurst = 0
} else {
x.KubeAPIBurst = int(r.DecodeInt(codecSelferBitsize1234))
x.KubeAPIBurst = int32(r.DecodeInt(32))
}
yyj79++
if yyhl79 {
......@@ -802,7 +802,7 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.De
if r.TryDecodeAsNil() {
x.KubeAPIQPS = 0
} else {
x.KubeAPIQPS = int(r.DecodeInt(codecSelferBitsize1234))
x.KubeAPIQPS = int32(r.DecodeInt(32))
}
yyj79++
if yyhl79 {
......@@ -869,13 +869,13 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.De
}
} else {
if x.OOMScoreAdj == nil {
x.OOMScoreAdj = new(int)
x.OOMScoreAdj = new(int32)
}
yym94 := z.DecBinary()
_ = yym94
if false {
} else {
*((*int)(x.OOMScoreAdj)) = int(r.DecodeInt(codecSelferBitsize1234))
*((*int32)(x.OOMScoreAdj)) = int32(r.DecodeInt(32))
}
}
yyj79++
......@@ -940,7 +940,7 @@ func (x *KubeProxyConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.De
if r.TryDecodeAsNil() {
x.UDPTimeoutMilliseconds = 0
} else {
x.UDPTimeoutMilliseconds = int(r.DecodeInt(codecSelferBitsize1234))
x.UDPTimeoutMilliseconds = int32(r.DecodeInt(32))
}
for {
yyj79++
......
......@@ -21,22 +21,22 @@ import "k8s.io/kubernetes/pkg/api/unversioned"
type KubeProxyConfiguration struct {
unversioned.TypeMeta
// bindAddress is the IP address for the proxy server to serve on (set to 0.0.0.0 for all interfaces)
// bindAddress is the IP address for the proxy server to serve on (set to 0.0.0.0 for all int32erfaces)
BindAddress string `json:"bindAddress"`
// cleanupIPTables
CleanupIPTables bool `json:"cleanupIPTables"`
// healthzBindAddress is the IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)
// healthzBindAddress is the IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all int32erfaces)
HealthzBindAddress string `json:"healthzBindAddress"`
// healthzPort is the port to bind the health check server. Use 0 to disable.
HealthzPort int `json:"healthzPort"`
HealthzPort int32 `json:"healthzPort"`
// hostnameOverride, if non-empty, will be used as the identity instead of the actual hostname.
HostnameOverride string `json:"hostnameOverride"`
// iptablesSyncPeriodSeconds is the period that iptables rules are refreshed (e.g. '5s', '1m', '2h22m'). Must be greater than 0.
IPTablesSyncePeriodSeconds int `json:"iptablesSyncPeriodSeconds"`
IPTablesSyncePeriodSeconds int32 `json:"iptablesSyncPeriodSeconds"`
// kubeAPIBurst is the burst to use while talking with kubernetes apiserver
KubeAPIBurst int `json:"kubeAPIBurst"`
KubeAPIBurst int32 `json:"kubeAPIBurst"`
// kubeAPIQPS is the max QPS to use while talking with kubernetes apiserver
KubeAPIQPS int `json:"kubeAPIQPS"`
KubeAPIQPS int32 `json:"kubeAPIQPS"`
// kubeconfigPath is the path to the kubeconfig file with authorization information (the master location is set by the master flag).
KubeconfigPath string `json:"kubeconfigPath"`
// masqueradeAll tells kube-proxy to SNAT everything if using the pure iptables proxy mode.
......@@ -44,7 +44,7 @@ type KubeProxyConfiguration struct {
// master is the address of the Kubernetes API server (overrides any value in kubeconfig)
Master string `json:"master"`
// oomScoreAdj is the oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]
OOMScoreAdj *int `json:"oomScoreAdj"`
OOMScoreAdj *int32 `json:"oomScoreAdj"`
// mode specifies which proxy mode to use.
Mode ProxyMode `json:"mode"`
// portRange is the range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.
......@@ -52,7 +52,7 @@ type KubeProxyConfiguration struct {
// resourceContainer is the bsolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).
ResourceContainer string `json:"resourceContainer"`
// udpTimeoutMilliseconds is how long an idle UDP connection will be kept open (e.g. '250ms', '2s'). Must be greater than 0. Only applicable for proxyMode=userspace.
UDPTimeoutMilliseconds int `json:"udpTimeoutMilliseconds"`
UDPTimeoutMilliseconds int32 `json:"udpTimeoutMilliseconds"`
}
// Currently two modes of proxying are available: 'userspace' (older, stable) or 'iptables' (experimental). If blank, look at the Node object on the Kubernetes API and respect the 'net.experimental.kubernetes.io/proxy-mode' annotation if provided. Otherwise use the best-available proxy (currently userspace, but may change in future versions). If the iptables proxy is selected, regardless of how, but the system's kernel or iptables versions are insufficient, this always falls back to the userspace proxy.
......
......@@ -203,8 +203,8 @@ func convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*extensions.DeploymentSpec))(in)
}
out.Replicas = new(int)
*out.Replicas = in.Replicas
out.Replicas = new(int32)
*out.Replicas = int32(in.Replicas)
if in.Selector != nil {
out.Selector = make(map[string]string)
for key, val := range in.Selector {
......@@ -229,7 +229,7 @@ func convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentS
defaulting.(func(*DeploymentSpec))(in)
}
if in.Replicas != nil {
out.Replicas = *in.Replicas
out.Replicas = int(*in.Replicas)
}
if in.Selector != nil {
out.Selector = make(map[string]string)
......@@ -299,7 +299,7 @@ func convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployme
if err := s.Convert(&in.MaxSurge, out.MaxSurge, 0); err != nil {
return err
}
out.MinReadySeconds = in.MinReadySeconds
out.MinReadySeconds = int32(in.MinReadySeconds)
return nil
}
......@@ -313,7 +313,7 @@ func convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployme
if err := s.Convert(in.MaxSurge, &out.MaxSurge, 0); err != nil {
return err
}
out.MinReadySeconds = in.MinReadySeconds
out.MinReadySeconds = int(in.MinReadySeconds)
return nil
}
......
......@@ -300,7 +300,7 @@ func deepCopy_v1_FCVolumeSource(in v1.FCVolumeSource, out *v1.FCVolumeSource, c
out.TargetWWNs = nil
}
if in.Lun != nil {
out.Lun = new(int)
out.Lun = new(int32)
*out.Lun = *in.Lun
} else {
out.Lun = nil
......@@ -1046,7 +1046,7 @@ func deepCopy_v1beta1_DeploymentList(in DeploymentList, out *DeploymentList, c *
func deepCopy_v1beta1_DeploymentSpec(in DeploymentSpec, out *DeploymentSpec, c *conversion.Cloner) error {
if in.Replicas != nil {
out.Replicas = new(int)
out.Replicas = new(int32)
*out.Replicas = *in.Replicas
} else {
out.Replicas = nil
......@@ -1156,7 +1156,7 @@ func deepCopy_v1beta1_HorizontalPodAutoscalerSpec(in HorizontalPodAutoscalerSpec
return err
}
if in.MinReplicas != nil {
out.MinReplicas = new(int)
out.MinReplicas = new(int32)
*out.MinReplicas = *in.MinReplicas
} else {
out.MinReplicas = nil
......@@ -1191,7 +1191,7 @@ func deepCopy_v1beta1_HorizontalPodAutoscalerStatus(in HorizontalPodAutoscalerSt
out.CurrentReplicas = in.CurrentReplicas
out.DesiredReplicas = in.DesiredReplicas
if in.CurrentCPUUtilizationPercentage != nil {
out.CurrentCPUUtilizationPercentage = new(int)
out.CurrentCPUUtilizationPercentage = new(int32)
*out.CurrentCPUUtilizationPercentage = *in.CurrentCPUUtilizationPercentage
} else {
out.CurrentCPUUtilizationPercentage = nil
......@@ -1344,13 +1344,13 @@ func deepCopy_v1beta1_JobList(in JobList, out *JobList, c *conversion.Cloner) er
func deepCopy_v1beta1_JobSpec(in JobSpec, out *JobSpec, c *conversion.Cloner) error {
if in.Parallelism != nil {
out.Parallelism = new(int)
out.Parallelism = new(int32)
*out.Parallelism = *in.Parallelism
} else {
out.Parallelism = nil
}
if in.Completions != nil {
out.Completions = new(int)
out.Completions = new(int32)
*out.Completions = *in.Completions
} else {
out.Completions = nil
......
......@@ -59,7 +59,7 @@ func addDefaultingFuncs() {
}
// Set DeploymentSpec.Replicas to 1 if it is not set.
if obj.Spec.Replicas == nil {
obj.Spec.Replicas = new(int)
obj.Spec.Replicas = new(int32)
*obj.Spec.Replicas = 1
}
strategy := &obj.Spec.Strategy
......@@ -102,7 +102,7 @@ func addDefaultingFuncs() {
}
}
if obj.Spec.Completions == nil {
completions := 1
completions := int32(1)
obj.Spec.Completions = &completions
}
if obj.Spec.Parallelism == nil {
......@@ -111,7 +111,7 @@ func addDefaultingFuncs() {
},
func(obj *HorizontalPodAutoscaler) {
if obj.Spec.MinReplicas == nil {
minReplicas := 1
minReplicas := int32(1)
obj.Spec.MinReplicas = &minReplicas
}
if obj.Spec.CPUUtilization == nil {
......
......@@ -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,8 +294,8 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
return obj3
}
func newInt(val int) *int {
p := new(int)
func newInt32(val int32) *int32 {
p := new(int32)
*p = val
return p
}
......
......@@ -25,13 +25,13 @@ import (
// describes the attributes of a scale subresource
type ScaleSpec struct {
// desired number of instances for the scaled object.
Replicas int `json:"replicas,omitempty"`
Replicas int32 `json:"replicas,omitempty"`
}
// represents the current status of a scale subresource.
type ScaleStatus struct {
// actual number of observed instances of the scaled object.
Replicas int `json:"replicas"`
Replicas int32 `json:"replicas"`
// label query over pods that should match the replicas count. More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
Selector map[string]string `json:"selector,omitempty"`
......@@ -70,7 +70,7 @@ type SubresourceReference struct {
type CPUTargetUtilization struct {
// fraction of the requested CPU that should be utilized/used,
// e.g. 70 means that 70% of the requested CPU should be in use.
TargetPercentage int `json:"targetPercentage"`
TargetPercentage int32 `json:"targetPercentage"`
}
// specification of a horizontal pod autoscaler.
......@@ -79,9 +79,9 @@ type HorizontalPodAutoscalerSpec struct {
// and will set the desired number of pods by modifying its spec.
ScaleRef SubresourceReference `json:"scaleRef"`
// lower limit for the number of pods that can be set by the autoscaler, default 1.
MinReplicas *int `json:"minReplicas,omitempty"`
MinReplicas *int32 `json:"minReplicas,omitempty"`
// upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas.
MaxReplicas int `json:"maxReplicas"`
MaxReplicas int32 `json:"maxReplicas"`
// target average CPU utilization (represented as a percentage of requested CPU) over all the pods;
// if not specified it defaults to the target CPU utilization at 80% of the requested resources.
CPUUtilization *CPUTargetUtilization `json:"cpuUtilization,omitempty"`
......@@ -97,14 +97,14 @@ type HorizontalPodAutoscalerStatus struct {
LastScaleTime *unversioned.Time `json:"lastScaleTime,omitempty"`
// current number of replicas of pods managed by this autoscaler.
CurrentReplicas int `json:"currentReplicas"`
CurrentReplicas int32 `json:"currentReplicas"`
// desired number of replicas of pods managed by this autoscaler.
DesiredReplicas int `json:"desiredReplicas"`
DesiredReplicas int32 `json:"desiredReplicas"`
// current average CPU utilization over all pods, represented as a percentage of requested CPU,
// e.g. 70 means that an average pod is using now 70% of its requested CPU.
CurrentCPUUtilizationPercentage *int `json:"currentCPUUtilizationPercentage,omitempty"`
CurrentCPUUtilizationPercentage *int32 `json:"currentCPUUtilizationPercentage,omitempty"`
}
// configuration of a horizontal pod autoscaler.
......@@ -192,7 +192,7 @@ type Deployment struct {
type DeploymentSpec struct {
// Number of desired pods. This is a pointer to distinguish between explicit
// zero and not specified. Defaults to 1.
Replicas *int `json:"replicas,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
// Label selector for pods. Existing ReplicationControllers whose pods are
// selected by this will be the ones affected by this deployment.
......@@ -268,16 +268,16 @@ type RollingUpdateDeployment struct {
// Minimum number of seconds for which a newly created pod should be ready
// without any of its container crashing, for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
MinReadySeconds int `json:"minReadySeconds,omitempty"`
MinReadySeconds int32 `json:"minReadySeconds,omitempty"`
}
// DeploymentStatus is the most recently observed status of the Deployment.
type DeploymentStatus struct {
// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
Replicas int `json:"replicas,omitempty"`
Replicas int32 `json:"replicas,omitempty"`
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
UpdatedReplicas int `json:"updatedReplicas,omitempty"`
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
}
// DeploymentList is a list of Deployments.
......@@ -311,17 +311,17 @@ type DaemonSetStatus struct {
// CurrentNumberScheduled is the number of nodes that are running at least 1
// daemon pod and are supposed to run the daemon pod.
// More info: http://releases.k8s.io/HEAD/docs/admin/daemon.md
CurrentNumberScheduled int `json:"currentNumberScheduled"`
CurrentNumberScheduled int32 `json:"currentNumberScheduled"`
// NumberMisscheduled is the number of nodes that are running the daemon pod, but are
// not supposed to run the daemon pod.
// More info: http://releases.k8s.io/HEAD/docs/admin/daemon.md
NumberMisscheduled int `json:"numberMisscheduled"`
NumberMisscheduled int32 `json:"numberMisscheduled"`
// DesiredNumberScheduled is the total number of nodes that should be running the daemon
// pod (including nodes correctly running the daemon pod).
// More info: http://releases.k8s.io/HEAD/docs/admin/daemon.md
DesiredNumberScheduled int `json:"desiredNumberScheduled"`
DesiredNumberScheduled int32 `json:"desiredNumberScheduled"`
}
// DaemonSet represents the configuration of a daemon set.
......@@ -400,12 +400,12 @@ type JobSpec struct {
// be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism),
// i.e. when the work left to do is less than max parallelism.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/jobs.md
Parallelism *int `json:"parallelism,omitempty"`
Parallelism *int32 `json:"parallelism,omitempty"`
// Completions specifies the desired number of successfully finished pods the
// job should be run with. Defaults to 1.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/jobs.md
Completions *int `json:"completions,omitempty"`
Completions *int32 `json:"completions,omitempty"`
// Selector is a label query over pods that should match the pod count.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
......@@ -435,13 +435,13 @@ type JobStatus struct {
CompletionTime *unversioned.Time `json:"completionTime,omitempty"`
// Active is the number of actively running pods.
Active int `json:"active,omitempty"`
Active int32 `json:"active,omitempty"`
// Succeeded is the number of pods which reached Phase Succeeded.
Succeeded int `json:"succeeded,omitempty"`
Succeeded int32 `json:"succeeded,omitempty"`
// Failed is the number of pods which reached Phase Failed.
Failed int `json:"failed,omitempty"`
Failed int32 `json:"failed,omitempty"`
}
type JobConditionType string
......@@ -621,10 +621,10 @@ type NodeUtilization struct {
// Configuration of the Cluster Autoscaler
type ClusterAutoscalerSpec struct {
// Minimum number of nodes that the cluster should have.
MinNodes int `json:"minNodes"`
MinNodes int32 `json:"minNodes"`
// Maximum number of nodes that the cluster should have.
MaxNodes int `json:"maxNodes"`
MaxNodes int32 `json:"maxNodes"`
// Target average utilization of the cluster nodes. New nodes will be added if one of the
// targets is exceeded. Cluster size will be decreased if the current utilization is too low
......
......@@ -249,7 +249,7 @@ func getIntOrPercentValue(intOrStringValue intstr.IntOrString) int {
if isPercent {
return value
}
return intOrStringValue.IntVal
return intOrStringValue.IntValue()
}
func IsNotMoreThan100Percent(intOrStringValue intstr.IntOrString, fieldName string) validation.ErrorList {
......@@ -525,7 +525,7 @@ func validateIngressBackend(backend *extensions.IngressBackend) validation.Error
if !validation.IsValidPortName(backend.ServicePort.StrVal) {
allErrs = append(allErrs, validation.NewInvalidError("servicePort", backend.ServicePort.StrVal, apivalidation.PortNameErrorMsg))
}
} else if !validation.IsValidPortNum(backend.ServicePort.IntVal) {
} else if !validation.IsValidPortNum(backend.ServicePort.IntValue()) {
allErrs = append(allErrs, validation.NewInvalidError("servicePort", backend.ServicePort, apivalidation.PortRangeErrorMsg))
}
return allErrs
......
......@@ -420,8 +420,9 @@ func prettyJSON(codec runtime.Codec, object runtime.Object, w http.ResponseWrite
// errorJSON renders an error to the response. Returns the HTTP status code of the error.
func errorJSON(err error, codec runtime.Codec, w http.ResponseWriter) int {
status := errToAPIStatus(err)
writeJSON(status.Code, codec, status, w, true)
return status.Code
code := int(status.Code)
writeJSON(code, codec, status, w, true)
return code
}
// errorJSONFatal renders an error to the response, and if codec fails will render plaintext.
......@@ -429,16 +430,17 @@ func errorJSON(err error, codec runtime.Codec, w http.ResponseWriter) int {
func errorJSONFatal(err error, codec runtime.Codec, w http.ResponseWriter) int {
util.HandleError(fmt.Errorf("apiserver was unable to write a JSON response: %v", err))
status := errToAPIStatus(err)
code := int(status.Code)
output, err := codec.Encode(status)
if err != nil {
w.WriteHeader(status.Code)
w.WriteHeader(code)
fmt.Fprintf(w, "%s: %s", status.Reason, status.Message)
return status.Code
return code
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status.Code)
w.WriteHeader(code)
w.Write(output)
return status.Code
return code
}
// writeRawJSON writes a non-API object in JSON.
......
......@@ -62,7 +62,7 @@ func errToAPIStatus(err error) *unversioned.Status {
util.HandleError(fmt.Errorf("apiserver received an error that is not an unversioned.Status: %v", err))
return &unversioned.Status{
Status: unversioned.StatusFailure,
Code: status,
Code: int32(status),
Reason: unversioned.StatusReasonUnknown,
Message: err.Error(),
}
......
......@@ -109,8 +109,9 @@ func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if err != nil {
httplog.LogOf(req, w).Addf("Error getting ResourceLocation: %v", err)
status := errToAPIStatus(err)
writeJSON(status.Code, r.codec, status, w, true)
httpCode = status.Code
code := int(status.Code)
writeJSON(code, r.codec, status, w, true)
httpCode = code
return
}
if location == nil {
......@@ -144,9 +145,10 @@ func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
newReq, err := http.NewRequest(req.Method, location.String(), req.Body)
if err != nil {
status := errToAPIStatus(err)
writeJSON(status.Code, r.codec, status, w, true)
code := int(status.Code)
writeJSON(code, r.codec, status, w, true)
notFound(w, req)
httpCode = status.Code
httpCode = code
return
}
httpCode = http.StatusOK
......@@ -211,7 +213,8 @@ func (r *ProxyHandler) tryUpgrade(w http.ResponseWriter, req, newReq *http.Reque
backendConn, err := proxyutil.DialURL(location, transport)
if err != nil {
status := errToAPIStatus(err)
writeJSON(status.Code, r.codec, status, w, true)
code := int(status.Code)
writeJSON(code, r.codec, status, w, true)
return true
}
defer backendConn.Close()
......@@ -222,14 +225,16 @@ func (r *ProxyHandler) tryUpgrade(w http.ResponseWriter, req, newReq *http.Reque
requestHijackedConn, _, err := w.(http.Hijacker).Hijack()
if err != nil {
status := errToAPIStatus(err)
writeJSON(status.Code, r.codec, status, w, true)
code := int(status.Code)
writeJSON(code, r.codec, status, w, true)
return true
}
defer requestHijackedConn.Close()
if err = newReq.Write(backendConn); err != nil {
status := errToAPIStatus(err)
writeJSON(status.Code, r.codec, status, w, true)
code := int(status.Code)
writeJSON(code, r.codec, status, w, true)
return true
}
......
......@@ -347,7 +347,7 @@ func TestTransformResponse(t *testing.T) {
t.Errorf("%d: response should have been transformable into APIStatus: %v", i, err)
continue
}
if status.Status().Code != test.Response.StatusCode {
if int(status.Status().Code) != test.Response.StatusCode {
t.Errorf("%d: status code did not match response: %#v", i, status.Status())
}
}
......
......@@ -419,7 +419,7 @@ func findPort(pod *api.Pod, svcPort *api.ServicePort) (int, error) {
}
}
case intstr.Int:
return portName.IntVal, nil
return portName.IntValue(), nil
}
return 0, fmt.Errorf("no suitable port for manifest: %s", pod.UID)
......
......@@ -489,7 +489,7 @@ func extractMaxValue(field intstr.IntOrString, name string, value int) (int, err
if field.IntVal < 0 {
return 0, fmt.Errorf("%s must be >= 0", name)
}
return field.IntVal, nil
return field.IntValue(), nil
case intstr.String:
s := strings.Replace(field.StrVal, "%", "", -1)
v, err := strconv.Atoi(s)
......
......@@ -33,7 +33,7 @@ func encodeOrDie(obj runtime.Object) []byte {
}
func TestSortingPrinter(t *testing.T) {
intPtr := func(val int) *int { return &val }
intPtr := func(val int32) *int32 { return &val }
a := &api.Pod{
ObjectMeta: api.ObjectMeta{
......
......@@ -68,19 +68,17 @@ func (hr *HandlerRunner) Run(containerID kubecontainer.ContainerID, pod *api.Pod
// port is found, an error is returned.
func resolvePort(portReference intstr.IntOrString, container *api.Container) (int, error) {
if portReference.Type == intstr.Int {
return portReference.IntVal, nil
} else {
portName := portReference.StrVal
port, err := strconv.Atoi(portName)
if err == nil {
return port, nil
}
for _, portSpec := range container.Ports {
if portSpec.Name == portName {
return portSpec.ContainerPort, nil
}
return portReference.IntValue(), nil
}
portName := portReference.StrVal
port, err := strconv.Atoi(portName)
if err == nil {
return port, nil
}
for _, portSpec := range container.Ports {
if portSpec.Name == portName {
return portSpec.ContainerPort, nil
}
}
return -1, fmt.Errorf("couldn't find port: %v in %v", portReference, container)
}
......
......@@ -163,7 +163,7 @@ func extractPort(param intstr.IntOrString, container api.Container) (int, error)
var err error
switch param.Type {
case intstr.Int:
port = param.IntVal
port = param.IntValue()
case intstr.String:
if port, err = findPortByName(container, param.StrVal); err != nil {
// Last ditch effort - maybe it was an int stored as string?
......
......@@ -163,7 +163,7 @@ func (w *worker) doProbe() (keepGoing bool) {
w.pod.Spec.RestartPolicy != api.RestartPolicyNever
}
if int64(time.Since(c.State.Running.StartedAt.Time).Seconds()) < w.spec.InitialDelaySeconds {
if int(time.Since(c.State.Running.StartedAt.Time).Seconds()) < w.spec.InitialDelaySeconds {
return true
}
......
......@@ -111,6 +111,22 @@ func (g *conversionGenerator) GenerateConversionsForType(gv unversioned.GroupVer
return nil
}
// primitiveConversion returns true if the two types can be converted via a cast.
func primitiveConversion(inType, outType reflect.Type) (string, bool) {
switch inType.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
reflect.Float32, reflect.Float64:
switch outType.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
reflect.Float32, reflect.Float64:
return outType.Name(), true
}
}
return "", false
}
func (g *conversionGenerator) generateConversionsBetween(inType, outType reflect.Type) error {
existingConversion := g.scheme.Converter().HasConversionFunc(inType, outType) && g.scheme.Converter().HasConversionFunc(outType, inType)
......@@ -126,6 +142,10 @@ func (g *conversionGenerator) generateConversionsBetween(inType, outType reflect
return nil
}
if _, ok := primitiveConversion(inType, outType); ok {
return nil
}
if inType.Kind() != outType.Kind() {
if existingConversion {
return nil
......
......@@ -24,13 +24,14 @@ import (
"github.com/google/gofuzz"
)
// IntOrString is a type that can hold an int or a string. When used in
// IntOrString is a type that can hold an int32 or a string. When used in
// 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 int
IntVal int32
StrVal string
}
......@@ -42,9 +43,12 @@ 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: val}
return IntOrString{Type: Int, IntVal: int32(val)}
}
// FromString creates an IntOrString object with a string value.
......@@ -67,7 +71,17 @@ func (intstr *IntOrString) String() string {
if intstr.Type == String {
return intstr.StrVal
}
return strconv.Itoa(intstr.IntVal)
return strconv.Itoa(intstr.IntValue())
}
// 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 {
i, _ := strconv.Atoi(intstr.StrVal)
return i
}
return int(intstr.IntVal)
}
// MarshalJSON implements the json.Marshaller interface.
......
......@@ -136,14 +136,14 @@ func Until(f func(), period time.Duration, stopCh <-chan struct{}) {
func GetIntOrPercentValue(intOrStr *intstr.IntOrString) (int, bool, error) {
switch intOrStr.Type {
case intstr.Int:
return intOrStr.IntVal, false, nil
return intOrStr.IntValue(), false, nil
case intstr.String:
s := strings.Replace(intOrStr.StrVal, "%", "", -1)
v, err := strconv.Atoi(s)
if err != nil {
return 0, false, fmt.Errorf("invalid value %q: %v", intOrStr.StrVal, err)
}
return v, true, nil
return int(v), true, nil
}
return 0, false, fmt.Errorf("invalid value: neither int nor percentage")
}
......
......@@ -616,7 +616,7 @@ var _ = Describe("Kubectl client", func() {
if port.Port != servicePort {
Failf("Wrong service port: %d", port.Port)
}
if port.TargetPort.IntVal != redisPort {
if port.TargetPort.IntValue() != redisPort {
Failf("Wrong target port: %d")
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment