Fix envfile detection
+ The envfiles were not added! see #8 TODO: what are the others properties to fix this way?
This commit is contained in:
@@ -59,6 +59,7 @@ func (p *Parser) Parse(appname string) {
|
||||
for _, s := range p.Data.Services {
|
||||
parseEnv(s)
|
||||
parseCommand(s)
|
||||
parseEnvFiles(s)
|
||||
}
|
||||
|
||||
c := p.Data
|
||||
@@ -143,7 +144,8 @@ func parseEnv(s *Service) {
|
||||
env = s.RawEnvironment.(map[string]string)
|
||||
case map[string]interface{}:
|
||||
for k, v := range s.RawEnvironment.(map[string]interface{}) {
|
||||
env[k] = v.(string)
|
||||
// force to string
|
||||
env[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
case []interface{}:
|
||||
for _, v := range s.RawEnvironment.([]interface{}) {
|
||||
@@ -156,7 +158,6 @@ func parseEnv(s *Service) {
|
||||
env[parts[0]] = parts[1]
|
||||
default:
|
||||
log.Printf("%+v, %T", s.RawEnvironment, s.RawEnvironment)
|
||||
log.Printf("%+v", s)
|
||||
log.Fatal("Environment type not supported")
|
||||
}
|
||||
s.Environment = env
|
||||
@@ -188,3 +189,23 @@ func parseCommand(s *Service) {
|
||||
log.Fatal("Command type not supported")
|
||||
}
|
||||
}
|
||||
|
||||
func parseEnvFiles(s *Service) {
|
||||
// Same than parseEnv, but for env files
|
||||
if s.RawEnvFiles == nil {
|
||||
return
|
||||
}
|
||||
envfiles := make([]string, 0)
|
||||
switch s.RawEnvFiles.(type) {
|
||||
case []string:
|
||||
envfiles = s.RawEnvFiles.([]string)
|
||||
case []interface{}:
|
||||
for _, v := range s.RawEnvFiles.([]interface{}) {
|
||||
envfiles = append(envfiles, v.(string))
|
||||
}
|
||||
default:
|
||||
log.Printf("%+v %T", s.RawEnvFiles, s.RawEnvFiles)
|
||||
log.Fatal("EnvFile type not supported")
|
||||
}
|
||||
s.EnvFiles = envfiles
|
||||
}
|
||||
|
Reference in New Issue
Block a user