Skip to content

Commit

Permalink
add buildtime, kernelversion and experimental to API version
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Vieux <[email protected]>
  • Loading branch information
vieux committed Jan 12, 2016
1 parent 14bf4e0 commit 6dcb170
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COPY . /go/src/github.com/docker/swarm
WORKDIR /go/src/github.com/docker/swarm

ENV GOPATH /go/src/github.com/docker/swarm/Godeps/_workspace:$GOPATH
RUN CGO_ENABLED=0 go install -v -a -tags netgo -installsuffix netgo -ldflags "-w -X github.com/docker/swarm/version.GITCOMMIT `git rev-parse --short HEAD`"
RUN CGO_ENABLED=0 go install -v -a -tags netgo -installsuffix netgo -ldflags "-w -X github.com/docker/swarm/version.GITCOMMIT `git rev-parse --short HEAD` -X github.com/docker/swarm/version.BUILDTIME \"`date -u`\""

ENV SWARM_HOST :2375
EXPOSE 2375
Expand Down
23 changes: 16 additions & 7 deletions api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import (
"strings"
"time"

"github.com/docker/docker/pkg/parsers/kernel"
apitypes "github.com/docker/engine-api/types"
dockerfilters "github.com/docker/engine-api/types/filters"
"github.com/docker/swarm/cluster"
"github.com/docker/swarm/experimental"
"github.com/docker/swarm/version"
"github.com/gorilla/mux"
"github.com/samalba/dockerclient"
Expand Down Expand Up @@ -55,13 +58,19 @@ func getInfo(c *context, w http.ResponseWriter, r *http.Request) {

// GET /version
func getVersion(c *context, w http.ResponseWriter, r *http.Request) {
version := dockerclient.Version{
Version: "swarm/" + version.VERSION,
ApiVersion: APIVERSION,
GoVersion: runtime.Version(),
GitCommit: version.GITCOMMIT,
Os: runtime.GOOS,
Arch: runtime.GOARCH,
version := apitypes.Version{
Version: "swarm/" + version.VERSION,
APIVersion: APIVERSION,
GoVersion: runtime.Version(),
GitCommit: version.GITCOMMIT,
Os: runtime.GOOS,
Arch: runtime.GOARCH,
Experimental: experimental.ENABLED,
BuildTime: version.BUILDTIME,
}

if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
version.KernelVersion = kernelVersion.String()
}

w.Header().Set("Content-Type", "application/json")
Expand Down
3 changes: 3 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ var (

// GITCOMMIT will be overwritten automatically by the build system
GITCOMMIT = "HEAD"

// BUILDTIME will be overwritten automatically by the build system
BUILDTIME = "<unknown>"
)

0 comments on commit 6dcb170

Please sign in to comment.