Skip to content

Commit 932c50d

Browse files
committed
proto: Port *.proto to proto3
Define syntax to fix [1]: protoc --go_out=./go config.proto [libprotobuf WARNING google/protobuf/compiler/parser.cc:492] No syntax specified for the proto file. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.) Drop 'optional' (with 'sed -i 's/\toptional /\t/' *.proto') to fix: protoc --go_out=./go config.proto config.proto:9:18: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. Replace the User extensions with 'Any' [2,3] to fix: protoc --go_out=./go config.proto config.proto: Extensions in proto3 are only allowed for defining options. Drop required (with 'sed -i 's/\trequired /\t/' *.proto') to fix: protoc --go_out=./go runtime_config.proto runtime_config.proto: Required fields are not allowed in proto3. Drop DefaultState to fix: protoc --go_out=./go runtime_config.proto runtime_config.proto: Explicit default values are not allowed in proto3. There's still some trouble with the resulting Go: go run ./example.go go/config.pb.go:26:8: cannot find package "google/protobuf" in any of: /usr/lib/go/src/google/protobuf (from $GOROOT) /home/wking/.local/lib/go/src/google/protobuf (from $GOPATH) Makefile:31: recipe for target 'example' failed But I haven't been able to figure that out yet. [1]: https://developers.google.com/protocol-buffers/docs/proto3#simple [2]: https://developers.google.com/protocol-buffers/docs/proto3#any [3]: protocolbuffers/protobuf#828 Signed-off-by: W. Trevor King <[email protected]>
1 parent b842176 commit 932c50d

File tree

2 files changed

+94
-109
lines changed

2 files changed

+94
-109
lines changed

proto/config.proto

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1+
syntax = "proto3";
2+
13
package oci;
24

5+
import "google/protobuf/any.proto";
6+
37
// Spec is the base configuration for the container. It specifies platform
48
// independent configuration.
59
message Spec {
610
// Version is the version of the specification that is supported.
7-
optional string version = 1;
11+
string version = 1;
812
// Platform is the host information for OS and Arch.
9-
optional Platform platform = 2;
13+
Platform platform = 2;
1014
// Process is the container's main process.
11-
optional Process process = 3;
15+
Process process = 3;
1216
// Root is the root information for the container's filesystem.
13-
optional Root root = 4;
17+
Root root = 4;
1418
// Hostname is the container's host name.
15-
optional string hostname = 5;
19+
string hostname = 5;
1620
// Mounts profile configuration for adding mounts to the container's
1721
// filesystem.
1822
repeated MountPoint mounts = 6;
@@ -21,10 +25,10 @@ message Spec {
2125

2226
// LinuxSpec is the full specification for linux containers.
2327
message LinuxSpec {
24-
optional Spec spec = 1;
28+
Spec spec = 1;
2529
// LinuxConfig is platform specific configuration for linux based
2630
// containers.
27-
optional LinuxConfig linux_config = 2;
31+
LinuxConfig linux_config = 2;
2832
}
2933

3034
// LinuxConfig contains platform specific configuration for linux based
@@ -38,69 +42,54 @@ message LinuxConfig {
3842
// container is created for.
3943
message Platform {
4044
// OS is the operating system.
41-
optional string os = 1;
45+
string os = 1;
4246
// Arch is the architecture
43-
optional string arch = 2;
47+
string arch = 2;
4448
}
4549

4650
// Process contains information to start a specific application inside the
4751
// container.
4852
message Process {
4953
// Terminal creates an interactive terminal for the container.
50-
optional bool terminal = 1;
54+
bool terminal = 1;
5155
// User specifies user information for the process.
52-
optional User user = 2;
56+
google.protobuf.Any user = 2;
5357
// Args specifies the binary and arguments for the application to
5458
// execute.
5559
repeated string args = 3;
5660
// Env populates the process environment for the process.
5761
repeated string env = 4;
5862
// Cwd is the current working directory for the process and must be
5963
// relative to the container's root.
60-
optional string cwd = 5;
61-
}
62-
63-
enum PlatformType {
64-
UNKNOWN = 0;
65-
LINUX = 1;
66-
}
67-
68-
// User specifies user information for the process.
69-
message User {
70-
// Type so that receivers of this message can `switch` for the fields
71-
// expected
72-
optional PlatformType type = 1;
73-
74-
//optional LinuxUser linux_type = 2;
75-
extensions 100 to 499;
64+
string cwd = 5;
7665
}
7766

7867
// LinuxUser specifies linux specific user and group information for the
7968
// container's main process.
80-
extend User {
69+
message LinuxUser {
8170
// Uid is the user id.
82-
optional int32 uid = 101;
71+
int32 uid = 101;
8372
// Gid is the group id.
84-
optional int32 gid = 102;
73+
int32 gid = 102;
8574
repeated int32 additional_gids = 103;
8675
}
8776

8877
// Root contains information about the container's root filesystem on the host.
8978
message Root {
9079
// Path is the absolute path to the container's root filesystem.
91-
optional string path = 1;
80+
string path = 1;
9281
// Readonly makes the root filesystem for the container readonly before
9382
// the process is executed.
94-
optional bool readonly = 2;
83+
bool readonly = 2;
9584
}
9685

9786
// MountPoint describes a directory that may be fullfilled by a mount in the
9887
// runtime.json.
9988
message MountPoint {
10089
// Name is a unique descriptive identifier for this mount point.
101-
optional string name = 1;
90+
string name = 1;
10291
// Path specifies the path of the mount. The path and child directories
10392
// MUST exist, a runtime MUST NOT create directories automatically to a
10493
// mount point.
105-
optional string path = 2;
94+
string path = 2;
10695
}

0 commit comments

Comments
 (0)