summaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go b/vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
index e081d7ff1..83b2e1393 100644
--- a/vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
+++ b/vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
@@ -96,6 +96,7 @@ type SerializerOptions struct {
Strict bool
}
+// Serializer handles encoding versioned objects into the proper JSON form
type Serializer struct {
meta MetaFactory
options SerializerOptions
@@ -144,10 +145,10 @@ func (customNumberDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
}
}
-// CaseSensitiveJsonIterator returns a jsoniterator API that's configured to be
+// CaseSensitiveJSONIterator returns a jsoniterator API that's configured to be
// case-sensitive when unmarshalling, and otherwise compatible with
// the encoding/json standard library.
-func CaseSensitiveJsonIterator() jsoniter.API {
+func CaseSensitiveJSONIterator() jsoniter.API {
config := jsoniter.Config{
EscapeHTML: true,
SortMapKeys: true,
@@ -159,10 +160,10 @@ func CaseSensitiveJsonIterator() jsoniter.API {
return config
}
-// StrictCaseSensitiveJsonIterator returns a jsoniterator API that's configured to be
+// StrictCaseSensitiveJSONIterator returns a jsoniterator API that's configured to be
// case-sensitive, but also disallows unknown fields when unmarshalling. It is compatible with
// the encoding/json standard library.
-func StrictCaseSensitiveJsonIterator() jsoniter.API {
+func StrictCaseSensitiveJSONIterator() jsoniter.API {
config := jsoniter.Config{
EscapeHTML: true,
SortMapKeys: true,
@@ -179,8 +180,8 @@ func StrictCaseSensitiveJsonIterator() jsoniter.API {
// from outside. Still does not protect from package level jsoniter.Register*() functions - someone calling them
// in some other library will mess with every usage of the jsoniter library in the whole program.
// See https://github.com/json-iterator/go/issues/265
-var caseSensitiveJsonIterator = CaseSensitiveJsonIterator()
-var strictCaseSensitiveJsonIterator = StrictCaseSensitiveJsonIterator()
+var caseSensitiveJSONIterator = CaseSensitiveJSONIterator()
+var strictCaseSensitiveJSONIterator = StrictCaseSensitiveJSONIterator()
// gvkWithDefaults returns group kind and version defaulting from provided default
func gvkWithDefaults(actual, defaultGVK schema.GroupVersionKind) schema.GroupVersionKind {
@@ -236,7 +237,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
types, _, err := s.typer.ObjectKinds(into)
switch {
case runtime.IsNotRegisteredError(err), isUnstructured:
- if err := caseSensitiveJsonIterator.Unmarshal(data, into); err != nil {
+ if err := caseSensitiveJSONIterator.Unmarshal(data, into); err != nil {
return nil, actual, err
}
return into, actual, nil
@@ -260,7 +261,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
return nil, actual, err
}
- if err := caseSensitiveJsonIterator.Unmarshal(data, obj); err != nil {
+ if err := caseSensitiveJSONIterator.Unmarshal(data, obj); err != nil {
return nil, actual, err
}
@@ -285,7 +286,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i
// due to that a matching field doesn't exist in the object. hence we can return a typed strictDecoderError,
// the actual error is that the object contains unknown field.
strictObj := obj.DeepCopyObject()
- if err := strictCaseSensitiveJsonIterator.Unmarshal(altered, strictObj); err != nil {
+ if err := strictCaseSensitiveJSONIterator.Unmarshal(altered, strictObj); err != nil {
return nil, actual, runtime.NewStrictDecodingError(err.Error(), string(originalData))
}
// Always return the same object as the non-strict serializer to avoid any deviations.
@@ -302,7 +303,7 @@ func (s *Serializer) Encode(obj runtime.Object, w io.Writer) error {
func (s *Serializer) doEncode(obj runtime.Object, w io.Writer) error {
if s.options.Yaml {
- json, err := caseSensitiveJsonIterator.Marshal(obj)
+ json, err := caseSensitiveJSONIterator.Marshal(obj)
if err != nil {
return err
}
@@ -315,7 +316,7 @@ func (s *Serializer) doEncode(obj runtime.Object, w io.Writer) error {
}
if s.options.Pretty {
- data, err := caseSensitiveJsonIterator.MarshalIndent(obj, "", " ")
+ data, err := caseSensitiveJSONIterator.MarshalIndent(obj, "", " ")
if err != nil {
return err
}