Skip to content

Commit

Permalink
add /info endpoint with build information
Browse files Browse the repository at this point in the history
clear out release.sh
  • Loading branch information
mjl- committed May 22, 2019
1 parent d763272 commit 725dcd2
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 40 deletions.
21 changes: 2 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ run: build
run-root: build
sudo ./ding serve local/local-root.conf


build:
go build
go vet
Expand All @@ -16,24 +15,8 @@ frontend:

test:
golint
go test -cover . -- local/local-test.conf

coverage:
go test -coverprofile=coverage.out -test.outputdir . -- local/local-test.conf
go tool cover -html=coverage.out

fmt:
go fmt .

release:
-mkdir local 2>/dev/null
(cd assets && zip -qr0 ../assets.zip .)
env GOOS=linux GOARCH=amd64 ./release.sh
env GOOS=linux GOARCH=386 ./release.sh
env GOOS=linux GOARCH=arm GOARM=6 ./release.sh
env GOOS=linux GOARCH=arm64 ./release.sh
env GOOS=darwin GOARCH=amd64 ./release.sh
env GOOS=openbsd GOARCH=amd64 ./release.sh
go test -race -coverprofile cover.out -- local/local-test.conf
go tool cover -html=cover.out -o cover.html

clean:
go clean
Expand Down
1 change: 1 addition & 0 deletions fabricate/fabricate.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func build(dest string) {
[]string{"www-src/licenses/angularjs-1.5.7"}},
{"UI Bootstrap 1.3.3",
[]string{"www-src/licenses/ui-bootstrap-1.3.3"}},
{"", []string{"vendor/github.com/mjl-/httpinfo/LICENSE"}},
{"", []string{"vendor/github.com/mjl-/sherpa/LICENSE"}},
{"", []string{"vendor/bitbucket.org/mjl/httpasset/LICENSE"}},
{"", []string{"vendor/github.com/mjl-/sconf/LICENSE"}},
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.12
require (
bitbucket.org/mjl/httpasset v0.0.4
github.com/lib/pq v1.1.1
github.com/mjl-/httpinfo v0.0.2
github.com/mjl-/sconf v0.0.0-20190512072357-ca074d2407b2
github.com/mjl-/sherpa v0.6.0
github.com/mjl-/sherpadoc v0.0.0-20190505200843-c0a7f43f5f1d
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mjl-/httpinfo v0.0.2 h1:6lSs4JowAuZeqx3OlTsBaYQjmlPo/5pqQdbFBhMjt/o=
github.com/mjl-/httpinfo v0.0.2/go.mod h1:o/nQc5HN+F0rwF5dFOcU11wqsLUePZuXOMAIsL/HglU=
github.com/mjl-/sconf v0.0.0-20190512072357-ca074d2407b2 h1:gJIMFIUb3dMd/pWgeoNGled+wRcqkK0Q3IHwJYqN4Io=
github.com/mjl-/sconf v0.0.0-20190512072357-ca074d2407b2/go.mod h1:DX63hxdqGErxyNhsm5guT7SXiP2GfoD/W+Yk7KOKWws=
github.com/mjl-/sherpa v0.6.0 h1:lNu86b3htqJVhftOOxAxJwfIZ5Xuo6lz1ifiZZ096Do=
Expand Down
11 changes: 11 additions & 0 deletions httpserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"strconv"
"strings"

"github.com/mjl-/httpinfo"
"github.com/mjl-/sherpa"
"github.com/mjl-/sherpadoc"
"github.com/mjl-/sherpaprom"
Expand Down Expand Up @@ -102,6 +103,16 @@ func servehttp(args []string) {
handler, err := sherpa.NewHandler("/ding/", version, Ding{}, &doc, opts)
check(err, "making sherpa handler")

// Since we set the version variables with ldflags -X, we cannot read them in the vars section.
// So we combine them into a CodeVersion during init, and add the handler while we're at it.
info := httpinfo.CodeVersion{
CommitHash: vcsCommitHash,
Tag: vcsTag,
Branch: vcsBranch,
Full: version,
}
http.Handle("/info", httpinfo.NewHandler(info, nil))

http.HandleFunc("/", serveAsset)
http.Handle("/ding/", handler)
http.Handle("/metrics", promhttp.Handler())
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ const (

var (
httpFS http.FileSystem
version = "dev"
database *sql.DB

version = "dev"
vcsCommitHash = ""
vcsTag = ""
vcsBranch = ""
)

var config struct {
Expand Down
20 changes: 0 additions & 20 deletions release.sh

This file was deleted.

7 changes: 7 additions & 0 deletions vendor/github.com/mjl-/httpinfo/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/mjl-/httpinfo/README.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/mjl-/httpinfo/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 114 additions & 0 deletions vendor/github.com/mjl-/httpinfo/httpinfo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/lib/pq/oid
github.com/lib/pq/scram
# github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/matttproud/golang_protobuf_extensions/pbutil
# github.com/mjl-/httpinfo v0.0.2
github.com/mjl-/httpinfo
# github.com/mjl-/sconf v0.0.0-20190512072357-ca074d2407b2
github.com/mjl-/sconf
# github.com/mjl-/sherpa v0.6.0
Expand Down

0 comments on commit 725dcd2

Please sign in to comment.