From 7c28f7d97eff863e077972be97d6b5ff65e5810a Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Sun, 22 Oct 2017 20:57:51 +0100 Subject: [PATCH] Add label support to Swarm Signed-off-by: Alex Ellis --- gateway/handlers/create_handler.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gateway/handlers/create_handler.go b/gateway/handlers/create_handler.go index 31385da5..6e1236e5 100644 --- a/gateway/handlers/create_handler.go +++ b/gateway/handlers/create_handler.go @@ -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