Add commit hash to routing version API

Signed-off-by: Brian Meek <brian@hntlabs.com>
This commit is contained in:
Brian Meek 2022-09-15 15:00:36 -07:00 committed by Tak Wai Wong
parent 4d77bed1f0
commit 8351e35287
No known key found for this signature in database
GPG key ID: 222E4AF2AA1F467D
2 changed files with 4 additions and 14 deletions

View file

@ -7,7 +7,7 @@ WORKDIR /build
COPY . /build COPY . /build
RUN mkdir -p bin RUN mkdir -p bin
RUN go build -trimpath -o bin/ ./cmd/dendrite-monolith-server RUN go build -ldflags="-X 'routing.CommitHash=`git rev-list -1 HEAD`'" -trimpath -o bin/ ./cmd/dendrite-monolith-server
RUN go build -trimpath -o bin/ ./cmd/create-account RUN go build -trimpath -o bin/ ./cmd/create-account
RUN go build -trimpath -o bin/ ./cmd/generate-keys RUN go build -trimpath -o bin/ ./cmd/generate-keys

View file

@ -19,8 +19,6 @@ import (
"net/http" "net/http"
"strings" "strings"
"runtime/debug"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util" "github.com/matrix-org/util"
@ -44,16 +42,8 @@ import (
userapi "github.com/matrix-org/dendrite/userapi/api" userapi "github.com/matrix-org/dendrite/userapi/api"
) )
var commitHash = func() string { // Added in build script Cokerfile.monolith
if info, ok := debug.ReadBuildInfo(); ok { var CommitHash string
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value
}
}
}
return ""
}()
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client // Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
// to clients which need to make outbound HTTP requests. // to clients which need to make outbound HTTP requests.
@ -128,7 +118,7 @@ func Setup(
"v1.0", "v1.0",
"v1.1", "v1.1",
"v1.2", "v1.2",
}, UnstableFeatures: unstableFeatures, CommitHash: commitHash}, }, UnstableFeatures: unstableFeatures, CommitHash: CommitHash},
} }
}), }),
).Methods(http.MethodGet, http.MethodOptions) ).Methods(http.MethodGet, http.MethodOptions)