Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #575: Replaced deprecated utils.Unmarshal and removed unused variables #579

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions config/provider/inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ package provider

import (
"sync"

"encoding/json"
"github.com/layer5io/meshkit/config"
"github.com/layer5io/meshkit/encoding"
"github.com/layer5io/meshkit/utils"
)

Expand Down Expand Up @@ -55,7 +54,7 @@ func (l *InMem) GetKey(key string) string {
func (l *InMem) GetObject(key string, result interface{}) error {
l.mutex.Lock()
defer l.mutex.Unlock()
return encoding.Unmarshal([]byte(l.store[key]), result)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

return json.Unmarshal([]byte(l.store[key]), result)
}

// SetObject sets an object value for the key
Expand Down
5 changes: 2 additions & 3 deletions utils/kubernetes/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package kubernetes

import (
"context"

"github.com/layer5io/meshkit/encoding"
"encoding/json"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/rest"
)
Expand Down Expand Up @@ -35,7 +34,7 @@ func GetAllCustomResourcesInCluster(ctx context.Context, client rest.Interface)
}
var xcrd CRD
gvks := []*schema.GroupVersionResource{}
err = encoding.Unmarshal(crdresult, &xcrd)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encoding.Unmarshal is not deprecated, in fact recommended to be used.
It is the encoder recently added in Meshkit, which supports both json/yaml.

err = json.Unmarshal(crdresult, &xcrd)
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion validator/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

var (
ErrValidateCode = ""
_ = "components.schemas"
cueschema cue.Value
mx sync.Mutex
isSchemaLoaded bool
Expand Down
Loading