From 2502989ca2c33d654f923687db8c53c5b44c8b5b Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 28 Sep 2023 10:20:35 +0200 Subject: [PATCH] Refactor --- pkg/schema/validate.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/schema/validate.go b/pkg/schema/validate.go index aec234c..77b6dbb 100644 --- a/pkg/schema/validate.go +++ b/pkg/schema/validate.go @@ -28,12 +28,13 @@ const ( //go:embed schemas/* var schemaFiles embed.FS -func Validate(k Kind, r io.Reader) (err error) { +func Validate(k Kind, r io.Reader) error { jsonschema.Loaders["embedfs"] = func(s string) (io.ReadCloser, error) { f := filepath.Join("schemas", strings.Split(s, "//")[1]) return schemaFiles.Open(f) } var s *jsonschema.Schema + var err error switch k { case Meta: @@ -54,7 +55,7 @@ func Validate(k Kind, r io.Reader) (err error) { } var v interface{} - if err := json.NewDecoder(r).Decode(&v); err != nil { + if err = json.NewDecoder(r).Decode(&v); err != nil { log.Warnf("Error while decoding raw json schema: %#v", err) return err }