1
0
mirror of https://github.com/rancher/os.git synced 2025-09-17 23:48:09 +00:00

Update godeps

This commit is contained in:
Darren Shepherd
2015-04-15 09:19:16 -07:00
parent b1c519ebe0
commit adc6825ee6
3 changed files with 46 additions and 17 deletions

8
Godeps/Godeps.json generated
View File

@@ -221,13 +221,13 @@
},
{
"ImportPath": "github.com/rancherio/rancher-compose/docker",
"Comment": "0.1.0-9-g7343438",
"Rev": "734343806223cab5de0532ea7add0beeb2cbea92"
"Comment": "0.1.0-10-g6c6a2e3",
"Rev": "6c6a2e3ad4023fafc7509787994dc51774006f26"
},
{
"ImportPath": "github.com/rancherio/rancher-compose/project",
"Comment": "0.1.0-9-g7343438",
"Rev": "734343806223cab5de0532ea7add0beeb2cbea92"
"Comment": "0.1.0-10-g6c6a2e3",
"Rev": "6c6a2e3ad4023fafc7509787994dc51774006f26"
},
{
"ImportPath": "github.com/ryanuber/go-glob",

View File

@@ -3,6 +3,7 @@ package project
import (
"bytes"
"errors"
"fmt"
"strings"
"sync"
@@ -33,8 +34,30 @@ 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))
for _, env := range config.Environment {
if strings.IndexRune(env, '=') != -1 {
parsedEnv = append(parsedEnv, env)
continue
}
value := p.EnvironmentLookup.Lookup(env, name, &config)
if value != "" {
parsedEnv = append(parsedEnv, fmt.Sprintf("%s=%s", env, value))
}
}
config.Environment = parsedEnv
}
return p.factory.Create(p, name, &config)
}
func (p *Project) AddConfig(name string, config *ServiceConfig) error {
service, err := p.factory.Create(p, name, config)
service, err := p.createService(name, *config)
if err != nil {
log.Errorf("Failed to create service for %s : %v", name, err)
return err

View File

@@ -7,8 +7,9 @@ type Event string
const (
CONTAINER_ID = "container_id"
CONTAINER_CREATED = Event("Created container")
CONTAINER_STARTED = Event("Started container")
CONTAINER_STARTING = Event("Starting container")
CONTAINER_CREATED = Event("Created container")
CONTAINER_STARTED = Event("Started container")
SERVICE_ADD = Event("Adding")
SERVICE_UP_START = Event("Starting")
@@ -56,17 +57,22 @@ type ServiceConfig struct {
ExternalLinks []string `yaml:"external_links,omitempty"`
}
type EnvironmentLookup interface {
Lookup(key, serviceName string, config *ServiceConfig) string
}
type Project struct {
Name string
configs map[string]*ServiceConfig
Services map[string]Service
file string
content []byte
client *client.RancherClient
factory ServiceFactory
ReloadCallback func() error
upCount int
listeners []chan<- ProjectEvent
EnvironmentLookup EnvironmentLookup
Name string
configs map[string]*ServiceConfig
Services map[string]Service
file string
content []byte
client *client.RancherClient
factory ServiceFactory
ReloadCallback func() error
upCount int
listeners []chan<- ProjectEvent
}
type Service interface {