Skip to content

Commit

Permalink
refactor: replace utils.Marshal/Unmarshal with json.Marshal/json.Unma…
Browse files Browse the repository at this point in the history
…rshal

Signed-off-by: devhindo <[email protected]>
  • Loading branch information
devhindo committed Dec 28, 2024
1 parent 5e7b75a commit 37d955e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout=5m
Expand Down
3 changes: 2 additions & 1 deletion meshsync/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"
"strings"
"time"
"encoding/json"

"github.com/google/uuid"
"github.com/layer5io/meshkit/broker"
Expand All @@ -46,7 +47,7 @@ func (h *Handler) processExecRequest(obj interface{}, cfg config.ListenerConfig)
return err
}

err = utils.Unmarshal(d, &reqs)
err = json.Unmarshal([]byte(d), &reqs)
if err != nil {
return err
}
Expand Down
9 changes: 5 additions & 4 deletions meshsync/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package meshsync
import (
"fmt"
"time"
"encoding/json"

"github.com/layer5io/meshkit/broker"
"github.com/layer5io/meshkit/utils"
Expand Down Expand Up @@ -98,14 +99,14 @@ func (h *Handler) ListenToRequests() {

// TODO: Add this to the broker pkg
case "informer-store":
d, err := utils.Marshal(request.Request.Payload)
d, err := json.Marshal(request.Request.Payload)
// TODO: Update broker pkg in Meshkit to include Reply types
var payload struct{ Reply string }
if err != nil {
h.Log.Error(err)
continue
}
err = utils.Unmarshal(d, &payload)
err = json.Unmarshal(d, &payload)
if err != nil {
h.Log.Error(err)
continue
Expand Down Expand Up @@ -188,13 +189,13 @@ func (h *Handler) WatchCRDs() {
for event := range crdWatcher.ResultChan() {

crd := &kubernetes.CRDItem{}
byt, err := utils.Marshal(event.Object)
byt, err := json.Marshal(event.Object)
if err != nil {
h.Log.Error(err)
continue
}

err = utils.Unmarshal(byt, crd)
err = json.Unmarshal(byt, crd)
if err != nil {
h.Log.Error(err)
continue
Expand Down
6 changes: 3 additions & 3 deletions meshsync/logstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"fmt"
"io"
"encoding/json"

"github.com/layer5io/meshkit/broker"
"github.com/layer5io/meshkit/utils"
"github.com/layer5io/meshsync/internal/channels"
"github.com/layer5io/meshsync/internal/config"
"github.com/layer5io/meshsync/pkg/model"
Expand All @@ -15,12 +15,12 @@ import (

func (h *Handler) processLogRequest(obj interface{}, cfg config.ListenerConfig) error {
reqs := make(model.LogRequests)
d, err := utils.Marshal(obj)
d, err := json.Marshal(obj)
if err != nil {
return err
}

err = utils.Unmarshal(d, &reqs)
err = json.Unmarshal(d, &reqs)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/model_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package model

import (
"encoding/base64"
"encoding/json"
"fmt"

"github.com/buger/jsonparser"
"github.com/google/uuid"
"github.com/layer5io/meshkit/broker"
"github.com/layer5io/meshkit/orchestration"
"github.com/layer5io/meshkit/utils"
iutils "github.com/layer5io/meshsync/pkg/utils"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

func ParseList(object unstructured.Unstructured, eventType broker.EventType) KubernetesResource {
data, _ := object.MarshalJSON()
result := KubernetesResource{}
_ = utils.Unmarshal(string(data), &result)
_ = json.Unmarshal(data, &result)

processorInstance := GetProcessorInstance(result.Kind)
// ObjectMeta internal models
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"net/url"
"strings"

"encoding/json"

"github.com/layer5io/meshkit/broker"
"github.com/layer5io/meshkit/utils"
"github.com/layer5io/meshkit/utils/kubernetes"
v1 "k8s.io/api/core/v1"
)
Expand All @@ -21,7 +21,7 @@ func (s *K8SService) Process(data []byte, k8sresource *KubernetesResource, evtyp

k8sservice := &v1.Service{}

err := utils.Unmarshal(string(data), k8sservice)
err := json.Unmarshal(data, k8sservice)
if err != nil {
return err
}
Expand Down

0 comments on commit 37d955e

Please sign in to comment.