Display <none> for clusterIP and port when service is ExternalName

This commit is contained in:
FengyunPan
2017-06-08 19:55:23 +08:00
parent 0b1ab50883
commit a97a9f9dd5

View File

@@ -745,7 +745,14 @@ func printService(svc *api.Service, w io.Writer, options printers.PrintOptions)
namespace := svc.Namespace
svcType := svc.Spec.Type
internalIP := svc.Spec.ClusterIP
if len(internalIP) == 0 {
internalIP = "<none>"
}
externalIP := getServiceExternalIP(svc, options.Wide)
svcPorts := makePortString(svc.Spec.Ports)
if len(svcPorts) == 0 {
svcPorts = "<none>"
}
if options.WithNamespace {
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
@@ -757,7 +764,7 @@ func printService(svc *api.Service, w io.Writer, options printers.PrintOptions)
string(svcType),
internalIP,
externalIP,
makePortString(svc.Spec.Ports),
svcPorts,
translateTimestamp(svc.CreationTimestamp),
); err != nil {
return err