Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proto: Port *.proto to proto3 #2

Closed
wants to merge 4 commits into from
Closed

Commits on Sep 26, 2015

  1. 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 <wking@tremily.us>
    wking committed Sep 26, 2015
    Configuration menu
    Copy the full SHA
    932c50d View commit details
    Browse the repository at this point in the history

Commits on Sep 29, 2015

  1. proto: Port example.go to proto3

    Using jsonpb [1,2].
    
    Drop the proto.String bits to avoid errors like:
    
      ./example.go:17: cannot use proto.String("linux") (type *string) as
        type string in field value
    
    And use a reference to s to avoid:
    
      ./example.go:29: cannot use s (type oci.LinuxSpec) as type
         proto.Message in argument to marshaler.Marshal: oci.LinuxSpec
         does not implement proto.Message (ProtoMessage method has pointer
         receiver)
    
    [1]: golang/protobuf#44
    [2]: http://godoc.org/github.com/golang/protobuf/jsonpb
    
    Signed-off-by: W. Trevor King <wking@tremily.us>
    wking committed Sep 29, 2015
    Configuration menu
    Copy the full SHA
    459cecb View commit details
    Browse the repository at this point in the history
  2. proto: Add support for Process.User's Any

    To avoid:
    
      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
    
    The Dockerfile changes will compile Google's any.proto to Go and
    install it in the GOPATH.  Unfortunately, the jsonpb rendering isn't
    quite right, since it's spitting out:
    
      "user": {
        "type_url": "oci.LinuxUser",
        "value": "qAYBsAYBuAYFuAYG"
      },
    
    When it should be spitting out [1]:
    
      "user": {
        "@type": "type.googleapis.com/oci.LinuxUser",
        "uid": 1,
        "gid": 1,
        "additionalGids": [
          5,
          6
        ]
      },
    
    [1]: https://developers.google.com/protocol-buffers/docs/proto3#json
    
    Signed-off-by: W. Trevor King <wking@tremily.us>
    wking committed Sep 29, 2015
    Configuration menu
    Copy the full SHA
    da7a33f View commit details
    Browse the repository at this point in the history

Commits on Oct 24, 2015

  1. proto/example: Drop EnumsAsString

    It became the default with golang/protobuf@9ebc6c4e (2015-10-19) and
    was removed completely with golang/protobuf@8a5d8e8b (jsonpb: Remove
    Marshaler.EnumsAsString, 2015-10-21).
    
    Signed-off-by: W. Trevor King <wking@tremily.us>
    wking committed Oct 24, 2015
    Configuration menu
    Copy the full SHA
    8214db4 View commit details
    Browse the repository at this point in the history