mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
Merge pull request #119618 from skitt/use-intstr-parse
Use intstr.Parse instead of reimplementing it
This commit is contained in:
commit
09cab7d521
@ -532,12 +532,7 @@ func (o *ExposeServiceOptions) createService() (*corev1.Service, error) {
|
|||||||
}
|
}
|
||||||
targetPortString := o.TargetPort
|
targetPortString := o.TargetPort
|
||||||
if len(targetPortString) > 0 {
|
if len(targetPortString) > 0 {
|
||||||
var targetPort intstr.IntOrString
|
targetPort := intstr.Parse(targetPortString)
|
||||||
if portNum, err := strconv.Atoi(targetPortString); err != nil {
|
|
||||||
targetPort = intstr.FromString(targetPortString)
|
|
||||||
} else {
|
|
||||||
targetPort = intstr.FromInt(portNum)
|
|
||||||
}
|
|
||||||
// Use the same target-port for every port
|
// Use the same target-port for every port
|
||||||
for i := range service.Spec.Ports {
|
for i := range service.Spec.Ports {
|
||||||
service.Spec.Ports[i].TargetPort = targetPort
|
service.Spec.Ports[i].TargetPort = targetPort
|
||||||
|
Loading…
Reference in New Issue
Block a user