Update k8s client version to 4.0.0 (#351)
Move to client-go v4.0.0 from 1.5.
This commit is contained in:
committed by
Soam Vasani
parent
e4d42797e6
commit
a25c167d23
@@ -26,7 +26,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
poolmgrClient "github.com/fission/fission/poolmgr/client"
|
||||
)
|
||||
@@ -34,7 +34,7 @@ import (
|
||||
type functionHandler struct {
|
||||
fmap *functionServiceMap
|
||||
poolmgr *poolmgrClient.Client
|
||||
function *api.ObjectMeta
|
||||
function *metav1.ObjectMeta
|
||||
}
|
||||
|
||||
func (fh *functionHandler) getServiceForFunction() (*url.URL, error) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func createBackendService(testResponseString string) *url.URL {
|
||||
@@ -49,7 +49,7 @@ func TestFunctionProxying(t *testing.T) {
|
||||
backendURL := createBackendService(testResponseString)
|
||||
log.Printf("Created backend svc at %v", backendURL)
|
||||
|
||||
fn := &api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}
|
||||
fn := &metav1.ObjectMeta{Name: "foo", Namespace: metav1.NamespaceDefault}
|
||||
|
||||
fmap := makeFunctionServiceMap(0)
|
||||
fmap.assign(fn, backendURL)
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/cache"
|
||||
@@ -44,7 +44,7 @@ type (
|
||||
// a distribution of requests across two functions.
|
||||
resolveResult struct {
|
||||
resolveResultType
|
||||
functionMetadata *api.ObjectMeta
|
||||
functionMetadata *metav1.ObjectMeta
|
||||
}
|
||||
|
||||
// namespacedFunctionReference is just a function reference plus a
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/cache"
|
||||
)
|
||||
@@ -31,7 +31,7 @@ type (
|
||||
cache *cache.Cache // map[metadataKey]*url.URL
|
||||
}
|
||||
|
||||
// api.ObjectMeta is not hashable, so we make a hashable copy
|
||||
// metav1.ObjectMeta is not hashable, so we make a hashable copy
|
||||
// of the subset of its fields that are identifiable.
|
||||
metadataKey struct {
|
||||
Name string
|
||||
@@ -46,7 +46,7 @@ func makeFunctionServiceMap(expiry time.Duration) *functionServiceMap {
|
||||
}
|
||||
}
|
||||
|
||||
func keyFromMetadata(m *api.ObjectMeta) *metadataKey {
|
||||
func keyFromMetadata(m *metav1.ObjectMeta) *metadataKey {
|
||||
return &metadataKey{
|
||||
Name: m.Name,
|
||||
Namespace: m.Namespace,
|
||||
@@ -54,7 +54,7 @@ func keyFromMetadata(m *api.ObjectMeta) *metadataKey {
|
||||
}
|
||||
}
|
||||
|
||||
func (fmap *functionServiceMap) lookup(f *api.ObjectMeta) (*url.URL, error) {
|
||||
func (fmap *functionServiceMap) lookup(f *metav1.ObjectMeta) (*url.URL, error) {
|
||||
mk := keyFromMetadata(f)
|
||||
item, err := fmap.cache.Get(*mk)
|
||||
if err != nil {
|
||||
@@ -64,7 +64,7 @@ func (fmap *functionServiceMap) lookup(f *api.ObjectMeta) (*url.URL, error) {
|
||||
return u, nil
|
||||
}
|
||||
|
||||
func (fmap *functionServiceMap) assign(f *api.ObjectMeta, serviceUrl *url.URL) {
|
||||
func (fmap *functionServiceMap) assign(f *metav1.ObjectMeta, serviceUrl *url.URL) {
|
||||
mk := keyFromMetadata(f)
|
||||
err, old := fmap.cache.Set(*mk, serviceUrl)
|
||||
if err != nil {
|
||||
|
||||
@@ -20,12 +20,12 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func TestFunctionServiceMap(t *testing.T) {
|
||||
m := makeFunctionServiceMap(0)
|
||||
fn := &api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}
|
||||
fn := &metav1.ObjectMeta{Name: "foo", Namespace: metav1.NamespaceDefault}
|
||||
u, err := url.Parse("/foo012")
|
||||
if err != nil {
|
||||
t.Errorf("can't parse url")
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
"k8s.io/client-go/1.5/pkg/watch"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
|
||||
"github.com/fission/fission"
|
||||
poolmgrClient "github.com/fission/fission/poolmgr/client"
|
||||
@@ -138,7 +138,7 @@ func (ts *HTTPTriggerSet) watchTriggers() {
|
||||
// Watch controller for updates to triggers and update the router accordingly.
|
||||
rv := ""
|
||||
for {
|
||||
wi, err := ts.fissionClient.Httptriggers(api.NamespaceAll).Watch(api.ListOptions{
|
||||
wi, err := ts.fissionClient.Httptriggers(metav1.NamespaceAll).Watch(metav1.ListOptions{
|
||||
ResourceVersion: rv,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -167,7 +167,7 @@ func (ts *HTTPTriggerSet) watchTriggers() {
|
||||
func (ts *HTTPTriggerSet) watchFunctions() {
|
||||
rv := ""
|
||||
for {
|
||||
wi, err := ts.fissionClient.Functions(api.NamespaceAll).Watch(api.ListOptions{
|
||||
wi, err := ts.fissionClient.Functions(metav1.NamespaceAll).Watch(metav1.ListOptions{
|
||||
ResourceVersion: rv,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -210,14 +210,14 @@ func (ts *HTTPTriggerSet) syncTriggers() {
|
||||
log.Printf("Syncing http triggers")
|
||||
|
||||
// get triggers
|
||||
triggers, err := ts.fissionClient.Httptriggers(api.NamespaceAll).List(api.ListOptions{})
|
||||
triggers, err := ts.fissionClient.Httptriggers(metav1.NamespaceAll).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get http trigger list: %v", err)
|
||||
}
|
||||
ts.triggers = triggers.Items
|
||||
|
||||
// get functions
|
||||
functions, err := ts.fissionClient.Functions(api.NamespaceAll).List(api.ListOptions{})
|
||||
functions, err := ts.fissionClient.Functions(metav1.NamespaceAll).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get function list: %v", err)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/tpr"
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
func TestRouter(t *testing.T) {
|
||||
// metadata for a fake function
|
||||
fn := &api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault}
|
||||
fn := &metav1.ObjectMeta{Name: "foo", Namespace: metav1.NamespaceDefault}
|
||||
|
||||
// and a reference to it
|
||||
fr := fission.FunctionReference{
|
||||
@@ -48,7 +48,7 @@ func TestRouter(t *testing.T) {
|
||||
// set up the resolver's cache for this function
|
||||
frr := makeFunctionReferenceResolver(nil)
|
||||
nfr := namespacedFunctionReference{
|
||||
namespace: api.NamespaceDefault,
|
||||
namespace: metav1.NamespaceDefault,
|
||||
functionReference: fr,
|
||||
}
|
||||
rr := resolveResult{
|
||||
@@ -62,9 +62,9 @@ func TestRouter(t *testing.T) {
|
||||
triggerUrl := "/foo"
|
||||
triggers.triggers = append(triggers.triggers,
|
||||
tpr.Httptrigger{
|
||||
Metadata: api.ObjectMeta{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "xxx",
|
||||
Namespace: api.NamespaceDefault,
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.HTTPTriggerSpec{
|
||||
RelativeURL: triggerUrl,
|
||||
|
||||
+6
-5
@@ -2,24 +2,25 @@ package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"k8s.io/client-go/1.5/pkg/api"
|
||||
"k8s.io/client-go/1.5/pkg/types"
|
||||
"net/http"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
const (
|
||||
HEADERS_FISSION_FUNCTION_PREFIX = "Fission-Function"
|
||||
)
|
||||
|
||||
func MetadataToHeaders(prefix string, meta *api.ObjectMeta, request *http.Request) {
|
||||
func MetadataToHeaders(prefix string, meta *metav1.ObjectMeta, request *http.Request) {
|
||||
request.Header.Add(fmt.Sprintf("X-%s-Uid", prefix), string(meta.UID))
|
||||
request.Header.Add(fmt.Sprintf("X-%s-Name", prefix), meta.Name)
|
||||
request.Header.Add(fmt.Sprintf("X-%s-Namespace", prefix), meta.Namespace)
|
||||
request.Header.Add(fmt.Sprintf("X-%s-ResourceVersion", prefix), meta.ResourceVersion)
|
||||
}
|
||||
|
||||
func HeadersToMetadata(prefix string, headers http.Header) *api.ObjectMeta {
|
||||
return &api.ObjectMeta{
|
||||
func HeadersToMetadata(prefix string, headers http.Header) *metav1.ObjectMeta {
|
||||
return &metav1.ObjectMeta{
|
||||
Name: headers.Get(fmt.Sprintf("X-%s-Name", prefix)),
|
||||
UID: types.UID(headers.Get(fmt.Sprintf("X-%s-Uid", prefix))),
|
||||
Namespace: headers.Get(fmt.Sprintf("X-%s-Namespace", prefix)),
|
||||
|
||||
Reference in New Issue
Block a user