From 9fb96a23c29a0456934a9499be5b066155b39b45 Mon Sep 17 00:00:00 2001 From: James Wallis Date: Mon, 15 Jun 2020 13:25:59 +0100 Subject: [PATCH] Add project name to project link list output (#495) * Add project name to link get output * Add url to human readable output Signed-off-by: James Wallis --- pkg/actions/project.go | 4 ++-- pkg/project/link.go | 7 ++++--- pkg/project/link_test.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/actions/project.go b/pkg/actions/project.go index add164c9..bdfc832c 100644 --- a/pkg/actions/project.go +++ b/pkg/actions/project.go @@ -304,9 +304,9 @@ func ProjectLinkList(c *cli.Context) { } else { w := new(tabwriter.Writer) w.Init(os.Stdout, 0, 8, 2, '\t', 0) - fmt.Fprintln(w, "ENVIRONMENT VARIABLE \tPROJECT ID") + fmt.Fprintln(w, "TARGET PROJECT \tENVIRONMENT VARIABLE \t TARGET URL") for _, project := range links { - fmt.Fprintln(w, project.EnvName+"\t"+project.ProjectID) + fmt.Fprintln(w, project.ProjectName+"\t"+project.EnvName+"\t"+project.ProjectURL) } fmt.Fprintln(w) w.Flush() diff --git a/pkg/project/link.go b/pkg/project/link.go index de729991..2f7f72eb 100644 --- a/pkg/project/link.go +++ b/pkg/project/link.go @@ -26,9 +26,10 @@ import ( type ( // Link : The structure of a Link object returned from PFE Link struct { - ProjectID string `json:"projectID"` - EnvName string `json:"envName"` - ProjectURL string `json:"projectURL"` + ProjectID string `json:"projectID"` + ProjectName string `json:"projectName"` + EnvName string `json:"envName"` + ProjectURL string `json:"projectURL"` } // LinkParameters : The request structure to create a link LinkParameters struct { diff --git a/pkg/project/link_test.go b/pkg/project/link_test.go index 3a7ade2d..0d131651 100644 --- a/pkg/project/link_test.go +++ b/pkg/project/link_test.go @@ -33,8 +33,8 @@ func TestGetProjectLinks(t *testing.T) { t.Run("Expect success - project links should be returned", func(t *testing.T) { // construct mock response body and status code links := []Link{ - Link{ProjectID: "1234", ProjectURL: "URL1", EnvName: "ENV1"}, - Link{ProjectID: "9999", ProjectURL: "URL2", EnvName: "ENV2"}, + Link{ProjectID: "1234", ProjectName: "name1", ProjectURL: "URL1", EnvName: "ENV1"}, + Link{ProjectID: "9999", ProjectName: "name2", ProjectURL: "URL2", EnvName: "ENV2"}, } jsonResponse, _ := json.Marshal(links) body := ioutil.NopCloser(bytes.NewReader([]byte(jsonResponse)))