build(deps): bump github.com/open-policy-agent/opa from 0.51.0 to 0.59.0

Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.51.0 to 0.59.0.
- [Release notes](https://github.com/open-policy-agent/opa/releases)
- [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-policy-agent/opa/compare/v0.51.0...v0.59.0)

---
updated-dependencies:
- dependency-name: github.com/open-policy-agent/opa
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-12-05 09:47:11 +01:00
committed by Ralf Haferkamp
parent a6a6c22c14
commit 1f069c7c00
197 changed files with 73803 additions and 3024 deletions
+21 -8
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
}