mirror of
https://github.com/rancher/os.git
synced 2025-06-30 16:51:47 +00:00
Update to newer compose
This commit is contained in:
parent
c556b8b231
commit
7f4c339034
8
Godeps/Godeps.json
generated
8
Godeps/Godeps.json
generated
@ -172,13 +172,13 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/rancherio/rancher-compose/librcompose/docker",
|
||||
"Comment": "0.1.0-22-gb05516d",
|
||||
"Rev": "b05516d2ddc60579cf34ff89d4214bf3e6421e45"
|
||||
"Comment": "0.1.0-25-g22c2b87",
|
||||
"Rev": "22c2b870151ab3fa7f3727cfc4504e326ea512e1"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/rancherio/rancher-compose/librcompose/project",
|
||||
"Comment": "0.1.0-22-gb05516d",
|
||||
"Rev": "b05516d2ddc60579cf34ff89d4214bf3e6421e45"
|
||||
"Comment": "0.1.0-25-g22c2b87",
|
||||
"Rev": "22c2b870151ab3fa7f3727cfc4504e326ea512e1"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/ryanuber/go-glob",
|
||||
|
@ -43,7 +43,7 @@ func Convert(c *project.ServiceConfig) (*runconfig.Config, *runconfig.HostConfig
|
||||
Hostname: c.Hostname,
|
||||
Domainname: c.DomainName,
|
||||
User: c.User,
|
||||
Env: c.Environment,
|
||||
Env: c.Environment.Slice(),
|
||||
Cmd: runconfig.NewCommand(cmd...),
|
||||
Image: c.Image,
|
||||
Labels: labels,
|
||||
|
@ -5,8 +5,9 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
type ServiceState string
|
||||
@ -33,9 +34,9 @@ func NewProject(name string, factory ServiceFactory) *Project {
|
||||
|
||||
func (p *Project) CreateService(name string, config ServiceConfig) (Service, error) {
|
||||
if p.EnvironmentLookup != nil {
|
||||
parsedEnv := make([]string, 0, len(config.Environment))
|
||||
parsedEnv := make([]string, 0, len(config.Environment.Slice()))
|
||||
|
||||
for _, env := range config.Environment {
|
||||
for _, env := range config.Environment.Slice() {
|
||||
if strings.IndexRune(env, '=') != -1 {
|
||||
parsedEnv = append(parsedEnv, env)
|
||||
continue
|
||||
@ -46,7 +47,7 @@ func (p *Project) CreateService(name string, config ServiceConfig) (Service, err
|
||||
}
|
||||
}
|
||||
|
||||
config.Environment = parsedEnv
|
||||
config.Environment = NewMaporslice(parsedEnv)
|
||||
}
|
||||
|
||||
return p.factory.Create(p, name, &config)
|
||||
@ -56,6 +57,7 @@ func (p *Project) AddConfig(name string, config *ServiceConfig) error {
|
||||
p.Notify(SERVICE_ADD, name, nil)
|
||||
|
||||
p.configs[name] = config
|
||||
p.reload = append(p.reload, name)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -77,10 +79,8 @@ func (p *Project) Load(bytes []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Project) Up() error {
|
||||
wrappers := make(map[string]*serviceWrapper)
|
||||
|
||||
for name, _ := range p.configs {
|
||||
func (p *Project) loadWrappers(wrappers map[string]*serviceWrapper) error {
|
||||
for _, name := range p.reload {
|
||||
wrapper, err := newServiceWrapper(name, p)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -88,9 +88,17 @@ func (p *Project) Up() error {
|
||||
wrappers[name] = wrapper
|
||||
}
|
||||
|
||||
p.reload = []string{}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Project) Up() error {
|
||||
wrappers := make(map[string]*serviceWrapper)
|
||||
|
||||
p.Notify(PROJECT_UP_START, "", nil)
|
||||
|
||||
err := p.startAll(wrappers, 0)
|
||||
err := p.startAll(wrappers)
|
||||
|
||||
if err == nil {
|
||||
p.Notify(PROJECT_UP_DONE, "", nil)
|
||||
@ -99,16 +107,16 @@ func (p *Project) Up() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *Project) startAll(wrappers map[string]*serviceWrapper, level int) error {
|
||||
func (p *Project) startAll(wrappers map[string]*serviceWrapper) error {
|
||||
restart := false
|
||||
|
||||
if level > 0 {
|
||||
for _, wrapper := range wrappers {
|
||||
if err := wrapper.Reset(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p.loadWrappers(wrappers)
|
||||
|
||||
for _, wrapper := range wrappers {
|
||||
go wrapper.Start(wrappers)
|
||||
@ -134,7 +142,7 @@ func (p *Project) startAll(wrappers map[string]*serviceWrapper, level int) error
|
||||
log.Errorf("Failed calling callback: %v", err)
|
||||
}
|
||||
}
|
||||
return p.startAll(wrappers, level+1)
|
||||
return p.startAll(wrappers)
|
||||
} else {
|
||||
return firstError
|
||||
}
|
||||
|
114
Godeps/_workspace/src/github.com/rancherio/rancher-compose/librcompose/project/types.go
generated
vendored
114
Godeps/_workspace/src/github.com/rancherio/rancher-compose/librcompose/project/types.go
generated
vendored
@ -1,11 +1,6 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/rancherio/go-rancher/client"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
import "github.com/rancherio/go-rancher/client"
|
||||
|
||||
type Event string
|
||||
|
||||
@ -26,120 +21,21 @@ const (
|
||||
PROJECT_RELOAD_TRIGGER = Event("Triggering project reload")
|
||||
)
|
||||
|
||||
type Stringorslice struct {
|
||||
parts []string
|
||||
}
|
||||
|
||||
func (s *Stringorslice) MarshalYAML() (interface{}, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
bytes, err := yaml.Marshal(s.Slice())
|
||||
return string(bytes), err
|
||||
}
|
||||
|
||||
func (s *Stringorslice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var sliceType []string
|
||||
err := unmarshal(&sliceType)
|
||||
if err == nil {
|
||||
s.parts = sliceType
|
||||
return nil
|
||||
}
|
||||
|
||||
var stringType string
|
||||
err = unmarshal(&stringType)
|
||||
if err == nil {
|
||||
sliceType = make([]string, 0, 1)
|
||||
s.parts = append(sliceType, string(stringType))
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Stringorslice) Len() int {
|
||||
if s == nil {
|
||||
return 0
|
||||
}
|
||||
return len(s.parts)
|
||||
}
|
||||
|
||||
func (s *Stringorslice) Slice() []string {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
return s.parts
|
||||
}
|
||||
|
||||
func NewStringorslice(parts ...string) *Stringorslice {
|
||||
return &Stringorslice{parts}
|
||||
}
|
||||
|
||||
type SliceorMap struct {
|
||||
parts map[string]string
|
||||
}
|
||||
|
||||
func (s *SliceorMap) MarshalYAML() (interface{}, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
bytes, err := yaml.Marshal(s.MapParts())
|
||||
return string(bytes), err
|
||||
}
|
||||
|
||||
func (s *SliceorMap) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
mapType := make(map[string]string)
|
||||
err := unmarshal(&mapType)
|
||||
if err == nil {
|
||||
s.parts = mapType
|
||||
return nil
|
||||
}
|
||||
|
||||
var sliceType []string
|
||||
var keyValueSlice []string
|
||||
var key string
|
||||
var value string
|
||||
|
||||
err = unmarshal(&sliceType)
|
||||
if err == nil {
|
||||
mapType = make(map[string]string)
|
||||
for _, slice := range sliceType {
|
||||
keyValueSlice = strings.Split(slice, "=") //split up key and value into []string
|
||||
key = keyValueSlice[0]
|
||||
value = keyValueSlice[1]
|
||||
mapType[key] = value
|
||||
}
|
||||
s.parts = mapType
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SliceorMap) MapParts() map[string]string {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
return s.parts
|
||||
}
|
||||
|
||||
func NewSliceorMap(parts map[string]string) *SliceorMap {
|
||||
return &SliceorMap{parts}
|
||||
}
|
||||
|
||||
type ServiceConfig struct {
|
||||
CapAdd []string `yaml:"cap_add,omitempty"`
|
||||
CapDrop []string `yaml:"cap_drop,omitempty"`
|
||||
CpuShares int64 `yaml:"cpu_shares,omitempty"`
|
||||
Command string `yaml:"command,omitempty"`
|
||||
Detach string `yaml:"detach,omitempty"`
|
||||
Dns *Stringorslice `yaml:"dns,omitempty"`
|
||||
DnsSearch *Stringorslice `yaml:"dns_search,omitempty"`
|
||||
Dns Stringorslice `yaml:"dns,omitempty"`
|
||||
DnsSearch Stringorslice `yaml:"dns_search,omitempty"`
|
||||
DomainName string `yaml:"domainname,omitempty"`
|
||||
Entrypoint string `yaml:"entrypoint,omitempty"`
|
||||
EnvFile string `yaml:"env_file,omitempty"`
|
||||
Environment []string `yaml:"environment,omitempty"`
|
||||
Environment Maporslice `yaml:"environment,omitempty"`
|
||||
Hostname string `yaml:"hostname,omitempty"`
|
||||
Image string `yaml:"image,omitempty"`
|
||||
Labels *SliceorMap `yaml:"labels,omitempty"`
|
||||
Labels SliceorMap `yaml:"labels,omitempty"`
|
||||
Links []string `yaml:"links,omitempty"`
|
||||
LogDriver string `yaml:"log_driver,omitempty"`
|
||||
MemLimit int64 `yaml:"mem_limit,omitempty"`
|
||||
|
146
Godeps/_workspace/src/github.com/rancherio/rancher-compose/librcompose/project/types_yaml.go
generated
vendored
Normal file
146
Godeps/_workspace/src/github.com/rancherio/rancher-compose/librcompose/project/types_yaml.go
generated
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type Stringorslice struct {
|
||||
parts []string
|
||||
}
|
||||
|
||||
func (s *Stringorslice) MarshalYAML() (interface{}, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
bytes, err := yaml.Marshal(s.Slice())
|
||||
return string(bytes), err
|
||||
}
|
||||
|
||||
func (s *Stringorslice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var sliceType []string
|
||||
err := unmarshal(&sliceType)
|
||||
if err == nil {
|
||||
s.parts = sliceType
|
||||
return nil
|
||||
}
|
||||
|
||||
var stringType string
|
||||
err = unmarshal(&stringType)
|
||||
if err == nil {
|
||||
sliceType = make([]string, 0, 1)
|
||||
s.parts = append(sliceType, string(stringType))
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Stringorslice) Len() int {
|
||||
if s == nil {
|
||||
return 0
|
||||
}
|
||||
return len(s.parts)
|
||||
}
|
||||
|
||||
func (s *Stringorslice) Slice() []string {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
return s.parts
|
||||
}
|
||||
|
||||
func NewStringorslice(parts ...string) Stringorslice {
|
||||
return Stringorslice{parts}
|
||||
}
|
||||
|
||||
type SliceorMap struct {
|
||||
parts map[string]string
|
||||
}
|
||||
|
||||
func (s *SliceorMap) MarshalYAML() (interface{}, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
bytes, err := yaml.Marshal(s.MapParts())
|
||||
return string(bytes), err
|
||||
}
|
||||
|
||||
func (s *SliceorMap) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
mapType := make(map[string]string)
|
||||
err := unmarshal(&mapType)
|
||||
if err == nil {
|
||||
s.parts = mapType
|
||||
return nil
|
||||
}
|
||||
|
||||
var sliceType []string
|
||||
var keyValueSlice []string
|
||||
var key string
|
||||
var value string
|
||||
|
||||
err = unmarshal(&sliceType)
|
||||
if err == nil {
|
||||
mapType = make(map[string]string)
|
||||
for _, slice := range sliceType {
|
||||
keyValueSlice = strings.Split(slice, "=") //split up key and value into []string
|
||||
key = keyValueSlice[0]
|
||||
value = keyValueSlice[1]
|
||||
mapType[key] = value
|
||||
}
|
||||
s.parts = mapType
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SliceorMap) MapParts() map[string]string {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
return s.parts
|
||||
}
|
||||
|
||||
func NewSliceorMap(parts map[string]string) SliceorMap {
|
||||
return SliceorMap{parts}
|
||||
}
|
||||
|
||||
type Maporslice struct {
|
||||
parts []string
|
||||
}
|
||||
|
||||
func (s *Maporslice) MarshalYAML() (interface{}, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
bytes, err := yaml.Marshal(s.Slice())
|
||||
return string(bytes), err
|
||||
}
|
||||
|
||||
func (s *Maporslice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
err := unmarshal(&s.parts)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var mapType map[string]string
|
||||
|
||||
err = unmarshal(&mapType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for k, v := range mapType {
|
||||
s.parts = append(s.parts, strings.Join([]string{k, v}, "="))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Maporslice) Slice() []string {
|
||||
return s.parts
|
||||
}
|
||||
|
||||
func NewMaporslice(parts []string) Maporslice {
|
||||
return Maporslice{parts}
|
||||
}
|
@ -102,9 +102,9 @@ func NewConfig() *Config {
|
||||
DETACH: "true",
|
||||
SCOPE: SYSTEM,
|
||||
}),
|
||||
Environment: []string{
|
||||
Environment: project.NewMaporslice([]string{
|
||||
"DAEMON=true",
|
||||
},
|
||||
}),
|
||||
VolumesFrom: []string{
|
||||
"system-volumes",
|
||||
},
|
||||
@ -211,9 +211,9 @@ func NewConfig() *Config {
|
||||
DETACH: "false",
|
||||
SCOPE: SYSTEM,
|
||||
}),
|
||||
Environment: []string{
|
||||
Environment: project.NewMaporslice([]string{
|
||||
"CLOUD_INIT_NETWORK=false",
|
||||
},
|
||||
}),
|
||||
VolumesFrom: []string{
|
||||
"command-volumes",
|
||||
"system-volumes",
|
||||
|
@ -84,9 +84,9 @@ outer:
|
||||
config.SCOPE: config.SYSTEM,
|
||||
}),
|
||||
LogDriver: "json-file",
|
||||
Environment: []string{
|
||||
Environment: project.NewMaporslice([]string{
|
||||
"MAGIC=" + boot2dockerMagic,
|
||||
},
|
||||
}),
|
||||
},
|
||||
"udev": &udev,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user