From e738a5959efaf67de4d4d9766caea66ef4faaba0 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Fri, 20 Sep 2019 11:22:37 +0100 Subject: [PATCH] Populate namespace when querying functions Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- Gopkg.lock | 10 +++++----- Gopkg.toml | 13 ++++++------- handlers/reader.go | 2 +- .../openfaas/faas-provider/logs/handler.go | 1 + vendor/github.com/openfaas/faas-provider/serve.go | 13 ++++++++----- .../openfaas/faas-provider/types/model.go | 9 ++++++++- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 130bac100..446f5fed3 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -224,11 +224,11 @@ name = "github.com/openfaas/faas" packages = ["gateway/requests"] pruneopts = "UT" - revision = "df97efafae36ce7093ad353e3e6acc0e93d6300e" - version = "0.16.0" + revision = "d322f109a8379d19b639c003846e721a24ce9dc0" + version = "0.17.3" [[projects]] - digest = "1:cd86dd9f4c066d041dff9341fb70dfe2528f6faee04bbd870c39a6b822ed7de3" + digest = "1:65979387f3042412e8ddf943c31a307b34b315e65434223c7a80faec677d0f05" name = "github.com/openfaas/faas-provider" packages = [ ".", @@ -238,8 +238,8 @@ "types", ] pruneopts = "UT" - revision = "a7f9772feb70aae25b0c4420dbb64ed31684c525" - version = "0.9.5" + revision = "ba3fa3b0ae00f0b9222851f3e03b2e6ea8672998" + version = "0.10.1" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index 6ee7fe7a3..8ccfc1a64 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,15 +1,14 @@ - -[[constraint]] - name = "github.com/gorilla/mux" - version = "1.6.1" - [[constraint]] name = "github.com/openfaas/faas" - version = "0.16.0" + version = "0.17.3" [[constraint]] name = "github.com/openfaas/faas-provider" - version = "0.9.5" + version = "0.10.1" + +[[constraint]] + name = "github.com/gorilla/mux" + version = "1.6.1" [[constraint]] name = "k8s.io/apimachinery" diff --git a/handlers/reader.go b/handlers/reader.go index ba8777190..bcda19171 100644 --- a/handlers/reader.go +++ b/handlers/reader.go @@ -73,7 +73,6 @@ func getService(functionNamespace string, functionName string, clientset *kubern } if item != nil { - function := readFunction(*item) if function != nil { return function, nil @@ -98,6 +97,7 @@ func readFunction(item appsv1.Deployment) *types.FunctionStatus { InvocationCount: 0, Labels: &labels, Annotations: &item.Spec.Template.Annotations, + Namespace: item.Namespace, } return &function diff --git a/vendor/github.com/openfaas/faas-provider/logs/handler.go b/vendor/github.com/openfaas/faas-provider/logs/handler.go index 1a1cc35d2..0ab10a021 100644 --- a/vendor/github.com/openfaas/faas-provider/logs/handler.go +++ b/vendor/github.com/openfaas/faas-provider/logs/handler.go @@ -115,6 +115,7 @@ func parseRequest(r *http.Request) (logRequest Request, err error) { return logRequest, err } } + // ignore error because it will default to false if we can't parse it logRequest.Follow, _ = strconv.ParseBool(getValue(query, "follow")) diff --git a/vendor/github.com/openfaas/faas-provider/serve.go b/vendor/github.com/openfaas/faas-provider/serve.go index b3f6d1b06..cabcfcc86 100644 --- a/vendor/github.com/openfaas/faas-provider/serve.go +++ b/vendor/github.com/openfaas/faas-provider/serve.go @@ -13,6 +13,9 @@ import ( "github.com/openfaas/faas-provider/types" ) +// NameExpression for a function / service +const NameExpression = "-a-zA-Z_0-9." + var r *mux.Router // Mark this as a Golang "package" @@ -55,17 +58,17 @@ func Serve(handlers *types.FaaSHandlers, config *types.FaaSConfig) { r.HandleFunc("/system/functions", handlers.DeleteHandler).Methods("DELETE") r.HandleFunc("/system/functions", handlers.UpdateHandler).Methods("PUT") - r.HandleFunc("/system/function/{name:[-a-zA-Z_0-9]+}", handlers.ReplicaReader).Methods("GET") - r.HandleFunc("/system/scale-function/{name:[-a-zA-Z_0-9]+}", handlers.ReplicaUpdater).Methods("POST") + r.HandleFunc("/system/function/{name:["+NameExpression+"]+}", handlers.ReplicaReader).Methods("GET") + r.HandleFunc("/system/scale-function/{name:["+NameExpression+"]+}", handlers.ReplicaUpdater).Methods("POST") r.HandleFunc("/system/info", handlers.InfoHandler).Methods("GET") r.HandleFunc("/system/secrets", handlers.SecretHandler).Methods(http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete) r.HandleFunc("/system/logs", handlers.LogHandler).Methods(http.MethodGet) // Open endpoints - r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}", handlers.FunctionProxy) - r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}/", handlers.FunctionProxy) - r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}/{params:.*}", handlers.FunctionProxy) + r.HandleFunc("/function/{name:["+NameExpression+"]+}", handlers.FunctionProxy) + r.HandleFunc("/function/{name:["+NameExpression+"]+}/", handlers.FunctionProxy) + r.HandleFunc("/function/{name:["+NameExpression+"]+}/{params:.*}", handlers.FunctionProxy) if config.EnableHealth { r.HandleFunc("/healthz", handlers.HealthHandler).Methods("GET") diff --git a/vendor/github.com/openfaas/faas-provider/types/model.go b/vendor/github.com/openfaas/faas-provider/types/model.go index 888cfccd8..ef65176c9 100644 --- a/vendor/github.com/openfaas/faas-provider/types/model.go +++ b/vendor/github.com/openfaas/faas-provider/types/model.go @@ -46,6 +46,9 @@ type FunctionDeployment struct { // ReadOnlyRootFilesystem removes write-access from the root filesystem // mount-point. ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem"` + + // Namespace for the function to be deployed into + Namespace string `json:"namespace,omitempty"` } // FunctionResources Memory and CPU @@ -72,7 +75,8 @@ type FunctionStatus struct { // EnvProcess is the process to pass to the watchdog, if in use EnvProcess string `json:"envProcess"` - // AvailableReplicas is the count of replicas ready to receive invocations as reported by the backend + // AvailableReplicas is the count of replicas ready to receive + // invocations as reported by the backend AvailableReplicas uint64 `json:"availableReplicas"` // Labels are metadata for functions which may be used by the @@ -82,6 +86,9 @@ type FunctionStatus struct { // Annotations are metadata for functions which may be used by the // backend for management, orchestration, events and build tasks Annotations *map[string]string `json:"annotations"` + + // Namespace where the function can be accessed + Namespace string `json:"namespace,omitempty"` } // Secret for underlying orchestrator