Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: create go.mod
run: |
# Fix for "cannot find main module" issue
go mod init github.com/opencontainers/runtime-spec

go get -d ./schema/...

- name: run golangci-lint
uses: golangci/golangci-lint-action@v8
- name: install golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.14
install-only: true

- name: run golangci-lint
run: |
golangci-lint run
cd schema/validate && golangci-lint run --path-prefix schema/validate

- name: run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
output
schema/validate
schema/validate/validate
version.md
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/opencontainers/runtime-spec

go 1.21
13 changes: 7 additions & 6 deletions schema/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
GOOD_TESTS = $(wildcard test/good/*.json)
BAD_TESTS = $(wildcard test/bad/*.json)
VALIDATE = validate/validate

default: validate

Expand All @@ -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); \
Expand All @@ -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 \
Expand All @@ -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; \
Expand All @@ -46,5 +46,6 @@ test: validate $(TESTS)
done; \
done

.PHONY: clean
clean:
rm -f validate
rm -f validate/validate
13 changes: 3 additions & 10 deletions schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,26 @@ 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

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
```

Then use it like:

```bash
./validate config-schema.json <yourpath>/config.json
./validate/validate config-schema.json <yourpath>/config.json
```

Or like:

```bash
./validate https://raw.githubusercontent.com/opencontainers/runtime-spec/<runtime-spec-version>/schema/config-schema.json <yourpath>/config.json
./validate/validate https://raw.githubusercontent.com/opencontainers/runtime-spec/<runtime-spec-version>/schema/config-schema.json <yourpath>/config.json
```
10 changes: 10 additions & 0 deletions schema/validate/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/opencontainers/runtime-spec/schema/validate

go 1.21

require github.com/xeipuuv/gojsonschema v1.2.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look if we can rewrite this to github.com/santhosh-tekuri/jsonschema/v6. This module is no longer maintained (I can have a look if it's an easy rewrite)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


require (
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
)
13 changes: 13 additions & 0 deletions schema/validate/go.sum
Original file line number Diff line number Diff line change
@@ -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=
File renamed without changes.
Loading