From 3535b9bada073a64b2e3b87390fdda3d0af85dd9 Mon Sep 17 00:00:00 2001 From: shivanshu Date: Sun, 25 Aug 2024 22:09:33 +0530 Subject: [PATCH] Fix #575: Replaced deprecated utils.Unmarshal and removed unused variables --- config/provider/inmem.go | 5 +++-- utils/kubernetes/crd.go | 5 +++-- validator/validate.go | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config/provider/inmem.go b/config/provider/inmem.go index 753c0064..6108b1c8 100644 --- a/config/provider/inmem.go +++ b/config/provider/inmem.go @@ -16,7 +16,7 @@ package provider import ( "sync" - + "encoding/json" "github.com/layer5io/meshkit/config" "github.com/layer5io/meshkit/utils" ) @@ -54,7 +54,8 @@ func (l *InMem) GetKey(key string) string { func (l *InMem) GetObject(key string, result interface{}) error { l.mutex.Lock() defer l.mutex.Unlock() - return utils.Unmarshal(l.store[key], result) + //return utils.Unmarshal(l.store[key], result) + return json.Unmarshal([]byte(l.store[key]), result) } // SetObject sets an object value for the key diff --git a/utils/kubernetes/crd.go b/utils/kubernetes/crd.go index b42cfbc9..69bf53af 100644 --- a/utils/kubernetes/crd.go +++ b/utils/kubernetes/crd.go @@ -2,8 +2,8 @@ package kubernetes import ( "context" + "encoding/json" - "github.com/layer5io/meshkit/utils" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/rest" ) @@ -35,7 +35,8 @@ func GetAllCustomResourcesInCluster(ctx context.Context, client rest.Interface) } var xcrd CRD gvks := []*schema.GroupVersionResource{} - err = utils.Unmarshal(string(crdresult), &xcrd) + //err = utils.Unmarshal(string(crdresult), &xcrd) + err = json.Unmarshal(crdresult, &xcrd) if err != nil { return nil, err } diff --git a/validator/validate.go b/validator/validate.go index dc043d52..69aaddd6 100644 --- a/validator/validate.go +++ b/validator/validate.go @@ -14,7 +14,6 @@ import ( var ( ErrValidateCode = "" - schemaPath = "components.schemas" cueschema cue.Value mx sync.Mutex isSchemaLoaded bool