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
6 changes: 6 additions & 0 deletions schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ Then use it like:
```bash
./validate schema.json <yourpath>/config.json
```

Or like:

```bash
./validate https://raw.githubusercontent.com/opencontainers/runtime-spec/v1.0.0-rc1/schema/schema.json <yourpath>/config.json
```
16 changes: 11 additions & 5 deletions schema/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/xeipuuv/gojsonschema"
)
Expand All @@ -16,12 +17,17 @@ func main() {
os.Exit(1)
}

schemaPath, err := filepath.Abs(os.Args[1])
if err != nil {
fmt.Println(err)
os.Exit(1)
schemaPath := os.Args[1]
if !strings.Contains(schemaPath, "://") {
schemaPath, err := filepath.Abs(schemaPath)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
schemaPath = "file://" + schemaPath
}
schemaLoader := gojsonschema.NewReferenceLoader("file://" + schemaPath)
schemaLoader := gojsonschema.NewReferenceLoader(schemaPath)

var documentLoader gojsonschema.JSONLoader

if nargs > 1 {
Expand Down