mirror of https://github.com/docker/docs.git
commit
83c67a9059
|
@ -1 +0,0 @@
|
|||
.git
|
|
@ -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 -ldflags '-w'
|
||||
RUN CGO_ENABLED=0 go install -v -a -tags netgo -ldflags "-w -X github.com/docker/swarm/version.GITCOMMIT `git rev-parse --short HEAD`"
|
||||
|
||||
EXPOSE 2375
|
||||
VOLUME $HOME/.swarm
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/docker/swarm/cluster"
|
||||
"github.com/docker/swarm/scheduler"
|
||||
"github.com/docker/swarm/scheduler/filter"
|
||||
"github.com/docker/swarm/version"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/samalba/dockerclient"
|
||||
)
|
||||
|
@ -28,7 +29,6 @@ type context struct {
|
|||
scheduler *scheduler.Scheduler
|
||||
eventsHandler *eventsHandler
|
||||
debug bool
|
||||
version string
|
||||
tlsConfig *tls.Config
|
||||
}
|
||||
|
||||
|
@ -68,10 +68,10 @@ func getVersion(c *context, w http.ResponseWriter, r *http.Request) {
|
|||
Os string
|
||||
Arch string
|
||||
}{
|
||||
Version: "swarm/" + c.version,
|
||||
Version: "swarm/" + version.VERSION,
|
||||
ApiVersion: APIVERSION,
|
||||
GoVersion: runtime.Version(),
|
||||
GitCommit: "n/a",
|
||||
GitCommit: version.GITCOMMIT,
|
||||
Os: runtime.GOOS,
|
||||
Arch: runtime.GOARCH,
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/docker/swarm/cluster"
|
||||
"github.com/docker/swarm/scheduler"
|
||||
"github.com/docker/swarm/version"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -15,7 +16,6 @@ func serveRequest(c *cluster.Cluster, s *scheduler.Scheduler, w http.ResponseWri
|
|||
context := &context{
|
||||
cluster: c,
|
||||
scheduler: s,
|
||||
version: "test-version",
|
||||
}
|
||||
|
||||
r := createRouter(context, false)
|
||||
|
@ -31,10 +31,10 @@ func TestGetVersion(t *testing.T) {
|
|||
assert.NoError(t, serveRequest(nil, nil, r, req))
|
||||
assert.Equal(t, r.Code, http.StatusOK)
|
||||
|
||||
version := struct {
|
||||
v := struct {
|
||||
Version string
|
||||
}{}
|
||||
|
||||
json.NewDecoder(r.Body).Decode(&version)
|
||||
assert.Equal(t, version.Version, "swarm/test-version")
|
||||
json.NewDecoder(r.Body).Decode(&v)
|
||||
assert.Equal(t, v.Version, "swarm/"+version.VERSION)
|
||||
}
|
||||
|
|
|
@ -29,11 +29,10 @@ func newListener(proto, addr string, tlsConfig *tls.Config) (net.Listener, error
|
|||
return l, nil
|
||||
}
|
||||
|
||||
func ListenAndServe(c *cluster.Cluster, s *scheduler.Scheduler, hosts []string, version string, enableCors bool, tlsConfig *tls.Config) error {
|
||||
func ListenAndServe(c *cluster.Cluster, s *scheduler.Scheduler, hosts []string, enableCors bool, tlsConfig *tls.Config) error {
|
||||
context := &context{
|
||||
cluster: c,
|
||||
scheduler: s,
|
||||
version: version,
|
||||
eventsHandler: NewEventsHandler(),
|
||||
tlsConfig: tlsConfig,
|
||||
}
|
||||
|
|
5
main.go
5
main.go
|
@ -7,7 +7,6 @@ import (
|
|||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/codegangsta/cli"
|
||||
|
||||
"github.com/docker/swarm/discovery"
|
||||
_ "github.com/docker/swarm/discovery/consul"
|
||||
_ "github.com/docker/swarm/discovery/etcd"
|
||||
|
@ -15,13 +14,15 @@ import (
|
|||
_ "github.com/docker/swarm/discovery/nodes"
|
||||
"github.com/docker/swarm/discovery/token"
|
||||
_ "github.com/docker/swarm/discovery/zookeeper"
|
||||
"github.com/docker/swarm/version"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = path.Base(os.Args[0])
|
||||
app.Usage = "a Docker-native clustering system"
|
||||
app.Version = "0.1.0"
|
||||
app.Version = version.VERSION + " (" + version.GITCOMMIT + ")"
|
||||
|
||||
app.Author = ""
|
||||
app.Email = ""
|
||||
|
||||
|
|
|
@ -146,5 +146,5 @@ func manage(c *cli.Context) {
|
|||
if c.IsSet("host") || c.IsSet("H") {
|
||||
hosts = hosts[1:]
|
||||
}
|
||||
log.Fatal(api.ListenAndServe(cluster, sched, hosts, c.App.Version, c.Bool("cors"), tlsConfig))
|
||||
log.Fatal(api.ListenAndServe(cluster, sched, hosts, c.Bool("cors"), tlsConfig))
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package version
|
||||
|
||||
var (
|
||||
// VERSION should be updated by hand at each release
|
||||
VERSION = "0.1.0"
|
||||
|
||||
// GITCOMMIT will be overritten automatically by the build system
|
||||
GITCOMMIT = "HEAD"
|
||||
)
|
Loading…
Reference in New Issue