From a760803a2cd8ad3b77064e2e5386ecab65d9bbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20P=C3=A9rez=20Schr=C3=B6der?= <2639770+nomonamo@users.noreply.github.com> Date: Mon, 25 Nov 2019 17:37:50 +0100 Subject: [PATCH] Expose version on API (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pablo Pérez Schröder <2639770+nomonamo@users.noreply.github.com> --- .travis.yml | 2 ++ api/server.go | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.travis.yml b/.travis.yml index e7fa5975..44db7534 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,9 +28,11 @@ before_script: script: - make test-travis + - make release # still don't know where to upload install-utask.sh ... after_success: - $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN - curl -sL https://git.io/goreleaser | head -n -2 | bash - tar -xf /tmp/goreleaser.tar.gz -C $GOPATH/bin + - git reset --hard HEAD # reset go.mod and go.sum, modified by make test-travis, is this an OK move? - make run-goreleaser \ No newline at end of file diff --git a/api/server.go b/api/server.go index fe12b2c0..c1f4b95d 100644 --- a/api/server.go +++ b/api/server.go @@ -241,12 +241,21 @@ func (s *Server) build(ctx context.Context) { }, maintenanceMode, tonic.Handler(handler.CancelResolution, 204)) + // authRoutes.POST("/resolution/:id/rollback", // []fizz.OperationOption{ // fizz.Summary(""), // }, // tonic.Handler(handler.ResolutionRollback, 200)) + authRoutes.GET("/", + []fizz.OperationOption{ + fizz.Summary("Redirect to /meta"), + }, + func(c *gin.Context) { + c.Redirect(http.StatusMovedPermanently, "/meta") + }) + authRoutes.GET("/meta", []fizz.OperationOption{ fizz.Summary("Display service name and user's status"), @@ -306,6 +315,8 @@ type rootOut struct { ApplicationName string `json:"application_name"` UserIsAdmin bool `json:"user_is_admin"` Username string `json:"username"` + Version string `json:"version"` + Commit string `json:"commit"` } func rootHandler(c *gin.Context) (*rootOut, error) { @@ -313,6 +324,8 @@ func rootHandler(c *gin.Context) (*rootOut, error) { ApplicationName: utask.AppName(), UserIsAdmin: auth.IsAdmin(c) == nil, Username: auth.GetIdentity(c), + Version: utask.Version, + Commit: utask.Commit, }, nil }