Pass env-vars to functions via API gateway

This commit is contained in:
Alex Ellis
2017-05-07 09:28:19 +01:00
parent 024bd5419b
commit 9e3eaea754
2 changed files with 7 additions and 3 deletions

View File

@ -198,6 +198,10 @@ func makeSpec(request *requests.CreateFunctionRequest) swarm.ServiceSpec {
if len(request.EnvProcess) > 0 { if len(request.EnvProcess) > 0 {
env = append(env, fmt.Sprintf("fprocess=%s", request.EnvProcess)) env = append(env, fmt.Sprintf("fprocess=%s", request.EnvProcess))
} }
for k, v := range request.EnvVars {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
if len(env) > 0 { if len(env) > 0 {
spec.TaskTemplate.ContainerSpec.Env = env spec.TaskTemplate.ContainerSpec.Env = env
} }

View File

@ -5,9 +5,9 @@ package requests
// CreateFunctionRequest create a function in the swarm. // CreateFunctionRequest create a function in the swarm.
type CreateFunctionRequest struct { type CreateFunctionRequest struct {
Service string `json:"service"` Service string `json:"service"`
Image string `json:"image"` Image string `json:"image"`
Network string `json:"network"` Network string `json:"network"`
// EnvProcess corresponds to the fprocess variable for your container watchdog. // EnvProcess corresponds to the fprocess variable for your container watchdog.
EnvProcess string `json:"envProcess"` EnvProcess string `json:"envProcess"`