Migrate away from requests package for Function structs

The function deployment and status structs have been moved away
into the faas-provider package.

Tested with a build, running tests, and CI.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2019-08-05 12:37:53 +01:00
committed by Alex Ellis
parent 8767514527
commit df97efafae
13 changed files with 125 additions and 105 deletions

View File

@ -29,7 +29,7 @@ import (
"time"
"github.com/gorilla/mux"
"github.com/openfaas/faas-provider/httputils"
"github.com/openfaas/faas-provider/httputil"
)
const (
@ -112,7 +112,7 @@ func proxyRequest(w http.ResponseWriter, originalReq *http.Request, proxyClient
pathVars := mux.Vars(originalReq)
functionName := pathVars["name"]
if functionName == "" {
httputils.Errorf(w, http.StatusBadRequest, errMissingFunctionName)
httputil.Errorf(w, http.StatusBadRequest, errMissingFunctionName)
return
}
@ -120,13 +120,13 @@ func proxyRequest(w http.ResponseWriter, originalReq *http.Request, proxyClient
if resolveErr != nil {
// TODO: Should record the 404/not found error in Prometheus.
log.Printf("resolver error: cannot find %s: %s\n", functionName, resolveErr.Error())
httputils.Errorf(w, http.StatusNotFound, "Cannot find service: %s.", functionName)
httputil.Errorf(w, http.StatusNotFound, "Cannot find service: %s.", functionName)
return
}
proxyReq, err := buildProxyRequest(originalReq, functionAddr, pathVars["params"])
if err != nil {
httputils.Errorf(w, http.StatusInternalServerError, "Failed to resolve service: %s.", functionName)
httputil.Errorf(w, http.StatusInternalServerError, "Failed to resolve service: %s.", functionName)
return
}
if proxyReq.Body != nil {
@ -140,7 +140,7 @@ func proxyRequest(w http.ResponseWriter, originalReq *http.Request, proxyClient
if err != nil {
log.Printf("error with proxy request to: %s, %s\n", proxyReq.URL.String(), err.Error())
httputils.Errorf(w, http.StatusInternalServerError, "Can't reach service for: %s.", functionName)
httputil.Errorf(w, http.StatusInternalServerError, "Can't reach service for: %s.", functionName)
return
}