Skip to content

Commit 9f41fd4

Browse files
committed
populate target port in service list
1 parent 92fe4dd commit 9f41fd4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: cmd/minikube/cmd/service_list.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ var serviceListCmd = &cobra.Command{
6666
if len(serviceURL.URLs) == 0 {
6767
data = append(data, []string{serviceURL.Namespace, serviceURL.Name, "No node port"})
6868
} else {
69+
servicePortNames := strings.Join(serviceURL.PortNames, "\n")
6970
serviceURLs := strings.Join(serviceURL.URLs, "\n")
7071

7172
// if we are running Docker on OSX we empty the internal service URLs
7273
if runtime.GOOS == "darwin" && cfg.Driver == oci.Docker {
7374
serviceURLs = ""
7475
}
7576

76-
data = append(data, []string{serviceURL.Namespace, serviceURL.Name, "", serviceURLs})
77+
data = append(data, []string{serviceURL.Namespace, serviceURL.Name, servicePortNames, serviceURLs})
7778
}
7879
}
7980

Diff for: pkg/minikube/service/service.go

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io"
2323
"net/url"
2424
"os"
25+
"strconv"
2526
"strings"
2627
"text/template"
2728
"time"
@@ -196,6 +197,13 @@ func printURLsForService(c typed_core.CoreV1Interface, ip, service, namespace st
196197
urls := []string{}
197198
portNames := []string{}
198199
for _, port := range svc.Spec.Ports {
200+
201+
if port.Name != "" {
202+
m[port.TargetPort.IntVal] = port.Name
203+
} else {
204+
m[port.TargetPort.IntVal] = strconv.Itoa(int(port.Port))
205+
}
206+
199207
if port.NodePort > 0 {
200208
var doc bytes.Buffer
201209
err = t.Execute(&doc, struct {

0 commit comments

Comments
 (0)