@@ -170,18 +170,18 @@ func parseCommand(s *Service) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// following the command type, it can be a "slice" or a simple sting, so we need to check it
|
// following the command type, it can be a "slice" or a simple sting, so we need to check it
|
||||||
switch s.RawCommand.(type) {
|
switch v := s.RawCommand.(type) {
|
||||||
case string:
|
case string:
|
||||||
// use shlex to parse the command
|
// use shlex to parse the command
|
||||||
command, err := shlex.Split(s.RawCommand.(string))
|
command, err := shlex.Split(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
s.Command = command
|
s.Command = command
|
||||||
case []string:
|
case []string:
|
||||||
s.Command = s.RawCommand.([]string)
|
s.Command = v
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
for _, v := range s.RawCommand.([]interface{}) {
|
for _, v := range v {
|
||||||
s.Command = append(s.Command, v.(string))
|
s.Command = append(s.Command, v.(string))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -196,11 +196,11 @@ func parseEnvFiles(s *Service) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
envfiles := make([]string, 0)
|
envfiles := make([]string, 0)
|
||||||
switch s.RawEnvFiles.(type) {
|
switch v := s.RawEnvFiles.(type) {
|
||||||
case []string:
|
case []string:
|
||||||
envfiles = s.RawEnvFiles.([]string)
|
envfiles = v
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
for _, v := range s.RawEnvFiles.([]interface{}) {
|
for _, v := range v {
|
||||||
envfiles = append(envfiles, v.(string))
|
envfiles = append(envfiles, v.(string))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -209,3 +209,28 @@ func parseEnvFiles(s *Service) {
|
|||||||
}
|
}
|
||||||
s.EnvFiles = envfiles
|
s.EnvFiles = envfiles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseHealthCheck(s *Service) {
|
||||||
|
// HealthCheck command can be a string or slice of strings
|
||||||
|
if s.HealthCheck.RawTest == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch v := s.HealthCheck.RawTest.(type) {
|
||||||
|
case string:
|
||||||
|
var err error
|
||||||
|
s.HealthCheck.Test, err = shlex.Split(v)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
case []string:
|
||||||
|
s.HealthCheck.Test = v
|
||||||
|
|
||||||
|
case []interface{}:
|
||||||
|
for _, v := range v {
|
||||||
|
s.HealthCheck.Test = append(s.HealthCheck.Test, v.(string))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
log.Printf("%+v %T", s.HealthCheck.RawTest, s.HealthCheck.RawTest)
|
||||||
|
log.Fatal("HealthCheck type not supported")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -17,11 +17,12 @@ func NewCompose() *Compose {
|
|||||||
|
|
||||||
// HealthCheck manage generic type to handle TCP, HTTP and TCP health check.
|
// HealthCheck manage generic type to handle TCP, HTTP and TCP health check.
|
||||||
type HealthCheck struct {
|
type HealthCheck struct {
|
||||||
Test []string `yaml:"test"`
|
Test []string `yaml:"-"`
|
||||||
Interval string `yaml:"interval"`
|
RawTest interface{} `yaml:"test"`
|
||||||
Timeout string `yaml:"timeout"`
|
Interval string `yaml:"interval"`
|
||||||
Retries int `yaml:"retries"`
|
Timeout string `yaml:"timeout"`
|
||||||
StartPeriod string `yaml:"start_period"`
|
Retries int `yaml:"retries"`
|
||||||
|
StartPeriod string `yaml:"start_period"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Service represent a "service" in a docker-compose file.
|
// Service represent a "service" in a docker-compose file.
|
||||||
|
Reference in New Issue
Block a user