-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Json schema for image manifest and manifest list #18
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
default: help | ||
|
||
help: | ||
@echo "Usage: make <target>" | ||
@echo | ||
@echo " * 'fmt' - format the json with indentation" | ||
@echo " * 'validate' - build the validation tool" | ||
|
||
fmt: | ||
for i in *.json ; do jq --indent 2 -M . "$${i}" > xx && cat xx > "$${i}" && rm xx ; done | ||
|
||
validate: validate.go | ||
go build ./validate.go | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
"description": "Definitions particular to OpenContainer Image Specification", | ||
"definitions": { | ||
"mediaType": { | ||
"id": "https://opencontainers.org/schema/image/mediaType", | ||
"type": "string", | ||
"pattern": "^[a-z]+/[0-9a-zA-Z.+]+$" | ||
}, | ||
"digest": { | ||
"description": "the cryptographic checksum digest of the object, in the pattern '<hash>:<hexadecimal digest>'", | ||
"type": "string", | ||
"pattern": "^[a-z0-9]+:[a-fA-F0-9]+$" | ||
}, | ||
"blobObject": { | ||
"id": "https://opencontainers.org/schema/image/blobObject", | ||
"type": "object", | ||
"required": [ | ||
"mediaType", | ||
"size", | ||
"digest" | ||
], | ||
"properties": { | ||
"mediaType": { | ||
"description": "the mediatype of the referenced object", | ||
"$ref": "#definitions/mediaType" | ||
}, | ||
"size": { | ||
"description": "the size in bytes of the referenced object", | ||
"type": "integer" | ||
}, | ||
"digest": { | ||
"$ref": "#definitions/digest" | ||
} | ||
} | ||
}, | ||
"manifestObject": { | ||
"id": "https://opencontainers.org/schema/image/manifestObject", | ||
"type": "object", | ||
"required": [ | ||
"mediaType", | ||
"size", | ||
"digest", | ||
"platform" | ||
], | ||
"properties": { | ||
"mediaType": { | ||
"description": "the mediatype of the referenced object", | ||
"$ref": "#definitions/mediaType" | ||
}, | ||
"size": { | ||
"description": "the size in bytes of the referenced object", | ||
"type": "integer" | ||
}, | ||
"digest": { | ||
"$ref": "#definitions/digest" | ||
}, | ||
"platform": { | ||
"id": "https://opencontainers.org/schema/image/platform", | ||
"type": "object", | ||
"required": [ | ||
"architecture", | ||
"os" | ||
], | ||
"properties": { | ||
"architecture": { | ||
"id": "https://opencontainers.org/schema/image/platform/architecture", | ||
"type": "string" | ||
}, | ||
"os": { | ||
"id": "https://opencontainers.org/schema/image/platform/os", | ||
"type": "string" | ||
}, | ||
"os.version": { | ||
"id": "https://opencontainers.org/schema/image/platform/os.version", | ||
"type": "string" | ||
}, | ||
"os.features": { | ||
"id": "https://opencontainers.org/schema/image/platform/os.features", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"variant": { | ||
"type": "string" | ||
}, | ||
"features": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"additionalProperties": false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
{ | ||
"description": "Definitions used throughout the OpenContainer Specification", | ||
"definitions": { | ||
"int8": { | ||
"type": "integer", | ||
"minimum": -128, | ||
"maximum": 127 | ||
}, | ||
"int16": { | ||
"type": "integer", | ||
"minimum": -32768, | ||
"maximum": 32767 | ||
}, | ||
"int32": { | ||
"type": "integer", | ||
"minimum": -2147483648, | ||
"maximum": 2147483647 | ||
}, | ||
"int64": { | ||
"type": "integer", | ||
"minimum": -9223372036854776000, | ||
"maximum": 9223372036854776000 | ||
}, | ||
"uint8": { | ||
"type": "integer", | ||
"minimum": 0, | ||
"maximum": 255 | ||
}, | ||
"uint16": { | ||
"type": "integer", | ||
"minimum": 0, | ||
"maximum": 65535 | ||
}, | ||
"uint32": { | ||
"type": "integer", | ||
"minimum": 0, | ||
"maximum": 4294967295 | ||
}, | ||
"uint64": { | ||
"type": "integer", | ||
"minimum": 0, | ||
"maximum": 18446744073709552000 | ||
}, | ||
"uint16Pointer": { | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/definitions/uint16" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
}, | ||
"uint64Pointer": { | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/definitions/uint64" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
}, | ||
"stringPointer": { | ||
"oneOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
}, | ||
"mapStringString": { | ||
"type": "object", | ||
"patternProperties": { | ||
".{1,}": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"UID": { | ||
"$ref": "#/definitions/uint32" | ||
}, | ||
"GID": { | ||
"$ref": "#/definitions/uint32" | ||
}, | ||
"ArrayOfGIDs": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/GID" | ||
} | ||
}, | ||
"ArrayOfStrings": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"FilePath": { | ||
"type": "string" | ||
}, | ||
"Env": { | ||
"$ref": "#/definitions/ArrayOfStrings" | ||
}, | ||
"Hook": { | ||
"properties": { | ||
"path": { | ||
"$ref": "#/definitions/FilePath" | ||
}, | ||
"args": { | ||
"$ref": "#/definitions/ArrayOfStrings" | ||
}, | ||
"env": { | ||
"$ref": "#/definitions/Env" | ||
} | ||
} | ||
}, | ||
"ArrayOfHooks": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Hook" | ||
} | ||
}, | ||
"IDMapping": { | ||
"properties": { | ||
"hostID": { | ||
"$ref": "#/definitions/uint32" | ||
}, | ||
"containerID": { | ||
"$ref": "#/definitions/uint32" | ||
}, | ||
"size": { | ||
"$ref": "#/definitions/uint32" | ||
} | ||
} | ||
}, | ||
"Mount": { | ||
"properties": { | ||
"source": { | ||
"$ref": "#/definitions/FilePath" | ||
}, | ||
"destination": { | ||
"$ref": "#/definitions/FilePath" | ||
}, | ||
"options": { | ||
"$ref": "#/definitions/ArrayOfStrings" | ||
}, | ||
"type": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"destination", | ||
"source", | ||
"type" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"description": "OpenContainer Image Manifest Specification", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"id": "https://opencontainers.org/schema/image/manifest", | ||
"type": "object", | ||
"properties": { | ||
"schemaVersion": { | ||
"description": "This field specifies the image manifest schema version as an integer", | ||
"id": "https://opencontainers.org/schema/image/manifest/schemaVersion", | ||
"type": "integer" | ||
}, | ||
"mediaType": { | ||
"id": "https://opencontainers.org/schema/image/manifest/mediaType", | ||
"$ref": "defs-image.json#/definitions/mediaType" | ||
}, | ||
"config": { | ||
"$ref": "defs-image.json#/definitions/blobObject" | ||
}, | ||
"layers": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "defs-image.json#/definitions/blobObject" | ||
} | ||
}, | ||
"annotations": { | ||
"id": "https://opencontainers.org/schema/image/manifest/annotations", | ||
"oneOf": [ | ||
{ | ||
"$ref": "defs.json#/definitions/mapStringString" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"schemaVersion", | ||
"mediaType", | ||
"config", | ||
"layers" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/xeipuuv/gojsonschema" | ||
) | ||
|
||
func main() { | ||
if len(os.Args[1:]) != 2 { | ||
fmt.Printf("ERROR: usage is: %s <schema.json> <config.json>", os.Args[0]) | ||
os.Exit(1) | ||
} | ||
|
||
schemaPath, err := filepath.Abs(os.Args[1]) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
documentPath, err := filepath.Abs(os.Args[2]) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
schemaLoader := gojsonschema.NewReferenceLoader("file://" + schemaPath) | ||
documentLoader := gojsonschema.NewReferenceLoader("file://" + documentPath) | ||
|
||
result, err := gojsonschema.Validate(schemaLoader, documentLoader) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
|
||
if result.Valid() { | ||
fmt.Printf("The document is valid\n") | ||
} else { | ||
fmt.Printf("The document is not valid. see errors :\n") | ||
for _, desc := range result.Errors() { | ||
fmt.Printf("- %s\n", desc) | ||
} | ||
os.Exit(1) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually called a "Descriptor".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is that defined?
On Fri, Apr 15, 2016 at 1:07 PM Stephen Day notifications@github.com
wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what we have called it from the start. The godoc is here. I am not sure how it never made into this specification.
Other types with further fields, such as the manifest descriptor, are extensions to the descriptor type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah fine. A name of a struct. Feel free to open a PR to include this in the
spec. I can update it here.
On Fri, Apr 15, 2016 at 1:27 PM Stephen Day notifications@github.com
wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I'll do that. Just reviewing old notifications.