Skip to content

Commit

Permalink
fix: use k8s json lib (#476)
Browse files Browse the repository at this point in the history
* fix: use k8s json lib

Signed-off-by: Charles-Edouard Brétéché <[email protected]>

* fix tests

Signed-off-by: Charles-Edouard Brétéché <[email protected]>

---------

Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Sep 16, 2024
1 parent ae1603e commit eed05d1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions pkg/apis/policy/v1alpha1/any.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package v1alpha1

import (
"encoding/json"

"github.com/jinzhu/copier"
"k8s.io/apimachinery/pkg/util/json"
)

// Any can be any type.
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/policy/v1alpha1/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestAny_UnmarshalJSON(t *testing.T) {
}, {
name: "int",
data: []byte("42"),
want: &Any{Value: 42.0},
want: &Any{Value: int64(42)},
wantErr: false,
}, {
name: "string",
Expand All @@ -119,7 +119,7 @@ func TestAny_UnmarshalJSON(t *testing.T) {
}, {
name: "map",
data: []byte(`{"foo":42}`),
want: &Any{Value: map[string]any{"foo": 42.0}},
want: &Any{Value: map[string]any{"foo": int64(42)}},
wantErr: false,
}, {
name: "error",
Expand Down
3 changes: 2 additions & 1 deletion pkg/engine/template/functions/json_parse.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package functions

import (
"encoding/json"
"errors"

"k8s.io/apimachinery/pkg/util/json"
)

func jpfJsonParse(arguments []any) (any, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/template/kyverno/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"crypto/x509"
"encoding/asn1"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
Expand All @@ -26,6 +25,7 @@ import (
regen "github.com/zach-klippenstein/goregen"
"golang.org/x/crypto/cryptobyte"
cryptobyte_asn1 "golang.org/x/crypto/cryptobyte/asn1"
"k8s.io/apimachinery/pkg/util/json"
"sigs.k8s.io/yaml"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/payload/load.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package payload

import (
"encoding/json"
"fmt"
"os"
"path/filepath"

"github.com/kyverno/pkg/ext/file"
yamlutils "github.com/kyverno/pkg/ext/yaml"
"gopkg.in/yaml.v3"
"k8s.io/apimachinery/pkg/util/json"
)

func Load(path string) (any, error) {
Expand Down

0 comments on commit eed05d1

Please sign in to comment.