Skip to content

Commit

Permalink
populate target port in service list
Browse files Browse the repository at this point in the history
  • Loading branch information
Prasad Katti authored and Prasad Katti committed Mar 4, 2020
1 parent 92fe4dd commit eab12d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/minikube/cmd/service_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ var serviceListCmd = &cobra.Command{
if len(serviceURL.URLs) == 0 {
data = append(data, []string{serviceURL.Namespace, serviceURL.Name, "No node port"})
} else {
servicePortNames := strings.Join(serviceURL.PortNames, "\n")
serviceURLs := strings.Join(serviceURL.URLs, "\n")

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

data = append(data, []string{serviceURL.Namespace, serviceURL.Name, "", serviceURLs})
data = append(data, []string{serviceURL.Namespace, serviceURL.Name, servicePortNames, serviceURLs})
}
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/minikube/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"net/url"
"os"
"strconv"
"strings"
"text/template"
"time"
Expand Down Expand Up @@ -196,6 +197,13 @@ func printURLsForService(c typed_core.CoreV1Interface, ip, service, namespace st
urls := []string{}
portNames := []string{}
for _, port := range svc.Spec.Ports {

if port.Name != "" {
m[port.TargetPort.IntVal] = port.Name
} else {
m[port.TargetPort.IntVal] = strconv.Itoa(int(port.Port))
}

if port.NodePort > 0 {
var doc bytes.Buffer
err = t.Execute(&doc, struct {
Expand Down

0 comments on commit eab12d9

Please sign in to comment.