Skip to content

Commit

Permalink
proto: Port *.proto to proto3
Browse files Browse the repository at this point in the history
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 <wking@tremily.us>
  • Loading branch information
wking committed Sep 26, 2015
1 parent b842176 commit 932c50d
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 109 deletions.
57 changes: 23 additions & 34 deletions proto/config.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
syntax = "proto3";

package oci;

import "google/protobuf/any.proto";

// Spec is the base configuration for the container. It specifies platform
// independent configuration.
message Spec {
// Version is the version of the specification that is supported.
optional string version = 1;
string version = 1;
// Platform is the host information for OS and Arch.
optional Platform platform = 2;
Platform platform = 2;
// Process is the container's main process.
optional Process process = 3;
Process process = 3;
// Root is the root information for the container's filesystem.
optional Root root = 4;
Root root = 4;
// Hostname is the container's host name.
optional string hostname = 5;
string hostname = 5;
// Mounts profile configuration for adding mounts to the container's
// filesystem.
repeated MountPoint mounts = 6;
Expand All @@ -21,10 +25,10 @@ message Spec {

// LinuxSpec is the full specification for linux containers.
message LinuxSpec {
optional Spec spec = 1;
Spec spec = 1;
// LinuxConfig is platform specific configuration for linux based
// containers.
optional LinuxConfig linux_config = 2;
LinuxConfig linux_config = 2;
}

// LinuxConfig contains platform specific configuration for linux based
Expand All @@ -38,69 +42,54 @@ message LinuxConfig {
// container is created for.
message Platform {
// OS is the operating system.
optional string os = 1;
string os = 1;
// Arch is the architecture
optional string arch = 2;
string arch = 2;
}

// Process contains information to start a specific application inside the
// container.
message Process {
// Terminal creates an interactive terminal for the container.
optional bool terminal = 1;
bool terminal = 1;
// User specifies user information for the process.
optional User user = 2;
google.protobuf.Any user = 2;
// Args specifies the binary and arguments for the application to
// execute.
repeated string args = 3;
// Env populates the process environment for the process.
repeated string env = 4;
// Cwd is the current working directory for the process and must be
// relative to the container's root.
optional string cwd = 5;
}

enum PlatformType {
UNKNOWN = 0;
LINUX = 1;
}

// User specifies user information for the process.
message User {
// Type so that receivers of this message can `switch` for the fields
// expected
optional PlatformType type = 1;

//optional LinuxUser linux_type = 2;
extensions 100 to 499;
string cwd = 5;
}

// LinuxUser specifies linux specific user and group information for the
// container's main process.
extend User {
message LinuxUser {
// Uid is the user id.
optional int32 uid = 101;
int32 uid = 101;
// Gid is the group id.
optional int32 gid = 102;
int32 gid = 102;
repeated int32 additional_gids = 103;
}

// Root contains information about the container's root filesystem on the host.
message Root {
// Path is the absolute path to the container's root filesystem.
optional string path = 1;
string path = 1;
// Readonly makes the root filesystem for the container readonly before
// the process is executed.
optional bool readonly = 2;
bool readonly = 2;
}

// MountPoint describes a directory that may be fullfilled by a mount in the
// runtime.json.
message MountPoint {
// Name is a unique descriptive identifier for this mount point.
optional string name = 1;
string name = 1;
// 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.
optional string path = 2;
string path = 2;
}

0 comments on commit 932c50d

Please sign in to comment.