diff --git a/.gitignore b/.gitignore index f9663c923..9882b7675 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ output -schema/validate +schema/validate/validate version.md diff --git a/schema/Makefile b/schema/Makefile index fe676ae66..3cb1c6925 100644 --- a/schema/Makefile +++ b/schema/Makefile @@ -1,5 +1,6 @@ GOOD_TESTS = $(wildcard test/good/*.json) BAD_TESTS = $(wildcard test/bad/*.json) +VALIDATE = validate/validate default: validate @@ -14,9 +15,8 @@ fmt: find . -name '*.json' -exec bash -c 'jq --indent 4 -M . {} > xx && mv xx {} || echo "skipping invalid {}"' \; .PHONY: validate -validate: validate.go - GO111MODULE=auto go get github.com/xeipuuv/gojsonschema - GO111MODULE=auto go build ./validate.go +validate: + cd validate && go build test: validate $(TESTS) for TYPE in $$(ls test); \ @@ -25,7 +25,7 @@ test: validate $(TESTS) for FILE in $$(ls "test/$${TYPE}/good"); \ do \ echo " testing test/$${TYPE}/good/$${FILE}"; \ - if ./validate "$${TYPE}-schema.json" "test/$${TYPE}/good/$${FILE}" ; \ + if $(VALIDATE) "$${TYPE}-schema.json" "test/$${TYPE}/good/$${FILE}" ; \ then \ echo " received expected validation success" ; \ else \ @@ -36,7 +36,7 @@ test: validate $(TESTS) for FILE in $$(ls "test/$${TYPE}/bad"); \ do \ echo " testing test/$${TYPE}/bad/$${FILE}"; \ - if ./validate "$${TYPE}-schema.json" "test/$${TYPE}/bad/$${FILE}" ; \ + if $(VALIDATE) "$${TYPE}-schema.json" "test/$${TYPE}/bad/$${FILE}" ; \ then \ echo " received unexpected validation success" ; \ exit 1; \ @@ -46,5 +46,6 @@ test: validate $(TESTS) done; \ done +.PHONY: clean clean: - rm -f validate + rm -f validate/validate diff --git a/schema/README.md b/schema/README.md index f8f7fb739..d1a721824 100644 --- a/schema/README.md +++ b/schema/README.md @@ -14,7 +14,7 @@ The layout of the files is as follows: * [defs.json](defs.json) - definitions for general types * [defs-linux.json](defs-linux.json) - definitions for Linux-specific types * [defs-windows.json](defs-windows.json) - definitions for Windows-specific types -* [validate.go](validate.go) - validation utility source code +* [validate](validate) - validation utility source code directory ## Utility @@ -22,13 +22,6 @@ The layout of the files is as follows: There is also included a simple utility for facilitating validation. To build it: -```bash -go get github.com/xeipuuv/gojsonschema -go build ./validate.go -``` - -Or you can just use make command to create the utility: - ```bash make validate ``` @@ -36,11 +29,11 @@ make validate Then use it like: ```bash -./validate config-schema.json /config.json +./validate/validate config-schema.json /config.json ``` Or like: ```bash -./validate https://raw.githubusercontent.com/opencontainers/runtime-spec//schema/config-schema.json /config.json +./validate/validate https://raw.githubusercontent.com/opencontainers/runtime-spec//schema/config-schema.json /config.json ``` diff --git a/schema/validate/go.mod b/schema/validate/go.mod new file mode 100644 index 000000000..539e5f0f5 --- /dev/null +++ b/schema/validate/go.mod @@ -0,0 +1,10 @@ +module github.com/opencontainers/runtime-spec/schema/validate + +go 1.21.6 + +require github.com/xeipuuv/gojsonschema v1.2.0 + +require ( + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect +) diff --git a/schema/validate/go.sum b/schema/validate/go.sum new file mode 100644 index 000000000..ebda4aba2 --- /dev/null +++ b/schema/validate/go.sum @@ -0,0 +1,13 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= diff --git a/schema/validate.go b/schema/validate/validate.go similarity index 100% rename from schema/validate.go rename to schema/validate/validate.go