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/example: Add version and fill in process #1

Open
wants to merge 2 commits into
base: protobuf
Choose a base branch
from

Conversation

wking
Copy link

@wking wking commented Sep 26, 2015

I thought it would be easier to judge JSON compatibility if I filled
in a few more fields. The version addition is pretty minor, but I'm
having trouble getting the process fields to serialize. With
7831505, I get:

$ make
go run ./example.go
{
  "spec": {
    "version": "0.1.0",
    "platform": {
      "os": "linux",
      "arch": "x86_64"
    },
    "process": {
      "terminal": true,
      "user": {
        "type": 1
      },
      "args": [
        "sh"
      ],
      "env": [
        "TERM=linux"
      ],
      "cwd": "/root"
    }
  }
}

The extension fields aren't serialized, and I expect that has
something to do with:

$ grep -B4 -A2 'extension.*json' go/config.pb.go 
type User struct {
        // Type so that receivers of this message can `switch` for the fields
        // expected
        Type             *PlatformType             `protobuf:"varint,1,opt,name=type,enum=oci.PlatformType" json:"type,omitempty"`
        XXX_extensions   map[int32]proto.Extension `json:"-"`
        XXX_unrecognized []byte                    `json:"-"`
}

I'll take a stab at the protobuf3 branch and see if I have better luck
there.

Feel free to pull these commits into your protobuf branch or not as
you see fit.

To match the example in config.md.

Signed-off-by: W. Trevor King <wking@tremily.us>
To match the example in config.md.

Signed-off-by: W. Trevor King <wking@tremily.us>
vbatts pushed a commit that referenced this pull request Apr 12, 2016
Don't use strings when you can use dictionaries/objects. JSON objects are trivial to parse and manipulate, unlike strings. String parsing is the #1 cause of security bugs, so if it can be trivially avoided, then why not ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant