Skip to content

Commit ebae480

Browse files
committed
api/socket: Add JSON Schema and Go types for the command-line API socket messages
Even though there aren't many new types, these are fairly different from the rest of the runtime-tools code, and a separate package lets folks pull in only the code they need (assuming they are sophisticated enough to grab only a subset of the Git repository). Mrunal approved the JSON Schema landing under schema/ [1]. [1]: http://ircbot.wl.linuxfoundation.org/meetings/opencontainers/2017/opencontainers.2017-03-15-21.02.log.html#l-122 Signed-off-by: W. Trevor King <[email protected]>
1 parent 2ce4a5d commit ebae480

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

api/socket/socket.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package socket
2+
3+
// Message is the normal data for messages passed on the console socket.
4+
type Message struct {
5+
// Type of message being passed
6+
Type string `json:"type"`
7+
}
8+
9+
// TerminalRequest is the normal data for messages passing a pseudoterminal master.
10+
type TerminalRequest struct {
11+
Message
12+
13+
// Container ID for the container whose pseudoterminal master is being set.
14+
Container string `json:"container"`
15+
}
16+
17+
// Response is the normal data for response messages.
18+
type Response struct {
19+
Message
20+
21+
// Message is a phrase describing the response.
22+
Message string `json:"message,omitempty"`
23+
}

docs/command-line-interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ The socket type MUST be [`SOCK_SEQPACKET`][socket-types] or [`SOCK_STREAM`][sock
8585
The server MUST send a single response for each runtime request.
8686
The [normal data][socket-queue] ([`msghdr.msg_iov*`][socket.h]) of all messages MUST be [UTF-8][] [JSON](glossary.md#json).
8787

88-
There are [JSON Schemas](schema/README.md) and [Go bindings](specs-go/socket/socket.go) for the messages specified in this section.
88+
There are [JSON Schemas](../schema/README.md#oci-runtime-command-line-interface) and [Go bindings](../api/socket/socket.go) for the messages specified in this section.
8989

9090
##### Requests
9191

schema/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# JSON schema
2+
3+
This directory contains [JSON Schema][json-schema] for validating JSON covered by local specifications.
4+
The runtime specification includes [a generic command line tool][validate] which may be used to validate JSON with these schemas.
5+
6+
## OCI Runtime Command Line Interface
7+
8+
The [Runtime Command Line Interface](../docs/command-line-interface.md) defines:
9+
10+
* [Terminal requests](../docs/command-line-interface.md#requests), which may be validated against [`socket-terminal-request.json`](socket-terminal-request.json).
11+
* [Responses](../docs/command-line-interface.md#reqponses), which may be validated against [`socket-response.json`](socket-response.json).
12+
13+
[json-schema]: http://json-schema.org/
14+
[validate]: https://github.com/opencontainers/runtime-spec/tree/v1.0.0-rc5/schema#utility

schema/socket-response.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"description": "Open Container Runtime Socket Response Schema",
3+
"$schema": "http://json-schema.org/draft-04/schema#",
4+
"id": "https://opencontainers.org/schema/runtime/socket/response",
5+
"type": "object",
6+
"properties": {
7+
"type": {
8+
"id": "https://opencontainers.org/schema/runtime/socket/response/type",
9+
"type": "string",
10+
"enum": [
11+
"success",
12+
"error"
13+
]
14+
},
15+
"message": {
16+
"id": "https://opencontainers.org/schema/runtime/socket/response/message",
17+
"description": "A phrase describing the response.",
18+
"type": "string"
19+
}
20+
},
21+
"required": [
22+
"type"
23+
]
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"description": "Open Container Runtime Socket Terminal Request Schema",
3+
"$schema": "http://json-schema.org/draft-04/schema#",
4+
"id": "https://opencontainers.org/schema/runtime/socket/terminal-request",
5+
"type": "object",
6+
"properties": {
7+
"type": {
8+
"id": "https://opencontainers.org/schema/runtime/socket/terminal/request/type",
9+
"type": "string",
10+
"enum": [
11+
"terminal"
12+
]
13+
},
14+
"container": {
15+
"id": "https://opencontainers.org/schema/runtime/state/id",
16+
"description": "the container's ID",
17+
"type": "string"
18+
}
19+
},
20+
"required": [
21+
"type",
22+
"container"
23+
]
24+
}

0 commit comments

Comments
 (0)