Skip to content

Commit e73beb0

Browse files
committed
proto: initial protobuf for config
To have a less source based, and more consumable example of structures, this is an initial pass at protobuf structures for the structures in config.go There is some exercise needed in platform specific structures. For the sake of example, the Makefile defaults to outputing golang source, but has a 'c' target (`make c`) for C source as well. Signed-off-by: Vincent Batts <[email protected]>
1 parent cbda521 commit e73beb0

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

proto/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
DESTDIR ?= .
3+
PROTO_FILES := $(wildcard *.proto)
4+
GO_FILES := $(patsubst %.proto,%.pb.go,$(PROTO_FILES))
5+
C_FILES := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
6+
C_HDR_FILES := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
7+
8+
default: go
9+
10+
go: $(GO_FILES)
11+
12+
%.pb.go: %.proto
13+
protoc --go_out=$(DESTDIR) $<
14+
15+
c: $(C_FILES)
16+
17+
%.pb-c.c: %.proto
18+
protoc-c --c_out=$(DESTDIR) $<
19+
20+
clean:
21+
rm -rf *~ $(GO_FILES) $(C_FILES) $(C_HDR_FILES)
22+

proto/config.proto

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package oci;
2+
3+
// Spec is the base configuration for the container. It specifies platform
4+
// independent configuration.
5+
message Spec {
6+
// Version is the version of the specification that is supported.
7+
required string Version = 1;
8+
// Platform is the host information for OS and Arch.
9+
required Platform Platform = 2; // [default=77];
10+
// Process is the container's main process.
11+
required Process Process = 3;
12+
// Root is the root information for the container's filesystem.
13+
required Root Root = 4;
14+
// Hostname is the container's host name.
15+
required string Hostname = 5;
16+
// Mounts profile configuration for adding mounts to the container's filesystem.
17+
repeated MountPoint Mounts = 6;
18+
}
19+
20+
// Platform specifies OS and arch information for the host system that the container
21+
// is created for.
22+
message Platform {
23+
// OS is the operating system.
24+
required string OS = 1;
25+
// Arch is the architecture
26+
required string Arch = 2;
27+
}
28+
29+
// Process contains information to start a specific application inside the container.
30+
message Process {
31+
// Terminal creates an interactive terminal for the container.
32+
required bool Terminal = 1;
33+
// User specifies user information for the process.
34+
// TODO(vbatts) figure out platform dependent types
35+
//required User User = 2;
36+
// Args specifies the binary and arguments for the application to execute.
37+
repeated string Args = 3;
38+
// Env populates the process environment for the process.
39+
repeated string Env = 4;
40+
// Cwd is the current working directory for the process and must be
41+
// relative to the container's root.
42+
required string Cwd = 5;
43+
}
44+
45+
// Root contains information about the container's root filesystem on the host.
46+
message Root {
47+
// Path is the absolute path to the container's root filesystem.
48+
required string Path = 1;
49+
// Readonly makes the root filesystem for the container readonly before the process is executed.
50+
required bool Readonly = 2;
51+
}
52+
53+
// MountPoint describes a directory that may be fullfilled by a mount in the runtime.json.
54+
message MountPoint {
55+
// Name is a unique descriptive identifier for this mount point.
56+
required string Name = 1;
57+
// Path specifies the path of the mount. The path and child directories MUST exist, a runtime MUST NOT create directories automatically to a mount point.
58+
required string Path = 2;
59+
}

0 commit comments

Comments
 (0)