mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-27 17:23:24 +00:00
This commit adds the EnvVars set on the process to the retuurn from the faasd provider. It gets the container process and then filters out PATH and fprocess (if found) and returns the remaining envVars as a map. This has using tests for getting the EnvVars from procees.env and has been tested on amd_64 faasd by building, deploying and using curl against the provider and gateway. Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
39 lines
995 B
Go
39 lines
995 B
Go
package handlers
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/containerd/containerd"
|
|
"github.com/gorilla/mux"
|
|
"github.com/openfaas/faas-provider/types"
|
|
)
|
|
|
|
func MakeReplicaReaderHandler(client *containerd.Client) func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
vars := mux.Vars(r)
|
|
functionName := vars["name"]
|
|
|
|
if f, err := GetFunction(client, functionName); err == nil {
|
|
found := types.FunctionStatus{
|
|
Name: functionName,
|
|
AvailableReplicas: uint64(f.replicas),
|
|
Replicas: uint64(f.replicas),
|
|
Namespace: f.namespace,
|
|
Labels: &f.labels,
|
|
Annotations: &f.annotations,
|
|
Secrets: f.secrets,
|
|
EnvVars: f.envVars,
|
|
}
|
|
|
|
functionBytes, _ := json.Marshal(found)
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(http.StatusOK)
|
|
w.Write(functionBytes)
|
|
} else {
|
|
w.WriteHeader(http.StatusNotFound)
|
|
}
|
|
}
|
|
}
|