feat: kubesphere 4.0 (#6115)

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

---------

Signed-off-by: ci-bot <ci-bot@kubesphere.io>
Co-authored-by: ks-ci-bot <ks-ci-bot@example.com>
Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
KubeSphere CI Bot
2024-09-06 11:05:52 +08:00
committed by GitHub
parent b5015ec7b9
commit 447a51f08b
8557 changed files with 546695 additions and 1146174 deletions

View File

@@ -11,7 +11,9 @@ import (
"io"
"reflect"
"github.com/ghodss/yaml"
"sigs.k8s.io/yaml"
"github.com/open-policy-agent/opa/loader/extension"
)
// UnmarshalJSON parses the JSON encoded data and stores the result in the value
@@ -19,10 +21,17 @@ import (
//
// This function is intended to be used in place of the standard json.Marshal
// function when json.Number is required.
func UnmarshalJSON(bs []byte, x interface{}) (err error) {
func UnmarshalJSON(bs []byte, x interface{}) error {
return unmarshalJSON(bs, x, true)
}
func unmarshalJSON(bs []byte, x interface{}, ext bool) error {
buf := bytes.NewBuffer(bs)
decoder := NewJSONDecoder(buf)
if err := decoder.Decode(x); err != nil {
if handler := extension.FindExtension(".json"); handler != nil && ext {
return handler(bs, x)
}
return err
}
@@ -103,14 +112,18 @@ func Reference(x interface{}) *interface{} {
return &x
}
// Unmarshal decodes a YAML or JSON value into the specified type.
// Unmarshal decodes a YAML, JSON or JSON extension value into the specified type.
func Unmarshal(bs []byte, v interface{}) error {
if json.Valid(bs) {
return UnmarshalJSON(bs, v)
return unmarshalJSON(bs, v, false)
}
bs, err := yaml.YAMLToJSON(bs)
if err != nil {
return err
nbs, err := yaml.YAMLToJSON(bs)
if err == nil {
return unmarshalJSON(nbs, v, false)
}
return UnmarshalJSON(bs, v)
// not json or yaml: try extensions
if handler := extension.FindExtension(".json"); handler != nil {
return handler(bs, v)
}
return err
}