Commit eea949b3 authored by Tim Hockin's avatar Tim Hockin

Print named ports in 'describe service'

Also in 'describe service'. This got missed in all the multiport work.
parent 45d8c97b
......@@ -29,6 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
)
......@@ -457,8 +458,8 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
name = "<unnamed>"
}
fmt.Fprintf(out, "Port:\t%s\t%d/%s\n", name, sp.Port, sp.Protocol)
fmt.Fprintf(out, "Endpoints:\t%s\t%s\n", name, formatEndpoints(endpoints, util.NewStringSet(sp.Name)))
}
fmt.Fprintf(out, "Endpoints:\t%s\n", formatEndpoints(endpoints))
fmt.Fprintf(out, "Session Affinity:\t%s\n", service.Spec.SessionAffinity)
if events != nil {
DescribeEvents(events, out)
......
......@@ -305,7 +305,8 @@ func (h *HumanReadablePrinter) printHeader(columnNames []string, w io.Writer) er
return nil
}
func formatEndpoints(endpoints *api.Endpoints) string {
// Pass ports=nil for all ports.
func formatEndpoints(endpoints *api.Endpoints, ports util.StringSet) string {
if len(endpoints.Subsets) == 0 {
return "<none>"
}
......@@ -317,7 +318,7 @@ Loop:
ss := &endpoints.Subsets[i]
for i := range ss.Ports {
port := &ss.Ports[i]
if port.Name == "" { // TODO: add multi-port support.
if ports == nil || ports.Has(port.Name) {
for i := range ss.Addresses {
if len(list) == max {
more = true
......@@ -555,7 +556,7 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
}
func printEndpoints(endpoints *api.Endpoints, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\n", endpoints.Name, formatEndpoints(endpoints))
_, err := fmt.Fprintf(w, "%s\t%s\n", endpoints.Name, formatEndpoints(endpoints, nil))
return err
}
......
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