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
|
WORKDIR /go/src/github.com/docker/swarm
|
||||||
|
|
||||||
ENV GOPATH /go/src/github.com/docker/swarm/Godeps/_workspace:$GOPATH
|
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
|
EXPOSE 2375
|
||||||
VOLUME $HOME/.swarm
|
VOLUME $HOME/.swarm
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/docker/swarm/cluster"
|
"github.com/docker/swarm/cluster"
|
||||||
"github.com/docker/swarm/scheduler"
|
"github.com/docker/swarm/scheduler"
|
||||||
"github.com/docker/swarm/scheduler/filter"
|
"github.com/docker/swarm/scheduler/filter"
|
||||||
|
"github.com/docker/swarm/version"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/samalba/dockerclient"
|
"github.com/samalba/dockerclient"
|
||||||
)
|
)
|
||||||
|
@ -28,7 +29,6 @@ type context struct {
|
||||||
scheduler *scheduler.Scheduler
|
scheduler *scheduler.Scheduler
|
||||||
eventsHandler *eventsHandler
|
eventsHandler *eventsHandler
|
||||||
debug bool
|
debug bool
|
||||||
version string
|
|
||||||
tlsConfig *tls.Config
|
tlsConfig *tls.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,10 +68,10 @@ func getVersion(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
Os string
|
Os string
|
||||||
Arch string
|
Arch string
|
||||||
}{
|
}{
|
||||||
Version: "swarm/" + c.version,
|
Version: "swarm/" + version.VERSION,
|
||||||
ApiVersion: APIVERSION,
|
ApiVersion: APIVERSION,
|
||||||
GoVersion: runtime.Version(),
|
GoVersion: runtime.Version(),
|
||||||
GitCommit: "n/a",
|
GitCommit: version.GITCOMMIT,
|
||||||
Os: runtime.GOOS,
|
Os: runtime.GOOS,
|
||||||
Arch: runtime.GOARCH,
|
Arch: runtime.GOARCH,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/swarm/cluster"
|
"github.com/docker/swarm/cluster"
|
||||||
"github.com/docker/swarm/scheduler"
|
"github.com/docker/swarm/scheduler"
|
||||||
|
"github.com/docker/swarm/version"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,7 +16,6 @@ func serveRequest(c *cluster.Cluster, s *scheduler.Scheduler, w http.ResponseWri
|
||||||
context := &context{
|
context := &context{
|
||||||
cluster: c,
|
cluster: c,
|
||||||
scheduler: s,
|
scheduler: s,
|
||||||
version: "test-version",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r := createRouter(context, false)
|
r := createRouter(context, false)
|
||||||
|
@ -31,10 +31,10 @@ func TestGetVersion(t *testing.T) {
|
||||||
assert.NoError(t, serveRequest(nil, nil, r, req))
|
assert.NoError(t, serveRequest(nil, nil, r, req))
|
||||||
assert.Equal(t, r.Code, http.StatusOK)
|
assert.Equal(t, r.Code, http.StatusOK)
|
||||||
|
|
||||||
version := struct {
|
v := struct {
|
||||||
Version string
|
Version string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
json.NewDecoder(r.Body).Decode(&version)
|
json.NewDecoder(r.Body).Decode(&v)
|
||||||
assert.Equal(t, version.Version, "swarm/test-version")
|
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
|
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{
|
context := &context{
|
||||||
cluster: c,
|
cluster: c,
|
||||||
scheduler: s,
|
scheduler: s,
|
||||||
version: version,
|
|
||||||
eventsHandler: NewEventsHandler(),
|
eventsHandler: NewEventsHandler(),
|
||||||
tlsConfig: tlsConfig,
|
tlsConfig: tlsConfig,
|
||||||
}
|
}
|
||||||
|
|
5
main.go
5
main.go
|
@ -7,7 +7,6 @@ import (
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
|
|
||||||
"github.com/docker/swarm/discovery"
|
"github.com/docker/swarm/discovery"
|
||||||
_ "github.com/docker/swarm/discovery/consul"
|
_ "github.com/docker/swarm/discovery/consul"
|
||||||
_ "github.com/docker/swarm/discovery/etcd"
|
_ "github.com/docker/swarm/discovery/etcd"
|
||||||
|
@ -15,13 +14,15 @@ import (
|
||||||
_ "github.com/docker/swarm/discovery/nodes"
|
_ "github.com/docker/swarm/discovery/nodes"
|
||||||
"github.com/docker/swarm/discovery/token"
|
"github.com/docker/swarm/discovery/token"
|
||||||
_ "github.com/docker/swarm/discovery/zookeeper"
|
_ "github.com/docker/swarm/discovery/zookeeper"
|
||||||
|
"github.com/docker/swarm/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = path.Base(os.Args[0])
|
app.Name = path.Base(os.Args[0])
|
||||||
app.Usage = "a Docker-native clustering system"
|
app.Usage = "a Docker-native clustering system"
|
||||||
app.Version = "0.1.0"
|
app.Version = version.VERSION + " (" + version.GITCOMMIT + ")"
|
||||||
|
|
||||||
app.Author = ""
|
app.Author = ""
|
||||||
app.Email = ""
|
app.Email = ""
|
||||||
|
|
||||||
|
|
|
@ -146,5 +146,5 @@ func manage(c *cli.Context) {
|
||||||
if c.IsSet("host") || c.IsSet("H") {
|
if c.IsSet("host") || c.IsSet("H") {
|
||||||
hosts = hosts[1:]
|
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