mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 20:16:37 +00:00
Add feature for invoking namespaced functions
When coupled with the latest version of faas-netes, the gateway can now invoke, query and deploy functions into alternative namespaces. Tested e2e by creating a namespace "fn" and deploying, then invoking a function deployed there and in the default namespace. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
0a90125aba
commit
238ce1be23
@ -179,7 +179,8 @@ func (s SingleHostBaseURLResolver) Resolve(r *http.Request) string {
|
||||
|
||||
// FunctionAsHostBaseURLResolver resolves URLs using a function from the URL as a host
|
||||
type FunctionAsHostBaseURLResolver struct {
|
||||
FunctionSuffix string
|
||||
FunctionSuffix string
|
||||
FunctionNamespace string
|
||||
}
|
||||
|
||||
// Resolve the base URL for a request
|
||||
@ -188,8 +189,13 @@ func (f FunctionAsHostBaseURLResolver) Resolve(r *http.Request) string {
|
||||
|
||||
const watchdogPort = 8080
|
||||
var suffix string
|
||||
|
||||
if len(f.FunctionSuffix) > 0 {
|
||||
suffix = "." + f.FunctionSuffix
|
||||
if index := strings.LastIndex(svcName, "."); index > -1 && len(svcName) > index+1 {
|
||||
suffix = strings.Replace(f.FunctionSuffix, f.FunctionNamespace, "", -1)
|
||||
} else {
|
||||
suffix = "." + f.FunctionSuffix
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf("http://%s%s:%d", svcName, suffix, watchdogPort)
|
||||
|
Reference in New Issue
Block a user