update vendor

Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
Jess Frazelle 2018-03-19 21:36:34 -04:00
parent 7a437ada25
commit 639756e8c6
4300 changed files with 824810 additions and 9292 deletions

View file

@ -0,0 +1,50 @@
GOOD_TESTS = $(wildcard test/good/*.json)
BAD_TESTS = $(wildcard test/bad/*.json)
default: validate
help:
@echo "Usage: make [target]"
@echo
@echo " * 'fmt' - format the json with indentation"
@echo " * 'help' - show this help information"
@echo " * 'validate' - build the validation tool"
fmt:
find . -name '*.json' -exec bash -c 'jq --indent 4 -M . {} > xx && mv xx {} || echo "skipping invalid {}"' \;
.PHONY: validate
validate: validate.go
go get -d ./...
go build ./validate.go
test: validate $(TESTS)
for TYPE in $$(ls test); \
do \
echo "testing $${TYPE}"; \
for FILE in $$(ls "test/$${TYPE}/good"); \
do \
echo " testing test/$${TYPE}/good/$${FILE}"; \
if ./validate "$${TYPE}-schema.json" "test/$${TYPE}/good/$${FILE}" ; \
then \
echo " received expected validation success" ; \
else \
echo " received unexpected validation failure" ; \
exit 1; \
fi \
done; \
for FILE in $$(ls "test/$${TYPE}/bad"); \
do \
echo " testing test/$${TYPE}/bad/$${FILE}"; \
if ./validate "$${TYPE}-schema.json" "test/$${TYPE}/good/$${FILE}" ; \
then \
echo " received unexpected validation success" ; \
exit 1; \
else \
echo " received expected validation failure" ; \
fi \
done; \
done
clean:
rm -f validate

View file

@ -0,0 +1,47 @@
# JSON schema
## Overview
This directory contains the [JSON Schema](http://json-schema.org/) for validating JSON covered by this specification.
The layout of the files is as follows:
* [config-schema.json](config-schema.json) - the primary entrypoint for the [configuration](../config.md) schema
* [config-linux.json](config-linux.json) - the [Linux-specific configuration sub-structure](../config-linux.md)
* [config-solaris.json](config-solaris.json) - the [Solaris-specific configuration sub-structure](../config-solaris.md)
* [config-windows.json](config-windows.json) - the [Windows-specific configuration sub-structure](../config-windows.md)
* [state-schema.json](state-schema.json) - the primary entrypoint for the [state JSON](../runtime.md#state) schema
* [defs.json](defs.json) - definitions for general types
* [defs-linux.json](defs-linux.json) - definitions for Linux-specific types
* [validate.go](validate.go) - validation utility source code
## Utility
There is also included a simple utility for facilitating validation.
To build it:
```bash
export GOPATH=`mktemp -d`
go get -d ./...
go build ./validate.go
rm -rf $GOPATH
```
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
```
Or like:
```bash
./validate https://raw.githubusercontent.com/opencontainers/runtime-spec/v1.0.0/schema/schema.json <yourpath>/config.json
```

View file

@ -0,0 +1,281 @@
{
"linux": {
"description": "Linux platform-specific configurations",
"id": "https://opencontainers.org/schema/bundle/linux",
"type": "object",
"properties": {
"devices": {
"id": "https://opencontainers.org/schema/bundle/linux/devices",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/Device"
}
},
"uidMappings": {
"id": "https://opencontainers.org/schema/bundle/linux/uidMappings",
"type": "array",
"items": {
"$ref": "defs.json#/definitions/IDMapping"
}
},
"gidMappings": {
"id": "https://opencontainers.org/schema/bundle/linux/gidMappings",
"type": "array",
"items": {
"$ref": "defs.json#/definitions/IDMapping"
}
},
"namespaces": {
"id": "https://opencontainers.org/schema/bundle/linux/namespaces",
"type": "array",
"items": {
"anyOf": [
{
"$ref": "defs-linux.json#/definitions/NamespaceReference"
}
]
}
},
"resources": {
"id": "https://opencontainers.org/schema/bundle/linux/resources",
"type": "object",
"properties": {
"devices": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/devices",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/DeviceCgroup"
}
},
"pids": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/pids",
"type": "object",
"properties": {
"limit": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/pids/limit",
"$ref": "defs.json#/definitions/int64"
}
},
"required": [
"limit"
]
},
"blockIO": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO",
"type": "object",
"properties": {
"weight": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/weight",
"$ref": "defs-linux.json#/definitions/weight"
},
"leafWeight": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/leafWeight",
"$ref": "defs-linux.json#/definitions/weight"
},
"throttleReadBpsDevice": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/throttleReadBpsDevice",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottle"
}
},
"throttleWriteBpsDevice": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/throttleWriteBpsDevice",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottle"
}
},
"throttleReadIOPSDevice": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/throttleReadIOPSDevice",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottle"
}
},
"throttleWriteIOPSDevice": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/throttleWriteIOPSDevice",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/blockIODeviceThrottle"
}
},
"weightDevice": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO/weightDevice",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/blockIODeviceWeight"
}
}
}
},
"cpu": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu",
"type": "object",
"properties": {
"cpus": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/cpus",
"type": "string"
},
"mems": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/mems",
"type": "string"
},
"period": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/period",
"$ref": "defs.json#/definitions/uint64"
},
"quota": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/quota",
"$ref": "defs.json#/definitions/int64"
},
"realtimePeriod": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/realtimePeriod",
"$ref": "defs.json#/definitions/uint64"
},
"realtimeRuntime": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/realtimeRuntime",
"$ref": "defs.json#/definitions/int64"
},
"shares": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/cpu/shares",
"$ref": "defs.json#/definitions/uint64"
}
}
},
"hugepageLimits": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/hugepageLimits",
"type": "array",
"items": {
"type": "object",
"properties": {
"pageSize": {
"type": "string"
},
"limit": {
"$ref": "defs.json#/definitions/uint64"
}
},
"required": [
"pageSize",
"limit"
]
}
},
"memory": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory",
"type": "object",
"properties": {
"kernel": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/kernel",
"$ref": "defs.json#/definitions/int64"
},
"kernelTCP": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/kernelTCP",
"$ref": "defs.json#/definitions/int64"
},
"limit": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/limit",
"$ref": "defs.json#/definitions/int64"
},
"reservation": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/reservation",
"$ref": "defs.json#/definitions/int64"
},
"swap": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/swap",
"$ref": "defs.json#/definitions/int64"
},
"swappiness": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/swappiness",
"$ref": "defs.json#/definitions/uint64"
},
"disableOOMKiller": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/disableOOMKiller",
"type": "boolean"
}
}
},
"network": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/network",
"type": "object",
"properties": {
"classID": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/network/classId",
"$ref": "defs.json#/definitions/uint32"
},
"priorities": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/network/priorities",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/NetworkInterfacePriority"
}
}
}
}
}
},
"cgroupsPath": {
"id": "https://opencontainers.org/schema/bundle/linux/cgroupsPath",
"type": "string"
},
"rootfsPropagation": {
"id": "https://opencontainers.org/schema/bundle/linux/rootfsPropagation",
"$ref": "defs-linux.json#/definitions/RootfsPropagation"
},
"seccomp": {
"id": "https://opencontainers.org/schema/bundle/linux/seccomp",
"type": "object",
"properties": {
"defaultAction": {
"id": "https://opencontainers.org/schema/bundle/linux/seccomp/defaultAction",
"type": "string"
},
"architectures": {
"id": "https://opencontainers.org/schema/bundle/linux/seccomp/architectures",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/SeccompArch"
}
},
"syscalls": {
"id": "https://opencontainers.org/schema/bundle/linux/seccomp/syscalls",
"type": "array",
"items": {
"$ref": "defs-linux.json#/definitions/Syscall"
}
}
},
"required": [
"defaultAction"
]
},
"sysctl": {
"id": "https://opencontainers.org/schema/bundle/linux/sysctl",
"$ref": "defs.json#/definitions/mapStringString"
},
"maskedPaths": {
"id": "https://opencontainers.org/schema/bundle/linux/maskedPaths",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"readonlyPaths": {
"id": "https://opencontainers.org/schema/bundle/linux/readonlyPaths",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"mountLabel": {
"id": "https://opencontainers.org/schema/bundle/linux/mountLabel",
"type": "string"
},
"intelRdt": {
"id": "https://opencontainers.org/schema/bundle/linux/intelRdt",
"type": "object",
"properties": {
"l3CacheSchema": {
"id": "https://opencontainers.org/schema/bundle/linux/intelRdt/l3CacheSchema",
"type": "string"
}
}
}
}
}
}

View file

@ -0,0 +1,207 @@
{
"description": "Open Container Initiative Runtime Specification Container Configuration Schema",
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://opencontainers.org/schema/bundle",
"type": "object",
"properties": {
"ociVersion": {
"id": "https://opencontainers.org/schema/bundle/ociVersion",
"$ref": "defs.json#/definitions/ociVersion"
},
"hooks": {
"id": "https://opencontainers.org/schema/bundle/hooks",
"type": "object",
"properties": {
"prestart": {
"$ref": "defs.json#/definitions/ArrayOfHooks"
},
"poststart": {
"$ref": "defs.json#/definitions/ArrayOfHooks"
},
"poststop": {
"$ref": "defs.json#/definitions/ArrayOfHooks"
}
}
},
"annotations": {
"$ref": "defs.json#/definitions/annotations"
},
"hostname": {
"id": "https://opencontainers.org/schema/bundle/hostname",
"type": "string"
},
"mounts": {
"id": "https://opencontainers.org/schema/bundle/mounts",
"type": "array",
"items": {
"$ref": "defs.json#/definitions/Mount"
}
},
"root": {
"description": "Configures the container's root filesystem.",
"id": "https://opencontainers.org/schema/bundle/root",
"type": "object",
"required": [
"path"
],
"properties": {
"path": {
"id": "https://opencontainers.org/schema/bundle/root/path",
"$ref": "defs.json#/definitions/FilePath"
},
"readonly": {
"id": "https://opencontainers.org/schema/bundle/root/readonly",
"type": "boolean"
}
}
},
"process": {
"id": "https://opencontainers.org/schema/bundle/process",
"type": "object",
"required": [
"cwd",
"args"
],
"properties": {
"args": {
"id": "https://opencontainers.org/schema/bundle/process/args",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"consoleSize": {
"id": "https://opencontainers.org/schema/bundle/process/consoleSize",
"type": "object",
"required": [
"height",
"width"
],
"properties": {
"height": {
"id": "https://opencontainers.org/schema/bundle/process/consoleSize/height",
"$ref": "defs.json#/definitions/uint64"
},
"width": {
"id": "https://opencontainers.org/schema/bundle/process/consoleSize/width",
"$ref": "defs.json#/definitions/uint64"
}
}
},
"cwd": {
"id": "https://opencontainers.org/schema/bundle/process/cwd",
"type": "string"
},
"env": {
"id": "https://opencontainers.org/schema/bundle/process/env",
"$ref": "defs.json#/definitions/Env"
},
"terminal": {
"id": "https://opencontainers.org/schema/bundle/process/terminal",
"type": "boolean"
},
"user": {
"id": "https://opencontainers.org/schema/bundle/process/user",
"type": "object",
"properties": {
"uid": {
"id": "https://opencontainers.org/schema/bundle/process/user/uid",
"$ref": "defs.json#/definitions/UID"
},
"gid": {
"id": "https://opencontainers.org/schema/bundle/process/user/gid",
"$ref": "defs.json#/definitions/GID"
},
"additionalGids": {
"id": "https://opencontainers.org/schema/bundle/process/user/additionalGids",
"$ref": "defs.json#/definitions/ArrayOfGIDs"
},
"username": {
"id": "https://opencontainers.org/schema/bundle/process/user/username",
"type": "string"
}
}
},
"capabilities": {
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities",
"type": "object",
"properties": {
"bounding": {
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/bounding",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"permitted": {
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/permitted",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"effective": {
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/effective",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"inheritable": {
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/inheritable",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"ambient": {
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/ambient",
"$ref": "defs.json#/definitions/ArrayOfStrings"
}
}
},
"apparmorProfile": {
"id": "https://opencontainers.org/schema/bundle/process/linux/apparmorProfile",
"type": "string"
},
"oomScoreAdj": {
"id": "https://opencontainers.org/schema/bundle/process/linux/oomScoreAdj",
"type": "integer"
},
"selinuxLabel": {
"id": "https://opencontainers.org/schema/bundle/process/linux/selinuxLabel",
"type": "string"
},
"noNewPrivileges": {
"id": "https://opencontainers.org/schema/bundle/process/linux/noNewPrivileges",
"type": "boolean"
},
"rlimits": {
"id": "https://opencontainers.org/schema/bundle/linux/rlimits",
"type": "array",
"items": {
"id": "https://opencontainers.org/schema/bundle/linux/rlimits/0",
"type": "object",
"required": [
"type",
"soft",
"hard"
],
"properties": {
"hard": {
"id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/hard",
"$ref": "defs.json#/definitions/uint64"
},
"soft": {
"id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/soft",
"$ref": "defs.json#/definitions/uint64"
},
"type": {
"id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/type",
"type": "string",
"pattern": "^RLIMIT_[A-Z]+$"
}
}
}
}
}
},
"linux": {
"$ref": "config-linux.json#/linux"
},
"solaris": {
"$ref": "config-solaris.json#/solaris"
},
"windows": {
"$ref": "config-windows.json#/windows"
}
},
"required": [
"ociVersion"
]
}

View file

@ -0,0 +1,75 @@
{
"solaris": {
"description": "Solaris platform-specific configurations",
"id": "https://opencontainers.org/schema/bundle/solaris",
"type": "object",
"properties": {
"milestone": {
"id": "https://opencontainers.org/schema/bundle/solaris/milestone",
"type": "string"
},
"limitpriv": {
"id": "https://opencontainers.org/schema/bundle/solaris/limitpriv",
"type": "string"
},
"maxShmMemory": {
"id": "https://opencontainers.org/schema/bundle/solaris/maxShmMemory",
"type": "string"
},
"cappedCPU": {
"id": "https://opencontainers.org/schema/bundle/solaris/cappedCPU",
"type": "object",
"properties": {
"ncpus": {
"id": "https://opencontainers.org/schema/bundle/solaris/cappedCPU/ncpus",
"type": "string"
}
}
},
"cappedMemory": {
"id": "https://opencontainers.org/schema/bundle/solaris/cappedMemory",
"type": "object",
"properties": {
"physical": {
"id": "https://opencontainers.org/schema/bundle/solaris/cappedMemory/physical",
"type": "string"
},
"swap": {
"id": "https://opencontainers.org/schema/bundle/solaris/cappedMemory/swap",
"type": "string"
}
}
},
"anet": {
"id": "https://opencontainers.org/schema/bundle/solaris/anet",
"type": "array",
"items": {
"type": "object",
"properties": {
"linkname": {
"type": "string"
},
"lowerLink": {
"type": "string"
},
"allowedAddress": {
"type": "string"
},
"configureAllowedAddress": {
"type": "string"
},
"defrouter": {
"type": "string"
},
"macAddress": {
"type": "string"
},
"linkProtection": {
"type": "string"
}
}
}
}
}
}
}

View file

@ -0,0 +1,116 @@
{
"windows": {
"description": "Windows platform-specific configurations",
"id": "https://opencontainers.org/schema/bundle/windows",
"type": "object",
"properties": {
"layerFolders": {
"id": "https://opencontainers.org/schema/bundle/windows/layerFolders",
"type": "array",
"items": {
"$ref": "defs.json#/definitions/FilePath"
},
"minItems": 1
},
"resources": {
"id": "https://opencontainers.org/schema/bundle/windows/resources",
"type": "object",
"properties": {
"memory": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/memory",
"type": "object",
"properties": {
"limit": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/memory/limit",
"$ref": "defs.json#/definitions/uint64"
}
}
},
"cpu": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu",
"type": "object",
"properties": {
"count": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/count",
"$ref": "defs.json#/definitions/uint64"
},
"shares": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/shares",
"$ref": "defs.json#/definitions/uint16"
},
"maximum": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/maximum",
"$ref": "defs.json#/definitions/uint16"
}
}
},
"storage": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage",
"type": "object",
"properties": {
"iops": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/iops",
"$ref": "defs.json#/definitions/uint64"
},
"bps": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/bps",
"$ref": "defs.json#/definitions/uint64"
},
"sandboxSize": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/sandboxSize",
"$ref": "defs.json#/definitions/uint64"
}
}
}
}
},
"network": {
"id": "https://opencontainers.org/schema/bundle/windows/network",
"type": "object",
"properties": {
"endpointList": {
"id": "https://opencontainers.org/schema/bundle/windows/network/endpointList",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"allowUnqualifiedDNSQuery": {
"id": "https://opencontainers.org/schema/bundle/windows/network/allowUnqualifiedDNSQuery",
"type": "boolean"
},
"DNSSearchList": {
"id": "https://opencontainers.org/schema/bundle/windows/network/DNSSearchList",
"$ref": "defs.json#/definitions/ArrayOfStrings"
},
"networkSharedContainerName": {
"id": "https://opencontainers.org/schema/bundle/windows/network/networkSharedContainerName",
"type": "string"
}
}
},
"credentialSpec": {
"id": "https://opencontainers.org/schema/bundle/windows/credentialSpec",
"type": "object"
},
"servicing": {
"id": "https://opencontainers.org/schema/bundle/windows/servicing",
"type": "boolean"
},
"ignoreFlushesDuringBoot": {
"id": "https://opencontainers.org/schema/bundle/windows/ignoreFlushesDuringBoot",
"type": "boolean"
},
"hyperv": {
"id": "https://opencontainers.org/schema/bundle/windows/hyperv",
"type": "object",
"properties": {
"utilityVMPath": {
"id": "https://opencontainers.org/schema/bundle/windows/hyperv/utilityVMPath",
"type": "string"
}
}
}
},
"required": [
"layerFolders"
]
}
}

View file

@ -0,0 +1,270 @@
{
"definitions": {
"RootfsPropagation": {
"type": "string",
"enum": [
"private",
"shared",
"slave",
"unbindable"
]
},
"SeccompArch": {
"type": "string",
"enum": [
"SCMP_ARCH_X86",
"SCMP_ARCH_X86_64",
"SCMP_ARCH_X32",
"SCMP_ARCH_ARM",
"SCMP_ARCH_AARCH64",
"SCMP_ARCH_MIPS",
"SCMP_ARCH_MIPS64",
"SCMP_ARCH_MIPS64N32",
"SCMP_ARCH_MIPSEL",
"SCMP_ARCH_MIPSEL64",
"SCMP_ARCH_MIPSEL64N32",
"SCMP_ARCH_PPC",
"SCMP_ARCH_PPC64",
"SCMP_ARCH_PPC64LE",
"SCMP_ARCH_S390",
"SCMP_ARCH_S390X",
"SCMP_ARCH_PARISC",
"SCMP_ARCH_PARISC64"
]
},
"SeccompAction": {
"type": "string",
"enum": [
"SCMP_ACT_KILL",
"SCMP_ACT_TRAP",
"SCMP_ACT_ERRNO",
"SCMP_ACT_TRACE",
"SCMP_ACT_ALLOW"
]
},
"SeccompOperators": {
"type": "string",
"enum": [
"SCMP_CMP_NE",
"SCMP_CMP_LT",
"SCMP_CMP_LE",
"SCMP_CMP_EQ",
"SCMP_CMP_GE",
"SCMP_CMP_GT",
"SCMP_CMP_MASKED_EQ"
]
},
"SyscallArg": {
"type": "object",
"properties": {
"index": {
"$ref": "defs.json#/definitions/uint32"
},
"value": {
"$ref": "defs.json#/definitions/uint64"
},
"valueTwo": {
"$ref": "defs.json#/definitions/uint64"
},
"op": {
"$ref": "#/definitions/SeccompOperators"
}
},
"required": [
"index",
"value",
"op"
]
},
"Syscall": {
"type": "object",
"properties": {
"names": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
},
"action": {
"$ref": "#/definitions/SeccompAction"
},
"args": {
"type": "array",
"items": {
"$ref": "#/definitions/SyscallArg"
}
}
},
"required": [
"names",
"action"
]
},
"Major": {
"description": "major device number",
"$ref": "defs.json#/definitions/int64"
},
"Minor": {
"description": "minor device number",
"$ref": "defs.json#/definitions/int64"
},
"FileMode": {
"description": "File permissions mode (typically an octal value)",
"type": "integer",
"minimum": 0,
"maximum": 512
},
"FileType": {
"description": "Type of a block or special character device",
"type": "string",
"pattern": "^[cbup]$"
},
"Device": {
"type": "object",
"required": [
"type",
"path"
],
"properties": {
"type": {
"$ref": "#/definitions/FileType"
},
"path": {
"$ref": "defs.json#/definitions/FilePath"
},
"fileMode": {
"$ref": "#/definitions/FileMode"
},
"major": {
"$ref": "#/definitions/Major"
},
"minor": {
"$ref": "#/definitions/Minor"
},
"uid": {
"$ref": "defs.json#/definitions/UID"
},
"gid": {
"$ref": "defs.json#/definitions/GID"
}
}
},
"weight": {
"type": "integer"
},
"blockIODevice": {
"type": "object",
"properties": {
"major": {
"$ref": "#/definitions/Major"
},
"minor": {
"$ref": "#/definitions/Minor"
}
},
"required": [
"major",
"minor"
]
},
"blockIODeviceWeight": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/blockIODevice"
},
{
"type": "object",
"properties": {
"weight": {
"$ref": "#/definitions/weight"
},
"leafWeight": {
"$ref": "#/definitions/weight"
}
}
}
]
},
"blockIODeviceThrottle": {
"allOf": [
{
"$ref": "#/definitions/blockIODevice"
},
{
"type": "object",
"properties": {
"rate": {
"$ref": "defs.json#/definitions/uint64"
}
}
}
]
},
"DeviceCgroup": {
"type": "object",
"properties": {
"allow": {
"type": "boolean"
},
"type": {
"type": "string"
},
"major": {
"$ref": "#/definitions/Major"
},
"minor": {
"$ref": "#/definitions/Minor"
},
"access": {
"type": "string"
}
},
"required": [
"allow"
]
},
"NetworkInterfacePriority": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"priority": {
"$ref": "defs.json#/definitions/uint32"
}
},
"required": [
"name",
"priority"
]
},
"NamespaceType": {
"type": "string",
"enum": [
"mount",
"pid",
"network",
"uts",
"ipc",
"user",
"cgroup"
]
},
"NamespaceReference": {
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/NamespaceType"
},
"path": {
"$ref": "defs.json#/definitions/FilePath"
}
},
"required": [
"type"
]
}
}
}

View file

@ -0,0 +1,155 @@
{
"description": "Definitions used throughout the Open Container Initiative Runtime 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
},
"percent": {
"type": "integer",
"minimum": 0,
"maximum": 100
},
"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": {
"type": "object",
"properties": {
"path": {
"$ref": "#/definitions/FilePath"
},
"args": {
"$ref": "#/definitions/ArrayOfStrings"
},
"env": {
"$ref": "#/definitions/Env"
},
"timeout": {
"type": "integer",
"minimum": 1
}
},
"required": [
"path"
]
},
"ArrayOfHooks": {
"type": "array",
"items": {
"$ref": "#/definitions/Hook"
}
},
"IDMapping": {
"type": "object",
"properties": {
"hostID": {
"$ref": "#/definitions/uint32"
},
"containerID": {
"$ref": "#/definitions/uint32"
},
"size": {
"$ref": "#/definitions/uint32"
}
},
"required": [
"hostID",
"containerID",
"size"
]
},
"Mount": {
"type": "object",
"properties": {
"source": {
"$ref": "#/definitions/FilePath"
},
"destination": {
"$ref": "#/definitions/FilePath"
},
"options": {
"$ref": "#/definitions/ArrayOfStrings"
},
"type": {
"type": "string"
}
},
"required": [
"destination"
]
},
"ociVersion": {
"description": "The version of Open Container Initiative Runtime Specification that the document complies with",
"type": "string"
},
"annotations": {
"$ref": "#/definitions/mapStringString"
}
}
}

View file

@ -0,0 +1,45 @@
{
"description": "Open Container Runtime State Schema",
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://opencontainers.org/schema/state",
"type": "object",
"properties": {
"ociVersion": {
"id": "https://opencontainers.org/schema/runtime/state/ociVersion",
"$ref": "defs.json#/definitions/ociVersion"
},
"id": {
"id": "https://opencontainers.org/schema/runtime/state/id",
"description": "the container's ID",
"type": "string"
},
"status": {
"id": "https://opencontainers.org/schema/runtime/state/status",
"type": "string",
"enum": [
"creating",
"created",
"running",
"stopped"
]
},
"pid": {
"id": "https://opencontainers.org/schema/runtime/state/pid",
"type": "integer",
"minimum": 0
},
"bundle": {
"id": "https://opencontainers.org/schema/runtime/state/bundle",
"type": "string"
},
"annotations": {
"$ref": "defs.json#/definitions/annotations"
}
},
"required": [
"ociVersion",
"id",
"status",
"bundle"
]
}

View file

@ -0,0 +1 @@
{]

View file

@ -0,0 +1,16 @@
{
"ociVersion": "1.0.0",
"root": {
"path": "rootfs"
},
"process": {
"cwd": "/",
"args": [
"sh"
],
"user": {
"uid": 0,
"gid": 0
}
}
}

View file

@ -0,0 +1,6 @@
{
"ociVersion": "1.0.0",
"root": {
"path": "rootfs"
}
}

View file

@ -0,0 +1,368 @@
{
"ociVersion": "0.5.0-dev",
"process": {
"terminal": true,
"user": {
"uid": 1,
"gid": 1,
"additionalGids": [
5,
6
]
},
"args": [
"sh"
],
"env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm"
],
"cwd": "/",
"capabilities": {
"bounding": [
"CAP_AUDIT_WRITE",
"CAP_KILL",
"CAP_NET_BIND_SERVICE"
],
"permitted": [
"CAP_AUDIT_WRITE",
"CAP_KILL",
"CAP_NET_BIND_SERVICE"
],
"inheritable": [
"CAP_AUDIT_WRITE",
"CAP_KILL",
"CAP_NET_BIND_SERVICE"
],
"effective": [
"CAP_AUDIT_WRITE",
"CAP_KILL"
],
"ambient": [
"CAP_NET_BIND_SERVICE"
]
},
"rlimits": [
{
"type": "RLIMIT_CORE",
"hard": 1024,
"soft": 1024
},
{
"type": "RLIMIT_NOFILE",
"hard": 1024,
"soft": 1024
}
],
"apparmorProfile": "acme_secure_profile",
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
"noNewPrivileges": true
},
"root": {
"path": "rootfs",
"readonly": true
},
"hostname": "slartibartfast",
"mounts": [
{
"destination": "/proc",
"type": "proc",
"source": "proc"
},
{
"destination": "/dev",
"type": "tmpfs",
"source": "tmpfs",
"options": [
"nosuid",
"strictatime",
"mode=755",
"size=65536k"
]
},
{
"destination": "/dev/pts",
"type": "devpts",
"source": "devpts",
"options": [
"nosuid",
"noexec",
"newinstance",
"ptmxmode=0666",
"mode=0620",
"gid=5"
]
},
{
"destination": "/dev/shm",
"type": "tmpfs",
"source": "shm",
"options": [
"nosuid",
"noexec",
"nodev",
"mode=1777",
"size=65536k"
]
},
{
"destination": "/dev/mqueue",
"type": "mqueue",
"source": "mqueue",
"options": [
"nosuid",
"noexec",
"nodev"
]
},
{
"destination": "/sys",
"type": "sysfs",
"source": "sysfs",
"options": [
"nosuid",
"noexec",
"nodev"
]
},
{
"destination": "/sys/fs/cgroup",
"type": "cgroup",
"source": "cgroup",
"options": [
"nosuid",
"noexec",
"nodev",
"relatime",
"ro"
]
}
],
"hooks": {
"prestart": [
{
"path": "/usr/bin/fix-mounts",
"args": [
"fix-mounts",
"arg1",
"arg2"
],
"env": [
"key1=value1"
]
},
{
"path": "/usr/bin/setup-network"
}
],
"poststart": [
{
"path": "/usr/bin/notify-start",
"timeout": 5
}
],
"poststop": [
{
"path": "/usr/sbin/cleanup.sh",
"args": [
"cleanup.sh",
"-f"
]
}
]
},
"linux": {
"devices": [
{
"path": "/dev/fuse",
"type": "c",
"major": 10,
"minor": 229,
"fileMode": 438,
"uid": 0,
"gid": 0
},
{
"path": "/dev/sda",
"type": "b",
"major": 8,
"minor": 0,
"fileMode": 432,
"uid": 0,
"gid": 0
}
],
"uidMappings": [
{
"hostID": 1000,
"containerID": 0,
"size": 32000
}
],
"gidMappings": [
{
"hostID": 1000,
"containerID": 0,
"size": 32000
}
],
"sysctl": {
"net.ipv4.ip_forward": "1",
"net.core.somaxconn": "256"
},
"cgroupsPath": "/myRuntime/myContainer",
"resources": {
"network": {
"classID": 1048577,
"priorities": [
{
"name": "eth0",
"priority": 500
},
{
"name": "eth1",
"priority": 1000
}
]
},
"pids": {
"limit": 32771
},
"hugepageLimits": [
{
"pageSize": "2MB",
"limit": 9223372036854772000
}
],
"oomScoreAdj": 100,
"memory": {
"limit": 536870912,
"reservation": 536870912,
"swap": 536870912,
"kernel": -1,
"kernelTCP": -1,
"swappiness": 0,
"disableOOMKiller": false
},
"cpu": {
"shares": 1024,
"quota": 1000000,
"period": 500000,
"realtimeRuntime": 950000,
"realtimePeriod": 1000000,
"cpus": "2-3",
"mems": "0-7"
},
"devices": [
{
"allow": false,
"access": "rwm"
},
{
"allow": true,
"type": "c",
"major": 10,
"minor": 229,
"access": "rw"
},
{
"allow": true,
"type": "b",
"major": 8,
"minor": 0,
"access": "r"
}
],
"blockIO": {
"weight": 10,
"leafWeight": 10,
"weightDevice": [
{
"major": 8,
"minor": 0,
"weight": 500,
"leafWeight": 300
},
{
"major": 8,
"minor": 16,
"weight": 500
}
],
"throttleReadBpsDevice": [
{
"major": 8,
"minor": 0,
"rate": 600
}
],
"throttleWriteIOPSDevice": [
{
"major": 8,
"minor": 16,
"rate": 300
}
]
}
},
"rootfsPropagation": "slave",
"seccomp": {
"defaultAction": "SCMP_ACT_ALLOW",
"architectures": [
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
],
"syscalls": [
{
"names": [
"getcwd",
"chmod"
],
"action": "SCMP_ACT_ERRNO"
}
]
},
"namespaces": [
{
"type": "pid"
},
{
"type": "network"
},
{
"type": "ipc"
},
{
"type": "uts"
},
{
"type": "mount"
},
{
"type": "user"
},
{
"type": "cgroup"
}
],
"maskedPaths": [
"/proc/kcore",
"/proc/latency_stats",
"/proc/timer_stats",
"/proc/sched_debug"
],
"readonlyPaths": [
"/proc/asound",
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
],
"mountLabel": "system_u:object_r:svirt_sandbox_file_t:s0:c715,c811"
},
"annotations": {
"com.example.key1": "value1",
"com.example.key2": "value2"
}
}

View file

@ -0,0 +1 @@
{]

View file

@ -0,0 +1,10 @@
{
"ociVersion": "0.2.0",
"id": "oci-container1",
"status": "running",
"pid": 4422,
"bundle": "/containers/redis",
"annotations": {
"myKey": "myValue"
}
}

View file

@ -0,0 +1,100 @@
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/xeipuuv/gojsonschema"
)
const usage = `Validate is used to check document with specified schema.
You can use validate in following ways:
1.specify document file as an argument
validate <schema.json> <document.json>
2.pass document content through a pipe
cat <document.json> | validate <schema.json>
3.input document content manually, ended with ctrl+d(or your self-defined EOF keys)
validate <schema.json>
[INPUT DOCUMENT CONTENT HERE]
`
func main() {
nargs := len(os.Args[1:])
if nargs == 0 || nargs > 2 {
fmt.Printf("ERROR: invalid arguments number\n\n%s\n", usage)
os.Exit(1)
}
if os.Args[1] == "help" ||
os.Args[1] == "--help" ||
os.Args[1] == "-h" {
fmt.Printf("%s\n", usage)
os.Exit(1)
}
schemaPath := os.Args[1]
if !strings.Contains(schemaPath, "://") {
var err error
schemaPath, err = formatFilePath(schemaPath)
if err != nil {
fmt.Printf("ERROR: invalid schema-file path: %s\n", err)
os.Exit(1)
}
schemaPath = "file://" + schemaPath
}
schemaLoader := gojsonschema.NewReferenceLoader(schemaPath)
var documentLoader gojsonschema.JSONLoader
if nargs > 1 {
documentPath, err := formatFilePath(os.Args[2])
if err != nil {
fmt.Printf("ERROR: invalid document-file path: %s\n", err)
os.Exit(1)
}
documentLoader = gojsonschema.NewReferenceLoader("file://" + documentPath)
} else {
documentBytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
documentString := string(documentBytes)
documentLoader = gojsonschema.NewStringLoader(documentString)
}
result, err := gojsonschema.Validate(schemaLoader, documentLoader)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
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)
}
}
func formatFilePath(path string) (string, error) {
if _, err := os.Stat(path); err != nil {
return "", err
}
absPath, err := filepath.Abs(path)
if err != nil {
return "", err
}
return absPath, nil
}