diff --git a/docker-compose.armhf.yml b/docker-compose.armhf.yml index 858f9814..4c37bb83 100644 --- a/docker-compose.armhf.yml +++ b/docker-compose.armhf.yml @@ -89,6 +89,8 @@ services: environment: max_inflight: "1" ack_wait: "30s" # Max duration of any async task / request + basic_auth: "false" + secret_mount_path: "/run/secrets/" deploy: resources: limits: diff --git a/docker-compose.yml b/docker-compose.yml index 8f961b03..689a0c08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -93,6 +93,8 @@ services: environment: max_inflight: "1" ack_wait: "300s" # Max duration of any async task / request + basic_auth: "${BASIC_AUTH:-true}" + secret_mount_path: "/run/secrets/" deploy: resources: limits: @@ -107,6 +109,10 @@ services: placement: constraints: - 'node.platform.os == linux' + secrets: + - basic-auth-user + - basic-auth-password + # End services # Start monitoring diff --git a/gateway/Makefile b/gateway/Makefile new file mode 100644 index 00000000..e56b00f8 --- /dev/null +++ b/gateway/Makefile @@ -0,0 +1,6 @@ +.PHONY: all build +TAG?=latest + +all: build +build: + ./build.sh ${TAG} diff --git a/gateway/server.go b/gateway/server.go index 5f33edac..f470eea2 100644 --- a/gateway/server.go +++ b/gateway/server.go @@ -1,5 +1,4 @@ // Copyright (c) Alex Ellis 2017. All rights reserved. -// Copyright (c) OpenFaaS Author(s). All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. package main @@ -85,13 +84,12 @@ func main() { faasHandlers.DeployFunction = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer) faasHandlers.DeleteFunction = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer) faasHandlers.UpdateFunction = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer) - queryFunction := handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer) + faasHandlers.QueryFunction = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer) + faasHandlers.InfoHandler = handlers.MakeInfoHandler(handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer)) alertHandler := plugin.NewExternalServiceQuery(*config.FunctionsProviderURL) faasHandlers.Alert = handlers.MakeAlertHandler(alertHandler) - infoHandler := handlers.MakeInfoHandler(handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer)) - if config.UseNATS() { log.Println("Async enabled: Using NATS Streaming.") natsQueue, queueErr := natsHandler.CreateNatsQueue(*config.NATSAddress, *config.NATSPort, natsHandler.DefaultNatsConfig{}) @@ -120,8 +118,8 @@ func main() { handlers.DecorateWithBasicAuth(faasHandlers.ListFunctions, credentials) faasHandlers.ScaleFunction = handlers.DecorateWithBasicAuth(faasHandlers.ScaleFunction, credentials) - infoHandler = handlers.DecorateWithBasicAuth(infoHandler, credentials) - queryFunction = handlers.DecorateWithBasicAuth(queryFunction, credentials) + faasHandlers.QueryFunction = handlers.DecorateWithBasicAuth(faasHandlers.QueryFunction, credentials) + faasHandlers.InfoHandler = handlers.DecorateWithBasicAuth(faasHandlers.InfoHandler, credentials) } r := mux.NewRouter() @@ -137,17 +135,17 @@ func main() { ServiceQuery: alertHandler, } - functionProxy = handlers.MakeScalingHandler(faasHandlers.Proxy, queryFunction, scalingConfig) + functionProxy = handlers.MakeScalingHandler(faasHandlers.Proxy, faasHandlers.QueryFunction, scalingConfig) } // r.StrictSlash(false) // This didn't work, so register routes twice. r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}", functionProxy) r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}/", functionProxy) r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}/{params:.*}", functionProxy) - r.HandleFunc("/system/info", infoHandler).Methods(http.MethodGet) - r.HandleFunc("/system/alert", faasHandlers.Alert) + r.HandleFunc("/system/info", faasHandlers.InfoHandler).Methods(http.MethodGet) + r.HandleFunc("/system/alert", faasHandlers.Alert).Methods(http.MethodPost) - r.HandleFunc("/system/function/{name:[-a-zA-Z_0-9]+}", queryFunction).Methods(http.MethodGet) + r.HandleFunc("/system/function/{name:[-a-zA-Z_0-9]+}", faasHandlers.QueryFunction).Methods(http.MethodGet) r.HandleFunc("/system/functions", faasHandlers.ListFunctions).Methods(http.MethodGet) r.HandleFunc("/system/functions", faasHandlers.DeployFunction).Methods(http.MethodPost) r.HandleFunc("/system/functions", faasHandlers.DeleteFunction).Methods(http.MethodDelete) diff --git a/gateway/types/handler_set.go b/gateway/types/handler_set.go index 80e5bb63..66bfe715 100644 --- a/gateway/types/handler_set.go +++ b/gateway/types/handler_set.go @@ -12,6 +12,9 @@ type HandlerSet struct { RoutelessProxy http.HandlerFunc UpdateFunction http.HandlerFunc + // QueryFunction - queries the metdata for a function + QueryFunction http.HandlerFunc + // QueuedProxy - queue work and return synchronous response QueuedProxy http.HandlerFunc @@ -20,4 +23,7 @@ type HandlerSet struct { // ScaleFunction allows a function to be scaled ScaleFunction http.HandlerFunc + + // InfoHandler provides version and build info + InfoHandler http.HandlerFunc }