From 1381de2c6892e8047cbebd4c8f122d435bdd6149 Mon Sep 17 00:00:00 2001 From: rajat404 <404rajat@gmail.com> Date: Fri, 6 Mar 2020 09:41:52 +0530 Subject: [PATCH] Display VM`s zone as well --- gcloud/instance.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcloud/instance.go b/gcloud/instance.go index a278971..7fee221 100644 --- a/gcloud/instance.go +++ b/gcloud/instance.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "os" + "strings" ) type Instance struct { @@ -15,7 +16,10 @@ type Instance struct { } func (i Instance) String() string { - res := fmt.Sprintf("%-30s : %-50s %-10s", i.Project, i.Name, i.IP()) + zoneURL := strings.Split(i.Zone, "zones/") + zone := zoneURL[len(zoneURL)-1] + + res := fmt.Sprintf("%-30s %-50s %-30s %-30s", i.Project, i.Name, i.IP(), zone) if i.ExternalIP() != "" { return fmt.Sprintf("%s External: %s", res, i.ExternalIP()) }