1
0
mirror of https://github.com/rancher/os.git synced 2025-08-17 14:28:16 +00:00

Merge pull request #307 from imikushin/godeps

update rancher-compose
This commit is contained in:
Darren Shepherd 2015-05-12 22:08:04 -07:00
commit e81cfe9217
2 changed files with 32 additions and 11 deletions

12
Godeps/Godeps.json generated
View File

@ -1,6 +1,6 @@
{ {
"ImportPath": "github.com/rancherio/os", "ImportPath": "github.com/rancherio/os",
"GoVersion": "go1.4.1", "GoVersion": "go1.4.2",
"Deps": [ "Deps": [
{ {
"ImportPath": "github.com/Sirupsen/logrus", "ImportPath": "github.com/Sirupsen/logrus",
@ -142,7 +142,7 @@
}, },
{ {
"ImportPath": "github.com/docker/machine/utils", "ImportPath": "github.com/docker/machine/utils",
"Comment": "v0.1.0-rc3-18-gd674e87", "Comment": "v0.1.0-rc4",
"Rev": "d674e87813ffc10048f55d884396be1af327705e" "Rev": "d674e87813ffc10048f55d884396be1af327705e"
}, },
{ {
@ -172,13 +172,13 @@
}, },
{ {
"ImportPath": "github.com/rancherio/rancher-compose/librcompose/docker", "ImportPath": "github.com/rancherio/rancher-compose/librcompose/docker",
"Comment": "0.1.0-25-g22c2b87", "Comment": "0.1.0-27-g1be3efa",
"Rev": "22c2b870151ab3fa7f3727cfc4504e326ea512e1" "Rev": "1be3efa22d0bbae71d1aed14fcdb870dd0706f1c"
}, },
{ {
"ImportPath": "github.com/rancherio/rancher-compose/librcompose/project", "ImportPath": "github.com/rancherio/rancher-compose/librcompose/project",
"Comment": "0.1.0-25-g22c2b87", "Comment": "0.1.0-27-g1be3efa",
"Rev": "22c2b870151ab3fa7f3727cfc4504e326ea512e1" "Rev": "1be3efa22d0bbae71d1aed14fcdb870dd0706f1c"
}, },
{ {
"ImportPath": "github.com/ryanuber/go-glob", "ImportPath": "github.com/ryanuber/go-glob",

View File

@ -10,10 +10,30 @@ import (
shlex "github.com/flynn/go-shlex" shlex "github.com/flynn/go-shlex"
) )
func Filter(vs []string, f func(string) bool) []string {
r := make([]string, 0, len(vs))
for _, v := range vs {
if f(v) {
r = append(r, v)
}
}
return r
}
func isBind(s string) bool {
return strings.ContainsRune(s, ':')
}
func isVolume(s string) bool {
return !isBind(s)
}
func Convert(c *project.ServiceConfig) (*runconfig.Config, *runconfig.HostConfig, error) { func Convert(c *project.ServiceConfig) (*runconfig.Config, *runconfig.HostConfig, error) {
volumes := map[string]struct{}{} vs := Filter(c.Volumes, isVolume)
for _, v := range c.Volumes {
volumes[strings.Split(v, ":")[0]] = struct{}{} volumes := make(map[string]struct {}, len(vs))
for _, v := range vs {
volumes[v] = struct {}{}
} }
cmd, _ := shlex.Split(c.Command) cmd, _ := shlex.Split(c.Command)
@ -51,6 +71,7 @@ func Convert(c *project.ServiceConfig) (*runconfig.Config, *runconfig.HostConfig
Tty: c.Tty, Tty: c.Tty,
OpenStdin: c.StdinOpen, OpenStdin: c.StdinOpen,
WorkingDir: c.WorkingDir, WorkingDir: c.WorkingDir,
Volumes: volumes,
} }
host_config := &runconfig.HostConfig{ host_config := &runconfig.HostConfig{
VolumesFrom: c.VolumesFrom, VolumesFrom: c.VolumesFrom,
@ -58,10 +79,10 @@ func Convert(c *project.ServiceConfig) (*runconfig.Config, *runconfig.HostConfig
CapDrop: c.CapDrop, CapDrop: c.CapDrop,
CpuShares: c.CpuShares, CpuShares: c.CpuShares,
Privileged: c.Privileged, Privileged: c.Privileged,
Binds: c.Volumes, Binds: Filter(c.Volumes, isBind),
Dns: dns, Dns: dns,
DnsSearch: dnssearch, DnsSearch: dnssearch,
LogConfig: runconfig.LogConfig{ LogConfig: runconfig.LogConfig{
Type: c.LogDriver, Type: c.LogDriver,
}, },
Memory: c.MemLimit, Memory: c.MemLimit,