From ac8c61a9d1ba7b63ab3b6e6df835ae1f7188a42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilson=20J=C3=BAnior?= Date: Mon, 12 Aug 2024 18:41:48 -0300 Subject: [PATCH] Implement Dashboard URL --- go.mod | 2 +- go.sum | 4 ++-- tsuru/client/apps.go | 7 +++++++ tsuru/client/jobs.go | 10 +++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 8dc8ecff..b717cf34 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/pmorie/go-open-service-broker-client v0.0.0-20180330214919-dca737037ce6 github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa - github.com/tsuru/go-tsuruclient v0.0.0-20240802204705-a93c2a18a794 + github.com/tsuru/go-tsuruclient v0.0.0-20240812213541-df5e446efabf github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6 github.com/tsuru/tsuru v0.0.0-20240703132558-bfd1d9c89602 golang.org/x/net v0.25.0 diff --git a/go.sum b/go.sum index 061797d8..59bb9882 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/tsuru/config v0.0.0-20201023175036-375aaee8b560 h1:fniQ/BmYAHdnNmY333 github.com/tsuru/config v0.0.0-20201023175036-375aaee8b560/go.mod h1:mj6t8JKWU51GScTT50XRmDj65T5XhTyNvO5FUNV5zS4= github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa h1:JlLQP1xa13a994p/Aau2e3K9xXYaHNoNvTDVIMHSUa4= github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa/go.mod h1:UibOSvkMFKRe/eiwktAPAvQG8L+p8nYsECJvu3Dgw7I= -github.com/tsuru/go-tsuruclient v0.0.0-20240802204705-a93c2a18a794 h1:3TdjKGfvCOaZIrWrxkMIaxqQ+qNLzmWiZXDkW1kY/xY= -github.com/tsuru/go-tsuruclient v0.0.0-20240802204705-a93c2a18a794/go.mod h1:qwh/KJ6ypa2GISRI79XFOHhnSjGOe1cZVPHF3nfrf18= +github.com/tsuru/go-tsuruclient v0.0.0-20240812213541-df5e446efabf h1:Jwxn42PtNz2bbOYKwQWFUMlo3sYy2LIYEDFcEPej7M0= +github.com/tsuru/go-tsuruclient v0.0.0-20240812213541-df5e446efabf/go.mod h1:qwh/KJ6ypa2GISRI79XFOHhnSjGOe1cZVPHF3nfrf18= github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6 h1:1XDdWFAjIbCSG1OjN9v9KdWhuM8UtYlFcfHe/Ldkchk= github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6/go.mod h1:ztYpOhW+u1k21FEqp7nZNgpWbr0dUKok5lgGCZi+1AQ= github.com/tsuru/tsuru v0.0.0-20240703132558-bfd1d9c89602 h1:HiF99OFCkd2F0DwyMzBDStxm43rtrK8sBnVA2ZyfIZ4= diff --git a/tsuru/client/apps.go b/tsuru/client/apps.go index 51a5c6e0..d752ccbc 100644 --- a/tsuru/client/apps.go +++ b/tsuru/client/apps.go @@ -555,6 +555,7 @@ type app struct { Routers []apptypes.AppRouter AutoScale []tsuru.AutoScaleSpec + DashboardURL string InternalAddresses []appInternalAddress UnitsMetrics []unitMetrics VolumeBinds []volumeTypes.VolumeBind @@ -657,6 +658,9 @@ const simplifiedFormat = `{{ if .Error -}} Error: {{ .Error }} {{ end -}} Application: {{.Name}} +{{ if .DashboardURL -}} +Dashboard: {{ .DashboardURL }} +{{- end }} {{- if .Description }} Description: {{.Description}} {{- end }} @@ -686,6 +690,9 @@ const fullFormat = `{{ if .Error -}} Error: {{ .Error }} {{ end -}} Application: {{.Name}} +{{ if .DashboardURL -}} +Dashboard: {{ .DashboardURL }} +{{- end }} {{- if .Description }} Description: {{.Description}} {{- end }} diff --git a/tsuru/client/jobs.go b/tsuru/client/jobs.go index d90de24d..e278ad27 100644 --- a/tsuru/client/jobs.go +++ b/tsuru/client/jobs.go @@ -207,6 +207,9 @@ const jobInfoFormat = `Job: {{.Job.Name}} {{- with .Job.Description }} Description: {{.}} {{- end }} +{{- with .DashboardURL }} +Dashboard: {{.}} +{{- end }} Teams: {{.Teams}} Created by: {{.Job.Owner}} Pool: {{.Job.Pool}} @@ -243,9 +246,10 @@ func (c *JobInfo) Run(ctx *cmd.Context) error { teams := renderTeams(jobInfo.Job) err = tmpl.Execute(&buf, struct { - Job tsuru.Job - Teams string - }{jobInfo.Job, teams}) + Job tsuru.Job + DashboardURL string + Teams string + }{Job: jobInfo.Job, DashboardURL: jobInfo.DashboardURL, Teams: teams}) if err != nil { return err }