Switch to official Kubernetes Go client -- client-go/1.4

Switch to client-go package instead of pulling the from kubernetes.
Use a versioned client with sensible compatiblity.

This change breaks 'go get'.  For now you have to manually checkout
the 'release-1.4' branch of the client-go package after 'go get'
fetches it.  TODO: use one of the build tools to fix this.
This commit is contained in:
Soam Vasani
2016-11-01 01:32:02 -07:00
parent 7d1058d7be
commit 40dfba1a41
3 changed files with 96 additions and 70 deletions
+25 -2
View File
@@ -18,14 +18,19 @@ package poolmgr
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"time"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/platform9/fission"
"github.com/platform9/fission/cache"
controllerclient "github.com/platform9/fission/controller/client"
"io/ioutil"
"log"
)
type funcSvc struct {
@@ -44,6 +49,15 @@ type API struct {
controller *controllerclient.Client
}
func MakeAPI(gpm *GenericPoolManager, controller *controllerclient.Client) *API {
return &API{
poolMgr: gpm,
functionEnv: cache.MakeCache(),
functionService: cache.MakeCache(),
controller: controller,
}
}
func (api *API) lookupApi(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
@@ -136,3 +150,12 @@ func (api *API) lookup(m *fission.Metadata) (string, error) {
return funcSvc.serviceName, nil
}
func (api *API) Serve(port int) {
r := mux.NewRouter()
r.HandleFunc("/v1/lookup", api.lookupApi).Methods("GET")
address := fmt.Sprintf(":%v", port)
log.Printf("starting poolmgr at port %v", port)
log.Fatal(http.ListenAndServe(address, handlers.LoggingHandler(os.Stdout, r)))
}