mirror of
https://github.com/openfaas/faas.git
synced 2025-06-20 13:06:40 +00:00
Pass env-vars to functions via API gateway
This commit is contained in:
@ -198,6 +198,10 @@ func makeSpec(request *requests.CreateFunctionRequest) swarm.ServiceSpec {
|
||||
if len(request.EnvProcess) > 0 {
|
||||
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 {
|
||||
spec.TaskTemplate.ContainerSpec.Env = env
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ package requests
|
||||
|
||||
// CreateFunctionRequest create a function in the swarm.
|
||||
type CreateFunctionRequest struct {
|
||||
Service string `json:"service"`
|
||||
Image string `json:"image"`
|
||||
Network string `json:"network"`
|
||||
Service string `json:"service"`
|
||||
Image string `json:"image"`
|
||||
Network string `json:"network"`
|
||||
|
||||
// EnvProcess corresponds to the fprocess variable for your container watchdog.
|
||||
EnvProcess string `json:"envProcess"`
|
||||
|
Reference in New Issue
Block a user