From 2b19c002cbcf2cb9f87f76cc71eac5f816ad74d9 Mon Sep 17 00:00:00 2001 From: Piotr Szczesniak Date: Wed, 17 Jun 2015 15:10:03 +0200 Subject: [PATCH] Migrated kubectl cluster-info to v1. Addresses #7018 Also fixed the case when kubernetes.io/name label is not defined (another fix for #9875) --- pkg/kubectl/cmd/clusterinfo.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/cmd/clusterinfo.go b/pkg/kubectl/cmd/clusterinfo.go index 28efaff3905..3641890feab 100644 --- a/pkg/kubectl/cmd/clusterinfo.go +++ b/pkg/kubectl/cmd/clusterinfo.go @@ -23,6 +23,7 @@ import ( "strconv" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/resource" @@ -82,9 +83,13 @@ func RunClusterInfo(factory *cmdutil.Factory, out io.Writer, cmd *cobra.Command) link += "http://" + ip + ":" + strconv.Itoa(port.Port) + " " } } else { - link = client.Host + "/api/v1beta3/proxy/namespaces/" + service.ObjectMeta.Namespace + "/services/" + service.ObjectMeta.Name + link = client.Host + "/api/" + latest.Version + "/proxy/namespaces/" + service.ObjectMeta.Namespace + "/services/" + service.ObjectMeta.Name } - printService(out, service.ObjectMeta.Labels["kubernetes.io/name"], link) + name := service.ObjectMeta.Labels["kubernetes.io/name"] + if len(name) == 0 { + name = service.ObjectMeta.Name + } + printService(out, name, link) } return nil })