Skip to content

Commit 8a33d07

Browse files
committed
proto: Platform type for User, and misc
This User structure does not map to the cleanliness of the current go structure, but will allow the definition to be all in one place, regardless of the host that is doing the compilation. Switching field rules to `optional` for now. Per vish and the docs, https://developers.google.com/protocol-buffers/docs/proto?csw=1#specifying-field-rules "! Required Is Forever" Also add a `make py` and `make all` target. Signed-off-by: Vincent Batts <[email protected]>
1 parent 9d3ed03 commit 8a33d07

File tree

2 files changed

+51
-19
lines changed

2 files changed

+51
-19
lines changed

proto/Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,28 @@ PROTO_FILES := $(wildcard *.proto)
44
GO_FILES := $(patsubst %.proto,%.pb.go,$(PROTO_FILES))
55
C_FILES := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
66
C_HDR_FILES := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
7+
PY_FILES := $(patsubst %.proto,%_pb2.py,$(PROTO_FILES))
78

89
defualt: go
910

11+
all: go py c
12+
1013
go: $(GO_FILES)
1114

1215
%.pb.go: %.proto
13-
protoc --go_out=$(DESTDIR) $<
16+
protoc --go_out=$(DESTDIR) $^
1417

1518
c: $(C_FILES)
1619

1720
%.pb-c.c: %.proto
18-
protoc-c --c_out=$(DESTDIR) $<
21+
protoc-c --c_out=$(DESTDIR) $^
22+
23+
py: $(PY_FILES)
24+
25+
%_pb2.py: %.proto
26+
protoc --python_out=$(DESTDIR) $^
27+
1928

2029
clean:
21-
rm -rf *~ $(GO_FILES) $(C_FILES) $(C_HDR_FILES)
30+
rm -rf *~ $(GO_FILES) $(C_FILES) $(C_HDR_FILES) $(PY_FILES)
2231

proto/config.proto

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package oci;
2-
2+
3+
//import "config_user.proto";
4+
35
// Spec is the base configuration for the container. It specifies platform
46
// independent configuration.
57
message Spec {
68
// Version is the version of the specification that is supported.
7-
required string Version = 1;
9+
optional string Version = 1;
810
// Platform is the host information for OS and Arch.
9-
required Platform Platform = 2; // [default=77];
11+
optional Platform Platform = 2; // [default=77];
1012
// Process is the container's main process.
11-
required Process Process = 3;
13+
optional Process Process = 3;
1214
// Root is the root information for the container's filesystem.
13-
required Root Root = 4;
15+
optional Root Root = 4;
1416
// Hostname is the container's host name.
15-
required string Hostname = 5;
17+
optional string Hostname = 5;
1618
// Mounts profile configuration for adding mounts to the container's filesystem.
1719
repeated MountPoint Mounts = 6;
1820
}
@@ -21,39 +23,60 @@ message Spec {
2123
// is created for.
2224
message Platform {
2325
// OS is the operating system.
24-
required string OS = 1;
26+
optional string OS = 1;
2527
// Arch is the architecture
26-
required string Arch = 2;
28+
optional string Arch = 2;
2729
}
2830

2931
// Process contains information to start a specific application inside the container.
3032
message Process {
3133
// Terminal creates an interactive terminal for the container.
32-
required bool Terminal = 1;
34+
optional bool Terminal = 1;
3335
// User specifies user information for the process.
34-
// TODO(vbatts) figure out platform dependent types
35-
//required User User = 2;
36+
optional User User = 2;
3637
// Args specifies the binary and arguments for the application to execute.
3738
repeated string Args = 3;
3839
// Env populates the process environment for the process.
3940
repeated string Env = 4;
4041
// Cwd is the current working directory for the process and must be
4142
// relative to the container's root.
42-
required string Cwd = 5;
43+
optional string Cwd = 5;
44+
}
45+
46+
enum PlatformType {
47+
LINUX = 1;
48+
}
49+
50+
// User specifies user information for the process.
51+
message User {
52+
// Type so that receivers of this message can `switch` for the fields expected
53+
optional PlatformType Type = 1 [default = LINUX];
54+
// LinuxUserFields are to be used when Type is LINUX
55+
optional linuxUserFields LinuxUserFields = 2;
56+
}
57+
58+
// User specifies linux specific user and group information for the container's
59+
// main process.
60+
message linuxUserFields {
61+
// UID is the user id.
62+
optional int32 UID = 1;
63+
// GID is the group id.
64+
optional int32 GID = 2;
65+
repeated int32 AdditionalGids = 3;
4366
}
4467

4568
// Root contains information about the container's root filesystem on the host.
4669
message Root {
4770
// Path is the absolute path to the container's root filesystem.
48-
required string Path = 1;
71+
optional string Path = 1;
4972
// Readonly makes the root filesystem for the container readonly before the process is executed.
50-
required bool Readonly = 2;
73+
optional bool Readonly = 2;
5174
}
5275

5376
// MountPoint describes a directory that may be fullfilled by a mount in the runtime.json.
5477
message MountPoint {
5578
// Name is a unique descriptive identifier for this mount point.
56-
required string Name = 1;
79+
optional string Name = 1;
5780
// 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;
81+
optional string Path = 2;
5982
}

0 commit comments

Comments
 (0)