Skip to content

Commit

Permalink
Expose version on API (#31)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Pérez Schröder <2639770+nomonamo@users.noreply.github.com>
  • Loading branch information
pablito-perez authored and w3st3ry committed Nov 25, 2019
1 parent dd2d2e3 commit a760803
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -306,13 +315,17 @@ 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) {
return &rootOut{
ApplicationName: utask.AppName(),
UserIsAdmin: auth.IsAdmin(c) == nil,
Username: auth.GetIdentity(c),
Version: utask.Version,
Commit: utask.Commit,
}, nil
}

Expand Down

0 comments on commit a760803

Please # to comment.