Merge pull request #8778 from kargakis/show-pod-number

Show pods number when describing services
pull/6/head
Tim Hockin 2015-05-28 14:59:02 -07:00
commit 32859c3954
2 changed files with 7 additions and 5 deletions

View File

@ -522,7 +522,7 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
if sp.NodePort != 0 {
fmt.Fprintf(out, "NodePort:\t%s\t%d/%s\n", name, sp.NodePort, 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, util.NewStringSet(sp.Name)))
}
fmt.Fprintf(out, "Session Affinity:\t%s\n", service.Spec.SessionAffinity)
if events != nil {

View File

@ -317,7 +317,7 @@ func formatEndpoints(endpoints *api.Endpoints, ports util.StringSet) string {
list := []string{}
max := 3
more := false
Loop:
count := 0
for i := range endpoints.Subsets {
ss := &endpoints.Subsets[i]
for i := range ss.Ports {
@ -326,17 +326,19 @@ Loop:
for i := range ss.Addresses {
if len(list) == max {
more = true
break Loop
}
addr := &ss.Addresses[i]
list = append(list, fmt.Sprintf("%s:%d", addr.IP, port.Port))
if !more {
list = append(list, fmt.Sprintf("%s:%d", addr.IP, port.Port))
}
count++
}
}
}
}
ret := strings.Join(list, ",")
if more {
ret += "..."
return fmt.Sprintf("%s + %d more...", ret, count-max)
}
return ret
}