Add label support to Swarm

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2017-10-22 20:57:51 +01:00
parent 35f0e9e657
commit 7c28f7d97e

View File

@ -82,6 +82,12 @@ func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64, resta
} else {
constraints = linuxOnlyConstraints
}
labels := map[string]string{"function": "true"}
if request.Labels != nil {
for k, v := range request.Labels {
labels[k] = v
}
}
labels := map[string]string{
"com.openfaas.function": request.Service,
@ -129,6 +135,10 @@ func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64, resta
Replicas: getMinReplicas(request),
},
},
Annotations: swarm.Annotations{
Name: request.Service,
Labels: labels,
},
}
// TODO: request.EnvProcess should only be set if it's not nil, otherwise we override anything in the Docker image already