mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-14 16:34:46 +00:00
Update santhosh-tekuri/jsonschema to v6
This commit is contained in:
parent
da924addff
commit
feb7360d30
111 changed files with 24453 additions and 4749 deletions
|
|
@ -6,10 +6,11 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/message"
|
||||
"io"
|
||||
|
||||
jsonschema "github.com/santhosh-tekuri/jsonschema/v5"
|
||||
_ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
|
||||
jsonschema "github.com/santhosh-tekuri/jsonschema/v6"
|
||||
"github.com/yannh/kubeconform/pkg/cache"
|
||||
"github.com/yannh/kubeconform/pkg/registry"
|
||||
"github.com/yannh/kubeconform/pkg/resource"
|
||||
|
|
@ -197,9 +198,13 @@ func (val *v) ValidateResource(res resource.Resource) Result {
|
|||
var e *jsonschema.ValidationError
|
||||
if errors.As(err, &e) {
|
||||
for _, ve := range e.Causes {
|
||||
path := ""
|
||||
for _, f := range ve.InstanceLocation {
|
||||
path = path + "/" + f
|
||||
}
|
||||
validationErrors = append(validationErrors, ValidationError{
|
||||
Path: ve.InstanceLocation,
|
||||
Msg: ve.Message,
|
||||
Path: path,
|
||||
Msg: ve.LocalizedError(message.NewPrinter(language.English)),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -256,9 +261,14 @@ func downloadSchema(registries []registry.Registry, kind, version, k8sVersion st
|
|||
for _, reg := range registries {
|
||||
path, schemaBytes, err = reg.DownloadSchema(kind, version, k8sVersion)
|
||||
if err == nil {
|
||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(schemaBytes))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
c := jsonschema.NewCompiler()
|
||||
c.Draft = jsonschema.Draft4
|
||||
if err := c.AddResource(path, bytes.NewReader(schemaBytes)); err != nil {
|
||||
c.DefaultDraft(jsonschema.Draft4)
|
||||
if err := c.AddResource(path, s); err != nil {
|
||||
continue
|
||||
}
|
||||
schema, err := c.Compile(path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue