shimv2: Revert shimv2, vendor commits

This reverts:
 - 590ed09 vendor: update gogo/protobuf, containerd and agent vendors
 - eabfd99 shimv2: Improve shim shutdown logic

These introduce a regression for starting pods with k8s 1.14 + contaienr
1.2.6

Fixes: #1781

Signed-off-by: Eric Ernst <eric.ernst@intel.com>
This commit is contained in:
Eric Ernst
2019-06-07 15:36:15 -07:00
parent 64e5e2129b
commit 7acdaa2d53
105 changed files with 7198 additions and 27814 deletions

32
Gopkg.lock generated
View File

@@ -65,14 +65,6 @@
revision = "ccb8e960c48f04d6935e72476ae4a51028f9e22f" revision = "ccb8e960c48f04d6935e72476ae4a51028f9e22f"
version = "v9" version = "v9"
[[projects]]
digest = "1:45c41cd27a8d986998680bfc86da0bbff5fa4f90d0f446c00636c8b099028ffe"
name = "github.com/blang/semver"
packages = ["."]
pruneopts = "NUT"
revision = "ba2c2ddd89069b46a7011d4106f6868f17ee1705"
version = "v3.6.1"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:8ecb89af7dfe3ac401bdb0c9390b134ef96a97e85f732d2b0604fb7b3977839f" digest = "1:8ecb89af7dfe3ac401bdb0c9390b134ef96a97e85f732d2b0604fb7b3977839f"
@@ -97,11 +89,10 @@
revision = "0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f" revision = "0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f"
[[projects]] [[projects]]
digest = "1:ef3233b859d777565e34a88b4dbf0a353225d10a6036c5581fe8b1fc6d2bda96" digest = "1:b1ddab63ebf3a38cdc2a80fa1f00c45e8dc98e27387968ccc0e5275a43f6cb5e"
name = "github.com/containerd/containerd" name = "github.com/containerd/containerd"
packages = [ packages = [
"api/events", "api/events",
"api/services/ttrpc/events/v1",
"api/types", "api/types",
"api/types/task", "api/types/task",
"errdefs", "errdefs",
@@ -109,7 +100,6 @@
"log", "log",
"mount", "mount",
"namespaces", "namespaces",
"pkg/ttrpcutil",
"runtime", "runtime",
"runtime/linux/runctypes", "runtime/linux/runctypes",
"runtime/v2/shim", "runtime/v2/shim",
@@ -117,7 +107,7 @@
"sys", "sys",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "25daa7355cdc1334718ce42e887f1c367aff9d0e" revision = "f05672357f56f26751a521175c5a96fc21fa8603"
[[projects]] [[projects]]
digest = "1:e7c346f795db5a431ca8bd284faed7aa5b4d544ba6538b20a39b968473f47774" digest = "1:e7c346f795db5a431ca8bd284faed7aa5b4d544ba6538b20a39b968473f47774"
@@ -146,11 +136,12 @@
revision = "7d11b49dc0769f6dbb0d1b19f3d48524d1bad9ad" revision = "7d11b49dc0769f6dbb0d1b19f3d48524d1bad9ad"
[[projects]] [[projects]]
digest = "1:1868182f06e2a19b42566facd65993accd29469fb3f7500ef23cdaffbfa98323" branch = "master"
digest = "1:25435262330720ca0cade25af7ee7fb96d0cb70cc1ea0c0961694681c12a90e6"
name = "github.com/containerd/ttrpc" name = "github.com/containerd/ttrpc"
packages = ["."] packages = ["."]
pruneopts = "NUT" pruneopts = "NUT"
revision = "f82148331ad2181edea8f3f649a1f7add6c3f9c2" revision = "69144327078caa5a2f1d5eda8bea6110bf16eeb3"
[[projects]] [[projects]]
branch = "master" branch = "master"
@@ -344,7 +335,7 @@
version = "v5.0.1" version = "v5.0.1"
[[projects]] [[projects]]
digest = "1:1f05c5d4f7fe7a5ce1c509907a9f367f89e0c23de046263b8e298a7e350d0153" digest = "1:0dfc35f448d29c2ff6a29fb3a6643f44175dc2a07925b1add2dea74e1dd6bf8d"
name = "github.com/gogo/protobuf" name = "github.com/gogo/protobuf"
packages = [ packages = [
"gogoproto", "gogoproto",
@@ -354,7 +345,7 @@
"types", "types",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "4cbf7e384e768b4e01799441fdf2a706a5635ae7" revision = "342cbe0a04158f6dcb03ca0079991a51a4248c02"
[[projects]] [[projects]]
digest = "1:2d0636a8c490d2272dd725db26f74a537111b99b9dbdda0d8b98febe63702aa4" digest = "1:2d0636a8c490d2272dd725db26f74a537111b99b9dbdda0d8b98febe63702aa4"
@@ -394,7 +385,7 @@
revision = "b3e7a9e78463a10f2a19e1a966c76a3afb215781" revision = "b3e7a9e78463a10f2a19e1a966c76a3afb215781"
[[projects]] [[projects]]
digest = "1:085659f5e732e3d3126863d90bdc92cf8f264b8f996e0bf5d4d412815fb2b15b" digest = "1:36dfd4701e98a9d8371dd3053e32d4f29e82b07bcc9e655db82138f9273bcb0f"
name = "github.com/kata-containers/agent" name = "github.com/kata-containers/agent"
packages = [ packages = [
"pkg/types", "pkg/types",
@@ -402,7 +393,7 @@
"protocols/grpc", "protocols/grpc",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "714bf625cc68505f31d802f98b84bf2b8006e146" revision = "48dd1c031530fce9bf16b0f6a7305979cedd8fc9"
[[projects]] [[projects]]
branch = "master" branch = "master"
@@ -417,11 +408,11 @@
revision = "6243d8e04c3f819e79757e8bc3faa15c3cb27003" revision = "6243d8e04c3f819e79757e8bc3faa15c3cb27003"
[[projects]] [[projects]]
digest = "1:b09f78822be5d574e052d4e377b133bac445cdbcbfaf884e0704f870e509ef21" digest = "1:f3e11773cc8a305f97b42c276f62d92899c9b0c1c3c584a667149b18f18a530a"
name = "github.com/mdlayher/vsock" name = "github.com/mdlayher/vsock"
packages = ["."] packages = ["."]
pruneopts = "NUT" pruneopts = "NUT"
revision = "7b7533a7ca4eba7dd23dab2de70e25ca6eecf7e2" revision = "676f733b747cd6406f297a51bd086ee8ec8abdbe"
[[projects]] [[projects]]
digest = "1:6a65dcd0d14fc0595ee982afc3c59deb5b769ca374455c80c649d92f8a152930" digest = "1:6a65dcd0d14fc0595ee982afc3c59deb5b769ca374455c80c649d92f8a152930"
@@ -693,7 +684,6 @@
analyzer-version = 1 analyzer-version = 1
input-imports = [ input-imports = [
"github.com/BurntSushi/toml", "github.com/BurntSushi/toml",
"github.com/blang/semver",
"github.com/containerd/cgroups", "github.com/containerd/cgroups",
"github.com/containerd/containerd/api/events", "github.com/containerd/containerd/api/events",
"github.com/containerd/containerd/api/types", "github.com/containerd/containerd/api/types",

View File

@@ -52,7 +52,7 @@
[[constraint]] [[constraint]]
name = "github.com/kata-containers/agent" name = "github.com/kata-containers/agent"
revision = "714bf625cc68505f31d802f98b84bf2b8006e146" revision = "48dd1c031530fce9bf16b0f6a7305979cedd8fc9"
[[constraint]] [[constraint]]
name = "github.com/containerd/cri-containerd" name = "github.com/containerd/cri-containerd"
@@ -64,7 +64,7 @@
[[constraint]] [[constraint]]
name = "github.com/containerd/containerd" name = "github.com/containerd/containerd"
revision = "25daa7355cdc1334718ce42e887f1c367aff9d0e" revision = "f05672357f56f26751a521175c5a96fc21fa8603"
[[constraint]] [[constraint]]
name = "github.com/firecracker-microvm/firecracker-go-sdk" name = "github.com/firecracker-microvm/firecracker-go-sdk"
@@ -72,11 +72,7 @@
[[constraint]] [[constraint]]
name = "github.com/gogo/protobuf" name = "github.com/gogo/protobuf"
revision = "4cbf7e384e768b4e01799441fdf2a706a5635ae7" revision = "342cbe0a04158f6dcb03ca0079991a51a4248c02"
[[override]]
name = "github.com/containerd/ttrpc"
revision = "f82148331ad2181edea8f3f649a1f7add6c3f9c2"
[[override]] [[override]]
branch = "master" branch = "master"

View File

@@ -16,6 +16,7 @@ import (
eventstypes "github.com/containerd/containerd/api/events" eventstypes "github.com/containerd/containerd/api/events"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
cdruntime "github.com/containerd/containerd/runtime" cdruntime "github.com/containerd/containerd/runtime"
cdshim "github.com/containerd/containerd/runtime/v2/shim" cdshim "github.com/containerd/containerd/runtime/v2/shim"
@@ -57,7 +58,7 @@ var (
var vci vc.VC = &vc.VCImpl{} var vci vc.VC = &vc.VCImpl{}
// New returns a new shim service that can be used via GRPC // New returns a new shim service that can be used via GRPC
func New(ctx context.Context, id string, publisher cdshim.Publisher, shutdown func()) (cdshim.Shim, error) { func New(ctx context.Context, id string, publisher events.Publisher) (cdshim.Shim, error) {
logger := logrus.WithField("ID", id) logger := logrus.WithField("ID", id)
// Discard the log before shim init its log output. Otherwise // Discard the log before shim init its log output. Otherwise
// it will output into stdio, from which containerd would like // it will output into stdio, from which containerd would like
@@ -66,6 +67,8 @@ func New(ctx context.Context, id string, publisher cdshim.Publisher, shutdown fu
vci.SetLogger(ctx, logger) vci.SetLogger(ctx, logger)
katautils.SetLogger(ctx, logger, logger.Logger.Level) katautils.SetLogger(ctx, logger, logger.Logger.Level)
ctx, cancel := context.WithCancel(ctx)
s := &service{ s := &service{
id: id, id: id,
pid: uint32(os.Getpid()), pid: uint32(os.Getpid()),
@@ -73,13 +76,13 @@ func New(ctx context.Context, id string, publisher cdshim.Publisher, shutdown fu
containers: make(map[string]*container), containers: make(map[string]*container),
events: make(chan interface{}, chSize), events: make(chan interface{}, chSize),
ec: make(chan exit, bufferSize), ec: make(chan exit, bufferSize),
cancel: shutdown, cancel: cancel,
mount: false, mount: false,
} }
go s.processExits() go s.processExits()
go s.forward(ctx, publisher) go s.forward(publisher)
return s, nil return s, nil
} }
@@ -213,20 +216,15 @@ func (s *service) StartShim(ctx context.Context, id, containerdBinary, container
return address, nil return address, nil
} }
func (s *service) forward(ctx context.Context, publisher cdshim.Publisher) { func (s *service) forward(publisher events.Publisher) {
ns, _ := namespaces.Namespace(ctx)
ctx = namespaces.WithNamespace(context.Background(), ns)
for e := range s.events { for e := range s.events {
ctx, cancel := context.WithTimeout(ctx, timeOut) ctx, cancel := context.WithTimeout(s.ctx, timeOut)
err := publisher.Publish(ctx, getTopic(e), e) err := publisher.Publish(ctx, getTopic(e), e)
cancel() cancel()
if err != nil { if err != nil {
logrus.WithError(err).Error("post event") logrus.WithError(err).Error("post event")
} }
} }
publisher.Close()
} }
func (s *service) send(evt interface{}) { func (s *service) send(evt interface{}) {
@@ -771,8 +769,11 @@ func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (_ *
s.mu.Unlock() s.mu.Unlock()
s.cancel() s.cancel()
close(s.events)
os.Exit(0)
// This will never be called, but this is only there to make sure the
// program can compile.
return empty, nil return empty, nil
} }

View File

@@ -1,22 +0,0 @@
The MIT License
Copyright (c) 2014 Benedikt Lang <github at benediktlang.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -1,23 +0,0 @@
package semver
import (
"encoding/json"
)
// MarshalJSON implements the encoding/json.Marshaler interface.
func (v Version) MarshalJSON() ([]byte, error) {
return json.Marshal(v.String())
}
// UnmarshalJSON implements the encoding/json.Unmarshaler interface.
func (v *Version) UnmarshalJSON(data []byte) (err error) {
var versionString string
if err = json.Unmarshal(data, &versionString); err != nil {
return
}
*v, err = Parse(versionString)
return
}

View File

@@ -1,416 +0,0 @@
package semver
import (
"fmt"
"strconv"
"strings"
"unicode"
)
type wildcardType int
const (
noneWildcard wildcardType = iota
majorWildcard wildcardType = 1
minorWildcard wildcardType = 2
patchWildcard wildcardType = 3
)
func wildcardTypefromInt(i int) wildcardType {
switch i {
case 1:
return majorWildcard
case 2:
return minorWildcard
case 3:
return patchWildcard
default:
return noneWildcard
}
}
type comparator func(Version, Version) bool
var (
compEQ comparator = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) == 0
}
compNE = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) != 0
}
compGT = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) == 1
}
compGE = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) >= 0
}
compLT = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) == -1
}
compLE = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) <= 0
}
)
type versionRange struct {
v Version
c comparator
}
// rangeFunc creates a Range from the given versionRange.
func (vr *versionRange) rangeFunc() Range {
return Range(func(v Version) bool {
return vr.c(v, vr.v)
})
}
// Range represents a range of versions.
// A Range can be used to check if a Version satisfies it:
//
// range, err := semver.ParseRange(">1.0.0 <2.0.0")
// range(semver.MustParse("1.1.1") // returns true
type Range func(Version) bool
// OR combines the existing Range with another Range using logical OR.
func (rf Range) OR(f Range) Range {
return Range(func(v Version) bool {
return rf(v) || f(v)
})
}
// AND combines the existing Range with another Range using logical AND.
func (rf Range) AND(f Range) Range {
return Range(func(v Version) bool {
return rf(v) && f(v)
})
}
// ParseRange parses a range and returns a Range.
// If the range could not be parsed an error is returned.
//
// Valid ranges are:
// - "<1.0.0"
// - "<=1.0.0"
// - ">1.0.0"
// - ">=1.0.0"
// - "1.0.0", "=1.0.0", "==1.0.0"
// - "!1.0.0", "!=1.0.0"
//
// A Range can consist of multiple ranges separated by space:
// Ranges can be linked by logical AND:
// - ">1.0.0 <2.0.0" would match between both ranges, so "1.1.1" and "1.8.7" but not "1.0.0" or "2.0.0"
// - ">1.0.0 <3.0.0 !2.0.3-beta.2" would match every version between 1.0.0 and 3.0.0 except 2.0.3-beta.2
//
// Ranges can also be linked by logical OR:
// - "<2.0.0 || >=3.0.0" would match "1.x.x" and "3.x.x" but not "2.x.x"
//
// AND has a higher precedence than OR. It's not possible to use brackets.
//
// Ranges can be combined by both AND and OR
//
// - `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1`
func ParseRange(s string) (Range, error) {
parts := splitAndTrim(s)
orParts, err := splitORParts(parts)
if err != nil {
return nil, err
}
expandedParts, err := expandWildcardVersion(orParts)
if err != nil {
return nil, err
}
var orFn Range
for _, p := range expandedParts {
var andFn Range
for _, ap := range p {
opStr, vStr, err := splitComparatorVersion(ap)
if err != nil {
return nil, err
}
vr, err := buildVersionRange(opStr, vStr)
if err != nil {
return nil, fmt.Errorf("Could not parse Range %q: %s", ap, err)
}
rf := vr.rangeFunc()
// Set function
if andFn == nil {
andFn = rf
} else { // Combine with existing function
andFn = andFn.AND(rf)
}
}
if orFn == nil {
orFn = andFn
} else {
orFn = orFn.OR(andFn)
}
}
return orFn, nil
}
// splitORParts splits the already cleaned parts by '||'.
// Checks for invalid positions of the operator and returns an
// error if found.
func splitORParts(parts []string) ([][]string, error) {
var ORparts [][]string
last := 0
for i, p := range parts {
if p == "||" {
if i == 0 {
return nil, fmt.Errorf("First element in range is '||'")
}
ORparts = append(ORparts, parts[last:i])
last = i + 1
}
}
if last == len(parts) {
return nil, fmt.Errorf("Last element in range is '||'")
}
ORparts = append(ORparts, parts[last:])
return ORparts, nil
}
// buildVersionRange takes a slice of 2: operator and version
// and builds a versionRange, otherwise an error.
func buildVersionRange(opStr, vStr string) (*versionRange, error) {
c := parseComparator(opStr)
if c == nil {
return nil, fmt.Errorf("Could not parse comparator %q in %q", opStr, strings.Join([]string{opStr, vStr}, ""))
}
v, err := Parse(vStr)
if err != nil {
return nil, fmt.Errorf("Could not parse version %q in %q: %s", vStr, strings.Join([]string{opStr, vStr}, ""), err)
}
return &versionRange{
v: v,
c: c,
}, nil
}
// inArray checks if a byte is contained in an array of bytes
func inArray(s byte, list []byte) bool {
for _, el := range list {
if el == s {
return true
}
}
return false
}
// splitAndTrim splits a range string by spaces and cleans whitespaces
func splitAndTrim(s string) (result []string) {
last := 0
var lastChar byte
excludeFromSplit := []byte{'>', '<', '='}
for i := 0; i < len(s); i++ {
if s[i] == ' ' && !inArray(lastChar, excludeFromSplit) {
if last < i-1 {
result = append(result, s[last:i])
}
last = i + 1
} else if s[i] != ' ' {
lastChar = s[i]
}
}
if last < len(s)-1 {
result = append(result, s[last:])
}
for i, v := range result {
result[i] = strings.Replace(v, " ", "", -1)
}
// parts := strings.Split(s, " ")
// for _, x := range parts {
// if s := strings.TrimSpace(x); len(s) != 0 {
// result = append(result, s)
// }
// }
return
}
// splitComparatorVersion splits the comparator from the version.
// Input must be free of leading or trailing spaces.
func splitComparatorVersion(s string) (string, string, error) {
i := strings.IndexFunc(s, unicode.IsDigit)
if i == -1 {
return "", "", fmt.Errorf("Could not get version from string: %q", s)
}
return strings.TrimSpace(s[0:i]), s[i:], nil
}
// getWildcardType will return the type of wildcard that the
// passed version contains
func getWildcardType(vStr string) wildcardType {
parts := strings.Split(vStr, ".")
nparts := len(parts)
wildcard := parts[nparts-1]
possibleWildcardType := wildcardTypefromInt(nparts)
if wildcard == "x" {
return possibleWildcardType
}
return noneWildcard
}
// createVersionFromWildcard will convert a wildcard version
// into a regular version, replacing 'x's with '0's, handling
// special cases like '1.x.x' and '1.x'
func createVersionFromWildcard(vStr string) string {
// handle 1.x.x
vStr2 := strings.Replace(vStr, ".x.x", ".x", 1)
vStr2 = strings.Replace(vStr2, ".x", ".0", 1)
parts := strings.Split(vStr2, ".")
// handle 1.x
if len(parts) == 2 {
return vStr2 + ".0"
}
return vStr2
}
// incrementMajorVersion will increment the major version
// of the passed version
func incrementMajorVersion(vStr string) (string, error) {
parts := strings.Split(vStr, ".")
i, err := strconv.Atoi(parts[0])
if err != nil {
return "", err
}
parts[0] = strconv.Itoa(i + 1)
return strings.Join(parts, "."), nil
}
// incrementMajorVersion will increment the minor version
// of the passed version
func incrementMinorVersion(vStr string) (string, error) {
parts := strings.Split(vStr, ".")
i, err := strconv.Atoi(parts[1])
if err != nil {
return "", err
}
parts[1] = strconv.Itoa(i + 1)
return strings.Join(parts, "."), nil
}
// expandWildcardVersion will expand wildcards inside versions
// following these rules:
//
// * when dealing with patch wildcards:
// >= 1.2.x will become >= 1.2.0
// <= 1.2.x will become < 1.3.0
// > 1.2.x will become >= 1.3.0
// < 1.2.x will become < 1.2.0
// != 1.2.x will become < 1.2.0 >= 1.3.0
//
// * when dealing with minor wildcards:
// >= 1.x will become >= 1.0.0
// <= 1.x will become < 2.0.0
// > 1.x will become >= 2.0.0
// < 1.0 will become < 1.0.0
// != 1.x will become < 1.0.0 >= 2.0.0
//
// * when dealing with wildcards without
// version operator:
// 1.2.x will become >= 1.2.0 < 1.3.0
// 1.x will become >= 1.0.0 < 2.0.0
func expandWildcardVersion(parts [][]string) ([][]string, error) {
var expandedParts [][]string
for _, p := range parts {
var newParts []string
for _, ap := range p {
if strings.Contains(ap, "x") {
opStr, vStr, err := splitComparatorVersion(ap)
if err != nil {
return nil, err
}
versionWildcardType := getWildcardType(vStr)
flatVersion := createVersionFromWildcard(vStr)
var resultOperator string
var shouldIncrementVersion bool
switch opStr {
case ">":
resultOperator = ">="
shouldIncrementVersion = true
case ">=":
resultOperator = ">="
case "<":
resultOperator = "<"
case "<=":
resultOperator = "<"
shouldIncrementVersion = true
case "", "=", "==":
newParts = append(newParts, ">="+flatVersion)
resultOperator = "<"
shouldIncrementVersion = true
case "!=", "!":
newParts = append(newParts, "<"+flatVersion)
resultOperator = ">="
shouldIncrementVersion = true
}
var resultVersion string
if shouldIncrementVersion {
switch versionWildcardType {
case patchWildcard:
resultVersion, _ = incrementMinorVersion(flatVersion)
case minorWildcard:
resultVersion, _ = incrementMajorVersion(flatVersion)
}
} else {
resultVersion = flatVersion
}
ap = resultOperator + resultVersion
}
newParts = append(newParts, ap)
}
expandedParts = append(expandedParts, newParts)
}
return expandedParts, nil
}
func parseComparator(s string) comparator {
switch s {
case "==":
fallthrough
case "":
fallthrough
case "=":
return compEQ
case ">":
return compGT
case ">=":
return compGE
case "<":
return compLT
case "<=":
return compLE
case "!":
fallthrough
case "!=":
return compNE
}
return nil
}
// MustParseRange is like ParseRange but panics if the range cannot be parsed.
func MustParseRange(s string) Range {
r, err := ParseRange(s)
if err != nil {
panic(`semver: ParseRange(` + s + `): ` + err.Error())
}
return r
}

View File

@@ -1,455 +0,0 @@
package semver
import (
"errors"
"fmt"
"strconv"
"strings"
)
const (
numbers string = "0123456789"
alphas = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"
alphanum = alphas + numbers
)
// SpecVersion is the latest fully supported spec version of semver
var SpecVersion = Version{
Major: 2,
Minor: 0,
Patch: 0,
}
// Version represents a semver compatible version
type Version struct {
Major uint64
Minor uint64
Patch uint64
Pre []PRVersion
Build []string //No Precedence
}
// Version to string
func (v Version) String() string {
b := make([]byte, 0, 5)
b = strconv.AppendUint(b, v.Major, 10)
b = append(b, '.')
b = strconv.AppendUint(b, v.Minor, 10)
b = append(b, '.')
b = strconv.AppendUint(b, v.Patch, 10)
if len(v.Pre) > 0 {
b = append(b, '-')
b = append(b, v.Pre[0].String()...)
for _, pre := range v.Pre[1:] {
b = append(b, '.')
b = append(b, pre.String()...)
}
}
if len(v.Build) > 0 {
b = append(b, '+')
b = append(b, v.Build[0]...)
for _, build := range v.Build[1:] {
b = append(b, '.')
b = append(b, build...)
}
}
return string(b)
}
// Equals checks if v is equal to o.
func (v Version) Equals(o Version) bool {
return (v.Compare(o) == 0)
}
// EQ checks if v is equal to o.
func (v Version) EQ(o Version) bool {
return (v.Compare(o) == 0)
}
// NE checks if v is not equal to o.
func (v Version) NE(o Version) bool {
return (v.Compare(o) != 0)
}
// GT checks if v is greater than o.
func (v Version) GT(o Version) bool {
return (v.Compare(o) == 1)
}
// GTE checks if v is greater than or equal to o.
func (v Version) GTE(o Version) bool {
return (v.Compare(o) >= 0)
}
// GE checks if v is greater than or equal to o.
func (v Version) GE(o Version) bool {
return (v.Compare(o) >= 0)
}
// LT checks if v is less than o.
func (v Version) LT(o Version) bool {
return (v.Compare(o) == -1)
}
// LTE checks if v is less than or equal to o.
func (v Version) LTE(o Version) bool {
return (v.Compare(o) <= 0)
}
// LE checks if v is less than or equal to o.
func (v Version) LE(o Version) bool {
return (v.Compare(o) <= 0)
}
// Compare compares Versions v to o:
// -1 == v is less than o
// 0 == v is equal to o
// 1 == v is greater than o
func (v Version) Compare(o Version) int {
if v.Major != o.Major {
if v.Major > o.Major {
return 1
}
return -1
}
if v.Minor != o.Minor {
if v.Minor > o.Minor {
return 1
}
return -1
}
if v.Patch != o.Patch {
if v.Patch > o.Patch {
return 1
}
return -1
}
// Quick comparison if a version has no prerelease versions
if len(v.Pre) == 0 && len(o.Pre) == 0 {
return 0
} else if len(v.Pre) == 0 && len(o.Pre) > 0 {
return 1
} else if len(v.Pre) > 0 && len(o.Pre) == 0 {
return -1
}
i := 0
for ; i < len(v.Pre) && i < len(o.Pre); i++ {
if comp := v.Pre[i].Compare(o.Pre[i]); comp == 0 {
continue
} else if comp == 1 {
return 1
} else {
return -1
}
}
// If all pr versions are the equal but one has further prversion, this one greater
if i == len(v.Pre) && i == len(o.Pre) {
return 0
} else if i == len(v.Pre) && i < len(o.Pre) {
return -1
} else {
return 1
}
}
// IncrementPatch increments the patch version
func (v *Version) IncrementPatch() error {
if v.Major == 0 {
return fmt.Errorf("Patch version can not be incremented for %q", v.String())
}
v.Patch += 1
return nil
}
// IncrementMinor increments the minor version
func (v *Version) IncrementMinor() error {
if v.Major == 0 {
return fmt.Errorf("Minor version can not be incremented for %q", v.String())
}
v.Minor += 1
v.Patch = 0
return nil
}
// IncrementMajor increments the major version
func (v *Version) IncrementMajor() error {
if v.Major == 0 {
return fmt.Errorf("Major version can not be incremented for %q", v.String())
}
v.Major += 1
v.Minor = 0
v.Patch = 0
return nil
}
// Validate validates v and returns error in case
func (v Version) Validate() error {
// Major, Minor, Patch already validated using uint64
for _, pre := range v.Pre {
if !pre.IsNum { //Numeric prerelease versions already uint64
if len(pre.VersionStr) == 0 {
return fmt.Errorf("Prerelease can not be empty %q", pre.VersionStr)
}
if !containsOnly(pre.VersionStr, alphanum) {
return fmt.Errorf("Invalid character(s) found in prerelease %q", pre.VersionStr)
}
}
}
for _, build := range v.Build {
if len(build) == 0 {
return fmt.Errorf("Build meta data can not be empty %q", build)
}
if !containsOnly(build, alphanum) {
return fmt.Errorf("Invalid character(s) found in build meta data %q", build)
}
}
return nil
}
// New is an alias for Parse and returns a pointer, parses version string and returns a validated Version or error
func New(s string) (vp *Version, err error) {
v, err := Parse(s)
vp = &v
return
}
// Make is an alias for Parse, parses version string and returns a validated Version or error
func Make(s string) (Version, error) {
return Parse(s)
}
// ParseTolerant allows for certain version specifications that do not strictly adhere to semver
// specs to be parsed by this library. It does so by normalizing versions before passing them to
// Parse(). It currently trims spaces, removes a "v" prefix, adds a 0 patch number to versions
// with only major and minor components specified, and removes leading 0s.
func ParseTolerant(s string) (Version, error) {
s = strings.TrimSpace(s)
s = strings.TrimPrefix(s, "v")
// Split into major.minor.(patch+pr+meta)
parts := strings.SplitN(s, ".", 3)
// Remove leading zeros.
for i, p := range parts {
if len(p) > 1 {
parts[i] = strings.TrimPrefix(p, "0")
}
}
// Fill up shortened versions.
if len(parts) < 3 {
if strings.ContainsAny(parts[len(parts)-1], "+-") {
return Version{}, errors.New("Short version cannot contain PreRelease/Build meta data")
}
for len(parts) < 3 {
parts = append(parts, "0")
}
}
s = strings.Join(parts, ".")
return Parse(s)
}
// Parse parses version string and returns a validated Version or error
func Parse(s string) (Version, error) {
if len(s) == 0 {
return Version{}, errors.New("Version string empty")
}
// Split into major.minor.(patch+pr+meta)
parts := strings.SplitN(s, ".", 3)
if len(parts) != 3 {
return Version{}, errors.New("No Major.Minor.Patch elements found")
}
// Major
if !containsOnly(parts[0], numbers) {
return Version{}, fmt.Errorf("Invalid character(s) found in major number %q", parts[0])
}
if hasLeadingZeroes(parts[0]) {
return Version{}, fmt.Errorf("Major number must not contain leading zeroes %q", parts[0])
}
major, err := strconv.ParseUint(parts[0], 10, 64)
if err != nil {
return Version{}, err
}
// Minor
if !containsOnly(parts[1], numbers) {
return Version{}, fmt.Errorf("Invalid character(s) found in minor number %q", parts[1])
}
if hasLeadingZeroes(parts[1]) {
return Version{}, fmt.Errorf("Minor number must not contain leading zeroes %q", parts[1])
}
minor, err := strconv.ParseUint(parts[1], 10, 64)
if err != nil {
return Version{}, err
}
v := Version{}
v.Major = major
v.Minor = minor
var build, prerelease []string
patchStr := parts[2]
if buildIndex := strings.IndexRune(patchStr, '+'); buildIndex != -1 {
build = strings.Split(patchStr[buildIndex+1:], ".")
patchStr = patchStr[:buildIndex]
}
if preIndex := strings.IndexRune(patchStr, '-'); preIndex != -1 {
prerelease = strings.Split(patchStr[preIndex+1:], ".")
patchStr = patchStr[:preIndex]
}
if !containsOnly(patchStr, numbers) {
return Version{}, fmt.Errorf("Invalid character(s) found in patch number %q", patchStr)
}
if hasLeadingZeroes(patchStr) {
return Version{}, fmt.Errorf("Patch number must not contain leading zeroes %q", patchStr)
}
patch, err := strconv.ParseUint(patchStr, 10, 64)
if err != nil {
return Version{}, err
}
v.Patch = patch
// Prerelease
for _, prstr := range prerelease {
parsedPR, err := NewPRVersion(prstr)
if err != nil {
return Version{}, err
}
v.Pre = append(v.Pre, parsedPR)
}
// Build meta data
for _, str := range build {
if len(str) == 0 {
return Version{}, errors.New("Build meta data is empty")
}
if !containsOnly(str, alphanum) {
return Version{}, fmt.Errorf("Invalid character(s) found in build meta data %q", str)
}
v.Build = append(v.Build, str)
}
return v, nil
}
// MustParse is like Parse but panics if the version cannot be parsed.
func MustParse(s string) Version {
v, err := Parse(s)
if err != nil {
panic(`semver: Parse(` + s + `): ` + err.Error())
}
return v
}
// PRVersion represents a PreRelease Version
type PRVersion struct {
VersionStr string
VersionNum uint64
IsNum bool
}
// NewPRVersion creates a new valid prerelease version
func NewPRVersion(s string) (PRVersion, error) {
if len(s) == 0 {
return PRVersion{}, errors.New("Prerelease is empty")
}
v := PRVersion{}
if containsOnly(s, numbers) {
if hasLeadingZeroes(s) {
return PRVersion{}, fmt.Errorf("Numeric PreRelease version must not contain leading zeroes %q", s)
}
num, err := strconv.ParseUint(s, 10, 64)
// Might never be hit, but just in case
if err != nil {
return PRVersion{}, err
}
v.VersionNum = num
v.IsNum = true
} else if containsOnly(s, alphanum) {
v.VersionStr = s
v.IsNum = false
} else {
return PRVersion{}, fmt.Errorf("Invalid character(s) found in prerelease %q", s)
}
return v, nil
}
// IsNumeric checks if prerelease-version is numeric
func (v PRVersion) IsNumeric() bool {
return v.IsNum
}
// Compare compares two PreRelease Versions v and o:
// -1 == v is less than o
// 0 == v is equal to o
// 1 == v is greater than o
func (v PRVersion) Compare(o PRVersion) int {
if v.IsNum && !o.IsNum {
return -1
} else if !v.IsNum && o.IsNum {
return 1
} else if v.IsNum && o.IsNum {
if v.VersionNum == o.VersionNum {
return 0
} else if v.VersionNum > o.VersionNum {
return 1
} else {
return -1
}
} else { // both are Alphas
if v.VersionStr == o.VersionStr {
return 0
} else if v.VersionStr > o.VersionStr {
return 1
} else {
return -1
}
}
}
// PreRelease version to string
func (v PRVersion) String() string {
if v.IsNum {
return strconv.FormatUint(v.VersionNum, 10)
}
return v.VersionStr
}
func containsOnly(s string, set string) bool {
return strings.IndexFunc(s, func(r rune) bool {
return !strings.ContainsRune(set, r)
}) == -1
}
func hasLeadingZeroes(s string) bool {
return len(s) > 1 && s[0] == '0'
}
// NewBuildVersion creates a new valid build version
func NewBuildVersion(s string) (string, error) {
if len(s) == 0 {
return "", errors.New("Buildversion is empty")
}
if !containsOnly(s, alphanum) {
return "", fmt.Errorf("Invalid character(s) found in build meta data %q", s)
}
return s, nil
}

View File

@@ -1,28 +0,0 @@
package semver
import (
"sort"
)
// Versions represents multiple versions.
type Versions []Version
// Len returns length of version collection
func (s Versions) Len() int {
return len(s)
}
// Swap swaps two versions inside the collection by its indices
func (s Versions) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// Less checks if version at index i is less than version at index j
func (s Versions) Less(i, j int) bool {
return s[i].LT(s[j])
}
// Sort sorts a slice of versions
func Sort(versions []Version) {
sort.Sort(Versions(versions))
}

View File

@@ -1,30 +0,0 @@
package semver
import (
"database/sql/driver"
"fmt"
)
// Scan implements the database/sql.Scanner interface.
func (v *Version) Scan(src interface{}) (err error) {
var str string
switch src := src.(type) {
case string:
str = src
case []byte:
str = string(src)
default:
return fmt.Errorf("version.Scan: cannot convert %T to string", src)
}
if t, err := Parse(str); err == nil {
*v = t
}
return
}
// Value implements the database/sql/driver.Valuer interface.
func (v Version) Value() (driver.Value, error) {
return v.String(), nil
}

View File

@@ -1,19 +1,60 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/containerd/containerd/api/events/container.proto // source: github.com/containerd/containerd/api/events/container.proto
/*
Package events is a generated protocol buffer package.
It is generated from these files:
github.com/containerd/containerd/api/events/container.proto
github.com/containerd/containerd/api/events/content.proto
github.com/containerd/containerd/api/events/image.proto
github.com/containerd/containerd/api/events/namespace.proto
github.com/containerd/containerd/api/events/snapshot.proto
github.com/containerd/containerd/api/events/task.proto
It has these top-level messages:
ContainerCreate
ContainerUpdate
ContainerDelete
ContentDelete
ImageCreate
ImageUpdate
ImageDelete
NamespaceCreate
NamespaceUpdate
NamespaceDelete
SnapshotPrepare
SnapshotCommit
SnapshotRemove
TaskCreate
TaskStart
TaskDelete
TaskIO
TaskExit
TaskOOM
TaskExecAdded
TaskExecStarted
TaskPaused
TaskResumed
TaskCheckpointed
*/
package events package events
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
github_com_containerd_typeurl "github.com/containerd/typeurl" import math "math"
proto "github.com/gogo/protobuf/proto" import google_protobuf "github.com/gogo/protobuf/types"
github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
types "github.com/gogo/protobuf/types" // skipping weak import gogoproto "github.com/gogo/protobuf/gogoproto"
io "io" // skipping weak import containerd_plugin "github.com/containerd/containerd/protobuf/plugin"
math "math"
reflect "reflect" import typeurl "github.com/containerd/typeurl"
strings "strings"
) import strings "strings"
import reflect "reflect"
import sortkeys "github.com/gogo/protobuf/sortkeys"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
@@ -27,209 +68,52 @@ var _ = math.Inf
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ContainerCreate struct { type ContainerCreate struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Image string `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"` Image string `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"`
Runtime *ContainerCreate_Runtime `protobuf:"bytes,3,opt,name=runtime,proto3" json:"runtime,omitempty"` Runtime *ContainerCreate_Runtime `protobuf:"bytes,3,opt,name=runtime" json:"runtime,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ContainerCreate) Reset() { *m = ContainerCreate{} } func (m *ContainerCreate) Reset() { *m = ContainerCreate{} }
func (*ContainerCreate) ProtoMessage() {} func (*ContainerCreate) ProtoMessage() {}
func (*ContainerCreate) Descriptor() ([]byte, []int) { func (*ContainerCreate) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{0} }
return fileDescriptor_0d1f05b8626f83ea, []int{0}
}
func (m *ContainerCreate) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ContainerCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ContainerCreate.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ContainerCreate) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContainerCreate.Merge(m, src)
}
func (m *ContainerCreate) XXX_Size() int {
return m.Size()
}
func (m *ContainerCreate) XXX_DiscardUnknown() {
xxx_messageInfo_ContainerCreate.DiscardUnknown(m)
}
var xxx_messageInfo_ContainerCreate proto.InternalMessageInfo
type ContainerCreate_Runtime struct { type ContainerCreate_Runtime struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Options *types.Any `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` Options *google_protobuf.Any `protobuf:"bytes,2,opt,name=options" json:"options,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ContainerCreate_Runtime) Reset() { *m = ContainerCreate_Runtime{} } func (m *ContainerCreate_Runtime) Reset() { *m = ContainerCreate_Runtime{} }
func (*ContainerCreate_Runtime) ProtoMessage() {} func (*ContainerCreate_Runtime) ProtoMessage() {}
func (*ContainerCreate_Runtime) Descriptor() ([]byte, []int) { func (*ContainerCreate_Runtime) Descriptor() ([]byte, []int) {
return fileDescriptor_0d1f05b8626f83ea, []int{0, 0} return fileDescriptorContainer, []int{0, 0}
} }
func (m *ContainerCreate_Runtime) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ContainerCreate_Runtime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ContainerCreate_Runtime.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ContainerCreate_Runtime) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContainerCreate_Runtime.Merge(m, src)
}
func (m *ContainerCreate_Runtime) XXX_Size() int {
return m.Size()
}
func (m *ContainerCreate_Runtime) XXX_DiscardUnknown() {
xxx_messageInfo_ContainerCreate_Runtime.DiscardUnknown(m)
}
var xxx_messageInfo_ContainerCreate_Runtime proto.InternalMessageInfo
type ContainerUpdate struct { type ContainerUpdate struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Image string `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"` Image string `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"`
Labels map[string]string `protobuf:"bytes,3,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Labels map[string]string `protobuf:"bytes,3,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
SnapshotKey string `protobuf:"bytes,4,opt,name=snapshot_key,json=snapshotKey,proto3" json:"snapshot_key,omitempty"` SnapshotKey string `protobuf:"bytes,4,opt,name=snapshot_key,json=snapshotKey,proto3" json:"snapshot_key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ContainerUpdate) Reset() { *m = ContainerUpdate{} } func (m *ContainerUpdate) Reset() { *m = ContainerUpdate{} }
func (*ContainerUpdate) ProtoMessage() {} func (*ContainerUpdate) ProtoMessage() {}
func (*ContainerUpdate) Descriptor() ([]byte, []int) { func (*ContainerUpdate) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{1} }
return fileDescriptor_0d1f05b8626f83ea, []int{1}
}
func (m *ContainerUpdate) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ContainerUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ContainerUpdate.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ContainerUpdate) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContainerUpdate.Merge(m, src)
}
func (m *ContainerUpdate) XXX_Size() int {
return m.Size()
}
func (m *ContainerUpdate) XXX_DiscardUnknown() {
xxx_messageInfo_ContainerUpdate.DiscardUnknown(m)
}
var xxx_messageInfo_ContainerUpdate proto.InternalMessageInfo
type ContainerDelete struct { type ContainerDelete struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ContainerDelete) Reset() { *m = ContainerDelete{} } func (m *ContainerDelete) Reset() { *m = ContainerDelete{} }
func (*ContainerDelete) ProtoMessage() {} func (*ContainerDelete) ProtoMessage() {}
func (*ContainerDelete) Descriptor() ([]byte, []int) { func (*ContainerDelete) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{2} }
return fileDescriptor_0d1f05b8626f83ea, []int{2}
}
func (m *ContainerDelete) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ContainerDelete) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ContainerDelete.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ContainerDelete) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContainerDelete.Merge(m, src)
}
func (m *ContainerDelete) XXX_Size() int {
return m.Size()
}
func (m *ContainerDelete) XXX_DiscardUnknown() {
xxx_messageInfo_ContainerDelete.DiscardUnknown(m)
}
var xxx_messageInfo_ContainerDelete proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*ContainerCreate)(nil), "containerd.events.ContainerCreate") proto.RegisterType((*ContainerCreate)(nil), "containerd.events.ContainerCreate")
proto.RegisterType((*ContainerCreate_Runtime)(nil), "containerd.events.ContainerCreate.Runtime") proto.RegisterType((*ContainerCreate_Runtime)(nil), "containerd.events.ContainerCreate.Runtime")
proto.RegisterType((*ContainerUpdate)(nil), "containerd.events.ContainerUpdate") proto.RegisterType((*ContainerUpdate)(nil), "containerd.events.ContainerUpdate")
proto.RegisterMapType((map[string]string)(nil), "containerd.events.ContainerUpdate.LabelsEntry")
proto.RegisterType((*ContainerDelete)(nil), "containerd.events.ContainerDelete") proto.RegisterType((*ContainerDelete)(nil), "containerd.events.ContainerDelete")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/container.proto", fileDescriptor_0d1f05b8626f83ea)
}
var fileDescriptor_0d1f05b8626f83ea = []byte{
// 413 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x0a, 0xd3, 0x30,
0x18, 0xc7, 0x97, 0x76, 0x6e, 0x98, 0x0a, 0x6a, 0x18, 0x52, 0x7b, 0xa8, 0x73, 0xa7, 0xe9, 0x21,
0x85, 0x7a, 0x51, 0x77, 0xd1, 0x6d, 0x0a, 0xa2, 0x82, 0x14, 0x84, 0xe1, 0x45, 0xd2, 0x35, 0xeb,
0x82, 0x6d, 0x52, 0xda, 0x74, 0xd0, 0x9b, 0x8f, 0xe2, 0xe3, 0xec, 0xe8, 0xc1, 0x83, 0x27, 0x71,
0x05, 0xdf, 0xc0, 0x07, 0x90, 0x26, 0xeb, 0x56, 0x14, 0x95, 0x9d, 0xfa, 0xcf, 0xd7, 0xff, 0x3f,
0xdf, 0xf7, 0xfb, 0x08, 0x9c, 0xc5, 0x4c, 0x6e, 0xcb, 0x10, 0xaf, 0x45, 0xea, 0xad, 0x05, 0x97,
0x84, 0x71, 0x9a, 0x47, 0x5d, 0x49, 0x32, 0xe6, 0xd1, 0x1d, 0xe5, 0xb2, 0x38, 0x57, 0x71, 0x96,
0x0b, 0x29, 0xd0, 0xcd, 0xb3, 0x0d, 0x6b, 0x8b, 0x73, 0x3b, 0x16, 0x22, 0x4e, 0xa8, 0xa7, 0x0c,
0x61, 0xb9, 0xf1, 0x08, 0xaf, 0xb4, 0xdb, 0x19, 0xc5, 0x22, 0x16, 0x4a, 0x7a, 0x8d, 0x3a, 0x56,
0x9f, 0xfc, 0x77, 0x80, 0xd3, 0x55, 0x59, 0x52, 0xc6, 0x8c, 0x7b, 0x1b, 0x46, 0x93, 0x28, 0x23,
0x72, 0xab, 0x6f, 0x98, 0x7c, 0x01, 0xf0, 0xfa, 0xa2, 0xb5, 0x2f, 0x72, 0x4a, 0x24, 0x45, 0xb7,
0xa0, 0xc1, 0x22, 0x1b, 0x8c, 0xc1, 0xf4, 0xea, 0x7c, 0x50, 0x7f, 0xbb, 0x63, 0xbc, 0x58, 0x06,
0x06, 0x8b, 0xd0, 0x08, 0x5e, 0x61, 0x29, 0x89, 0xa9, 0x6d, 0x34, 0xbf, 0x02, 0x7d, 0x40, 0x4b,
0x38, 0xcc, 0x4b, 0x2e, 0x59, 0x4a, 0x6d, 0x73, 0x0c, 0xa6, 0x96, 0x7f, 0x1f, 0xff, 0x41, 0x86,
0x7f, 0x6b, 0x81, 0x03, 0x9d, 0x08, 0xda, 0xa8, 0xf3, 0x1a, 0x0e, 0x8f, 0x35, 0x84, 0x60, 0x9f,
0x93, 0x94, 0xea, 0x01, 0x02, 0xa5, 0x11, 0x86, 0x43, 0x91, 0x49, 0x26, 0x78, 0xa1, 0x9a, 0x5b,
0xfe, 0x08, 0xeb, 0x5d, 0xe1, 0x16, 0x10, 0x3f, 0xe5, 0x55, 0xd0, 0x9a, 0x26, 0x3f, 0xba, 0x58,
0x6f, 0xb3, 0xe8, 0x72, 0xac, 0xe7, 0x70, 0x90, 0x90, 0x90, 0x26, 0x85, 0x6d, 0x8e, 0xcd, 0xa9,
0xe5, 0xe3, 0x7f, 0x51, 0xe9, 0x0e, 0xf8, 0x95, 0x0a, 0x3c, 0xe3, 0x32, 0xaf, 0x82, 0x63, 0x1a,
0xdd, 0x85, 0xd7, 0x0a, 0x4e, 0xb2, 0x62, 0x2b, 0xe4, 0xfb, 0x0f, 0xb4, 0xb2, 0xfb, 0xaa, 0x89,
0xd5, 0xd6, 0x5e, 0xd2, 0xca, 0x79, 0x04, 0xad, 0x4e, 0x12, 0xdd, 0x80, 0x66, 0x63, 0xd4, 0xf8,
0x8d, 0x6c, 0x26, 0xdc, 0x91, 0xa4, 0x3c, 0x4d, 0xa8, 0x0e, 0x8f, 0x8d, 0x87, 0x60, 0x72, 0xaf,
0x83, 0xb9, 0xa4, 0x09, 0xfd, 0x3b, 0xe6, 0xfc, 0xcd, 0xfe, 0xe0, 0xf6, 0xbe, 0x1e, 0xdc, 0xde,
0xc7, 0xda, 0x05, 0xfb, 0xda, 0x05, 0x9f, 0x6b, 0x17, 0x7c, 0xaf, 0x5d, 0xf0, 0xe9, 0xa7, 0x0b,
0xde, 0xf9, 0x17, 0x3c, 0xe5, 0x99, 0xfe, 0xac, 0xc0, 0xca, 0x08, 0x07, 0x6a, 0xff, 0x0f, 0x7e,
0x05, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x09, 0xe0, 0xd6, 0x0b, 0x03, 0x00, 0x00,
}
// Field returns the value for the given fieldpath as a string, if defined. // Field returns the value for the given fieldpath as a string, if defined.
// If the value is not defined, the second value will be false. // If the value is not defined, the second value will be false.
func (m *ContainerCreate) Field(fieldpath []string) (string, bool) { func (m *ContainerCreate) Field(fieldpath []string) (string, bool) {
@@ -269,7 +153,7 @@ func (m *ContainerCreate_Runtime) Field(fieldpath []string) (string, bool) {
case "name": case "name":
return string(m.Name), len(m.Name) > 0 return string(m.Name), len(m.Name) > 0
case "options": case "options":
decoded, err := github_com_containerd_typeurl.UnmarshalAny(m.Options) decoded, err := typeurl.UnmarshalAny(m.Options)
if err != nil { if err != nil {
return "", false return "", false
} }
@@ -359,9 +243,6 @@ func (m *ContainerCreate) MarshalTo(dAtA []byte) (int, error) {
} }
i += n1 i += n1
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -396,9 +277,6 @@ func (m *ContainerCreate_Runtime) MarshalTo(dAtA []byte) (int, error) {
} }
i += n2 i += n2
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -452,9 +330,6 @@ func (m *ContainerUpdate) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintContainer(dAtA, i, uint64(len(m.SnapshotKey))) i = encodeVarintContainer(dAtA, i, uint64(len(m.SnapshotKey)))
i += copy(dAtA[i:], m.SnapshotKey) i += copy(dAtA[i:], m.SnapshotKey)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -479,9 +354,6 @@ func (m *ContainerDelete) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintContainer(dAtA, i, uint64(len(m.ID))) i = encodeVarintContainer(dAtA, i, uint64(len(m.ID)))
i += copy(dAtA[i:], m.ID) i += copy(dAtA[i:], m.ID)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -495,9 +367,6 @@ func encodeVarintContainer(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *ContainerCreate) Size() (n int) { func (m *ContainerCreate) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.ID) l = len(m.ID)
@@ -512,16 +381,10 @@ func (m *ContainerCreate) Size() (n int) {
l = m.Runtime.Size() l = m.Runtime.Size()
n += 1 + l + sovContainer(uint64(l)) n += 1 + l + sovContainer(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *ContainerCreate_Runtime) Size() (n int) { func (m *ContainerCreate_Runtime) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Name) l = len(m.Name)
@@ -532,16 +395,10 @@ func (m *ContainerCreate_Runtime) Size() (n int) {
l = m.Options.Size() l = m.Options.Size()
n += 1 + l + sovContainer(uint64(l)) n += 1 + l + sovContainer(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *ContainerUpdate) Size() (n int) { func (m *ContainerUpdate) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.ID) l = len(m.ID)
@@ -564,25 +421,16 @@ func (m *ContainerUpdate) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovContainer(uint64(l)) n += 1 + l + sovContainer(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *ContainerDelete) Size() (n int) { func (m *ContainerDelete) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.ID) l = len(m.ID)
if l > 0 { if l > 0 {
n += 1 + l + sovContainer(uint64(l)) n += 1 + l + sovContainer(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -607,7 +455,6 @@ func (this *ContainerCreate) String() string {
`ID:` + fmt.Sprintf("%v", this.ID) + `,`, `ID:` + fmt.Sprintf("%v", this.ID) + `,`,
`Image:` + fmt.Sprintf("%v", this.Image) + `,`, `Image:` + fmt.Sprintf("%v", this.Image) + `,`,
`Runtime:` + strings.Replace(fmt.Sprintf("%v", this.Runtime), "ContainerCreate_Runtime", "ContainerCreate_Runtime", 1) + `,`, `Runtime:` + strings.Replace(fmt.Sprintf("%v", this.Runtime), "ContainerCreate_Runtime", "ContainerCreate_Runtime", 1) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -618,8 +465,7 @@ func (this *ContainerCreate_Runtime) String() string {
} }
s := strings.Join([]string{`&ContainerCreate_Runtime{`, s := strings.Join([]string{`&ContainerCreate_Runtime{`,
`Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
`Options:` + strings.Replace(fmt.Sprintf("%v", this.Options), "Any", "types.Any", 1) + `,`, `Options:` + strings.Replace(fmt.Sprintf("%v", this.Options), "Any", "google_protobuf.Any", 1) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -632,7 +478,7 @@ func (this *ContainerUpdate) String() string {
for k, _ := range this.Labels { for k, _ := range this.Labels {
keysForLabels = append(keysForLabels, k) keysForLabels = append(keysForLabels, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForLabels) sortkeys.Strings(keysForLabels)
mapStringForLabels := "map[string]string{" mapStringForLabels := "map[string]string{"
for _, k := range keysForLabels { for _, k := range keysForLabels {
mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k]) mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k])
@@ -643,7 +489,6 @@ func (this *ContainerUpdate) String() string {
`Image:` + fmt.Sprintf("%v", this.Image) + `,`, `Image:` + fmt.Sprintf("%v", this.Image) + `,`,
`Labels:` + mapStringForLabels + `,`, `Labels:` + mapStringForLabels + `,`,
`SnapshotKey:` + fmt.Sprintf("%v", this.SnapshotKey) + `,`, `SnapshotKey:` + fmt.Sprintf("%v", this.SnapshotKey) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -654,7 +499,6 @@ func (this *ContainerDelete) String() string {
} }
s := strings.Join([]string{`&ContainerDelete{`, s := strings.Join([]string{`&ContainerDelete{`,
`ID:` + fmt.Sprintf("%v", this.ID) + `,`, `ID:` + fmt.Sprintf("%v", this.ID) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -682,7 +526,7 @@ func (m *ContainerCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -710,7 +554,7 @@ func (m *ContainerCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -720,9 +564,6 @@ func (m *ContainerCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -742,7 +583,7 @@ func (m *ContainerCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -752,9 +593,6 @@ func (m *ContainerCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -774,7 +612,7 @@ func (m *ContainerCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -783,9 +621,6 @@ func (m *ContainerCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -805,13 +640,9 @@ func (m *ContainerCreate) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthContainer
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -836,7 +667,7 @@ func (m *ContainerCreate_Runtime) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -864,7 +695,7 @@ func (m *ContainerCreate_Runtime) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -874,9 +705,6 @@ func (m *ContainerCreate_Runtime) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -896,7 +724,7 @@ func (m *ContainerCreate_Runtime) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -905,14 +733,11 @@ func (m *ContainerCreate_Runtime) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if m.Options == nil { if m.Options == nil {
m.Options = &types.Any{} m.Options = &google_protobuf.Any{}
} }
if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err return err
@@ -927,13 +752,9 @@ func (m *ContainerCreate_Runtime) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthContainer
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -958,7 +779,7 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -986,7 +807,7 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -996,9 +817,6 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -1018,7 +836,7 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -1028,9 +846,6 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -1050,7 +865,7 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -1059,9 +874,6 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -1082,7 +894,7 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -1099,7 +911,7 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift stringLenmapkey |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -1109,9 +921,6 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postStringIndexmapkey := iNdEx + intStringLenmapkey postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthContainer
}
if postStringIndexmapkey > l { if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -1128,7 +937,7 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift stringLenmapvalue |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -1138,9 +947,6 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postStringIndexmapvalue := iNdEx + intStringLenmapvalue postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthContainer
}
if postStringIndexmapvalue > l { if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -1177,7 +983,7 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -1187,9 +993,6 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -1204,13 +1007,9 @@ func (m *ContainerUpdate) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthContainer
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -1235,7 +1034,7 @@ func (m *ContainerDelete) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -1263,7 +1062,7 @@ func (m *ContainerDelete) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -1273,9 +1072,6 @@ func (m *ContainerDelete) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthContainer
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -1290,13 +1086,9 @@ func (m *ContainerDelete) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthContainer return ErrInvalidLengthContainer
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthContainer
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -1360,11 +1152,8 @@ func skipContainer(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthContainer
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthContainer return 0, ErrInvalidLengthContainer
} }
return iNdEx, nil return iNdEx, nil
@@ -1395,9 +1184,6 @@ func skipContainer(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthContainer
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -1416,3 +1202,37 @@ var (
ErrInvalidLengthContainer = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthContainer = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowContainer = fmt.Errorf("proto: integer overflow") ErrIntOverflowContainer = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/container.proto", fileDescriptorContainer)
}
var fileDescriptorContainer = []byte{
// 413 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x0a, 0xd3, 0x30,
0x18, 0xc7, 0x97, 0x76, 0x6e, 0x98, 0x0a, 0x6a, 0x18, 0x52, 0x7b, 0xa8, 0x73, 0xa7, 0xe9, 0x21,
0x85, 0x7a, 0x51, 0x77, 0xd1, 0x6d, 0x0a, 0xa2, 0x82, 0x14, 0x84, 0xe1, 0x45, 0xd2, 0x35, 0xeb,
0x82, 0x6d, 0x52, 0xda, 0x74, 0xd0, 0x9b, 0x8f, 0xe2, 0xe3, 0xec, 0xe8, 0xc1, 0x83, 0x27, 0x71,
0x05, 0xdf, 0xc0, 0x07, 0x90, 0x26, 0xeb, 0x56, 0x14, 0x95, 0x9d, 0xfa, 0xcf, 0xd7, 0xff, 0x3f,
0xdf, 0xf7, 0xfb, 0x08, 0x9c, 0xc5, 0x4c, 0x6e, 0xcb, 0x10, 0xaf, 0x45, 0xea, 0xad, 0x05, 0x97,
0x84, 0x71, 0x9a, 0x47, 0x5d, 0x49, 0x32, 0xe6, 0xd1, 0x1d, 0xe5, 0xb2, 0x38, 0x57, 0x71, 0x96,
0x0b, 0x29, 0xd0, 0xcd, 0xb3, 0x0d, 0x6b, 0x8b, 0x73, 0x3b, 0x16, 0x22, 0x4e, 0xa8, 0xa7, 0x0c,
0x61, 0xb9, 0xf1, 0x08, 0xaf, 0xb4, 0xdb, 0x19, 0xc5, 0x22, 0x16, 0x4a, 0x7a, 0x8d, 0x3a, 0x56,
0x9f, 0xfc, 0x77, 0x80, 0xd3, 0x55, 0x59, 0x52, 0xc6, 0x8c, 0x7b, 0x1b, 0x46, 0x93, 0x28, 0x23,
0x72, 0xab, 0x6f, 0x98, 0x7c, 0x01, 0xf0, 0xfa, 0xa2, 0xb5, 0x2f, 0x72, 0x4a, 0x24, 0x45, 0xb7,
0xa0, 0xc1, 0x22, 0x1b, 0x8c, 0xc1, 0xf4, 0xea, 0x7c, 0x50, 0x7f, 0xbb, 0x63, 0xbc, 0x58, 0x06,
0x06, 0x8b, 0xd0, 0x08, 0x5e, 0x61, 0x29, 0x89, 0xa9, 0x6d, 0x34, 0xbf, 0x02, 0x7d, 0x40, 0x4b,
0x38, 0xcc, 0x4b, 0x2e, 0x59, 0x4a, 0x6d, 0x73, 0x0c, 0xa6, 0x96, 0x7f, 0x1f, 0xff, 0x41, 0x86,
0x7f, 0x6b, 0x81, 0x03, 0x9d, 0x08, 0xda, 0xa8, 0xf3, 0x1a, 0x0e, 0x8f, 0x35, 0x84, 0x60, 0x9f,
0x93, 0x94, 0xea, 0x01, 0x02, 0xa5, 0x11, 0x86, 0x43, 0x91, 0x49, 0x26, 0x78, 0xa1, 0x9a, 0x5b,
0xfe, 0x08, 0xeb, 0x5d, 0xe1, 0x16, 0x10, 0x3f, 0xe5, 0x55, 0xd0, 0x9a, 0x26, 0x3f, 0xba, 0x58,
0x6f, 0xb3, 0xe8, 0x72, 0xac, 0xe7, 0x70, 0x90, 0x90, 0x90, 0x26, 0x85, 0x6d, 0x8e, 0xcd, 0xa9,
0xe5, 0xe3, 0x7f, 0x51, 0xe9, 0x0e, 0xf8, 0x95, 0x0a, 0x3c, 0xe3, 0x32, 0xaf, 0x82, 0x63, 0x1a,
0xdd, 0x85, 0xd7, 0x0a, 0x4e, 0xb2, 0x62, 0x2b, 0xe4, 0xfb, 0x0f, 0xb4, 0xb2, 0xfb, 0xaa, 0x89,
0xd5, 0xd6, 0x5e, 0xd2, 0xca, 0x79, 0x04, 0xad, 0x4e, 0x12, 0xdd, 0x80, 0x66, 0x63, 0xd4, 0xf8,
0x8d, 0x6c, 0x26, 0xdc, 0x91, 0xa4, 0x3c, 0x4d, 0xa8, 0x0e, 0x8f, 0x8d, 0x87, 0x60, 0x72, 0xaf,
0x83, 0xb9, 0xa4, 0x09, 0xfd, 0x3b, 0xe6, 0xfc, 0xcd, 0xfe, 0xe0, 0xf6, 0xbe, 0x1e, 0xdc, 0xde,
0xc7, 0xda, 0x05, 0xfb, 0xda, 0x05, 0x9f, 0x6b, 0x17, 0x7c, 0xaf, 0x5d, 0xf0, 0xe9, 0xa7, 0x0b,
0xde, 0xf9, 0x17, 0x3c, 0xe5, 0x99, 0xfe, 0xac, 0xc0, 0xca, 0x08, 0x07, 0x6a, 0xff, 0x0f, 0x7e,
0x05, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x09, 0xe0, 0xd6, 0x0b, 0x03, 0x00, 0x00,
}

View File

@@ -3,93 +3,37 @@
package events package events
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
github_com_opencontainers_go_digest "github.com/opencontainers/go-digest"
io "io" // skipping weak import gogoproto "github.com/gogo/protobuf/gogoproto"
math "math" // skipping weak import containerd_plugin "github.com/containerd/containerd/protobuf/plugin"
reflect "reflect"
strings "strings" import github_com_opencontainers_go_digest "github.com/opencontainers/go-digest"
)
import strings "strings"
import reflect "reflect"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ContentDelete struct { type ContentDelete struct {
Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,1,opt,name=digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"digest"` Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,1,opt,name=digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"digest"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ContentDelete) Reset() { *m = ContentDelete{} } func (m *ContentDelete) Reset() { *m = ContentDelete{} }
func (*ContentDelete) ProtoMessage() {} func (*ContentDelete) ProtoMessage() {}
func (*ContentDelete) Descriptor() ([]byte, []int) { func (*ContentDelete) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{0} }
return fileDescriptor_dfb34b8b808e2ecd, []int{0}
}
func (m *ContentDelete) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ContentDelete) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ContentDelete.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ContentDelete) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContentDelete.Merge(m, src)
}
func (m *ContentDelete) XXX_Size() int {
return m.Size()
}
func (m *ContentDelete) XXX_DiscardUnknown() {
xxx_messageInfo_ContentDelete.DiscardUnknown(m)
}
var xxx_messageInfo_ContentDelete proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*ContentDelete)(nil), "containerd.events.ContentDelete") proto.RegisterType((*ContentDelete)(nil), "containerd.events.ContentDelete")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/content.proto", fileDescriptor_dfb34b8b808e2ecd)
}
var fileDescriptor_dfb34b8b808e2ecd = []byte{
// 228 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0x83, 0x45, 0x53,
0xf3, 0x4a, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0x11, 0x8a, 0xf4, 0x20, 0x0a, 0xa4,
0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, 0xa1, 0x94, 0x03, 0x41, 0x3b,
0xc0, 0xea, 0x92, 0x4a, 0xd3, 0xf4, 0x0b, 0x72, 0x4a, 0xd3, 0x33, 0xf3, 0xf4, 0xd3, 0x32, 0x53,
0x73, 0x52, 0x0a, 0x12, 0x4b, 0x32, 0x20, 0x26, 0x28, 0x45, 0x73, 0xf1, 0x3a, 0x43, 0xec, 0x76,
0x49, 0xcd, 0x49, 0x2d, 0x49, 0x15, 0xf2, 0xe2, 0x62, 0x4b, 0xc9, 0x4c, 0x4f, 0x2d, 0x2e, 0x91,
0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x32, 0x3a, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0x2d,
0x24, 0xab, 0xf2, 0x0b, 0x52, 0xf3, 0xe0, 0x76, 0x14, 0xeb, 0xa7, 0xe7, 0xeb, 0x42, 0xb4, 0xe8,
0xb9, 0x80, 0xa9, 0x20, 0xa8, 0x09, 0x4e, 0x01, 0x27, 0x1e, 0xca, 0x31, 0xdc, 0x78, 0x28, 0xc7,
0xd0, 0xf0, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92,
0x63, 0x5c, 0xf0, 0x45, 0x8e, 0x31, 0xca, 0x88, 0x84, 0x00, 0xb2, 0x86, 0x50, 0x11, 0x0c, 0x11,
0x8c, 0x49, 0x6c, 0x60, 0x97, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x78, 0x99, 0xee,
0x61, 0x01, 0x00, 0x00,
}
// Field returns the value for the given fieldpath as a string, if defined. // Field returns the value for the given fieldpath as a string, if defined.
// If the value is not defined, the second value will be false. // If the value is not defined, the second value will be false.
func (m *ContentDelete) Field(fieldpath []string) (string, bool) { func (m *ContentDelete) Field(fieldpath []string) (string, bool) {
@@ -124,9 +68,6 @@ func (m *ContentDelete) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintContent(dAtA, i, uint64(len(m.Digest))) i = encodeVarintContent(dAtA, i, uint64(len(m.Digest)))
i += copy(dAtA[i:], m.Digest) i += copy(dAtA[i:], m.Digest)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -140,18 +81,12 @@ func encodeVarintContent(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *ContentDelete) Size() (n int) { func (m *ContentDelete) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Digest) l = len(m.Digest)
if l > 0 { if l > 0 {
n += 1 + l + sovContent(uint64(l)) n += 1 + l + sovContent(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -174,7 +109,6 @@ func (this *ContentDelete) String() string {
} }
s := strings.Join([]string{`&ContentDelete{`, s := strings.Join([]string{`&ContentDelete{`,
`Digest:` + fmt.Sprintf("%v", this.Digest) + `,`, `Digest:` + fmt.Sprintf("%v", this.Digest) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -202,7 +136,7 @@ func (m *ContentDelete) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -230,7 +164,7 @@ func (m *ContentDelete) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -240,9 +174,6 @@ func (m *ContentDelete) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthContent return ErrInvalidLengthContent
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthContent
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -257,13 +188,9 @@ func (m *ContentDelete) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthContent return ErrInvalidLengthContent
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthContent
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -327,11 +254,8 @@ func skipContent(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthContent
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthContent return 0, ErrInvalidLengthContent
} }
return iNdEx, nil return iNdEx, nil
@@ -362,9 +286,6 @@ func skipContent(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthContent
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -383,3 +304,26 @@ var (
ErrInvalidLengthContent = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthContent = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowContent = fmt.Errorf("proto: integer overflow") ErrIntOverflowContent = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/content.proto", fileDescriptorContent)
}
var fileDescriptorContent = []byte{
// 228 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0x83, 0x45, 0x53,
0xf3, 0x4a, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0x11, 0x8a, 0xf4, 0x20, 0x0a, 0xa4,
0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, 0xa1, 0x94, 0x03, 0x41, 0x3b,
0xc0, 0xea, 0x92, 0x4a, 0xd3, 0xf4, 0x0b, 0x72, 0x4a, 0xd3, 0x33, 0xf3, 0xf4, 0xd3, 0x32, 0x53,
0x73, 0x52, 0x0a, 0x12, 0x4b, 0x32, 0x20, 0x26, 0x28, 0x45, 0x73, 0xf1, 0x3a, 0x43, 0xec, 0x76,
0x49, 0xcd, 0x49, 0x2d, 0x49, 0x15, 0xf2, 0xe2, 0x62, 0x4b, 0xc9, 0x4c, 0x4f, 0x2d, 0x2e, 0x91,
0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x32, 0x3a, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0x2d,
0x24, 0xab, 0xf2, 0x0b, 0x52, 0xf3, 0xe0, 0x76, 0x14, 0xeb, 0xa7, 0xe7, 0xeb, 0x42, 0xb4, 0xe8,
0xb9, 0x80, 0xa9, 0x20, 0xa8, 0x09, 0x4e, 0x01, 0x27, 0x1e, 0xca, 0x31, 0xdc, 0x78, 0x28, 0xc7,
0xd0, 0xf0, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92,
0x63, 0x5c, 0xf0, 0x45, 0x8e, 0x31, 0xca, 0x88, 0x84, 0x00, 0xb2, 0x86, 0x50, 0x11, 0x0c, 0x11,
0x8c, 0x49, 0x6c, 0x60, 0x97, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x78, 0x99, 0xee,
0x61, 0x01, 0x00, 0x00,
}

View File

@@ -3,181 +3,55 @@
package events package events
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
io "io" // skipping weak import containerd_plugin "github.com/containerd/containerd/protobuf/plugin"
math "math"
reflect "reflect" import strings "strings"
strings "strings" import reflect "reflect"
) import sortkeys "github.com/gogo/protobuf/sortkeys"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ImageCreate struct { type ImageCreate struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Labels map[string]string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Labels map[string]string `protobuf:"bytes,2,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ImageCreate) Reset() { *m = ImageCreate{} } func (m *ImageCreate) Reset() { *m = ImageCreate{} }
func (*ImageCreate) ProtoMessage() {} func (*ImageCreate) ProtoMessage() {}
func (*ImageCreate) Descriptor() ([]byte, []int) { func (*ImageCreate) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{0} }
return fileDescriptor_7085610f7b33e042, []int{0}
}
func (m *ImageCreate) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ImageCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ImageCreate.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ImageCreate) XXX_Merge(src proto.Message) {
xxx_messageInfo_ImageCreate.Merge(m, src)
}
func (m *ImageCreate) XXX_Size() int {
return m.Size()
}
func (m *ImageCreate) XXX_DiscardUnknown() {
xxx_messageInfo_ImageCreate.DiscardUnknown(m)
}
var xxx_messageInfo_ImageCreate proto.InternalMessageInfo
type ImageUpdate struct { type ImageUpdate struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Labels map[string]string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Labels map[string]string `protobuf:"bytes,2,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ImageUpdate) Reset() { *m = ImageUpdate{} } func (m *ImageUpdate) Reset() { *m = ImageUpdate{} }
func (*ImageUpdate) ProtoMessage() {} func (*ImageUpdate) ProtoMessage() {}
func (*ImageUpdate) Descriptor() ([]byte, []int) { func (*ImageUpdate) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{1} }
return fileDescriptor_7085610f7b33e042, []int{1}
}
func (m *ImageUpdate) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ImageUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ImageUpdate.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ImageUpdate) XXX_Merge(src proto.Message) {
xxx_messageInfo_ImageUpdate.Merge(m, src)
}
func (m *ImageUpdate) XXX_Size() int {
return m.Size()
}
func (m *ImageUpdate) XXX_DiscardUnknown() {
xxx_messageInfo_ImageUpdate.DiscardUnknown(m)
}
var xxx_messageInfo_ImageUpdate proto.InternalMessageInfo
type ImageDelete struct { type ImageDelete struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ImageDelete) Reset() { *m = ImageDelete{} } func (m *ImageDelete) Reset() { *m = ImageDelete{} }
func (*ImageDelete) ProtoMessage() {} func (*ImageDelete) ProtoMessage() {}
func (*ImageDelete) Descriptor() ([]byte, []int) { func (*ImageDelete) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{2} }
return fileDescriptor_7085610f7b33e042, []int{2}
}
func (m *ImageDelete) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ImageDelete) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ImageDelete.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ImageDelete) XXX_Merge(src proto.Message) {
xxx_messageInfo_ImageDelete.Merge(m, src)
}
func (m *ImageDelete) XXX_Size() int {
return m.Size()
}
func (m *ImageDelete) XXX_DiscardUnknown() {
xxx_messageInfo_ImageDelete.DiscardUnknown(m)
}
var xxx_messageInfo_ImageDelete proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*ImageCreate)(nil), "containerd.services.images.v1.ImageCreate") proto.RegisterType((*ImageCreate)(nil), "containerd.services.images.v1.ImageCreate")
proto.RegisterMapType((map[string]string)(nil), "containerd.services.images.v1.ImageCreate.LabelsEntry")
proto.RegisterType((*ImageUpdate)(nil), "containerd.services.images.v1.ImageUpdate") proto.RegisterType((*ImageUpdate)(nil), "containerd.services.images.v1.ImageUpdate")
proto.RegisterMapType((map[string]string)(nil), "containerd.services.images.v1.ImageUpdate.LabelsEntry")
proto.RegisterType((*ImageDelete)(nil), "containerd.services.images.v1.ImageDelete") proto.RegisterType((*ImageDelete)(nil), "containerd.services.images.v1.ImageDelete")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/image.proto", fileDescriptor_7085610f7b33e042)
}
var fileDescriptor_7085610f7b33e042 = []byte{
// 292 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4f, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x67, 0xe6,
0x26, 0xa6, 0xa7, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0x94, 0xe8, 0x15, 0xa7,
0x16, 0x95, 0x65, 0x26, 0xa7, 0x16, 0xeb, 0x81, 0x15, 0x14, 0xeb, 0x95, 0x19, 0x4a, 0x39, 0x10,
0x34, 0x17, 0x6c, 0x4c, 0x52, 0x69, 0x9a, 0x7e, 0x41, 0x4e, 0x69, 0x7a, 0x66, 0x9e, 0x7e, 0x5a,
0x66, 0x6a, 0x4e, 0x4a, 0x41, 0x62, 0x49, 0x06, 0xc4, 0x02, 0xa5, 0x35, 0x8c, 0x5c, 0xdc, 0x9e,
0x20, 0xf3, 0x9c, 0x8b, 0x52, 0x13, 0x4b, 0x52, 0x85, 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53,
0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, 0x21, 0x3f, 0x2e, 0xb6, 0x9c, 0xc4, 0xa4,
0xd4, 0x9c, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x33, 0x3d, 0xbc, 0xae, 0xd2, 0x43,
0x32, 0x4f, 0xcf, 0x07, 0xac, 0xd1, 0x35, 0xaf, 0xa4, 0xa8, 0x32, 0x08, 0x6a, 0x8a, 0x94, 0x25,
0x17, 0x37, 0x92, 0xb0, 0x90, 0x00, 0x17, 0x73, 0x76, 0x6a, 0x25, 0xd4, 0x46, 0x10, 0x53, 0x48,
0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x09, 0x2c, 0x06, 0xe1, 0x58, 0x31, 0x59,
0x30, 0x22, 0x9c, 0x1b, 0x5a, 0x90, 0x42, 0x55, 0xe7, 0x42, 0xcc, 0xa3, 0xb6, 0x73, 0x15, 0xa1,
0xae, 0x75, 0x49, 0xcd, 0x49, 0xc5, 0xee, 0x5a, 0xa7, 0x80, 0x13, 0x0f, 0xe5, 0x18, 0x6e, 0x3c,
0x94, 0x63, 0x68, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f,
0x1e, 0xc9, 0x31, 0x2e, 0xf8, 0x22, 0xc7, 0x18, 0x65, 0x44, 0x42, 0xc2, 0xb1, 0x86, 0x50, 0x11,
0x0c, 0x49, 0x6c, 0xe0, 0xb8, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x41, 0x80, 0x92, 0x17,
0x77, 0x02, 0x00, 0x00,
}
// Field returns the value for the given fieldpath as a string, if defined. // Field returns the value for the given fieldpath as a string, if defined.
// If the value is not defined, the second value will be false. // If the value is not defined, the second value will be false.
func (m *ImageCreate) Field(fieldpath []string) (string, bool) { func (m *ImageCreate) Field(fieldpath []string) (string, bool) {
@@ -273,9 +147,6 @@ func (m *ImageCreate) MarshalTo(dAtA []byte) (int, error) {
i += copy(dAtA[i:], v) i += copy(dAtA[i:], v)
} }
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -317,9 +188,6 @@ func (m *ImageUpdate) MarshalTo(dAtA []byte) (int, error) {
i += copy(dAtA[i:], v) i += copy(dAtA[i:], v)
} }
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -344,9 +212,6 @@ func (m *ImageDelete) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintImage(dAtA, i, uint64(len(m.Name))) i = encodeVarintImage(dAtA, i, uint64(len(m.Name)))
i += copy(dAtA[i:], m.Name) i += copy(dAtA[i:], m.Name)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -360,9 +225,6 @@ func encodeVarintImage(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *ImageCreate) Size() (n int) { func (m *ImageCreate) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Name) l = len(m.Name)
@@ -377,16 +239,10 @@ func (m *ImageCreate) Size() (n int) {
n += mapEntrySize + 1 + sovImage(uint64(mapEntrySize)) n += mapEntrySize + 1 + sovImage(uint64(mapEntrySize))
} }
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *ImageUpdate) Size() (n int) { func (m *ImageUpdate) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Name) l = len(m.Name)
@@ -401,25 +257,16 @@ func (m *ImageUpdate) Size() (n int) {
n += mapEntrySize + 1 + sovImage(uint64(mapEntrySize)) n += mapEntrySize + 1 + sovImage(uint64(mapEntrySize))
} }
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *ImageDelete) Size() (n int) { func (m *ImageDelete) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Name) l = len(m.Name)
if l > 0 { if l > 0 {
n += 1 + l + sovImage(uint64(l)) n += 1 + l + sovImage(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -444,7 +291,7 @@ func (this *ImageCreate) String() string {
for k, _ := range this.Labels { for k, _ := range this.Labels {
keysForLabels = append(keysForLabels, k) keysForLabels = append(keysForLabels, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForLabels) sortkeys.Strings(keysForLabels)
mapStringForLabels := "map[string]string{" mapStringForLabels := "map[string]string{"
for _, k := range keysForLabels { for _, k := range keysForLabels {
mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k]) mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k])
@@ -453,7 +300,6 @@ func (this *ImageCreate) String() string {
s := strings.Join([]string{`&ImageCreate{`, s := strings.Join([]string{`&ImageCreate{`,
`Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
`Labels:` + mapStringForLabels + `,`, `Labels:` + mapStringForLabels + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -466,7 +312,7 @@ func (this *ImageUpdate) String() string {
for k, _ := range this.Labels { for k, _ := range this.Labels {
keysForLabels = append(keysForLabels, k) keysForLabels = append(keysForLabels, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForLabels) sortkeys.Strings(keysForLabels)
mapStringForLabels := "map[string]string{" mapStringForLabels := "map[string]string{"
for _, k := range keysForLabels { for _, k := range keysForLabels {
mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k]) mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k])
@@ -475,7 +321,6 @@ func (this *ImageUpdate) String() string {
s := strings.Join([]string{`&ImageUpdate{`, s := strings.Join([]string{`&ImageUpdate{`,
`Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
`Labels:` + mapStringForLabels + `,`, `Labels:` + mapStringForLabels + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -486,7 +331,6 @@ func (this *ImageDelete) String() string {
} }
s := strings.Join([]string{`&ImageDelete{`, s := strings.Join([]string{`&ImageDelete{`,
`Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -514,7 +358,7 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -542,7 +386,7 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -552,9 +396,6 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthImage
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -574,7 +415,7 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -583,9 +424,6 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthImage
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -606,7 +444,7 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -623,7 +461,7 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift stringLenmapkey |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -633,9 +471,6 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postStringIndexmapkey := iNdEx + intStringLenmapkey postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthImage
}
if postStringIndexmapkey > l { if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -652,7 +487,7 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift stringLenmapvalue |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -662,9 +497,6 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postStringIndexmapvalue := iNdEx + intStringLenmapvalue postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthImage
}
if postStringIndexmapvalue > l { if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -696,13 +528,9 @@ func (m *ImageCreate) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthImage
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -727,7 +555,7 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -755,7 +583,7 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -765,9 +593,6 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthImage
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -787,7 +612,7 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -796,9 +621,6 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthImage
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -819,7 +641,7 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -836,7 +658,7 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift stringLenmapkey |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -846,9 +668,6 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postStringIndexmapkey := iNdEx + intStringLenmapkey postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthImage
}
if postStringIndexmapkey > l { if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -865,7 +684,7 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift stringLenmapvalue |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -875,9 +694,6 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postStringIndexmapvalue := iNdEx + intStringLenmapvalue postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthImage
}
if postStringIndexmapvalue > l { if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -909,13 +725,9 @@ func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthImage
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -940,7 +752,7 @@ func (m *ImageDelete) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -968,7 +780,7 @@ func (m *ImageDelete) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -978,9 +790,6 @@ func (m *ImageDelete) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthImage
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -995,13 +804,9 @@ func (m *ImageDelete) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthImage return ErrInvalidLengthImage
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthImage
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -1065,11 +870,8 @@ func skipImage(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthImage
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthImage return 0, ErrInvalidLengthImage
} }
return iNdEx, nil return iNdEx, nil
@@ -1100,9 +902,6 @@ func skipImage(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthImage
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -1121,3 +920,30 @@ var (
ErrInvalidLengthImage = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthImage = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowImage = fmt.Errorf("proto: integer overflow") ErrIntOverflowImage = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/image.proto", fileDescriptorImage)
}
var fileDescriptorImage = []byte{
// 292 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4f, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x67, 0xe6,
0x26, 0xa6, 0xa7, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0x94, 0xe8, 0x15, 0xa7,
0x16, 0x95, 0x65, 0x26, 0xa7, 0x16, 0xeb, 0x81, 0x15, 0x14, 0xeb, 0x95, 0x19, 0x4a, 0x39, 0x10,
0x34, 0x17, 0x6c, 0x4c, 0x52, 0x69, 0x9a, 0x7e, 0x41, 0x4e, 0x69, 0x7a, 0x66, 0x9e, 0x7e, 0x5a,
0x66, 0x6a, 0x4e, 0x4a, 0x41, 0x62, 0x49, 0x06, 0xc4, 0x02, 0xa5, 0x35, 0x8c, 0x5c, 0xdc, 0x9e,
0x20, 0xf3, 0x9c, 0x8b, 0x52, 0x13, 0x4b, 0x52, 0x85, 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53,
0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, 0x21, 0x3f, 0x2e, 0xb6, 0x9c, 0xc4, 0xa4,
0xd4, 0x9c, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x33, 0x3d, 0xbc, 0xae, 0xd2, 0x43,
0x32, 0x4f, 0xcf, 0x07, 0xac, 0xd1, 0x35, 0xaf, 0xa4, 0xa8, 0x32, 0x08, 0x6a, 0x8a, 0x94, 0x25,
0x17, 0x37, 0x92, 0xb0, 0x90, 0x00, 0x17, 0x73, 0x76, 0x6a, 0x25, 0xd4, 0x46, 0x10, 0x53, 0x48,
0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x09, 0x2c, 0x06, 0xe1, 0x58, 0x31, 0x59,
0x30, 0x22, 0x9c, 0x1b, 0x5a, 0x90, 0x42, 0x55, 0xe7, 0x42, 0xcc, 0xa3, 0xb6, 0x73, 0x15, 0xa1,
0xae, 0x75, 0x49, 0xcd, 0x49, 0xc5, 0xee, 0x5a, 0xa7, 0x80, 0x13, 0x0f, 0xe5, 0x18, 0x6e, 0x3c,
0x94, 0x63, 0x68, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f,
0x1e, 0xc9, 0x31, 0x2e, 0xf8, 0x22, 0xc7, 0x18, 0x65, 0x44, 0x42, 0xc2, 0xb1, 0x86, 0x50, 0x11,
0x0c, 0x49, 0x6c, 0xe0, 0xb8, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x41, 0x80, 0x92, 0x17,
0x77, 0x02, 0x00, 0x00,
}

View File

@@ -3,181 +3,56 @@
package events package events
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
io "io" // skipping weak import gogoproto "github.com/gogo/protobuf/gogoproto"
math "math" // skipping weak import containerd_plugin "github.com/containerd/containerd/protobuf/plugin"
reflect "reflect"
strings "strings" import strings "strings"
) import reflect "reflect"
import sortkeys "github.com/gogo/protobuf/sortkeys"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type NamespaceCreate struct { type NamespaceCreate struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Labels map[string]string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Labels map[string]string `protobuf:"bytes,2,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *NamespaceCreate) Reset() { *m = NamespaceCreate{} } func (m *NamespaceCreate) Reset() { *m = NamespaceCreate{} }
func (*NamespaceCreate) ProtoMessage() {} func (*NamespaceCreate) ProtoMessage() {}
func (*NamespaceCreate) Descriptor() ([]byte, []int) { func (*NamespaceCreate) Descriptor() ([]byte, []int) { return fileDescriptorNamespace, []int{0} }
return fileDescriptor_6cd45d1d5adffe29, []int{0}
}
func (m *NamespaceCreate) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *NamespaceCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_NamespaceCreate.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *NamespaceCreate) XXX_Merge(src proto.Message) {
xxx_messageInfo_NamespaceCreate.Merge(m, src)
}
func (m *NamespaceCreate) XXX_Size() int {
return m.Size()
}
func (m *NamespaceCreate) XXX_DiscardUnknown() {
xxx_messageInfo_NamespaceCreate.DiscardUnknown(m)
}
var xxx_messageInfo_NamespaceCreate proto.InternalMessageInfo
type NamespaceUpdate struct { type NamespaceUpdate struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Labels map[string]string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Labels map[string]string `protobuf:"bytes,2,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *NamespaceUpdate) Reset() { *m = NamespaceUpdate{} } func (m *NamespaceUpdate) Reset() { *m = NamespaceUpdate{} }
func (*NamespaceUpdate) ProtoMessage() {} func (*NamespaceUpdate) ProtoMessage() {}
func (*NamespaceUpdate) Descriptor() ([]byte, []int) { func (*NamespaceUpdate) Descriptor() ([]byte, []int) { return fileDescriptorNamespace, []int{1} }
return fileDescriptor_6cd45d1d5adffe29, []int{1}
}
func (m *NamespaceUpdate) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *NamespaceUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_NamespaceUpdate.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *NamespaceUpdate) XXX_Merge(src proto.Message) {
xxx_messageInfo_NamespaceUpdate.Merge(m, src)
}
func (m *NamespaceUpdate) XXX_Size() int {
return m.Size()
}
func (m *NamespaceUpdate) XXX_DiscardUnknown() {
xxx_messageInfo_NamespaceUpdate.DiscardUnknown(m)
}
var xxx_messageInfo_NamespaceUpdate proto.InternalMessageInfo
type NamespaceDelete struct { type NamespaceDelete struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *NamespaceDelete) Reset() { *m = NamespaceDelete{} } func (m *NamespaceDelete) Reset() { *m = NamespaceDelete{} }
func (*NamespaceDelete) ProtoMessage() {} func (*NamespaceDelete) ProtoMessage() {}
func (*NamespaceDelete) Descriptor() ([]byte, []int) { func (*NamespaceDelete) Descriptor() ([]byte, []int) { return fileDescriptorNamespace, []int{2} }
return fileDescriptor_6cd45d1d5adffe29, []int{2}
}
func (m *NamespaceDelete) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *NamespaceDelete) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_NamespaceDelete.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *NamespaceDelete) XXX_Merge(src proto.Message) {
xxx_messageInfo_NamespaceDelete.Merge(m, src)
}
func (m *NamespaceDelete) XXX_Size() int {
return m.Size()
}
func (m *NamespaceDelete) XXX_DiscardUnknown() {
xxx_messageInfo_NamespaceDelete.DiscardUnknown(m)
}
var xxx_messageInfo_NamespaceDelete proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*NamespaceCreate)(nil), "containerd.events.NamespaceCreate") proto.RegisterType((*NamespaceCreate)(nil), "containerd.events.NamespaceCreate")
proto.RegisterMapType((map[string]string)(nil), "containerd.events.NamespaceCreate.LabelsEntry")
proto.RegisterType((*NamespaceUpdate)(nil), "containerd.events.NamespaceUpdate") proto.RegisterType((*NamespaceUpdate)(nil), "containerd.events.NamespaceUpdate")
proto.RegisterMapType((map[string]string)(nil), "containerd.events.NamespaceUpdate.LabelsEntry")
proto.RegisterType((*NamespaceDelete)(nil), "containerd.events.NamespaceDelete") proto.RegisterType((*NamespaceDelete)(nil), "containerd.events.NamespaceDelete")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/namespace.proto", fileDescriptor_6cd45d1d5adffe29)
}
var fileDescriptor_6cd45d1d5adffe29 = []byte{
// 296 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4e, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0xe7, 0x25,
0xe6, 0xa6, 0x16, 0x17, 0x24, 0x26, 0xa7, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x22,
0x94, 0xe9, 0x41, 0x94, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x65, 0xf5, 0x41, 0x2c, 0x88,
0x42, 0x29, 0x07, 0x82, 0xb6, 0x80, 0xd5, 0x25, 0x95, 0xa6, 0xe9, 0x17, 0xe4, 0x94, 0xa6, 0x67,
0xe6, 0xe9, 0xa7, 0x65, 0xa6, 0xe6, 0xa4, 0x14, 0x24, 0x96, 0x64, 0x40, 0x4c, 0x50, 0x5a, 0xc1,
0xc8, 0xc5, 0xef, 0x07, 0xb3, 0xde, 0xb9, 0x28, 0x35, 0xb1, 0x24, 0x55, 0x48, 0x88, 0x8b, 0x05,
0xe4, 0x22, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x30, 0x5b, 0xc8, 0x8d, 0x8b, 0x2d, 0x27,
0x31, 0x29, 0x35, 0xa7, 0x58, 0x82, 0x49, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x4f, 0x0f, 0xc3, 0x8d,
0x7a, 0x68, 0xe6, 0xe8, 0xf9, 0x80, 0x35, 0xb8, 0xe6, 0x95, 0x14, 0x55, 0x06, 0x41, 0x75, 0x4b,
0x59, 0x72, 0x71, 0x23, 0x09, 0x0b, 0x09, 0x70, 0x31, 0x67, 0xa7, 0x56, 0x42, 0x6d, 0x02, 0x31,
0x85, 0x44, 0xb8, 0x58, 0xcb, 0x12, 0x73, 0x4a, 0x53, 0x25, 0x98, 0xc0, 0x62, 0x10, 0x8e, 0x15,
0x93, 0x05, 0x23, 0xaa, 0x53, 0x43, 0x0b, 0x52, 0xa8, 0xe2, 0x54, 0x88, 0x39, 0xd4, 0x76, 0xaa,
0x2a, 0x92, 0x4b, 0x5d, 0x52, 0x73, 0x52, 0xb1, 0xbb, 0xd4, 0x29, 0xe0, 0xc4, 0x43, 0x39, 0x86,
0x1b, 0x0f, 0xe5, 0x18, 0x1a, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c,
0xe3, 0x83, 0x47, 0x72, 0x8c, 0x0b, 0xbe, 0xc8, 0x31, 0x46, 0x19, 0x91, 0x90, 0x84, 0xac, 0x21,
0x54, 0x04, 0x43, 0x04, 0x63, 0x12, 0x1b, 0x38, 0x66, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff,
0x00, 0x50, 0x87, 0x59, 0x83, 0x02, 0x00, 0x00,
}
// Field returns the value for the given fieldpath as a string, if defined. // Field returns the value for the given fieldpath as a string, if defined.
// If the value is not defined, the second value will be false. // If the value is not defined, the second value will be false.
func (m *NamespaceCreate) Field(fieldpath []string) (string, bool) { func (m *NamespaceCreate) Field(fieldpath []string) (string, bool) {
@@ -273,9 +148,6 @@ func (m *NamespaceCreate) MarshalTo(dAtA []byte) (int, error) {
i += copy(dAtA[i:], v) i += copy(dAtA[i:], v)
} }
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -317,9 +189,6 @@ func (m *NamespaceUpdate) MarshalTo(dAtA []byte) (int, error) {
i += copy(dAtA[i:], v) i += copy(dAtA[i:], v)
} }
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -344,9 +213,6 @@ func (m *NamespaceDelete) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintNamespace(dAtA, i, uint64(len(m.Name))) i = encodeVarintNamespace(dAtA, i, uint64(len(m.Name)))
i += copy(dAtA[i:], m.Name) i += copy(dAtA[i:], m.Name)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -360,9 +226,6 @@ func encodeVarintNamespace(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *NamespaceCreate) Size() (n int) { func (m *NamespaceCreate) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Name) l = len(m.Name)
@@ -377,16 +240,10 @@ func (m *NamespaceCreate) Size() (n int) {
n += mapEntrySize + 1 + sovNamespace(uint64(mapEntrySize)) n += mapEntrySize + 1 + sovNamespace(uint64(mapEntrySize))
} }
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *NamespaceUpdate) Size() (n int) { func (m *NamespaceUpdate) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Name) l = len(m.Name)
@@ -401,25 +258,16 @@ func (m *NamespaceUpdate) Size() (n int) {
n += mapEntrySize + 1 + sovNamespace(uint64(mapEntrySize)) n += mapEntrySize + 1 + sovNamespace(uint64(mapEntrySize))
} }
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *NamespaceDelete) Size() (n int) { func (m *NamespaceDelete) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Name) l = len(m.Name)
if l > 0 { if l > 0 {
n += 1 + l + sovNamespace(uint64(l)) n += 1 + l + sovNamespace(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -444,7 +292,7 @@ func (this *NamespaceCreate) String() string {
for k, _ := range this.Labels { for k, _ := range this.Labels {
keysForLabels = append(keysForLabels, k) keysForLabels = append(keysForLabels, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForLabels) sortkeys.Strings(keysForLabels)
mapStringForLabels := "map[string]string{" mapStringForLabels := "map[string]string{"
for _, k := range keysForLabels { for _, k := range keysForLabels {
mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k]) mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k])
@@ -453,7 +301,6 @@ func (this *NamespaceCreate) String() string {
s := strings.Join([]string{`&NamespaceCreate{`, s := strings.Join([]string{`&NamespaceCreate{`,
`Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
`Labels:` + mapStringForLabels + `,`, `Labels:` + mapStringForLabels + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -466,7 +313,7 @@ func (this *NamespaceUpdate) String() string {
for k, _ := range this.Labels { for k, _ := range this.Labels {
keysForLabels = append(keysForLabels, k) keysForLabels = append(keysForLabels, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForLabels) sortkeys.Strings(keysForLabels)
mapStringForLabels := "map[string]string{" mapStringForLabels := "map[string]string{"
for _, k := range keysForLabels { for _, k := range keysForLabels {
mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k]) mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k])
@@ -475,7 +322,6 @@ func (this *NamespaceUpdate) String() string {
s := strings.Join([]string{`&NamespaceUpdate{`, s := strings.Join([]string{`&NamespaceUpdate{`,
`Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
`Labels:` + mapStringForLabels + `,`, `Labels:` + mapStringForLabels + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -486,7 +332,6 @@ func (this *NamespaceDelete) String() string {
} }
s := strings.Join([]string{`&NamespaceDelete{`, s := strings.Join([]string{`&NamespaceDelete{`,
`Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -514,7 +359,7 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -542,7 +387,7 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -552,9 +397,6 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthNamespace
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -574,7 +416,7 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -583,9 +425,6 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthNamespace
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -606,7 +445,7 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -623,7 +462,7 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift stringLenmapkey |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -633,9 +472,6 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postStringIndexmapkey := iNdEx + intStringLenmapkey postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthNamespace
}
if postStringIndexmapkey > l { if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -652,7 +488,7 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift stringLenmapvalue |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -662,9 +498,6 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postStringIndexmapvalue := iNdEx + intStringLenmapvalue postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthNamespace
}
if postStringIndexmapvalue > l { if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -696,13 +529,9 @@ func (m *NamespaceCreate) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthNamespace
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -727,7 +556,7 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -755,7 +584,7 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -765,9 +594,6 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthNamespace
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -787,7 +613,7 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -796,9 +622,6 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthNamespace
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -819,7 +642,7 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -836,7 +659,7 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift stringLenmapkey |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -846,9 +669,6 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postStringIndexmapkey := iNdEx + intStringLenmapkey postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthNamespace
}
if postStringIndexmapkey > l { if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -865,7 +685,7 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift stringLenmapvalue |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -875,9 +695,6 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postStringIndexmapvalue := iNdEx + intStringLenmapvalue postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthNamespace
}
if postStringIndexmapvalue > l { if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -909,13 +726,9 @@ func (m *NamespaceUpdate) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthNamespace
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -940,7 +753,7 @@ func (m *NamespaceDelete) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -968,7 +781,7 @@ func (m *NamespaceDelete) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -978,9 +791,6 @@ func (m *NamespaceDelete) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthNamespace
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -995,13 +805,9 @@ func (m *NamespaceDelete) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthNamespace return ErrInvalidLengthNamespace
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthNamespace
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -1065,11 +871,8 @@ func skipNamespace(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthNamespace
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthNamespace return 0, ErrInvalidLengthNamespace
} }
return iNdEx, nil return iNdEx, nil
@@ -1100,9 +903,6 @@ func skipNamespace(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthNamespace
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -1121,3 +921,30 @@ var (
ErrInvalidLengthNamespace = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthNamespace = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowNamespace = fmt.Errorf("proto: integer overflow") ErrIntOverflowNamespace = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/namespace.proto", fileDescriptorNamespace)
}
var fileDescriptorNamespace = []byte{
// 296 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4e, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0xe7, 0x25,
0xe6, 0xa6, 0x16, 0x17, 0x24, 0x26, 0xa7, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x22,
0x94, 0xe9, 0x41, 0x94, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x65, 0xf5, 0x41, 0x2c, 0x88,
0x42, 0x29, 0x07, 0x82, 0xb6, 0x80, 0xd5, 0x25, 0x95, 0xa6, 0xe9, 0x17, 0xe4, 0x94, 0xa6, 0x67,
0xe6, 0xe9, 0xa7, 0x65, 0xa6, 0xe6, 0xa4, 0x14, 0x24, 0x96, 0x64, 0x40, 0x4c, 0x50, 0x5a, 0xc1,
0xc8, 0xc5, 0xef, 0x07, 0xb3, 0xde, 0xb9, 0x28, 0x35, 0xb1, 0x24, 0x55, 0x48, 0x88, 0x8b, 0x05,
0xe4, 0x22, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x30, 0x5b, 0xc8, 0x8d, 0x8b, 0x2d, 0x27,
0x31, 0x29, 0x35, 0xa7, 0x58, 0x82, 0x49, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x4f, 0x0f, 0xc3, 0x8d,
0x7a, 0x68, 0xe6, 0xe8, 0xf9, 0x80, 0x35, 0xb8, 0xe6, 0x95, 0x14, 0x55, 0x06, 0x41, 0x75, 0x4b,
0x59, 0x72, 0x71, 0x23, 0x09, 0x0b, 0x09, 0x70, 0x31, 0x67, 0xa7, 0x56, 0x42, 0x6d, 0x02, 0x31,
0x85, 0x44, 0xb8, 0x58, 0xcb, 0x12, 0x73, 0x4a, 0x53, 0x25, 0x98, 0xc0, 0x62, 0x10, 0x8e, 0x15,
0x93, 0x05, 0x23, 0xaa, 0x53, 0x43, 0x0b, 0x52, 0xa8, 0xe2, 0x54, 0x88, 0x39, 0xd4, 0x76, 0xaa,
0x2a, 0x92, 0x4b, 0x5d, 0x52, 0x73, 0x52, 0xb1, 0xbb, 0xd4, 0x29, 0xe0, 0xc4, 0x43, 0x39, 0x86,
0x1b, 0x0f, 0xe5, 0x18, 0x1a, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c,
0xe3, 0x83, 0x47, 0x72, 0x8c, 0x0b, 0xbe, 0xc8, 0x31, 0x46, 0x19, 0x91, 0x90, 0x84, 0xac, 0x21,
0x54, 0x04, 0x43, 0x04, 0x63, 0x12, 0x1b, 0x38, 0x66, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff,
0x00, 0x50, 0x87, 0x59, 0x83, 0x02, 0x00, 0x00,
}

View File

@@ -3,144 +3,47 @@
package events package events
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
io "io"
math "math" // skipping weak import containerd_plugin "github.com/containerd/containerd/protobuf/plugin"
reflect "reflect"
strings "strings" import strings "strings"
) import reflect "reflect"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type SnapshotPrepare struct { type SnapshotPrepare struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *SnapshotPrepare) Reset() { *m = SnapshotPrepare{} } func (m *SnapshotPrepare) Reset() { *m = SnapshotPrepare{} }
func (*SnapshotPrepare) ProtoMessage() {} func (*SnapshotPrepare) ProtoMessage() {}
func (*SnapshotPrepare) Descriptor() ([]byte, []int) { func (*SnapshotPrepare) Descriptor() ([]byte, []int) { return fileDescriptorSnapshot, []int{0} }
return fileDescriptor_bd6c184d3d9aa5f2, []int{0}
}
func (m *SnapshotPrepare) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SnapshotPrepare) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SnapshotPrepare.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *SnapshotPrepare) XXX_Merge(src proto.Message) {
xxx_messageInfo_SnapshotPrepare.Merge(m, src)
}
func (m *SnapshotPrepare) XXX_Size() int {
return m.Size()
}
func (m *SnapshotPrepare) XXX_DiscardUnknown() {
xxx_messageInfo_SnapshotPrepare.DiscardUnknown(m)
}
var xxx_messageInfo_SnapshotPrepare proto.InternalMessageInfo
type SnapshotCommit struct { type SnapshotCommit struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *SnapshotCommit) Reset() { *m = SnapshotCommit{} } func (m *SnapshotCommit) Reset() { *m = SnapshotCommit{} }
func (*SnapshotCommit) ProtoMessage() {} func (*SnapshotCommit) ProtoMessage() {}
func (*SnapshotCommit) Descriptor() ([]byte, []int) { func (*SnapshotCommit) Descriptor() ([]byte, []int) { return fileDescriptorSnapshot, []int{1} }
return fileDescriptor_bd6c184d3d9aa5f2, []int{1}
}
func (m *SnapshotCommit) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SnapshotCommit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SnapshotCommit.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *SnapshotCommit) XXX_Merge(src proto.Message) {
xxx_messageInfo_SnapshotCommit.Merge(m, src)
}
func (m *SnapshotCommit) XXX_Size() int {
return m.Size()
}
func (m *SnapshotCommit) XXX_DiscardUnknown() {
xxx_messageInfo_SnapshotCommit.DiscardUnknown(m)
}
var xxx_messageInfo_SnapshotCommit proto.InternalMessageInfo
type SnapshotRemove struct { type SnapshotRemove struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *SnapshotRemove) Reset() { *m = SnapshotRemove{} } func (m *SnapshotRemove) Reset() { *m = SnapshotRemove{} }
func (*SnapshotRemove) ProtoMessage() {} func (*SnapshotRemove) ProtoMessage() {}
func (*SnapshotRemove) Descriptor() ([]byte, []int) { func (*SnapshotRemove) Descriptor() ([]byte, []int) { return fileDescriptorSnapshot, []int{2} }
return fileDescriptor_bd6c184d3d9aa5f2, []int{2}
}
func (m *SnapshotRemove) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SnapshotRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SnapshotRemove.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *SnapshotRemove) XXX_Merge(src proto.Message) {
xxx_messageInfo_SnapshotRemove.Merge(m, src)
}
func (m *SnapshotRemove) XXX_Size() int {
return m.Size()
}
func (m *SnapshotRemove) XXX_DiscardUnknown() {
xxx_messageInfo_SnapshotRemove.DiscardUnknown(m)
}
var xxx_messageInfo_SnapshotRemove proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*SnapshotPrepare)(nil), "containerd.events.SnapshotPrepare") proto.RegisterType((*SnapshotPrepare)(nil), "containerd.events.SnapshotPrepare")
@@ -148,29 +51,6 @@ func init() {
proto.RegisterType((*SnapshotRemove)(nil), "containerd.events.SnapshotRemove") proto.RegisterType((*SnapshotRemove)(nil), "containerd.events.SnapshotRemove")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/snapshot.proto", fileDescriptor_bd6c184d3d9aa5f2)
}
var fileDescriptor_bd6c184d3d9aa5f2 = []byte{
// 235 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4a, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x17, 0xe7,
0x25, 0x16, 0x14, 0x67, 0xe4, 0x97, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x22, 0x54,
0xe9, 0x41, 0x54, 0x48, 0x39, 0x10, 0x34, 0x0e, 0xac, 0x35, 0xa9, 0x34, 0x4d, 0xbf, 0x20, 0xa7,
0x34, 0x3d, 0x33, 0x4f, 0x3f, 0x2d, 0x33, 0x35, 0x27, 0xa5, 0x20, 0xb1, 0x24, 0x03, 0x62, 0xa8,
0x92, 0x35, 0x17, 0x7f, 0x30, 0xd4, 0x9a, 0x80, 0xa2, 0xd4, 0x82, 0xc4, 0xa2, 0x54, 0x21, 0x01,
0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x10, 0x53, 0x48, 0x8c,
0x8b, 0x0d, 0x24, 0x93, 0x57, 0x22, 0xc1, 0x04, 0x16, 0x84, 0xf2, 0x94, 0xcc, 0xb8, 0xf8, 0x60,
0x9a, 0x9d, 0xf3, 0x73, 0x73, 0x33, 0x4b, 0xb0, 0xe8, 0x15, 0xe2, 0x62, 0xc9, 0x4b, 0xcc, 0x4d,
0x85, 0xea, 0x04, 0xb3, 0x95, 0x94, 0x10, 0xfa, 0x82, 0x52, 0x73, 0xf3, 0xcb, 0xb0, 0xd8, 0xe9,
0x14, 0x70, 0xe2, 0xa1, 0x1c, 0xc3, 0x8d, 0x87, 0x72, 0x0c, 0x0d, 0x8f, 0xe4, 0x18, 0x4f, 0x3c,
0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x05, 0x5f, 0xe4, 0x18, 0xa3,
0x8c, 0x48, 0x08, 0x47, 0x6b, 0x08, 0x15, 0xc1, 0x90, 0xc4, 0x06, 0xf6, 0xb3, 0x31, 0x20, 0x00,
0x00, 0xff, 0xff, 0x69, 0x66, 0xa9, 0x2a, 0x86, 0x01, 0x00, 0x00,
}
// Field returns the value for the given fieldpath as a string, if defined. // Field returns the value for the given fieldpath as a string, if defined.
// If the value is not defined, the second value will be false. // If the value is not defined, the second value will be false.
func (m *SnapshotPrepare) Field(fieldpath []string) (string, bool) { func (m *SnapshotPrepare) Field(fieldpath []string) (string, bool) {
@@ -243,9 +123,6 @@ func (m *SnapshotPrepare) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Parent))) i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Parent)))
i += copy(dAtA[i:], m.Parent) i += copy(dAtA[i:], m.Parent)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -276,9 +153,6 @@ func (m *SnapshotCommit) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Name))) i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Name)))
i += copy(dAtA[i:], m.Name) i += copy(dAtA[i:], m.Name)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -303,9 +177,6 @@ func (m *SnapshotRemove) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Key))) i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Key)))
i += copy(dAtA[i:], m.Key) i += copy(dAtA[i:], m.Key)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -319,9 +190,6 @@ func encodeVarintSnapshot(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *SnapshotPrepare) Size() (n int) { func (m *SnapshotPrepare) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Key) l = len(m.Key)
@@ -332,16 +200,10 @@ func (m *SnapshotPrepare) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovSnapshot(uint64(l)) n += 1 + l + sovSnapshot(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *SnapshotCommit) Size() (n int) { func (m *SnapshotCommit) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Key) l = len(m.Key)
@@ -352,25 +214,16 @@ func (m *SnapshotCommit) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovSnapshot(uint64(l)) n += 1 + l + sovSnapshot(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *SnapshotRemove) Size() (n int) { func (m *SnapshotRemove) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Key) l = len(m.Key)
if l > 0 { if l > 0 {
n += 1 + l + sovSnapshot(uint64(l)) n += 1 + l + sovSnapshot(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -394,7 +247,6 @@ func (this *SnapshotPrepare) String() string {
s := strings.Join([]string{`&SnapshotPrepare{`, s := strings.Join([]string{`&SnapshotPrepare{`,
`Key:` + fmt.Sprintf("%v", this.Key) + `,`, `Key:` + fmt.Sprintf("%v", this.Key) + `,`,
`Parent:` + fmt.Sprintf("%v", this.Parent) + `,`, `Parent:` + fmt.Sprintf("%v", this.Parent) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -406,7 +258,6 @@ func (this *SnapshotCommit) String() string {
s := strings.Join([]string{`&SnapshotCommit{`, s := strings.Join([]string{`&SnapshotCommit{`,
`Key:` + fmt.Sprintf("%v", this.Key) + `,`, `Key:` + fmt.Sprintf("%v", this.Key) + `,`,
`Name:` + fmt.Sprintf("%v", this.Name) + `,`, `Name:` + fmt.Sprintf("%v", this.Name) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -417,7 +268,6 @@ func (this *SnapshotRemove) String() string {
} }
s := strings.Join([]string{`&SnapshotRemove{`, s := strings.Join([]string{`&SnapshotRemove{`,
`Key:` + fmt.Sprintf("%v", this.Key) + `,`, `Key:` + fmt.Sprintf("%v", this.Key) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -445,7 +295,7 @@ func (m *SnapshotPrepare) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -473,7 +323,7 @@ func (m *SnapshotPrepare) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -483,9 +333,6 @@ func (m *SnapshotPrepare) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthSnapshot return ErrInvalidLengthSnapshot
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthSnapshot
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -505,7 +352,7 @@ func (m *SnapshotPrepare) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -515,9 +362,6 @@ func (m *SnapshotPrepare) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthSnapshot return ErrInvalidLengthSnapshot
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthSnapshot
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -532,13 +376,9 @@ func (m *SnapshotPrepare) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthSnapshot return ErrInvalidLengthSnapshot
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthSnapshot
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -563,7 +403,7 @@ func (m *SnapshotCommit) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -591,7 +431,7 @@ func (m *SnapshotCommit) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -601,9 +441,6 @@ func (m *SnapshotCommit) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthSnapshot return ErrInvalidLengthSnapshot
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthSnapshot
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -623,7 +460,7 @@ func (m *SnapshotCommit) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -633,9 +470,6 @@ func (m *SnapshotCommit) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthSnapshot return ErrInvalidLengthSnapshot
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthSnapshot
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -650,13 +484,9 @@ func (m *SnapshotCommit) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthSnapshot return ErrInvalidLengthSnapshot
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthSnapshot
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -681,7 +511,7 @@ func (m *SnapshotRemove) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -709,7 +539,7 @@ func (m *SnapshotRemove) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -719,9 +549,6 @@ func (m *SnapshotRemove) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthSnapshot return ErrInvalidLengthSnapshot
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthSnapshot
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -736,13 +563,9 @@ func (m *SnapshotRemove) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthSnapshot return ErrInvalidLengthSnapshot
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthSnapshot
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -806,11 +629,8 @@ func skipSnapshot(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthSnapshot
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthSnapshot return 0, ErrInvalidLengthSnapshot
} }
return iNdEx, nil return iNdEx, nil
@@ -841,9 +661,6 @@ func skipSnapshot(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthSnapshot
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -862,3 +679,26 @@ var (
ErrInvalidLengthSnapshot = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthSnapshot = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowSnapshot = fmt.Errorf("proto: integer overflow") ErrIntOverflowSnapshot = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/events/snapshot.proto", fileDescriptorSnapshot)
}
var fileDescriptorSnapshot = []byte{
// 235 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4a, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x17, 0xe7,
0x25, 0x16, 0x14, 0x67, 0xe4, 0x97, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x22, 0x54,
0xe9, 0x41, 0x54, 0x48, 0x39, 0x10, 0x34, 0x0e, 0xac, 0x35, 0xa9, 0x34, 0x4d, 0xbf, 0x20, 0xa7,
0x34, 0x3d, 0x33, 0x4f, 0x3f, 0x2d, 0x33, 0x35, 0x27, 0xa5, 0x20, 0xb1, 0x24, 0x03, 0x62, 0xa8,
0x92, 0x35, 0x17, 0x7f, 0x30, 0xd4, 0x9a, 0x80, 0xa2, 0xd4, 0x82, 0xc4, 0xa2, 0x54, 0x21, 0x01,
0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x10, 0x53, 0x48, 0x8c,
0x8b, 0x0d, 0x24, 0x93, 0x57, 0x22, 0xc1, 0x04, 0x16, 0x84, 0xf2, 0x94, 0xcc, 0xb8, 0xf8, 0x60,
0x9a, 0x9d, 0xf3, 0x73, 0x73, 0x33, 0x4b, 0xb0, 0xe8, 0x15, 0xe2, 0x62, 0xc9, 0x4b, 0xcc, 0x4d,
0x85, 0xea, 0x04, 0xb3, 0x95, 0x94, 0x10, 0xfa, 0x82, 0x52, 0x73, 0xf3, 0xcb, 0xb0, 0xd8, 0xe9,
0x14, 0x70, 0xe2, 0xa1, 0x1c, 0xc3, 0x8d, 0x87, 0x72, 0x0c, 0x0d, 0x8f, 0xe4, 0x18, 0x4f, 0x3c,
0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x05, 0x5f, 0xe4, 0x18, 0xa3,
0x8c, 0x48, 0x08, 0x47, 0x6b, 0x08, 0x15, 0xc1, 0x90, 0xc4, 0x06, 0xf6, 0xb3, 0x31, 0x20, 0x00,
0x00, 0xff, 0xff, 0x69, 0x66, 0xa9, 0x2a, 0x86, 0x01, 0x00, 0x00,
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +0,0 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package events defines the event pushing and subscription service.
package events

View File

@@ -1,778 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/containerd/containerd/api/services/ttrpc/events/v1/events.proto
package events
import (
context "context"
fmt "fmt"
github_com_containerd_ttrpc "github.com/containerd/ttrpc"
github_com_containerd_typeurl "github.com/containerd/typeurl"
proto "github.com/gogo/protobuf/proto"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
types "github.com/gogo/protobuf/types"
io "io"
math "math"
reflect "reflect"
strings "strings"
time "time"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
var _ = time.Kitchen
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ForwardRequest struct {
Envelope *Envelope `protobuf:"bytes,1,opt,name=envelope,proto3" json:"envelope,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ForwardRequest) Reset() { *m = ForwardRequest{} }
func (*ForwardRequest) ProtoMessage() {}
func (*ForwardRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_19f98672016720b5, []int{0}
}
func (m *ForwardRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ForwardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ForwardRequest.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ForwardRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ForwardRequest.Merge(m, src)
}
func (m *ForwardRequest) XXX_Size() int {
return m.Size()
}
func (m *ForwardRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ForwardRequest.DiscardUnknown(m)
}
var xxx_messageInfo_ForwardRequest proto.InternalMessageInfo
type Envelope struct {
Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"timestamp"`
Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"`
Topic string `protobuf:"bytes,3,opt,name=topic,proto3" json:"topic,omitempty"`
Event *types.Any `protobuf:"bytes,4,opt,name=event,proto3" json:"event,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Envelope) Reset() { *m = Envelope{} }
func (*Envelope) ProtoMessage() {}
func (*Envelope) Descriptor() ([]byte, []int) {
return fileDescriptor_19f98672016720b5, []int{1}
}
func (m *Envelope) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Envelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Envelope.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Envelope) XXX_Merge(src proto.Message) {
xxx_messageInfo_Envelope.Merge(m, src)
}
func (m *Envelope) XXX_Size() int {
return m.Size()
}
func (m *Envelope) XXX_DiscardUnknown() {
xxx_messageInfo_Envelope.DiscardUnknown(m)
}
var xxx_messageInfo_Envelope proto.InternalMessageInfo
func init() {
proto.RegisterType((*ForwardRequest)(nil), "containerd.services.events.ttrpc.v1.ForwardRequest")
proto.RegisterType((*Envelope)(nil), "containerd.services.events.ttrpc.v1.Envelope")
}
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/services/ttrpc/events/v1/events.proto", fileDescriptor_19f98672016720b5)
}
var fileDescriptor_19f98672016720b5 = []byte{
// 396 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0xc1, 0x8e, 0xd3, 0x30,
0x10, 0x8d, 0x61, 0x77, 0x69, 0x8d, 0xc4, 0xc1, 0xaa, 0x50, 0x08, 0x28, 0x59, 0x2d, 0x97, 0x15,
0x12, 0xb6, 0x76, 0xf7, 0x06, 0x17, 0xa8, 0x28, 0x12, 0x1c, 0x23, 0x84, 0x2a, 0x90, 0x10, 0x6e,
0x3a, 0x4d, 0x2d, 0x25, 0xb6, 0x49, 0x9c, 0xa0, 0xde, 0xfa, 0x09, 0x7c, 0x0c, 0x17, 0xfe, 0xa0,
0x47, 0x8e, 0x9c, 0x80, 0xe6, 0x4b, 0x50, 0x9d, 0xa4, 0x81, 0xf6, 0x40, 0xa5, 0xbd, 0xbd, 0xcc,
0x7b, 0x6f, 0xde, 0xcc, 0xc4, 0xf8, 0x75, 0x2c, 0xcc, 0xbc, 0x98, 0xd0, 0x48, 0xa5, 0x2c, 0x52,
0xd2, 0x70, 0x21, 0x21, 0x9b, 0xfe, 0x0d, 0xb9, 0x16, 0x2c, 0x87, 0xac, 0x14, 0x11, 0xe4, 0xcc,
0x98, 0x4c, 0x47, 0x0c, 0x4a, 0x90, 0x26, 0x67, 0xe5, 0x45, 0x83, 0xa8, 0xce, 0x94, 0x51, 0xe4,
0x61, 0xe7, 0xa2, 0xad, 0x83, 0x36, 0x0a, 0x6b, 0xa4, 0xe5, 0x85, 0xf7, 0xec, 0xbf, 0x81, 0xb6,
0xd9, 0xa4, 0x98, 0x31, 0x9d, 0x14, 0xb1, 0x90, 0x6c, 0x26, 0x20, 0x99, 0x6a, 0x6e, 0xe6, 0x75,
0x8c, 0x37, 0x88, 0x55, 0xac, 0x2c, 0x64, 0x1b, 0xd4, 0x54, 0xef, 0xc5, 0x4a, 0xc5, 0x09, 0x74,
0x6e, 0x2e, 0x17, 0x0d, 0x75, 0x7f, 0x97, 0x82, 0x54, 0x9b, 0x96, 0x0c, 0x76, 0x49, 0x23, 0x52,
0xc8, 0x0d, 0x4f, 0x75, 0x2d, 0x38, 0x7b, 0x8f, 0xef, 0xbc, 0x54, 0xd9, 0x67, 0x9e, 0x4d, 0x43,
0xf8, 0x54, 0x40, 0x6e, 0xc8, 0x2b, 0xdc, 0x03, 0x59, 0x42, 0xa2, 0x34, 0xb8, 0xe8, 0x14, 0x9d,
0xdf, 0xbe, 0x7c, 0x4c, 0x0f, 0x58, 0x9d, 0x8e, 0x1a, 0x53, 0xb8, 0xb5, 0x9f, 0x7d, 0x45, 0xb8,
0xd7, 0x96, 0xc9, 0x10, 0xf7, 0xb7, 0xe1, 0x4d, 0x63, 0x8f, 0xd6, 0xe3, 0xd1, 0x76, 0x3c, 0xfa,
0xa6, 0x55, 0x0c, 0x7b, 0xab, 0x9f, 0x81, 0xf3, 0xe5, 0x57, 0x80, 0xc2, 0xce, 0x46, 0x1e, 0xe0,
0xbe, 0xe4, 0x29, 0xe4, 0x9a, 0x47, 0xe0, 0xde, 0x38, 0x45, 0xe7, 0xfd, 0xb0, 0x2b, 0x90, 0x01,
0x3e, 0x36, 0x4a, 0x8b, 0xc8, 0xbd, 0x69, 0x99, 0xfa, 0x83, 0x3c, 0xc2, 0xc7, 0x76, 0x54, 0xf7,
0xc8, 0x66, 0x0e, 0xf6, 0x32, 0x9f, 0xcb, 0x45, 0x58, 0x4b, 0x9e, 0x1c, 0x2d, 0xbf, 0x05, 0xe8,
0xf2, 0x23, 0x3e, 0x19, 0xd9, 0xe5, 0xc8, 0x5b, 0x7c, 0xab, 0xb9, 0x0e, 0xb9, 0x3a, 0xe8, 0x08,
0xff, 0xde, 0xd2, 0xbb, 0xbb, 0x17, 0x36, 0xda, 0xfc, 0x9c, 0xe1, 0x87, 0xd5, 0xda, 0x77, 0x7e,
0xac, 0x7d, 0x67, 0x59, 0xf9, 0x68, 0x55, 0xf9, 0xe8, 0x7b, 0xe5, 0xa3, 0xdf, 0x95, 0x8f, 0xde,
0xbd, 0xb8, 0xd6, 0x8b, 0x7d, 0x5a, 0xa3, 0xb1, 0x33, 0x46, 0x93, 0x13, 0x9b, 0x79, 0xf5, 0x27,
0x00, 0x00, 0xff, 0xff, 0xd4, 0x90, 0xbd, 0x09, 0x04, 0x03, 0x00, 0x00,
}
// Field returns the value for the given fieldpath as a string, if defined.
// If the value is not defined, the second value will be false.
func (m *Envelope) Field(fieldpath []string) (string, bool) {
if len(fieldpath) == 0 {
return "", false
}
switch fieldpath[0] {
// unhandled: timestamp
case "namespace":
return string(m.Namespace), len(m.Namespace) > 0
case "topic":
return string(m.Topic), len(m.Topic) > 0
case "event":
decoded, err := github_com_containerd_typeurl.UnmarshalAny(m.Event)
if err != nil {
return "", false
}
adaptor, ok := decoded.(interface{ Field([]string) (string, bool) })
if !ok {
return "", false
}
return adaptor.Field(fieldpath[1:])
}
return "", false
}
func (m *ForwardRequest) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ForwardRequest) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Envelope != nil {
dAtA[i] = 0xa
i++
i = encodeVarintEvents(dAtA, i, uint64(m.Envelope.Size()))
n1, err := m.Envelope.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil
}
func (m *Envelope) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Envelope) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
dAtA[i] = 0xa
i++
i = encodeVarintEvents(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp)))
n2, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i:])
if err != nil {
return 0, err
}
i += n2
if len(m.Namespace) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintEvents(dAtA, i, uint64(len(m.Namespace)))
i += copy(dAtA[i:], m.Namespace)
}
if len(m.Topic) > 0 {
dAtA[i] = 0x1a
i++
i = encodeVarintEvents(dAtA, i, uint64(len(m.Topic)))
i += copy(dAtA[i:], m.Topic)
}
if m.Event != nil {
dAtA[i] = 0x22
i++
i = encodeVarintEvents(dAtA, i, uint64(m.Event.Size()))
n3, err := m.Event.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n3
}
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil
}
func encodeVarintEvents(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *ForwardRequest) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Envelope != nil {
l = m.Envelope.Size()
n += 1 + l + sovEvents(uint64(l))
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func (m *Envelope) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp)
n += 1 + l + sovEvents(uint64(l))
l = len(m.Namespace)
if l > 0 {
n += 1 + l + sovEvents(uint64(l))
}
l = len(m.Topic)
if l > 0 {
n += 1 + l + sovEvents(uint64(l))
}
if m.Event != nil {
l = m.Event.Size()
n += 1 + l + sovEvents(uint64(l))
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func sovEvents(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozEvents(x uint64) (n int) {
return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *ForwardRequest) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&ForwardRequest{`,
`Envelope:` + strings.Replace(fmt.Sprintf("%v", this.Envelope), "Envelope", "Envelope", 1) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func (this *Envelope) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&Envelope{`,
`Timestamp:` + strings.Replace(strings.Replace(this.Timestamp.String(), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`,
`Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`,
`Topic:` + fmt.Sprintf("%v", this.Topic) + `,`,
`Event:` + strings.Replace(fmt.Sprintf("%v", this.Event), "Any", "types.Any", 1) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func valueToStringEvents(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
type EventsService interface {
Forward(ctx context.Context, req *ForwardRequest) (*types.Empty, error)
}
func RegisterEventsService(srv *github_com_containerd_ttrpc.Server, svc EventsService) {
srv.Register("containerd.services.events.ttrpc.v1.Events", map[string]github_com_containerd_ttrpc.Method{
"Forward": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req ForwardRequest
if err := unmarshal(&req); err != nil {
return nil, err
}
return svc.Forward(ctx, &req)
},
})
}
type eventsClient struct {
client *github_com_containerd_ttrpc.Client
}
func NewEventsClient(client *github_com_containerd_ttrpc.Client) EventsService {
return &eventsClient{
client: client,
}
}
func (c *eventsClient) Forward(ctx context.Context, req *ForwardRequest) (*types.Empty, error) {
var resp types.Empty
if err := c.client.Call(ctx, "containerd.services.events.ttrpc.v1.Events", "Forward", req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
func (m *ForwardRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: ForwardRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ForwardRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Envelope", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthEvents
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthEvents
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Envelope == nil {
m.Envelope = &Envelope{}
}
if err := m.Envelope.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipEvents(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthEvents
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthEvents
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Envelope) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Envelope: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Envelope: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthEvents
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthEvents
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthEvents
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthEvents
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Namespace = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Topic", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthEvents
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthEvents
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Topic = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Event", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthEvents
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthEvents
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Event == nil {
m.Event = &types.Any{}
}
if err := m.Event.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipEvents(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthEvents
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthEvents
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipEvents(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowEvents
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowEvents
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowEvents
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthEvents
}
iNdEx += length
if iNdEx < 0 {
return 0, ErrInvalidLengthEvents
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowEvents
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipEvents(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthEvents
}
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow")
)

View File

@@ -1,18 +1,35 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/containerd/containerd/api/types/descriptor.proto // source: github.com/containerd/containerd/api/types/descriptor.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
github.com/containerd/containerd/api/types/descriptor.proto
github.com/containerd/containerd/api/types/metrics.proto
github.com/containerd/containerd/api/types/mount.proto
github.com/containerd/containerd/api/types/platform.proto
It has these top-level messages:
Descriptor
Metric
Mount
Platform
*/
package types package types
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
github_com_opencontainers_go_digest "github.com/opencontainers/go-digest" // skipping weak import gogoproto "github.com/gogo/protobuf/gogoproto"
io "io"
math "math" import github_com_opencontainers_go_digest "github.com/opencontainers/go-digest"
reflect "reflect"
strings "strings" import strings "strings"
) import reflect "reflect"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
@@ -31,80 +48,18 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// oci descriptor found in a manifest. // oci descriptor found in a manifest.
// See https://godoc.org/github.com/opencontainers/image-spec/specs-go/v1#Descriptor // See https://godoc.org/github.com/opencontainers/image-spec/specs-go/v1#Descriptor
type Descriptor struct { type Descriptor struct {
MediaType string `protobuf:"bytes,1,opt,name=media_type,json=mediaType,proto3" json:"media_type,omitempty"` MediaType string `protobuf:"bytes,1,opt,name=media_type,json=mediaType,proto3" json:"media_type,omitempty"`
Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,2,opt,name=digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"digest"` Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,2,opt,name=digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"digest"`
Size_ int64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"` Size_ int64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"`
Annotations map[string]string `protobuf:"bytes,5,rep,name=annotations,proto3" json:"annotations,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Descriptor) Reset() { *m = Descriptor{} } func (m *Descriptor) Reset() { *m = Descriptor{} }
func (*Descriptor) ProtoMessage() {} func (*Descriptor) ProtoMessage() {}
func (*Descriptor) Descriptor() ([]byte, []int) { func (*Descriptor) Descriptor() ([]byte, []int) { return fileDescriptorDescriptor, []int{0} }
return fileDescriptor_37f958df3707db9e, []int{0}
}
func (m *Descriptor) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Descriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Descriptor.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Descriptor) XXX_Merge(src proto.Message) {
xxx_messageInfo_Descriptor.Merge(m, src)
}
func (m *Descriptor) XXX_Size() int {
return m.Size()
}
func (m *Descriptor) XXX_DiscardUnknown() {
xxx_messageInfo_Descriptor.DiscardUnknown(m)
}
var xxx_messageInfo_Descriptor proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*Descriptor)(nil), "containerd.types.Descriptor") proto.RegisterType((*Descriptor)(nil), "containerd.types.Descriptor")
proto.RegisterMapType((map[string]string)(nil), "containerd.types.Descriptor.AnnotationsEntry")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/descriptor.proto", fileDescriptor_37f958df3707db9e)
}
var fileDescriptor_37f958df3707db9e = []byte{
// 311 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4e, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0xa7, 0xa4, 0x16,
0x27, 0x17, 0x65, 0x16, 0x94, 0xe4, 0x17, 0xe9, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x20,
0x94, 0xe9, 0x81, 0x95, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf5, 0x41, 0x2c, 0x88,
0x3a, 0xa5, 0x39, 0x4c, 0x5c, 0x5c, 0x2e, 0x70, 0xcd, 0x42, 0xb2, 0x5c, 0x5c, 0xb9, 0xa9, 0x29,
0x99, 0x89, 0xf1, 0x20, 0x3d, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x9c, 0x60, 0x91, 0x90,
0xca, 0x82, 0x54, 0x21, 0x2f, 0x2e, 0xb6, 0x94, 0xcc, 0xf4, 0xd4, 0xe2, 0x12, 0x09, 0x26, 0x90,
0x94, 0x93, 0xd1, 0x89, 0x7b, 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0x6b, 0x21, 0x39, 0x35, 0xbf, 0x20,
0x35, 0x0f, 0x6e, 0x79, 0xb1, 0x7e, 0x7a, 0xbe, 0x2e, 0x44, 0x8b, 0x9e, 0x0b, 0x98, 0x0a, 0x82,
0x9a, 0x20, 0x24, 0xc4, 0xc5, 0x52, 0x9c, 0x59, 0x95, 0x2a, 0xc1, 0xac, 0xc0, 0xa8, 0xc1, 0x1c,
0x04, 0x66, 0x0b, 0xf9, 0x73, 0x71, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7,
0x15, 0x4b, 0xb0, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xe9, 0xea, 0xa1, 0xfb, 0x45, 0x0f, 0xe1, 0x62,
0x3d, 0x47, 0x84, 0x7a, 0xd7, 0xbc, 0x92, 0xa2, 0xca, 0x20, 0x64, 0x13, 0xa4, 0xec, 0xb8, 0x04,
0xd0, 0x15, 0x08, 0x09, 0x70, 0x31, 0x67, 0xa7, 0x56, 0x42, 0x3d, 0x07, 0x62, 0x0a, 0x89, 0x70,
0xb1, 0x96, 0x25, 0xe6, 0x94, 0xa6, 0x42, 0x7c, 0x15, 0x04, 0xe1, 0x58, 0x31, 0x59, 0x30, 0x3a,
0x79, 0x9d, 0x78, 0x28, 0xc7, 0x70, 0xe3, 0xa1, 0x1c, 0x43, 0xc3, 0x23, 0x39, 0xc6, 0x13, 0x8f,
0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x31, 0xca, 0x80, 0xf8, 0xd8, 0xb1,
0x06, 0x93, 0x11, 0x0c, 0x49, 0x6c, 0xe0, 0x30, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x22,
0x8a, 0x20, 0x4a, 0xda, 0x01, 0x00, 0x00,
}
func (m *Descriptor) Marshal() (dAtA []byte, err error) { func (m *Descriptor) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@@ -137,26 +92,6 @@ func (m *Descriptor) MarshalTo(dAtA []byte) (int, error) {
i++ i++
i = encodeVarintDescriptor(dAtA, i, uint64(m.Size_)) i = encodeVarintDescriptor(dAtA, i, uint64(m.Size_))
} }
if len(m.Annotations) > 0 {
for k, _ := range m.Annotations {
dAtA[i] = 0x2a
i++
v := m.Annotations[k]
mapSize := 1 + len(k) + sovDescriptor(uint64(len(k))) + 1 + len(v) + sovDescriptor(uint64(len(v)))
i = encodeVarintDescriptor(dAtA, i, uint64(mapSize))
dAtA[i] = 0xa
i++
i = encodeVarintDescriptor(dAtA, i, uint64(len(k)))
i += copy(dAtA[i:], k)
dAtA[i] = 0x12
i++
i = encodeVarintDescriptor(dAtA, i, uint64(len(v)))
i += copy(dAtA[i:], v)
}
}
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -170,9 +105,6 @@ func encodeVarintDescriptor(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *Descriptor) Size() (n int) { func (m *Descriptor) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.MediaType) l = len(m.MediaType)
@@ -186,17 +118,6 @@ func (m *Descriptor) Size() (n int) {
if m.Size_ != 0 { if m.Size_ != 0 {
n += 1 + sovDescriptor(uint64(m.Size_)) n += 1 + sovDescriptor(uint64(m.Size_))
} }
if len(m.Annotations) > 0 {
for k, v := range m.Annotations {
_ = k
_ = v
mapEntrySize := 1 + len(k) + sovDescriptor(uint64(len(k))) + 1 + len(v) + sovDescriptor(uint64(len(v)))
n += mapEntrySize + 1 + sovDescriptor(uint64(mapEntrySize))
}
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -217,22 +138,10 @@ func (this *Descriptor) String() string {
if this == nil { if this == nil {
return "nil" return "nil"
} }
keysForAnnotations := make([]string, 0, len(this.Annotations))
for k, _ := range this.Annotations {
keysForAnnotations = append(keysForAnnotations, k)
}
github_com_gogo_protobuf_sortkeys.Strings(keysForAnnotations)
mapStringForAnnotations := "map[string]string{"
for _, k := range keysForAnnotations {
mapStringForAnnotations += fmt.Sprintf("%v: %v,", k, this.Annotations[k])
}
mapStringForAnnotations += "}"
s := strings.Join([]string{`&Descriptor{`, s := strings.Join([]string{`&Descriptor{`,
`MediaType:` + fmt.Sprintf("%v", this.MediaType) + `,`, `MediaType:` + fmt.Sprintf("%v", this.MediaType) + `,`,
`Digest:` + fmt.Sprintf("%v", this.Digest) + `,`, `Digest:` + fmt.Sprintf("%v", this.Digest) + `,`,
`Size_:` + fmt.Sprintf("%v", this.Size_) + `,`, `Size_:` + fmt.Sprintf("%v", this.Size_) + `,`,
`Annotations:` + mapStringForAnnotations + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -260,7 +169,7 @@ func (m *Descriptor) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -288,7 +197,7 @@ func (m *Descriptor) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -298,9 +207,6 @@ func (m *Descriptor) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthDescriptor return ErrInvalidLengthDescriptor
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthDescriptor
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -320,7 +226,7 @@ func (m *Descriptor) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -330,9 +236,6 @@ func (m *Descriptor) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthDescriptor return ErrInvalidLengthDescriptor
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthDescriptor
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -352,138 +255,11 @@ func (m *Descriptor) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.Size_ |= int64(b&0x7F) << shift m.Size_ |= (int64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
} }
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Annotations", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDescriptor
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthDescriptor
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthDescriptor
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Annotations == nil {
m.Annotations = make(map[string]string)
}
var mapkey string
var mapvalue string
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDescriptor
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
var stringLenmapkey uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDescriptor
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapkey := int(stringLenmapkey)
if intStringLenmapkey < 0 {
return ErrInvalidLengthDescriptor
}
postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthDescriptor
}
if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF
}
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
iNdEx = postStringIndexmapkey
} else if fieldNum == 2 {
var stringLenmapvalue uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDescriptor
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapvalue := int(stringLenmapvalue)
if intStringLenmapvalue < 0 {
return ErrInvalidLengthDescriptor
}
postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthDescriptor
}
if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF
}
mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue])
iNdEx = postStringIndexmapvalue
} else {
iNdEx = entryPreIndex
skippy, err := skipDescriptor(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthDescriptor
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.Annotations[mapkey] = mapvalue
iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex
skippy, err := skipDescriptor(dAtA[iNdEx:]) skippy, err := skipDescriptor(dAtA[iNdEx:])
@@ -493,13 +269,9 @@ func (m *Descriptor) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthDescriptor return ErrInvalidLengthDescriptor
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthDescriptor
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -563,11 +335,8 @@ func skipDescriptor(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthDescriptor
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthDescriptor return 0, ErrInvalidLengthDescriptor
} }
return iNdEx, nil return iNdEx, nil
@@ -598,9 +367,6 @@ func skipDescriptor(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthDescriptor
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -619,3 +385,26 @@ var (
ErrInvalidLengthDescriptor = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthDescriptor = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowDescriptor = fmt.Errorf("proto: integer overflow") ErrIntOverflowDescriptor = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/descriptor.proto", fileDescriptorDescriptor)
}
var fileDescriptorDescriptor = []byte{
// 234 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4e, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0xa7, 0xa4, 0x16,
0x27, 0x17, 0x65, 0x16, 0x94, 0xe4, 0x17, 0xe9, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x20,
0x94, 0xe9, 0x81, 0x95, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf5, 0x41, 0x2c, 0x88,
0x3a, 0xa5, 0x6e, 0x46, 0x2e, 0x2e, 0x17, 0xb8, 0x66, 0x21, 0x59, 0x2e, 0xae, 0xdc, 0xd4, 0x94,
0xcc, 0xc4, 0x78, 0x90, 0x1e, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x4e, 0xb0, 0x48, 0x48,
0x65, 0x41, 0xaa, 0x90, 0x17, 0x17, 0x5b, 0x4a, 0x66, 0x7a, 0x6a, 0x71, 0x89, 0x04, 0x13, 0x48,
0xca, 0xc9, 0xe8, 0xc4, 0x3d, 0x79, 0x86, 0x5b, 0xf7, 0xe4, 0xb5, 0x90, 0x9c, 0x9a, 0x5f, 0x90,
0x9a, 0x07, 0xb7, 0xbc, 0x58, 0x3f, 0x3d, 0x5f, 0x17, 0xa2, 0x45, 0xcf, 0x05, 0x4c, 0x05, 0x41,
0x4d, 0x10, 0x12, 0xe2, 0x62, 0x29, 0xce, 0xac, 0x4a, 0x95, 0x60, 0x56, 0x60, 0xd4, 0x60, 0x0e,
0x02, 0xb3, 0x9d, 0xbc, 0x4e, 0x3c, 0x94, 0x63, 0xb8, 0xf1, 0x50, 0x8e, 0xa1, 0xe1, 0x91, 0x1c,
0xe3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x18, 0x65, 0x40,
0x7c, 0x60, 0x58, 0x83, 0xc9, 0x08, 0x86, 0x24, 0x36, 0xb0, 0x17, 0x8d, 0x01, 0x01, 0x00, 0x00,
0xff, 0xff, 0xea, 0xac, 0x78, 0x9a, 0x49, 0x01, 0x00, 0x00,
}

View File

@@ -3,17 +3,22 @@
package types package types
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
types "github.com/gogo/protobuf/types" // skipping weak import gogoproto "github.com/gogo/protobuf/gogoproto"
io "io" import google_protobuf1 "github.com/gogo/protobuf/types"
math "math" import _ "github.com/gogo/protobuf/types"
reflect "reflect"
strings "strings" import time "time"
time "time"
) import types1 "github.com/gogo/protobuf/types"
import strings "strings"
import reflect "reflect"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
@@ -21,82 +26,19 @@ var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
var _ = time.Kitchen var _ = time.Kitchen
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type Metric struct { type Metric struct {
Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"timestamp"` Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,stdtime" json:"timestamp"`
ID string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` ID string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
Data *types.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` Data *google_protobuf1.Any `protobuf:"bytes,3,opt,name=data" json:"data,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Metric) Reset() { *m = Metric{} } func (m *Metric) Reset() { *m = Metric{} }
func (*Metric) ProtoMessage() {} func (*Metric) ProtoMessage() {}
func (*Metric) Descriptor() ([]byte, []int) { func (*Metric) Descriptor() ([]byte, []int) { return fileDescriptorMetrics, []int{0} }
return fileDescriptor_8d594d87edf6e6bc, []int{0}
}
func (m *Metric) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Metric) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Metric.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Metric) XXX_Merge(src proto.Message) {
xxx_messageInfo_Metric.Merge(m, src)
}
func (m *Metric) XXX_Size() int {
return m.Size()
}
func (m *Metric) XXX_DiscardUnknown() {
xxx_messageInfo_Metric.DiscardUnknown(m)
}
var xxx_messageInfo_Metric proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*Metric)(nil), "containerd.types.Metric") proto.RegisterType((*Metric)(nil), "containerd.types.Metric")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/metrics.proto", fileDescriptor_8d594d87edf6e6bc)
}
var fileDescriptor_8d594d87edf6e6bc = []byte{
// 258 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x48, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0xe7, 0xa6, 0x96,
0x14, 0x65, 0x26, 0x17, 0xeb, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x20, 0xd4, 0xe8, 0x81,
0xe5, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x94, 0x64,
0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x3e, 0x98, 0x97, 0x54, 0x9a, 0xa6, 0x9f, 0x98, 0x57, 0x09,
0x95, 0x92, 0x47, 0x97, 0x2a, 0xc9, 0xcc, 0x4d, 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0x80, 0x28, 0x50,
0xea, 0x63, 0xe4, 0x62, 0xf3, 0x05, 0xdb, 0x2a, 0xe4, 0xc4, 0xc5, 0x09, 0x97, 0x95, 0x60, 0x54,
0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd2, 0x83, 0xe8, 0xd7, 0x83, 0xe9, 0xd7, 0x0b, 0x81, 0xa9, 0x70,
0xe2, 0x38, 0x71, 0x4f, 0x9e, 0x61, 0xc2, 0x7d, 0x79, 0xc6, 0x20, 0x84, 0x36, 0x21, 0x31, 0x2e,
0xa6, 0xcc, 0x14, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xb6, 0x47, 0xf7, 0xe4, 0x99, 0x3c,
0x5d, 0x82, 0x98, 0x32, 0x53, 0x84, 0x34, 0xb8, 0x58, 0x52, 0x12, 0x4b, 0x12, 0x25, 0x98, 0xc1,
0xc6, 0x8a, 0x60, 0x18, 0xeb, 0x98, 0x57, 0x19, 0x04, 0x56, 0xe1, 0xe4, 0x75, 0xe2, 0xa1, 0x1c,
0xc3, 0x8d, 0x87, 0x72, 0x0c, 0x0d, 0x8f, 0xe4, 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48,
0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x28, 0x03, 0xe2, 0x03, 0xd2, 0x1a, 0x4c, 0x46, 0x30, 0x24,
0xb1, 0x81, 0x6d, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xde, 0x0d, 0x02, 0xfe, 0x85, 0x01,
0x00, 0x00,
}
func (m *Metric) Marshal() (dAtA []byte, err error) { func (m *Metric) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@@ -114,8 +56,8 @@ func (m *Metric) MarshalTo(dAtA []byte) (int, error) {
_ = l _ = l
dAtA[i] = 0xa dAtA[i] = 0xa
i++ i++
i = encodeVarintMetrics(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp))) i = encodeVarintMetrics(dAtA, i, uint64(types1.SizeOfStdTime(m.Timestamp)))
n1, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i:]) n1, err := types1.StdTimeMarshalTo(m.Timestamp, dAtA[i:])
if err != nil { if err != nil {
return 0, err return 0, err
} }
@@ -136,9 +78,6 @@ func (m *Metric) MarshalTo(dAtA []byte) (int, error) {
} }
i += n2 i += n2
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -152,12 +91,9 @@ func encodeVarintMetrics(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *Metric) Size() (n int) { func (m *Metric) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp) l = types1.SizeOfStdTime(m.Timestamp)
n += 1 + l + sovMetrics(uint64(l)) n += 1 + l + sovMetrics(uint64(l))
l = len(m.ID) l = len(m.ID)
if l > 0 { if l > 0 {
@@ -167,9 +103,6 @@ func (m *Metric) Size() (n int) {
l = m.Data.Size() l = m.Data.Size()
n += 1 + l + sovMetrics(uint64(l)) n += 1 + l + sovMetrics(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -191,10 +124,9 @@ func (this *Metric) String() string {
return "nil" return "nil"
} }
s := strings.Join([]string{`&Metric{`, s := strings.Join([]string{`&Metric{`,
`Timestamp:` + strings.Replace(strings.Replace(this.Timestamp.String(), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`, `Timestamp:` + strings.Replace(strings.Replace(this.Timestamp.String(), "Timestamp", "google_protobuf2.Timestamp", 1), `&`, ``, 1) + `,`,
`ID:` + fmt.Sprintf("%v", this.ID) + `,`, `ID:` + fmt.Sprintf("%v", this.ID) + `,`,
`Data:` + strings.Replace(fmt.Sprintf("%v", this.Data), "Any", "types.Any", 1) + `,`, `Data:` + strings.Replace(fmt.Sprintf("%v", this.Data), "Any", "google_protobuf1.Any", 1) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -222,7 +154,7 @@ func (m *Metric) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -250,7 +182,7 @@ func (m *Metric) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -259,13 +191,10 @@ func (m *Metric) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthMetrics return ErrInvalidLengthMetrics
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthMetrics
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { if err := types1.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil {
return err return err
} }
iNdEx = postIndex iNdEx = postIndex
@@ -283,7 +212,7 @@ func (m *Metric) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -293,9 +222,6 @@ func (m *Metric) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthMetrics return ErrInvalidLengthMetrics
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthMetrics
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -315,7 +241,7 @@ func (m *Metric) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -324,14 +250,11 @@ func (m *Metric) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthMetrics return ErrInvalidLengthMetrics
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthMetrics
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if m.Data == nil { if m.Data == nil {
m.Data = &types.Any{} m.Data = &google_protobuf1.Any{}
} }
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err return err
@@ -346,13 +269,9 @@ func (m *Metric) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthMetrics return ErrInvalidLengthMetrics
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthMetrics
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -416,11 +335,8 @@ func skipMetrics(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthMetrics
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthMetrics return 0, ErrInvalidLengthMetrics
} }
return iNdEx, nil return iNdEx, nil
@@ -451,9 +367,6 @@ func skipMetrics(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthMetrics
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -472,3 +385,28 @@ var (
ErrInvalidLengthMetrics = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthMetrics = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowMetrics = fmt.Errorf("proto: integer overflow") ErrIntOverflowMetrics = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/metrics.proto", fileDescriptorMetrics)
}
var fileDescriptorMetrics = []byte{
// 258 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x48, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0xe7, 0xa6, 0x96,
0x14, 0x65, 0x26, 0x17, 0xeb, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x20, 0xd4, 0xe8, 0x81,
0xe5, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x94, 0x64,
0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x3e, 0x98, 0x97, 0x54, 0x9a, 0xa6, 0x9f, 0x98, 0x57, 0x09,
0x95, 0x92, 0x47, 0x97, 0x2a, 0xc9, 0xcc, 0x4d, 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0x80, 0x28, 0x50,
0xea, 0x63, 0xe4, 0x62, 0xf3, 0x05, 0xdb, 0x2a, 0xe4, 0xc4, 0xc5, 0x09, 0x97, 0x95, 0x60, 0x54,
0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd2, 0x83, 0xe8, 0xd7, 0x83, 0xe9, 0xd7, 0x0b, 0x81, 0xa9, 0x70,
0xe2, 0x38, 0x71, 0x4f, 0x9e, 0x61, 0xc2, 0x7d, 0x79, 0xc6, 0x20, 0x84, 0x36, 0x21, 0x31, 0x2e,
0xa6, 0xcc, 0x14, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xb6, 0x47, 0xf7, 0xe4, 0x99, 0x3c,
0x5d, 0x82, 0x98, 0x32, 0x53, 0x84, 0x34, 0xb8, 0x58, 0x52, 0x12, 0x4b, 0x12, 0x25, 0x98, 0xc1,
0xc6, 0x8a, 0x60, 0x18, 0xeb, 0x98, 0x57, 0x19, 0x04, 0x56, 0xe1, 0xe4, 0x75, 0xe2, 0xa1, 0x1c,
0xc3, 0x8d, 0x87, 0x72, 0x0c, 0x0d, 0x8f, 0xe4, 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48,
0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x28, 0x03, 0xe2, 0x03, 0xd2, 0x1a, 0x4c, 0x46, 0x30, 0x24,
0xb1, 0x81, 0x6d, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xde, 0x0d, 0x02, 0xfe, 0x85, 0x01,
0x00, 0x00,
}

View File

@@ -3,26 +3,22 @@
package types package types
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
io "io"
math "math" // skipping weak import gogoproto "github.com/gogo/protobuf/gogoproto"
reflect "reflect"
strings "strings" import strings "strings"
) import reflect "reflect"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// Mount describes mounts for a container. // Mount describes mounts for a container.
// //
// This type is the lingua franca of ContainerD. All services provide mounts // This type is the lingua franca of ContainerD. All services provide mounts
@@ -39,69 +35,16 @@ type Mount struct {
// Target path in container // Target path in container
Target string `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"` Target string `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"`
// Options specifies zero or more fstab style mount options. // Options specifies zero or more fstab style mount options.
Options []string `protobuf:"bytes,4,rep,name=options,proto3" json:"options,omitempty"` Options []string `protobuf:"bytes,4,rep,name=options" json:"options,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Mount) Reset() { *m = Mount{} } func (m *Mount) Reset() { *m = Mount{} }
func (*Mount) ProtoMessage() {} func (*Mount) ProtoMessage() {}
func (*Mount) Descriptor() ([]byte, []int) { func (*Mount) Descriptor() ([]byte, []int) { return fileDescriptorMount, []int{0} }
return fileDescriptor_920196890d4a7b9f, []int{0}
}
func (m *Mount) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Mount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Mount.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Mount) XXX_Merge(src proto.Message) {
xxx_messageInfo_Mount.Merge(m, src)
}
func (m *Mount) XXX_Size() int {
return m.Size()
}
func (m *Mount) XXX_DiscardUnknown() {
xxx_messageInfo_Mount.DiscardUnknown(m)
}
var xxx_messageInfo_Mount proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*Mount)(nil), "containerd.types.Mount") proto.RegisterType((*Mount)(nil), "containerd.types.Mount")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/mount.proto", fileDescriptor_920196890d4a7b9f)
}
var fileDescriptor_920196890d4a7b9f = []byte{
// 202 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4b, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0xe7, 0xe6, 0x97,
0xe6, 0x95, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x20, 0x54, 0xe8, 0x81, 0x65, 0xa5,
0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x52, 0x2a, 0x17, 0xab,
0x2f, 0x48, 0x9b, 0x90, 0x10, 0x17, 0x0b, 0x48, 0x9d, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10,
0x98, 0x2d, 0x24, 0xc6, 0xc5, 0x56, 0x9c, 0x5f, 0x5a, 0x94, 0x9c, 0x2a, 0xc1, 0x04, 0x16, 0x85,
0xf2, 0x40, 0xe2, 0x25, 0x89, 0x45, 0xe9, 0xa9, 0x25, 0x12, 0xcc, 0x10, 0x71, 0x08, 0x4f, 0x48,
0x82, 0x8b, 0x3d, 0xbf, 0xa0, 0x24, 0x33, 0x3f, 0xaf, 0x58, 0x82, 0x45, 0x81, 0x59, 0x83, 0x33,
0x08, 0xc6, 0x75, 0xf2, 0x3a, 0xf1, 0x50, 0x8e, 0xe1, 0xc6, 0x43, 0x39, 0x86, 0x86, 0x47, 0x72,
0x8c, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0x63, 0x94, 0x01,
0xf1, 0x1e, 0xb4, 0x06, 0x93, 0x11, 0x0c, 0x49, 0x6c, 0x60, 0xb7, 0x1b, 0x03, 0x02, 0x00, 0x00,
0xff, 0xff, 0x82, 0x1c, 0x02, 0x18, 0x1d, 0x01, 0x00, 0x00,
}
func (m *Mount) Marshal() (dAtA []byte, err error) { func (m *Mount) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@@ -150,9 +93,6 @@ func (m *Mount) MarshalTo(dAtA []byte) (int, error) {
i += copy(dAtA[i:], s) i += copy(dAtA[i:], s)
} }
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -166,9 +106,6 @@ func encodeVarintMount(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *Mount) Size() (n int) { func (m *Mount) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Type) l = len(m.Type)
@@ -189,9 +126,6 @@ func (m *Mount) Size() (n int) {
n += 1 + l + sovMount(uint64(l)) n += 1 + l + sovMount(uint64(l))
} }
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -217,7 +151,6 @@ func (this *Mount) String() string {
`Source:` + fmt.Sprintf("%v", this.Source) + `,`, `Source:` + fmt.Sprintf("%v", this.Source) + `,`,
`Target:` + fmt.Sprintf("%v", this.Target) + `,`, `Target:` + fmt.Sprintf("%v", this.Target) + `,`,
`Options:` + fmt.Sprintf("%v", this.Options) + `,`, `Options:` + fmt.Sprintf("%v", this.Options) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -245,7 +178,7 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -273,7 +206,7 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -283,9 +216,6 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthMount return ErrInvalidLengthMount
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthMount
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -305,7 +235,7 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -315,9 +245,6 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthMount return ErrInvalidLengthMount
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthMount
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -337,7 +264,7 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -347,9 +274,6 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthMount return ErrInvalidLengthMount
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthMount
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -369,7 +293,7 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -379,9 +303,6 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthMount return ErrInvalidLengthMount
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthMount
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -396,13 +317,9 @@ func (m *Mount) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthMount return ErrInvalidLengthMount
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthMount
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -466,11 +383,8 @@ func skipMount(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthMount
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthMount return 0, ErrInvalidLengthMount
} }
return iNdEx, nil return iNdEx, nil
@@ -501,9 +415,6 @@ func skipMount(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthMount
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -522,3 +433,24 @@ var (
ErrInvalidLengthMount = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthMount = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowMount = fmt.Errorf("proto: integer overflow") ErrIntOverflowMount = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/mount.proto", fileDescriptorMount)
}
var fileDescriptorMount = []byte{
// 202 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4b, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0xe7, 0xe6, 0x97,
0xe6, 0x95, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x20, 0x54, 0xe8, 0x81, 0x65, 0xa5,
0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x52, 0x2a, 0x17, 0xab,
0x2f, 0x48, 0x9b, 0x90, 0x10, 0x17, 0x0b, 0x48, 0x9d, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10,
0x98, 0x2d, 0x24, 0xc6, 0xc5, 0x56, 0x9c, 0x5f, 0x5a, 0x94, 0x9c, 0x2a, 0xc1, 0x04, 0x16, 0x85,
0xf2, 0x40, 0xe2, 0x25, 0x89, 0x45, 0xe9, 0xa9, 0x25, 0x12, 0xcc, 0x10, 0x71, 0x08, 0x4f, 0x48,
0x82, 0x8b, 0x3d, 0xbf, 0xa0, 0x24, 0x33, 0x3f, 0xaf, 0x58, 0x82, 0x45, 0x81, 0x59, 0x83, 0x33,
0x08, 0xc6, 0x75, 0xf2, 0x3a, 0xf1, 0x50, 0x8e, 0xe1, 0xc6, 0x43, 0x39, 0x86, 0x86, 0x47, 0x72,
0x8c, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0x63, 0x94, 0x01,
0xf1, 0x1e, 0xb4, 0x06, 0x93, 0x11, 0x0c, 0x49, 0x6c, 0x60, 0xb7, 0x1b, 0x03, 0x02, 0x00, 0x00,
0xff, 0xff, 0x82, 0x1c, 0x02, 0x18, 0x1d, 0x01, 0x00, 0x00,
}

View File

@@ -3,94 +3,37 @@
package types package types
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
io "io"
math "math" // skipping weak import gogoproto "github.com/gogo/protobuf/gogoproto"
reflect "reflect"
strings "strings" import strings "strings"
) import reflect "reflect"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// Platform follows the structure of the OCI platform specification, from // Platform follows the structure of the OCI platform specification, from
// descriptors. // descriptors.
type Platform struct { type Platform struct {
OS string `protobuf:"bytes,1,opt,name=os,proto3" json:"os,omitempty"` OS string `protobuf:"bytes,1,opt,name=os,proto3" json:"os,omitempty"`
Architecture string `protobuf:"bytes,2,opt,name=architecture,proto3" json:"architecture,omitempty"` Architecture string `protobuf:"bytes,2,opt,name=architecture,proto3" json:"architecture,omitempty"`
Variant string `protobuf:"bytes,3,opt,name=variant,proto3" json:"variant,omitempty"` Variant string `protobuf:"bytes,3,opt,name=variant,proto3" json:"variant,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Platform) Reset() { *m = Platform{} } func (m *Platform) Reset() { *m = Platform{} }
func (*Platform) ProtoMessage() {} func (*Platform) ProtoMessage() {}
func (*Platform) Descriptor() ([]byte, []int) { func (*Platform) Descriptor() ([]byte, []int) { return fileDescriptorPlatform, []int{0} }
return fileDescriptor_24ba7a4b83e2367e, []int{0}
}
func (m *Platform) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Platform) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Platform.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Platform) XXX_Merge(src proto.Message) {
xxx_messageInfo_Platform.Merge(m, src)
}
func (m *Platform) XXX_Size() int {
return m.Size()
}
func (m *Platform) XXX_DiscardUnknown() {
xxx_messageInfo_Platform.DiscardUnknown(m)
}
var xxx_messageInfo_Platform proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*Platform)(nil), "containerd.types.Platform") proto.RegisterType((*Platform)(nil), "containerd.types.Platform")
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/platform.proto", fileDescriptor_24ba7a4b83e2367e)
}
var fileDescriptor_24ba7a4b83e2367e = []byte{
// 205 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0x17, 0xe4, 0x24,
0x96, 0xa4, 0xe5, 0x17, 0xe5, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x20, 0x14, 0xe9,
0x81, 0x15, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf5, 0x41, 0x2c, 0x88, 0x3a, 0xa5,
0x04, 0x2e, 0x8e, 0x00, 0xa8, 0x4e, 0x21, 0x31, 0x2e, 0xa6, 0xfc, 0x62, 0x09, 0x46, 0x05, 0x46,
0x0d, 0x4e, 0x27, 0xb6, 0x47, 0xf7, 0xe4, 0x99, 0xfc, 0x83, 0x83, 0x98, 0xf2, 0x8b, 0x85, 0x94,
0xb8, 0x78, 0x12, 0x8b, 0x92, 0x33, 0x32, 0x4b, 0x52, 0x93, 0x4b, 0x4a, 0x8b, 0x52, 0x25, 0x98,
0x40, 0x2a, 0x82, 0x50, 0xc4, 0x84, 0x24, 0xb8, 0xd8, 0xcb, 0x12, 0x8b, 0x32, 0x13, 0xf3, 0x4a,
0x24, 0x98, 0xc1, 0xd2, 0x30, 0xae, 0x93, 0xd7, 0x89, 0x87, 0x72, 0x0c, 0x37, 0x1e, 0xca, 0x31,
0x34, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4,
0x18, 0xa3, 0x0c, 0x88, 0xf7, 0x9e, 0x35, 0x98, 0x8c, 0x60, 0x48, 0x62, 0x03, 0x3b, 0xdb, 0x18,
0x10, 0x00, 0x00, 0xff, 0xff, 0x05, 0xaa, 0xda, 0xa1, 0x1b, 0x01, 0x00, 0x00,
}
func (m *Platform) Marshal() (dAtA []byte, err error) { func (m *Platform) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@@ -124,9 +67,6 @@ func (m *Platform) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintPlatform(dAtA, i, uint64(len(m.Variant))) i = encodeVarintPlatform(dAtA, i, uint64(len(m.Variant)))
i += copy(dAtA[i:], m.Variant) i += copy(dAtA[i:], m.Variant)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -140,9 +80,6 @@ func encodeVarintPlatform(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *Platform) Size() (n int) { func (m *Platform) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.OS) l = len(m.OS)
@@ -157,9 +94,6 @@ func (m *Platform) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovPlatform(uint64(l)) n += 1 + l + sovPlatform(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -184,7 +118,6 @@ func (this *Platform) String() string {
`OS:` + fmt.Sprintf("%v", this.OS) + `,`, `OS:` + fmt.Sprintf("%v", this.OS) + `,`,
`Architecture:` + fmt.Sprintf("%v", this.Architecture) + `,`, `Architecture:` + fmt.Sprintf("%v", this.Architecture) + `,`,
`Variant:` + fmt.Sprintf("%v", this.Variant) + `,`, `Variant:` + fmt.Sprintf("%v", this.Variant) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -212,7 +145,7 @@ func (m *Platform) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -240,7 +173,7 @@ func (m *Platform) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -250,9 +183,6 @@ func (m *Platform) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthPlatform return ErrInvalidLengthPlatform
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthPlatform
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -272,7 +202,7 @@ func (m *Platform) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -282,9 +212,6 @@ func (m *Platform) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthPlatform return ErrInvalidLengthPlatform
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthPlatform
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -304,7 +231,7 @@ func (m *Platform) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -314,9 +241,6 @@ func (m *Platform) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthPlatform return ErrInvalidLengthPlatform
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthPlatform
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -331,13 +255,9 @@ func (m *Platform) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthPlatform return ErrInvalidLengthPlatform
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthPlatform
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -401,11 +321,8 @@ func skipPlatform(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthPlatform
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthPlatform return 0, ErrInvalidLengthPlatform
} }
return iNdEx, nil return iNdEx, nil
@@ -436,9 +353,6 @@ func skipPlatform(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthPlatform
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -457,3 +371,24 @@ var (
ErrInvalidLengthPlatform = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthPlatform = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowPlatform = fmt.Errorf("proto: integer overflow") ErrIntOverflowPlatform = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/platform.proto", fileDescriptorPlatform)
}
var fileDescriptorPlatform = []byte{
// 205 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0x17, 0xe4, 0x24,
0x96, 0xa4, 0xe5, 0x17, 0xe5, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x20, 0x14, 0xe9,
0x81, 0x15, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf5, 0x41, 0x2c, 0x88, 0x3a, 0xa5,
0x04, 0x2e, 0x8e, 0x00, 0xa8, 0x4e, 0x21, 0x31, 0x2e, 0xa6, 0xfc, 0x62, 0x09, 0x46, 0x05, 0x46,
0x0d, 0x4e, 0x27, 0xb6, 0x47, 0xf7, 0xe4, 0x99, 0xfc, 0x83, 0x83, 0x98, 0xf2, 0x8b, 0x85, 0x94,
0xb8, 0x78, 0x12, 0x8b, 0x92, 0x33, 0x32, 0x4b, 0x52, 0x93, 0x4b, 0x4a, 0x8b, 0x52, 0x25, 0x98,
0x40, 0x2a, 0x82, 0x50, 0xc4, 0x84, 0x24, 0xb8, 0xd8, 0xcb, 0x12, 0x8b, 0x32, 0x13, 0xf3, 0x4a,
0x24, 0x98, 0xc1, 0xd2, 0x30, 0xae, 0x93, 0xd7, 0x89, 0x87, 0x72, 0x0c, 0x37, 0x1e, 0xca, 0x31,
0x34, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4,
0x18, 0xa3, 0x0c, 0x88, 0xf7, 0x9e, 0x35, 0x98, 0x8c, 0x60, 0x48, 0x62, 0x03, 0x3b, 0xdb, 0x18,
0x10, 0x00, 0x00, 0xff, 0xff, 0x05, 0xaa, 0xda, 0xa1, 0x1b, 0x01, 0x00, 0x00,
}

View File

@@ -1,19 +1,34 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/containerd/containerd/api/types/task/task.proto // source: github.com/containerd/containerd/api/types/task/task.proto
/*
Package task is a generated protocol buffer package.
It is generated from these files:
github.com/containerd/containerd/api/types/task/task.proto
It has these top-level messages:
Process
ProcessInfo
*/
package task package task
import ( import proto "github.com/gogo/protobuf/proto"
fmt "fmt" import fmt "fmt"
proto "github.com/gogo/protobuf/proto" import math "math"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
types "github.com/gogo/protobuf/types" // skipping weak import gogoproto "github.com/gogo/protobuf/gogoproto"
io "io" import _ "github.com/gogo/protobuf/types"
math "math" import google_protobuf2 "github.com/gogo/protobuf/types"
reflect "reflect"
strings "strings" import time "time"
time "time"
) import types "github.com/gogo/protobuf/types"
import strings "strings"
import reflect "reflect"
import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
@@ -46,7 +61,6 @@ var Status_name = map[int32]string{
4: "PAUSED", 4: "PAUSED",
5: "PAUSING", 5: "PAUSING",
} }
var Status_value = map[string]int32{ var Status_value = map[string]int32{
"UNKNOWN": 0, "UNKNOWN": 0,
"CREATED": 1, "CREATED": 1,
@@ -59,58 +73,24 @@ var Status_value = map[string]int32{
func (x Status) String() string { func (x Status) String() string {
return proto.EnumName(Status_name, int32(x)) return proto.EnumName(Status_name, int32(x))
} }
func (Status) EnumDescriptor() ([]byte, []int) { return fileDescriptorTask, []int{0} }
func (Status) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_391ef18c8ab0dc16, []int{0}
}
type Process struct { type Process struct {
ContainerID string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` ContainerID string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"`
ID string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` ID string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
Pid uint32 `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"` Pid uint32 `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"`
Status Status `protobuf:"varint,4,opt,name=status,proto3,enum=containerd.v1.types.Status" json:"status,omitempty"` Status Status `protobuf:"varint,4,opt,name=status,proto3,enum=containerd.v1.types.Status" json:"status,omitempty"`
Stdin string `protobuf:"bytes,5,opt,name=stdin,proto3" json:"stdin,omitempty"` Stdin string `protobuf:"bytes,5,opt,name=stdin,proto3" json:"stdin,omitempty"`
Stdout string `protobuf:"bytes,6,opt,name=stdout,proto3" json:"stdout,omitempty"` Stdout string `protobuf:"bytes,6,opt,name=stdout,proto3" json:"stdout,omitempty"`
Stderr string `protobuf:"bytes,7,opt,name=stderr,proto3" json:"stderr,omitempty"` Stderr string `protobuf:"bytes,7,opt,name=stderr,proto3" json:"stderr,omitempty"`
Terminal bool `protobuf:"varint,8,opt,name=terminal,proto3" json:"terminal,omitempty"` Terminal bool `protobuf:"varint,8,opt,name=terminal,proto3" json:"terminal,omitempty"`
ExitStatus uint32 `protobuf:"varint,9,opt,name=exit_status,json=exitStatus,proto3" json:"exit_status,omitempty"` ExitStatus uint32 `protobuf:"varint,9,opt,name=exit_status,json=exitStatus,proto3" json:"exit_status,omitempty"`
ExitedAt time.Time `protobuf:"bytes,10,opt,name=exited_at,json=exitedAt,proto3,stdtime" json:"exited_at"` ExitedAt time.Time `protobuf:"bytes,10,opt,name=exited_at,json=exitedAt,stdtime" json:"exited_at"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Process) Reset() { *m = Process{} } func (m *Process) Reset() { *m = Process{} }
func (*Process) ProtoMessage() {} func (*Process) ProtoMessage() {}
func (*Process) Descriptor() ([]byte, []int) { func (*Process) Descriptor() ([]byte, []int) { return fileDescriptorTask, []int{0} }
return fileDescriptor_391ef18c8ab0dc16, []int{0}
}
func (m *Process) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Process) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Process.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Process) XXX_Merge(src proto.Message) {
xxx_messageInfo_Process.Merge(m, src)
}
func (m *Process) XXX_Size() int {
return m.Size()
}
func (m *Process) XXX_DiscardUnknown() {
xxx_messageInfo_Process.DiscardUnknown(m)
}
var xxx_messageInfo_Process proto.InternalMessageInfo
type ProcessInfo struct { type ProcessInfo struct {
// PID is the process ID. // PID is the process ID.
@@ -118,93 +98,18 @@ type ProcessInfo struct {
// Info contains additional process information. // Info contains additional process information.
// //
// Info varies by platform. // Info varies by platform.
Info *types.Any `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` Info *google_protobuf2.Any `protobuf:"bytes,2,opt,name=info" json:"info,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ProcessInfo) Reset() { *m = ProcessInfo{} } func (m *ProcessInfo) Reset() { *m = ProcessInfo{} }
func (*ProcessInfo) ProtoMessage() {} func (*ProcessInfo) ProtoMessage() {}
func (*ProcessInfo) Descriptor() ([]byte, []int) { func (*ProcessInfo) Descriptor() ([]byte, []int) { return fileDescriptorTask, []int{1} }
return fileDescriptor_391ef18c8ab0dc16, []int{1}
}
func (m *ProcessInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ProcessInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ProcessInfo.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *ProcessInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_ProcessInfo.Merge(m, src)
}
func (m *ProcessInfo) XXX_Size() int {
return m.Size()
}
func (m *ProcessInfo) XXX_DiscardUnknown() {
xxx_messageInfo_ProcessInfo.DiscardUnknown(m)
}
var xxx_messageInfo_ProcessInfo proto.InternalMessageInfo
func init() { func init() {
proto.RegisterEnum("containerd.v1.types.Status", Status_name, Status_value)
proto.RegisterType((*Process)(nil), "containerd.v1.types.Process") proto.RegisterType((*Process)(nil), "containerd.v1.types.Process")
proto.RegisterType((*ProcessInfo)(nil), "containerd.v1.types.ProcessInfo") proto.RegisterType((*ProcessInfo)(nil), "containerd.v1.types.ProcessInfo")
proto.RegisterEnum("containerd.v1.types.Status", Status_name, Status_value)
} }
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/task/task.proto", fileDescriptor_391ef18c8ab0dc16)
}
var fileDescriptor_391ef18c8ab0dc16 = []byte{
// 545 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x3f, 0x6f, 0xd3, 0x40,
0x18, 0xc6, 0x7d, 0x6e, 0xeb, 0xa6, 0xe7, 0xb6, 0x18, 0x13, 0x55, 0xc6, 0x20, 0xdb, 0xea, 0x64,
0x31, 0xd8, 0x22, 0xdd, 0xd8, 0xf2, 0x4f, 0xc8, 0x42, 0x72, 0x23, 0x27, 0x11, 0x6c, 0x91, 0x13,
0x5f, 0xcc, 0xa9, 0xcd, 0x9d, 0x65, 0x9f, 0x81, 0x6c, 0x8c, 0xa8, 0x13, 0x5f, 0xa0, 0x13, 0x7c,
0x0a, 0x3e, 0x41, 0x46, 0x26, 0xc4, 0x14, 0xa8, 0x3f, 0x09, 0x3a, 0xdb, 0x49, 0x23, 0x60, 0x39,
0xbd, 0xef, 0xf3, 0x7b, 0xee, 0xbd, 0xf7, 0x1e, 0xf8, 0x22, 0xc6, 0xec, 0x6d, 0x3e, 0x75, 0x66,
0x74, 0xe1, 0xce, 0x28, 0x61, 0x21, 0x26, 0x28, 0x8d, 0x76, 0xcb, 0x30, 0xc1, 0x2e, 0x5b, 0x26,
0x28, 0x73, 0x59, 0x98, 0x5d, 0x95, 0x87, 0x93, 0xa4, 0x94, 0x51, 0xf5, 0xd1, 0xbd, 0xcb, 0x79,
0xf7, 0xdc, 0x29, 0x4d, 0x7a, 0x33, 0xa6, 0x31, 0x2d, 0xb9, 0xcb, 0xab, 0xca, 0xaa, 0x9b, 0x31,
0xa5, 0xf1, 0x35, 0x72, 0xcb, 0x6e, 0x9a, 0xcf, 0x5d, 0x86, 0x17, 0x28, 0x63, 0xe1, 0x22, 0xa9,
0x0d, 0x8f, 0xff, 0x36, 0x84, 0x64, 0x59, 0xa1, 0xf3, 0x42, 0x84, 0x87, 0x83, 0x94, 0xce, 0x50,
0x96, 0xa9, 0x2d, 0x78, 0xbc, 0x7d, 0x74, 0x82, 0x23, 0x0d, 0x58, 0xc0, 0x3e, 0xea, 0x3c, 0x28,
0xd6, 0xa6, 0xdc, 0xdd, 0xe8, 0x5e, 0x2f, 0x90, 0xb7, 0x26, 0x2f, 0x52, 0xcf, 0xa0, 0x88, 0x23,
0x4d, 0x2c, 0x9d, 0x52, 0xb1, 0x36, 0x45, 0xaf, 0x17, 0x88, 0x38, 0x52, 0x15, 0xb8, 0x97, 0xe0,
0x48, 0xdb, 0xb3, 0x80, 0x7d, 0x12, 0xf0, 0x52, 0xbd, 0x80, 0x52, 0xc6, 0x42, 0x96, 0x67, 0xda,
0xbe, 0x05, 0xec, 0xd3, 0xd6, 0x13, 0xe7, 0x3f, 0x3f, 0x74, 0x86, 0xa5, 0x25, 0xa8, 0xad, 0x6a,
0x13, 0x1e, 0x64, 0x2c, 0xc2, 0x44, 0x3b, 0xe0, 0x2f, 0x04, 0x55, 0xa3, 0x9e, 0xf1, 0x51, 0x11,
0xcd, 0x99, 0x26, 0x95, 0x72, 0xdd, 0xd5, 0x3a, 0x4a, 0x53, 0xed, 0x70, 0xab, 0xa3, 0x34, 0x55,
0x75, 0xd8, 0x60, 0x28, 0x5d, 0x60, 0x12, 0x5e, 0x6b, 0x0d, 0x0b, 0xd8, 0x8d, 0x60, 0xdb, 0xab,
0x26, 0x94, 0xd1, 0x07, 0xcc, 0x26, 0xf5, 0x6e, 0x47, 0xe5, 0xc2, 0x90, 0x4b, 0xd5, 0x2a, 0x6a,
0x1b, 0x1e, 0xf1, 0x0e, 0x45, 0x93, 0x90, 0x69, 0xd0, 0x02, 0xb6, 0xdc, 0xd2, 0x9d, 0x2a, 0x50,
0x67, 0x13, 0xa8, 0x33, 0xda, 0x24, 0xde, 0x69, 0xac, 0xd6, 0xa6, 0xf0, 0xf9, 0x97, 0x09, 0x82,
0x46, 0x75, 0xad, 0xcd, 0xce, 0x3d, 0x28, 0xd7, 0x19, 0x7b, 0x64, 0x4e, 0x37, 0xd9, 0x80, 0xfb,
0x6c, 0x6c, 0xb8, 0x8f, 0xc9, 0x9c, 0x96, 0x39, 0xca, 0xad, 0xe6, 0x3f, 0xe3, 0xdb, 0x64, 0x19,
0x94, 0x8e, 0x67, 0x3f, 0x00, 0x94, 0xea, 0xc5, 0x0c, 0x78, 0x38, 0xf6, 0x5f, 0xf9, 0x97, 0xaf,
0x7d, 0x45, 0xd0, 0x1f, 0xde, 0xdc, 0x5a, 0x27, 0x15, 0x18, 0x93, 0x2b, 0x42, 0xdf, 0x13, 0xce,
0xbb, 0x41, 0xbf, 0x3d, 0xea, 0xf7, 0x14, 0xb0, 0xcb, 0xbb, 0x29, 0x0a, 0x19, 0x8a, 0x38, 0x0f,
0xc6, 0xbe, 0xef, 0xf9, 0x2f, 0x15, 0x71, 0x97, 0x07, 0x39, 0x21, 0x98, 0xc4, 0x9c, 0x0f, 0x47,
0x97, 0x83, 0x41, 0xbf, 0xa7, 0xec, 0xed, 0xf2, 0x21, 0xa3, 0x49, 0x82, 0x22, 0xf5, 0x29, 0x94,
0x06, 0xed, 0xf1, 0xb0, 0xdf, 0x53, 0xf6, 0x75, 0xe5, 0xe6, 0xd6, 0x3a, 0xae, 0xf0, 0x20, 0xcc,
0xb3, 0x6a, 0x3a, 0xa7, 0x7c, 0xfa, 0xc1, 0xee, 0x6d, 0x8e, 0x31, 0x89, 0xf5, 0xd3, 0x4f, 0x5f,
0x0c, 0xe1, 0xdb, 0x57, 0xa3, 0xfe, 0x4d, 0x47, 0x5b, 0xdd, 0x19, 0xc2, 0xcf, 0x3b, 0x43, 0xf8,
0x58, 0x18, 0x60, 0x55, 0x18, 0xe0, 0x7b, 0x61, 0x80, 0xdf, 0x85, 0x01, 0xde, 0x08, 0x53, 0xa9,
0x0c, 0xe2, 0xe2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x32, 0xd2, 0x86, 0x50, 0x03, 0x00,
0x00,
}
func (m *Process) Marshal() (dAtA []byte, err error) { func (m *Process) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@@ -277,15 +182,12 @@ func (m *Process) MarshalTo(dAtA []byte) (int, error) {
} }
dAtA[i] = 0x52 dAtA[i] = 0x52
i++ i++
i = encodeVarintTask(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.ExitedAt))) i = encodeVarintTask(dAtA, i, uint64(types.SizeOfStdTime(m.ExitedAt)))
n1, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.ExitedAt, dAtA[i:]) n1, err := types.StdTimeMarshalTo(m.ExitedAt, dAtA[i:])
if err != nil { if err != nil {
return 0, err return 0, err
} }
i += n1 i += n1
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -319,9 +221,6 @@ func (m *ProcessInfo) MarshalTo(dAtA []byte) (int, error) {
} }
i += n2 i += n2
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -335,9 +234,6 @@ func encodeVarintTask(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *Process) Size() (n int) { func (m *Process) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.ContainerID) l = len(m.ContainerID)
@@ -372,18 +268,12 @@ func (m *Process) Size() (n int) {
if m.ExitStatus != 0 { if m.ExitStatus != 0 {
n += 1 + sovTask(uint64(m.ExitStatus)) n += 1 + sovTask(uint64(m.ExitStatus))
} }
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.ExitedAt) l = types.SizeOfStdTime(m.ExitedAt)
n += 1 + l + sovTask(uint64(l)) n += 1 + l + sovTask(uint64(l))
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *ProcessInfo) Size() (n int) { func (m *ProcessInfo) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if m.Pid != 0 { if m.Pid != 0 {
@@ -393,9 +283,6 @@ func (m *ProcessInfo) Size() (n int) {
l = m.Info.Size() l = m.Info.Size()
n += 1 + l + sovTask(uint64(l)) n += 1 + l + sovTask(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -426,8 +313,7 @@ func (this *Process) String() string {
`Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`, `Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`,
`Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`, `Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`,
`ExitStatus:` + fmt.Sprintf("%v", this.ExitStatus) + `,`, `ExitStatus:` + fmt.Sprintf("%v", this.ExitStatus) + `,`,
`ExitedAt:` + strings.Replace(strings.Replace(this.ExitedAt.String(), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`, `ExitedAt:` + strings.Replace(strings.Replace(this.ExitedAt.String(), "Timestamp", "google_protobuf1.Timestamp", 1), `&`, ``, 1) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -438,8 +324,7 @@ func (this *ProcessInfo) String() string {
} }
s := strings.Join([]string{`&ProcessInfo{`, s := strings.Join([]string{`&ProcessInfo{`,
`Pid:` + fmt.Sprintf("%v", this.Pid) + `,`, `Pid:` + fmt.Sprintf("%v", this.Pid) + `,`,
`Info:` + strings.Replace(fmt.Sprintf("%v", this.Info), "Any", "types.Any", 1) + `,`, `Info:` + strings.Replace(fmt.Sprintf("%v", this.Info), "Any", "google_protobuf2.Any", 1) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -467,7 +352,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -495,7 +380,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -505,9 +390,6 @@ func (m *Process) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTask
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -527,7 +409,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -537,9 +419,6 @@ func (m *Process) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTask
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -559,7 +438,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.Pid |= uint32(b&0x7F) << shift m.Pid |= (uint32(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -578,7 +457,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.Status |= Status(b&0x7F) << shift m.Status |= (Status(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -597,7 +476,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -607,9 +486,6 @@ func (m *Process) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTask
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -629,7 +505,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -639,9 +515,6 @@ func (m *Process) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTask
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -661,7 +534,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -671,9 +544,6 @@ func (m *Process) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTask
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@@ -693,7 +563,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
v |= int(b&0x7F) << shift v |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -713,7 +583,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.ExitStatus |= uint32(b&0x7F) << shift m.ExitStatus |= (uint32(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -732,7 +602,7 @@ func (m *Process) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -741,13 +611,10 @@ func (m *Process) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTask
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.ExitedAt, dAtA[iNdEx:postIndex]); err != nil { if err := types.StdTimeUnmarshal(&m.ExitedAt, dAtA[iNdEx:postIndex]); err != nil {
return err return err
} }
iNdEx = postIndex iNdEx = postIndex
@@ -760,13 +627,9 @@ func (m *Process) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthTask
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -791,7 +654,7 @@ func (m *ProcessInfo) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= uint64(b&0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -819,7 +682,7 @@ func (m *ProcessInfo) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.Pid |= uint32(b&0x7F) << shift m.Pid |= (uint32(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -838,7 +701,7 @@ func (m *ProcessInfo) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
msglen |= int(b&0x7F) << shift msglen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@@ -847,14 +710,11 @@ func (m *ProcessInfo) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
postIndex := iNdEx + msglen postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTask
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if m.Info == nil { if m.Info == nil {
m.Info = &types.Any{} m.Info = &google_protobuf2.Any{}
} }
if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err return err
@@ -869,13 +729,9 @@ func (m *ProcessInfo) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthTask return ErrInvalidLengthTask
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthTask
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -939,11 +795,8 @@ func skipTask(dAtA []byte) (n int, err error) {
break break
} }
} }
if length < 0 {
return 0, ErrInvalidLengthTask
}
iNdEx += length iNdEx += length
if iNdEx < 0 { if length < 0 {
return 0, ErrInvalidLengthTask return 0, ErrInvalidLengthTask
} }
return iNdEx, nil return iNdEx, nil
@@ -974,9 +827,6 @@ func skipTask(dAtA []byte) (n int, err error) {
return 0, err return 0, err
} }
iNdEx = start + next iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthTask
}
} }
return iNdEx, nil return iNdEx, nil
case 4: case 4:
@@ -995,3 +845,46 @@ var (
ErrInvalidLengthTask = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthTask = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowTask = fmt.Errorf("proto: integer overflow") ErrIntOverflowTask = fmt.Errorf("proto: integer overflow")
) )
func init() {
proto.RegisterFile("github.com/containerd/containerd/api/types/task/task.proto", fileDescriptorTask)
}
var fileDescriptorTask = []byte{
// 545 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x3f, 0x6f, 0xd3, 0x40,
0x18, 0xc6, 0x7d, 0x6e, 0xeb, 0xa6, 0xe7, 0xb6, 0x18, 0x13, 0x55, 0xc6, 0x20, 0xdb, 0xea, 0x64,
0x31, 0xd8, 0x22, 0xdd, 0xd8, 0xf2, 0x4f, 0xc8, 0x42, 0x72, 0x23, 0x27, 0x11, 0x6c, 0x91, 0x13,
0x5f, 0xcc, 0xa9, 0xcd, 0x9d, 0x65, 0x9f, 0x81, 0x6c, 0x8c, 0xa8, 0x13, 0x5f, 0xa0, 0x13, 0x7c,
0x0a, 0x3e, 0x41, 0x46, 0x26, 0xc4, 0x14, 0xa8, 0x3f, 0x09, 0x3a, 0xdb, 0x49, 0x23, 0x60, 0x39,
0xbd, 0xef, 0xf3, 0x7b, 0xee, 0xbd, 0xf7, 0x1e, 0xf8, 0x22, 0xc6, 0xec, 0x6d, 0x3e, 0x75, 0x66,
0x74, 0xe1, 0xce, 0x28, 0x61, 0x21, 0x26, 0x28, 0x8d, 0x76, 0xcb, 0x30, 0xc1, 0x2e, 0x5b, 0x26,
0x28, 0x73, 0x59, 0x98, 0x5d, 0x95, 0x87, 0x93, 0xa4, 0x94, 0x51, 0xf5, 0xd1, 0xbd, 0xcb, 0x79,
0xf7, 0xdc, 0x29, 0x4d, 0x7a, 0x33, 0xa6, 0x31, 0x2d, 0xb9, 0xcb, 0xab, 0xca, 0xaa, 0x9b, 0x31,
0xa5, 0xf1, 0x35, 0x72, 0xcb, 0x6e, 0x9a, 0xcf, 0x5d, 0x86, 0x17, 0x28, 0x63, 0xe1, 0x22, 0xa9,
0x0d, 0x8f, 0xff, 0x36, 0x84, 0x64, 0x59, 0xa1, 0xf3, 0x42, 0x84, 0x87, 0x83, 0x94, 0xce, 0x50,
0x96, 0xa9, 0x2d, 0x78, 0xbc, 0x7d, 0x74, 0x82, 0x23, 0x0d, 0x58, 0xc0, 0x3e, 0xea, 0x3c, 0x28,
0xd6, 0xa6, 0xdc, 0xdd, 0xe8, 0x5e, 0x2f, 0x90, 0xb7, 0x26, 0x2f, 0x52, 0xcf, 0xa0, 0x88, 0x23,
0x4d, 0x2c, 0x9d, 0x52, 0xb1, 0x36, 0x45, 0xaf, 0x17, 0x88, 0x38, 0x52, 0x15, 0xb8, 0x97, 0xe0,
0x48, 0xdb, 0xb3, 0x80, 0x7d, 0x12, 0xf0, 0x52, 0xbd, 0x80, 0x52, 0xc6, 0x42, 0x96, 0x67, 0xda,
0xbe, 0x05, 0xec, 0xd3, 0xd6, 0x13, 0xe7, 0x3f, 0x3f, 0x74, 0x86, 0xa5, 0x25, 0xa8, 0xad, 0x6a,
0x13, 0x1e, 0x64, 0x2c, 0xc2, 0x44, 0x3b, 0xe0, 0x2f, 0x04, 0x55, 0xa3, 0x9e, 0xf1, 0x51, 0x11,
0xcd, 0x99, 0x26, 0x95, 0x72, 0xdd, 0xd5, 0x3a, 0x4a, 0x53, 0xed, 0x70, 0xab, 0xa3, 0x34, 0x55,
0x75, 0xd8, 0x60, 0x28, 0x5d, 0x60, 0x12, 0x5e, 0x6b, 0x0d, 0x0b, 0xd8, 0x8d, 0x60, 0xdb, 0xab,
0x26, 0x94, 0xd1, 0x07, 0xcc, 0x26, 0xf5, 0x6e, 0x47, 0xe5, 0xc2, 0x90, 0x4b, 0xd5, 0x2a, 0x6a,
0x1b, 0x1e, 0xf1, 0x0e, 0x45, 0x93, 0x90, 0x69, 0xd0, 0x02, 0xb6, 0xdc, 0xd2, 0x9d, 0x2a, 0x50,
0x67, 0x13, 0xa8, 0x33, 0xda, 0x24, 0xde, 0x69, 0xac, 0xd6, 0xa6, 0xf0, 0xf9, 0x97, 0x09, 0x82,
0x46, 0x75, 0xad, 0xcd, 0xce, 0x3d, 0x28, 0xd7, 0x19, 0x7b, 0x64, 0x4e, 0x37, 0xd9, 0x80, 0xfb,
0x6c, 0x6c, 0xb8, 0x8f, 0xc9, 0x9c, 0x96, 0x39, 0xca, 0xad, 0xe6, 0x3f, 0xe3, 0xdb, 0x64, 0x19,
0x94, 0x8e, 0x67, 0x3f, 0x00, 0x94, 0xea, 0xc5, 0x0c, 0x78, 0x38, 0xf6, 0x5f, 0xf9, 0x97, 0xaf,
0x7d, 0x45, 0xd0, 0x1f, 0xde, 0xdc, 0x5a, 0x27, 0x15, 0x18, 0x93, 0x2b, 0x42, 0xdf, 0x13, 0xce,
0xbb, 0x41, 0xbf, 0x3d, 0xea, 0xf7, 0x14, 0xb0, 0xcb, 0xbb, 0x29, 0x0a, 0x19, 0x8a, 0x38, 0x0f,
0xc6, 0xbe, 0xef, 0xf9, 0x2f, 0x15, 0x71, 0x97, 0x07, 0x39, 0x21, 0x98, 0xc4, 0x9c, 0x0f, 0x47,
0x97, 0x83, 0x41, 0xbf, 0xa7, 0xec, 0xed, 0xf2, 0x21, 0xa3, 0x49, 0x82, 0x22, 0xf5, 0x29, 0x94,
0x06, 0xed, 0xf1, 0xb0, 0xdf, 0x53, 0xf6, 0x75, 0xe5, 0xe6, 0xd6, 0x3a, 0xae, 0xf0, 0x20, 0xcc,
0xb3, 0x6a, 0x3a, 0xa7, 0x7c, 0xfa, 0xc1, 0xee, 0x6d, 0x8e, 0x31, 0x89, 0xf5, 0xd3, 0x4f, 0x5f,
0x0c, 0xe1, 0xdb, 0x57, 0xa3, 0xfe, 0x4d, 0x47, 0x5b, 0xdd, 0x19, 0xc2, 0xcf, 0x3b, 0x43, 0xf8,
0x58, 0x18, 0x60, 0x55, 0x18, 0xe0, 0x7b, 0x61, 0x80, 0xdf, 0x85, 0x01, 0xde, 0x08, 0x53, 0xa9,
0x0c, 0xe2, 0xe2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x32, 0xd2, 0x86, 0x50, 0x03, 0x00,
0x00,
}

View File

@@ -111,18 +111,7 @@ func unmount(target string, flags int) error {
// UnmountAll repeatedly unmounts the given mount point until there // UnmountAll repeatedly unmounts the given mount point until there
// are no mounts remaining (EINVAL is returned by mount), which is // are no mounts remaining (EINVAL is returned by mount), which is
// useful for undoing a stack of mounts on the same mount point. // useful for undoing a stack of mounts on the same mount point.
// UnmountAll all is noop when the first argument is an empty string.
// This is done when the containerd client did not specify any rootfs
// mounts (e.g. because the rootfs is managed outside containerd)
// UnmountAll is noop when the mount path does not exist.
func UnmountAll(mount string, flags int) error { func UnmountAll(mount string, flags int) error {
if mount == "" {
return nil
}
if _, err := os.Stat(mount); os.IsNotExist(err) {
return nil
}
for { for {
if err := unmount(mount, flags); err != nil { if err := unmount(mount, flags); err != nil {
// EINVAL is returned if the target is not a // EINVAL is returned if the target is not a

View File

@@ -25,8 +25,6 @@ import (
"os" "os"
"strconv" "strconv"
"strings" "strings"
"github.com/pkg/errors"
) )
// Self retrieves a list of mounts for the current running process. // Self retrieves a list of mounts for the current running process.
@@ -43,15 +41,13 @@ func Self() ([]Info, error) {
func parseInfoFile(r io.Reader) ([]Info, error) { func parseInfoFile(r io.Reader) ([]Info, error) {
s := bufio.NewScanner(r) s := bufio.NewScanner(r)
out := []Info{} out := []Info{}
var err error
for s.Scan() { for s.Scan() {
if err = s.Err(); err != nil { if err := s.Err(); err != nil {
return nil, err return nil, err
} }
/* /*
See http://man7.org/linux/man-pages/man5/proc.5.html
36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
(1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11)
(1) mount ID: unique identifier of the mount (may be reused after umount) (1) mount ID: unique identifier of the mount (may be reused after umount)
@@ -72,7 +68,7 @@ func parseInfoFile(r io.Reader) ([]Info, error) {
numFields := len(fields) numFields := len(fields)
if numFields < 10 { if numFields < 10 {
// should be at least 10 fields // should be at least 10 fields
return nil, errors.Errorf("parsing '%s' failed: not enough fields (%d)", text, numFields) return nil, fmt.Errorf("parsing '%s' failed: not enough fields (%d)", text, numFields)
} }
p := Info{} p := Info{}
// ignore any numbers parsing errors, as there should not be any // ignore any numbers parsing errors, as there should not be any
@@ -80,19 +76,13 @@ func parseInfoFile(r io.Reader) ([]Info, error) {
p.Parent, _ = strconv.Atoi(fields[1]) p.Parent, _ = strconv.Atoi(fields[1])
mm := strings.Split(fields[2], ":") mm := strings.Split(fields[2], ":")
if len(mm) != 2 { if len(mm) != 2 {
return nil, errors.Errorf("parsing '%s' failed: unexpected minor:major pair %s", text, mm) return nil, fmt.Errorf("parsing '%s' failed: unexpected minor:major pair %s", text, mm)
} }
p.Major, _ = strconv.Atoi(mm[0]) p.Major, _ = strconv.Atoi(mm[0])
p.Minor, _ = strconv.Atoi(mm[1]) p.Minor, _ = strconv.Atoi(mm[1])
p.Root, err = strconv.Unquote(`"` + fields[3] + `"`) p.Root = fields[3]
if err != nil { p.Mountpoint = fields[4]
return nil, errors.Wrapf(err, "parsing '%s' failed: unable to unquote root field", fields[3])
}
p.Mountpoint, err = strconv.Unquote(`"` + fields[4] + `"`)
if err != nil {
return nil, errors.Wrapf(err, "parsing '%s' failed: unable to unquote mount point field", fields[4])
}
p.Options = fields[5] p.Options = fields[5]
// one or more optional fields, when a separator (-) // one or more optional fields, when a separator (-)
@@ -111,11 +101,11 @@ func parseInfoFile(r io.Reader) ([]Info, error) {
} }
} }
if i == numFields { if i == numFields {
return nil, errors.Errorf("parsing '%s' failed: missing separator ('-')", text) return nil, fmt.Errorf("parsing '%s' failed: missing separator ('-')", text)
} }
// There should be 3 fields after the separator... // There should be 3 fields after the separator...
if i+4 > numFields { if i+4 > numFields {
return nil, errors.Errorf("parsing '%s' failed: not enough fields after a separator", text) return nil, fmt.Errorf("parsing '%s' failed: not enough fields after a separator", text)
} }
// ... but in Linux <= 3.9 mounting a cifs with spaces in a share name // ... but in Linux <= 3.9 mounting a cifs with spaces in a share name
// (like "//serv/My Documents") _may_ end up having a space in the last field // (like "//serv/My Documents") _may_ end up having a space in the last field

View File

@@ -1,105 +0,0 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ttrpcutil
import (
"sync"
"time"
v1 "github.com/containerd/containerd/api/services/ttrpc/events/v1"
"github.com/containerd/ttrpc"
"github.com/pkg/errors"
)
const ttrpcDialTimeout = 5 * time.Second
type ttrpcConnector func() (*ttrpc.Client, error)
// Client is the client to interact with TTRPC part of containerd server (plugins, events)
type Client struct {
mu sync.Mutex
connector ttrpcConnector
client *ttrpc.Client
closed bool
}
// NewClient returns a new containerd TTRPC client that is connected to the containerd instance provided by address
func NewClient(address string, opts ...ttrpc.ClientOpts) (*Client, error) {
connector := func() (*ttrpc.Client, error) {
conn, err := ttrpcDial(address, ttrpcDialTimeout)
if err != nil {
return nil, errors.Wrap(err, "failed to connect")
}
client := ttrpc.NewClient(conn, opts...)
return client, nil
}
client, err := connector()
if err != nil {
return nil, err
}
return &Client{
connector: connector,
client: client,
}, nil
}
// Reconnect re-establishes the TTRPC connection to the containerd daemon
func (c *Client) Reconnect() error {
c.mu.Lock()
defer c.mu.Unlock()
if c.connector == nil {
return errors.New("unable to reconnect to containerd, no connector available")
}
if c.closed {
return errors.New("client is closed")
}
client, err := c.connector()
if err != nil {
return err
}
c.client = client
return nil
}
// EventsService creates an EventsService client
func (c *Client) EventsService() v1.EventsService {
return v1.NewEventsClient(c.Client())
}
// Client returns the underlying TTRPC client object
func (c *Client) Client() *ttrpc.Client {
c.mu.Lock()
defer c.mu.Unlock()
return c.client
}
// Close closes the clients TTRPC connection to containerd
func (c *Client) Close() error {
c.mu.Lock()
defer c.mu.Unlock()
c.closed = true
return c.client.Close()
}

View File

@@ -1,30 +0,0 @@
// +build !windows
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ttrpcutil
import (
"net"
"strings"
"time"
)
func ttrpcDial(address string, timeout time.Duration) (net.Conn, error) {
address = strings.TrimPrefix(address, "unix://")
return net.DialTimeout("unix", address, timeout)
}

View File

@@ -1,60 +0,0 @@
// +build windows
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ttrpcutil
import (
"net"
"os"
"time"
winio "github.com/Microsoft/go-winio"
"github.com/pkg/errors"
)
func ttrpcDial(address string, timeout time.Duration) (net.Conn, error) {
var c net.Conn
var lastError error
timedOutError := errors.Errorf("timed out waiting for npipe %s", address)
start := time.Now()
for {
remaining := timeout - time.Since(start)
if remaining <= 0 {
lastError = timedOutError
break
}
c, lastError = winio.DialPipe(address, &remaining)
if lastError == nil {
break
}
if !os.IsNotExist(lastError) {
break
}
// There is nobody serving the pipe. We limit the timeout for this case
// to 5 seconds because any shim that would serve this endpoint should
// serve it within 5 seconds. We use the passed in timeout for the
// `DialPipe` timeout if the pipe exists however to give the pipe time
// to `Accept` the connection.
if time.Since(start) >= 5*time.Second {
lastError = timedOutError
break
}
time.Sleep(10 * time.Millisecond)
}
return c, lastError
}

File diff suppressed because it is too large Load Diff

View File

@@ -69,8 +69,4 @@ type PlatformRuntime interface {
// Tasks returns all the current tasks for the runtime. // Tasks returns all the current tasks for the runtime.
// Any container runs at most one task at a time. // Any container runs at most one task at a time.
Tasks(context.Context, bool) ([]Task, error) Tasks(context.Context, bool) ([]Task, error)
// Add adds a task into runtime.
Add(context.Context, Task) error
// Delete remove a task.
Delete(context.Context, string)
} }

View File

@@ -1,150 +0,0 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package shim
import (
"context"
"sync"
"time"
v1 "github.com/containerd/containerd/api/services/ttrpc/events/v1"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/pkg/ttrpcutil"
"github.com/containerd/ttrpc"
"github.com/containerd/typeurl"
"github.com/sirupsen/logrus"
)
const (
queueSize = 2048
maxRequeue = 5
)
type item struct {
ev *v1.Envelope
ctx context.Context
count int
}
func newPublisher(address string) (*remoteEventsPublisher, error) {
client, err := ttrpcutil.NewClient(address)
if err != nil {
return nil, err
}
l := &remoteEventsPublisher{
client: client,
closed: make(chan struct{}),
requeue: make(chan *item, queueSize),
}
go l.processQueue()
return l, nil
}
type remoteEventsPublisher struct {
client *ttrpcutil.Client
closed chan struct{}
closer sync.Once
requeue chan *item
}
func (l *remoteEventsPublisher) Done() <-chan struct{} {
return l.closed
}
func (l *remoteEventsPublisher) Close() (err error) {
err = l.client.Close()
l.closer.Do(func() {
close(l.closed)
})
return err
}
func (l *remoteEventsPublisher) processQueue() {
for i := range l.requeue {
if i.count > maxRequeue {
logrus.Errorf("evicting %s from queue because of retry count", i.ev.Topic)
// drop the event
continue
}
if err := l.forwardRequest(i.ctx, &v1.ForwardRequest{Envelope: i.ev}); err != nil {
logrus.WithError(err).Error("forward event")
l.queue(i)
}
}
}
func (l *remoteEventsPublisher) queue(i *item) {
go func() {
i.count++
// re-queue after a short delay
time.Sleep(time.Duration(1*i.count) * time.Second)
l.requeue <- i
}()
}
func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error {
ns, err := namespaces.NamespaceRequired(ctx)
if err != nil {
return err
}
any, err := typeurl.MarshalAny(event)
if err != nil {
return err
}
i := &item{
ev: &v1.Envelope{
Timestamp: time.Now(),
Namespace: ns,
Topic: topic,
Event: any,
},
ctx: ctx,
}
if err := l.forwardRequest(i.ctx, &v1.ForwardRequest{Envelope: i.ev}); err != nil {
l.queue(i)
return err
}
return nil
}
func (l *remoteEventsPublisher) forwardRequest(ctx context.Context, req *v1.ForwardRequest) error {
_, err := l.client.EventsService().Forward(ctx, req)
if err == nil {
return nil
}
if err != ttrpc.ErrClosed {
return err
}
// Reconnect and retry request
if err := l.client.Reconnect(); err != nil {
return err
}
if _, err := l.client.EventsService().Forward(ctx, req); err != nil {
return err
}
return nil
}

View File

@@ -20,7 +20,6 @@ import (
"context" "context"
"flag" "flag"
"fmt" "fmt"
"io"
"os" "os"
"runtime" "runtime"
"runtime/debug" "runtime/debug"
@@ -44,14 +43,8 @@ type Client struct {
signals chan os.Signal signals chan os.Signal
} }
// Publisher for events
type Publisher interface {
events.Publisher
io.Closer
}
// Init func for the creation of a shim server // Init func for the creation of a shim server
type Init func(context.Context, string, Publisher, func()) (Shim, error) type Init func(context.Context, string, events.Publisher) (Shim, error)
// Shim server interface // Shim server interface
type Shim interface { type Shim interface {
@@ -78,8 +71,6 @@ type Config struct {
NoSubreaper bool NoSubreaper bool
// NoReaper disables the shim binary from reaping any child process implicitly // NoReaper disables the shim binary from reaping any child process implicitly
NoReaper bool NoReaper bool
// NoSetupLogger disables automatic configuration of logrus to use the shim FIFO
NoSetupLogger bool
} }
var ( var (
@@ -162,24 +153,19 @@ func run(id string, initFunc Init, config Config) error {
return err return err
} }
} }
publisher := &remoteEventsPublisher{
address := fmt.Sprintf("%s.ttrpc", addressFlag) address: addressFlag,
publisher, err := newPublisher(address) containerdBinaryPath: containerdBinaryFlag,
if err != nil { noReaper: config.NoReaper,
return err
} }
defer publisher.Close()
if namespaceFlag == "" { if namespaceFlag == "" {
return fmt.Errorf("shim namespace cannot be empty") return fmt.Errorf("shim namespace cannot be empty")
} }
ctx := namespaces.WithNamespace(context.Background(), namespaceFlag) ctx := namespaces.WithNamespace(context.Background(), namespaceFlag)
ctx = context.WithValue(ctx, OptsKey{}, Opts{BundlePath: bundlePath, Debug: debugFlag}) ctx = context.WithValue(ctx, OptsKey{}, Opts{BundlePath: bundlePath, Debug: debugFlag})
ctx = log.WithLogger(ctx, log.G(ctx).WithField("runtime", id)) ctx = log.WithLogger(ctx, log.G(ctx).WithField("runtime", id))
ctx, cancel := context.WithCancel(ctx)
service, err := initFunc(ctx, idFlag, publisher, cancel) service, err := initFunc(ctx, idFlag, publisher)
if err != nil { if err != nil {
return err return err
} }
@@ -189,7 +175,7 @@ func run(id string, initFunc Init, config Config) error {
"pid": os.Getpid(), "pid": os.Getpid(),
"namespace": namespaceFlag, "namespace": namespaceFlag,
}) })
go handleSignals(ctx, logger, signals) go handleSignals(logger, signals)
response, err := service.Cleanup(ctx) response, err := service.Cleanup(ctx)
if err != nil { if err != nil {
return err return err
@@ -212,23 +198,11 @@ func run(id string, initFunc Init, config Config) error {
} }
return nil return nil
default: default:
if !config.NoSetupLogger { if err := setLogger(ctx, idFlag); err != nil {
if err := setLogger(ctx, idFlag); err != nil { return err
return err
}
} }
client := NewShimClient(ctx, service, signals) client := NewShimClient(ctx, service, signals)
if err := client.Serve(); err != nil { return client.Serve()
if err != context.Canceled {
return err
}
}
select {
case <-publisher.Done():
return nil
case <-time.After(5 * time.Second):
return errors.New("publisher not closed")
}
} }
} }
@@ -272,7 +246,7 @@ func (s *Client) Serve() error {
dumpStacks(logger) dumpStacks(logger)
} }
}() }()
return handleSignals(s.context, logger, s.signals) return handleSignals(logger, s.signals)
} }
// serve serves the ttrpc API over a unix socket at the provided path // serve serves the ttrpc API over a unix socket at the provided path
@@ -306,3 +280,9 @@ func dumpStacks(logger *logrus.Entry) {
buf = buf[:stackSize] buf = buf[:stackSize]
logger.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf) logger.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
} }
type remoteEventsPublisher struct {
address string
containerdBinaryPath string
noReaper bool
}

View File

@@ -1,29 +0,0 @@
// +build freebsd
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package shim
import "github.com/containerd/ttrpc"
func newServer() (*ttrpc.Server, error) {
return ttrpc.NewServer()
}
func subreaper() error {
return nil
}

View File

@@ -19,14 +19,19 @@
package shim package shim
import ( import (
"bytes"
"context" "context"
"io" "io"
"net" "net"
"os" "os"
"os/exec"
"os/signal" "os/signal"
"syscall" "syscall"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/fifo" "github.com/containerd/fifo"
"github.com/containerd/typeurl"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
@@ -69,13 +74,10 @@ func serveListener(path string) (net.Listener, error) {
return l, nil return l, nil
} }
func handleSignals(ctx context.Context, logger *logrus.Entry, signals chan os.Signal) error { func handleSignals(logger *logrus.Entry, signals chan os.Signal) error {
logger.Info("starting signal loop") logger.Info("starting signal loop")
for { for {
select { select {
case <-ctx.Done():
return ctx.Err()
case s := <-signals: case s := <-signals:
switch s { switch s {
case unix.SIGCHLD: case unix.SIGCHLD:
@@ -91,3 +93,38 @@ func handleSignals(ctx context.Context, logger *logrus.Entry, signals chan os.Si
func openLog(ctx context.Context, _ string) (io.Writer, error) { func openLog(ctx context.Context, _ string) (io.Writer, error) {
return fifo.OpenFifo(ctx, "log", unix.O_WRONLY, 0700) return fifo.OpenFifo(ctx, "log", unix.O_WRONLY, 0700)
} }
func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error {
ns, _ := namespaces.Namespace(ctx)
encoded, err := typeurl.MarshalAny(event)
if err != nil {
return err
}
data, err := encoded.Marshal()
if err != nil {
return err
}
cmd := exec.CommandContext(ctx, l.containerdBinaryPath, "--address", l.address, "publish", "--topic", topic, "--namespace", ns)
cmd.Stdin = bytes.NewReader(data)
if l.noReaper {
if err := cmd.Start(); err != nil {
return err
}
if err := cmd.Wait(); err != nil {
return errors.Wrap(err, "failed to publish event")
}
return nil
}
c, err := Default.Start(cmd)
if err != nil {
return err
}
status, err := Default.Wait(cmd, c)
if err != nil {
return err
}
if status != 0 {
return errors.New("failed to publish event")
}
return nil
}

View File

@@ -25,12 +25,15 @@ import (
"io" "io"
"net" "net"
"os" "os"
"os/exec"
"sync" "sync"
"unsafe" "unsafe"
winio "github.com/Microsoft/go-winio" winio "github.com/Microsoft/go-winio"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/ttrpc" "github.com/containerd/ttrpc"
"github.com/containerd/typeurl"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
@@ -103,17 +106,14 @@ func serveListener(path string) (net.Listener, error) {
return l, nil return l, nil
} }
func handleSignals(ctx context.Context, logger *logrus.Entry, signals chan os.Signal) error { func handleSignals(logger *logrus.Entry, signals chan os.Signal) error {
logger.Info("starting signal loop") logger.Info("starting signal loop")
for { for {
select { select {
case <-ctx.Done():
return ctx.Err()
case s := <-signals: case s := <-signals:
switch s { switch s {
case os.Interrupt: case os.Interrupt:
return nil break
} }
} }
} }
@@ -285,3 +285,18 @@ func openLog(ctx context.Context, id string) (io.Writer, error) {
go dswl.beginAccept() go dswl.beginAccept()
return dswl, nil return dswl, nil
} }
func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error {
ns, _ := namespaces.Namespace(ctx)
encoded, err := typeurl.MarshalAny(event)
if err != nil {
return err
}
data, err := encoded.Marshal()
if err != nil {
return err
}
cmd := exec.CommandContext(ctx, l.containerdBinaryPath, "--address", l.address, "publish", "--topic", topic, "--namespace", ns)
cmd.Stdin = bytes.NewReader(data)
return cmd.Run()
}

View File

@@ -17,10 +17,8 @@
package shim package shim
import ( import (
"bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil"
"net" "net"
"os" "os"
"os/exec" "os/exec"
@@ -30,15 +28,15 @@ import (
"time" "time"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/types"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
const shimBinaryFormat = "containerd-shim-%s-%s"
var runtimePaths sync.Map var runtimePaths sync.Map
// Command returns the shim command with the provided args and configuration // Command returns the shim command with the provided args and configuration
func Command(ctx context.Context, runtime, containerdAddress, path string, opts *types.Any, cmdArgs ...string) (*exec.Cmd, error) { func Command(ctx context.Context, runtime, containerdAddress, path string, cmdArgs ...string) (*exec.Cmd, error) {
ns, err := namespaces.NamespaceRequired(ctx) ns, err := namespaces.NamespaceRequired(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -67,19 +65,7 @@ func Command(ctx context.Context, runtime, containerdAddress, path string, opts
if cmdPath, lerr = exec.LookPath(name); lerr != nil { if cmdPath, lerr = exec.LookPath(name); lerr != nil {
if eerr, ok := lerr.(*exec.Error); ok { if eerr, ok := lerr.(*exec.Error); ok {
if eerr.Err == exec.ErrNotFound { if eerr.Err == exec.ErrNotFound {
// LookPath only finds current directory matches based on return nil, errors.Wrapf(os.ErrNotExist, "runtime %q binary not installed %q", runtime, name)
// the callers current directory but the caller is not
// likely in the same directory as the containerd
// executables. Instead match the calling binaries path
// (containerd) and see if they are side by side. If so
// execute the shim found there.
testPath := filepath.Join(filepath.Dir(self), name)
if _, serr := os.Stat(testPath); serr == nil {
cmdPath = testPath
}
if cmdPath == "" {
return nil, errors.Wrapf(os.ErrNotExist, "runtime %q binary not installed %q", runtime, name)
}
} }
} }
} }
@@ -97,13 +83,6 @@ func Command(ctx context.Context, runtime, containerdAddress, path string, opts
cmd.Dir = path cmd.Dir = path
cmd.Env = append(os.Environ(), "GOMAXPROCS=2") cmd.Env = append(os.Environ(), "GOMAXPROCS=2")
cmd.SysProcAttr = getSysProcAttr() cmd.SysProcAttr = getSysProcAttr()
if opts != nil {
d, err := proto.Marshal(opts)
if err != nil {
return nil, err
}
cmd.Stdin = bytes.NewReader(d)
}
return cmd, nil return cmd, nil
} }
@@ -161,22 +140,3 @@ func WriteAddress(path, address string) error {
} }
return os.Rename(tempPath, path) return os.Rename(tempPath, path)
} }
// ErrNoAddress is returned when the address file has no content
var ErrNoAddress = errors.New("no shim address")
// ReadAddress returns the shim's abstract socket address from the path
func ReadAddress(path string) (string, error) {
path, err := filepath.Abs(path)
if err != nil {
return "", err
}
data, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
if len(data) == 0 {
return "", ErrNoAddress
}
return string(data), nil
}

View File

@@ -20,8 +20,6 @@ package shim
import ( import (
"context" "context"
"crypto/sha256"
"fmt"
"net" "net"
"path/filepath" "path/filepath"
"strings" "strings"
@@ -33,8 +31,6 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
const shimBinaryFormat = "containerd-shim-%s-%s"
func getSysProcAttr() *syscall.SysProcAttr { func getSysProcAttr() *syscall.SysProcAttr {
return &syscall.SysProcAttr{ return &syscall.SysProcAttr{
Setpgid: true, Setpgid: true,
@@ -52,8 +48,7 @@ func SocketAddress(ctx context.Context, id string) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
d := sha256.Sum256([]byte(filepath.Join(ns, id))) return filepath.Join(string(filepath.Separator), "containerd-shim", ns, id, "shim.sock"), nil
return filepath.Join(string(filepath.Separator), "containerd-shim", fmt.Sprintf("%x.sock", d)), nil
} }
// AnonDialer returns a dialer for an abstract socket // AnonDialer returns a dialer for an abstract socket

View File

@@ -29,8 +29,6 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
const shimBinaryFormat = "containerd-shim-%s-%s.exe"
func getSysProcAttr() *syscall.SysProcAttr { func getSysProcAttr() *syscall.SysProcAttr {
return nil return nil
} }
@@ -56,7 +54,7 @@ func AnonDialer(address string, timeout time.Duration) (net.Conn, error) {
timedOutError := errors.Errorf("timed out waiting for npipe %s", address) timedOutError := errors.Errorf("timed out waiting for npipe %s", address)
start := time.Now() start := time.Now()
for { for {
remaining := timeout - time.Since(start) remaining := timeout - time.Now().Sub(start)
if remaining <= 0 { if remaining <= 0 {
lastError = timedOutError lastError = timedOutError
break break
@@ -73,7 +71,7 @@ func AnonDialer(address string, timeout time.Duration) (net.Conn, error) {
// serve it within 5 seconds. We use the passed in timeout for the // serve it within 5 seconds. We use the passed in timeout for the
// `DialPipe` timeout if the pipe exists however to give the pipe time // `DialPipe` timeout if the pipe exists however to give the pipe time
// to `Accept` the connection. // to `Accept` the connection.
if time.Since(start) >= 5*time.Second { if time.Now().Sub(start) >= 5*time.Second {
lastError = timedOutError lastError = timedOutError
break break
} }

File diff suppressed because it is too large Load Diff

View File

@@ -24,8 +24,3 @@ import "os"
func ForceRemoveAll(path string) error { func ForceRemoveAll(path string) error {
return os.RemoveAll(path) return os.RemoveAll(path)
} }
// MkdirAllWithACL is a wrapper for os.MkdirAll on Unix systems.
func MkdirAllWithACL(path string, perm os.FileMode) error {
return os.MkdirAll(path, perm)
}

View File

@@ -30,11 +30,6 @@ import (
"github.com/Microsoft/hcsshim" "github.com/Microsoft/hcsshim"
) )
const (
// SddlAdministratorsLocalSystem is local administrators plus NT AUTHORITY\System
SddlAdministratorsLocalSystem = "D:P(A;OICI;GA;;;BA)(A;OICI;GA;;;SY)"
)
// MkdirAllWithACL is a wrapper for MkdirAll that creates a directory // MkdirAllWithACL is a wrapper for MkdirAll that creates a directory
// ACL'd for Builtin Administrators and Local System. // ACL'd for Builtin Administrators and Local System.
func MkdirAllWithACL(path string, perm os.FileMode) error { func MkdirAllWithACL(path string, perm os.FileMode) error {
@@ -83,7 +78,7 @@ func mkdirall(path string, adminAndLocalSystem bool) error {
if j > 1 { if j > 1 {
// Create parent // Create parent
err = mkdirall(path[0:j-1], adminAndLocalSystem) err = mkdirall(path[0:j-1], false)
if err != nil { if err != nil {
return err return err
} }
@@ -117,7 +112,8 @@ func mkdirall(path string, adminAndLocalSystem bool) error {
// and Local System. // and Local System.
func mkdirWithACL(name string) error { func mkdirWithACL(name string) error {
sa := syscall.SecurityAttributes{Length: 0} sa := syscall.SecurityAttributes{Length: 0}
sd, err := winio.SddlToSecurityDescriptor(SddlAdministratorsLocalSystem) sddl := "D:P(A;OICI;GA;;;BA)(A;OICI;GA;;;SY)"
sd, err := winio.SddlToSecurityDescriptor(sddl)
if err != nil { if err != nil {
return &os.PathError{Op: "mkdir", Path: name, Err: err} return &os.PathError{Op: "mkdir", Path: name, Err: err}
} }

View File

@@ -20,10 +20,8 @@ package sys
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"strconv" "strconv"
"strings"
"github.com/opencontainers/runc/libcontainer/system" "github.com/opencontainers/runc/libcontainer/system"
) )
@@ -47,13 +45,3 @@ func SetOOMScore(pid, score int) error {
} }
return nil return nil
} }
// GetOOMScoreAdj gets the oom score for a process
func GetOOMScoreAdj(pid int) (int, error) {
path := fmt.Sprintf("/proc/%d/oom_score_adj", pid)
data, err := ioutil.ReadFile(path)
if err != nil {
return 0, err
}
return strconv.Atoi(strings.TrimSpace(string(data)))
}

View File

@@ -22,10 +22,3 @@ package sys
func SetOOMScore(pid, score int) error { func SetOOMScore(pid, score int) error {
return nil return nil
} }
// GetOOMScoreAdj gets the oom score for a process
//
// Not implemented on Windows
func GetOOMScoreAdj(pid int) (int, error) {
return 0, nil
}

View File

@@ -49,15 +49,7 @@ type Client struct {
err error err error
} }
type ClientOpts func(c *Client) func NewClient(conn net.Conn) *Client {
func WithOnClose(onClose func()) ClientOpts {
return func(c *Client) {
c.closeFunc = onClose
}
}
func NewClient(conn net.Conn, opts ...ClientOpts) *Client {
c := &Client{ c := &Client{
codec: codec{}, codec: codec{},
conn: conn, conn: conn,
@@ -68,10 +60,6 @@ func NewClient(conn net.Conn, opts ...ClientOpts) *Client {
closeFunc: func() {}, closeFunc: func() {},
} }
for _, o := range opts {
o(c)
}
go c.run() go c.run()
return c return c
} }
@@ -153,6 +141,11 @@ func (c *Client) Close() error {
return nil return nil
} }
// OnClose allows a close func to be called when the server is closed
func (c *Client) OnClose(closer func()) {
c.closeFunc = closer
}
type message struct { type message struct {
messageHeader messageHeader
p []byte p []byte

View File

@@ -449,12 +449,7 @@ func (c *serverConn) run(sctx context.Context) {
// branch. Basically, it means that we are no longer receiving // branch. Basically, it means that we are no longer receiving
// requests due to a terminal error. // requests due to a terminal error.
recvErr = nil // connection is now "closing" recvErr = nil // connection is now "closing"
if err == io.EOF || err == io.ErrUnexpectedEOF { if err != nil && err != io.EOF {
// The client went away and we should stop processing
// requests, so that the client connection is closed
return
}
if err != nil {
logrus.WithError(err).Error("error receiving message") logrus.WithError(err).Error("error receiving message")
} }
case <-shutdown: case <-shutdown:

View File

@@ -11,7 +11,6 @@ John Shahid <jvshahid@gmail.com>
John Tuley <john@tuley.org> John Tuley <john@tuley.org>
Laurent <laurent@adyoulike.com> Laurent <laurent@adyoulike.com>
Patrick Lee <patrick@dropbox.com> Patrick Lee <patrick@dropbox.com>
Peter Edge <peter.edge@gmail.com>
Roger Johansson <rogeralsing@gmail.com> Roger Johansson <rogeralsing@gmail.com>
Sam Nguyen <sam.nguyen@sendgrid.com> Sam Nguyen <sam.nguyen@sendgrid.com>
Sergio Arbeo <serabe@gmail.com> Sergio Arbeo <serabe@gmail.com>

View File

@@ -1,7 +1,8 @@
Copyright (c) 2013, The GoGo Authors. All rights reserved.
Protocol Buffers for Go with Gadgets Protocol Buffers for Go with Gadgets
Copyright (c) 2013, The GoGo Authors. All rights reserved.
http://github.com/gogo/protobuf
Go support for Protocol Buffers - Google's data interchange format Go support for Protocol Buffers - Google's data interchange format
Copyright 2010 The Go Authors. All rights reserved. Copyright 2010 The Go Authors. All rights reserved.

View File

@@ -162,7 +162,7 @@ The most complete way to see examples is to look at
github.com/gogo/protobuf/test/thetest.proto github.com/gogo/protobuf/test/thetest.proto
Gogoprototest is a seperate project, Gogoprototest is a seperate project,
because we want to keep gogoprotobuf independent of goprotobuf, because we want to keep gogoprotobuf independant of goprotobuf,
but we still want to test it thoroughly. but we still want to test it thoroughly.
*/ */

View File

@@ -1,12 +1,20 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: gogo.proto // source: gogo.proto
package gogoproto // import "github.com/gogo/protobuf/gogoproto" /*
Package gogoproto is a generated protocol buffer package.
It is generated from these files:
gogo.proto
It has these top-level messages:
*/
package gogoproto
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
import fmt "fmt" import fmt "fmt"
import math "math" import math "math"
import descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
@@ -20,7 +28,7 @@ var _ = math.Inf
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
var E_GoprotoEnumPrefix = &proto.ExtensionDesc{ var E_GoprotoEnumPrefix = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil), ExtendedType: (*google_protobuf.EnumOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 62001, Field: 62001,
Name: "gogoproto.goproto_enum_prefix", Name: "gogoproto.goproto_enum_prefix",
@@ -29,7 +37,7 @@ var E_GoprotoEnumPrefix = &proto.ExtensionDesc{
} }
var E_GoprotoEnumStringer = &proto.ExtensionDesc{ var E_GoprotoEnumStringer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil), ExtendedType: (*google_protobuf.EnumOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 62021, Field: 62021,
Name: "gogoproto.goproto_enum_stringer", Name: "gogoproto.goproto_enum_stringer",
@@ -38,7 +46,7 @@ var E_GoprotoEnumStringer = &proto.ExtensionDesc{
} }
var E_EnumStringer = &proto.ExtensionDesc{ var E_EnumStringer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil), ExtendedType: (*google_protobuf.EnumOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 62022, Field: 62022,
Name: "gogoproto.enum_stringer", Name: "gogoproto.enum_stringer",
@@ -47,7 +55,7 @@ var E_EnumStringer = &proto.ExtensionDesc{
} }
var E_EnumCustomname = &proto.ExtensionDesc{ var E_EnumCustomname = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil), ExtendedType: (*google_protobuf.EnumOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 62023, Field: 62023,
Name: "gogoproto.enum_customname", Name: "gogoproto.enum_customname",
@@ -56,7 +64,7 @@ var E_EnumCustomname = &proto.ExtensionDesc{
} }
var E_Enumdecl = &proto.ExtensionDesc{ var E_Enumdecl = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil), ExtendedType: (*google_protobuf.EnumOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 62024, Field: 62024,
Name: "gogoproto.enumdecl", Name: "gogoproto.enumdecl",
@@ -65,7 +73,7 @@ var E_Enumdecl = &proto.ExtensionDesc{
} }
var E_EnumvalueCustomname = &proto.ExtensionDesc{ var E_EnumvalueCustomname = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumValueOptions)(nil), ExtendedType: (*google_protobuf.EnumValueOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 66001, Field: 66001,
Name: "gogoproto.enumvalue_customname", Name: "gogoproto.enumvalue_customname",
@@ -74,7 +82,7 @@ var E_EnumvalueCustomname = &proto.ExtensionDesc{
} }
var E_GoprotoGettersAll = &proto.ExtensionDesc{ var E_GoprotoGettersAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63001, Field: 63001,
Name: "gogoproto.goproto_getters_all", Name: "gogoproto.goproto_getters_all",
@@ -83,7 +91,7 @@ var E_GoprotoGettersAll = &proto.ExtensionDesc{
} }
var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{ var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63002, Field: 63002,
Name: "gogoproto.goproto_enum_prefix_all", Name: "gogoproto.goproto_enum_prefix_all",
@@ -92,7 +100,7 @@ var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{
} }
var E_GoprotoStringerAll = &proto.ExtensionDesc{ var E_GoprotoStringerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63003, Field: 63003,
Name: "gogoproto.goproto_stringer_all", Name: "gogoproto.goproto_stringer_all",
@@ -101,7 +109,7 @@ var E_GoprotoStringerAll = &proto.ExtensionDesc{
} }
var E_VerboseEqualAll = &proto.ExtensionDesc{ var E_VerboseEqualAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63004, Field: 63004,
Name: "gogoproto.verbose_equal_all", Name: "gogoproto.verbose_equal_all",
@@ -110,7 +118,7 @@ var E_VerboseEqualAll = &proto.ExtensionDesc{
} }
var E_FaceAll = &proto.ExtensionDesc{ var E_FaceAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63005, Field: 63005,
Name: "gogoproto.face_all", Name: "gogoproto.face_all",
@@ -119,7 +127,7 @@ var E_FaceAll = &proto.ExtensionDesc{
} }
var E_GostringAll = &proto.ExtensionDesc{ var E_GostringAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63006, Field: 63006,
Name: "gogoproto.gostring_all", Name: "gogoproto.gostring_all",
@@ -128,7 +136,7 @@ var E_GostringAll = &proto.ExtensionDesc{
} }
var E_PopulateAll = &proto.ExtensionDesc{ var E_PopulateAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63007, Field: 63007,
Name: "gogoproto.populate_all", Name: "gogoproto.populate_all",
@@ -137,7 +145,7 @@ var E_PopulateAll = &proto.ExtensionDesc{
} }
var E_StringerAll = &proto.ExtensionDesc{ var E_StringerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63008, Field: 63008,
Name: "gogoproto.stringer_all", Name: "gogoproto.stringer_all",
@@ -146,7 +154,7 @@ var E_StringerAll = &proto.ExtensionDesc{
} }
var E_OnlyoneAll = &proto.ExtensionDesc{ var E_OnlyoneAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63009, Field: 63009,
Name: "gogoproto.onlyone_all", Name: "gogoproto.onlyone_all",
@@ -155,7 +163,7 @@ var E_OnlyoneAll = &proto.ExtensionDesc{
} }
var E_EqualAll = &proto.ExtensionDesc{ var E_EqualAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63013, Field: 63013,
Name: "gogoproto.equal_all", Name: "gogoproto.equal_all",
@@ -164,7 +172,7 @@ var E_EqualAll = &proto.ExtensionDesc{
} }
var E_DescriptionAll = &proto.ExtensionDesc{ var E_DescriptionAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63014, Field: 63014,
Name: "gogoproto.description_all", Name: "gogoproto.description_all",
@@ -173,7 +181,7 @@ var E_DescriptionAll = &proto.ExtensionDesc{
} }
var E_TestgenAll = &proto.ExtensionDesc{ var E_TestgenAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63015, Field: 63015,
Name: "gogoproto.testgen_all", Name: "gogoproto.testgen_all",
@@ -182,7 +190,7 @@ var E_TestgenAll = &proto.ExtensionDesc{
} }
var E_BenchgenAll = &proto.ExtensionDesc{ var E_BenchgenAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63016, Field: 63016,
Name: "gogoproto.benchgen_all", Name: "gogoproto.benchgen_all",
@@ -191,7 +199,7 @@ var E_BenchgenAll = &proto.ExtensionDesc{
} }
var E_MarshalerAll = &proto.ExtensionDesc{ var E_MarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63017, Field: 63017,
Name: "gogoproto.marshaler_all", Name: "gogoproto.marshaler_all",
@@ -200,7 +208,7 @@ var E_MarshalerAll = &proto.ExtensionDesc{
} }
var E_UnmarshalerAll = &proto.ExtensionDesc{ var E_UnmarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63018, Field: 63018,
Name: "gogoproto.unmarshaler_all", Name: "gogoproto.unmarshaler_all",
@@ -209,7 +217,7 @@ var E_UnmarshalerAll = &proto.ExtensionDesc{
} }
var E_StableMarshalerAll = &proto.ExtensionDesc{ var E_StableMarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63019, Field: 63019,
Name: "gogoproto.stable_marshaler_all", Name: "gogoproto.stable_marshaler_all",
@@ -218,7 +226,7 @@ var E_StableMarshalerAll = &proto.ExtensionDesc{
} }
var E_SizerAll = &proto.ExtensionDesc{ var E_SizerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63020, Field: 63020,
Name: "gogoproto.sizer_all", Name: "gogoproto.sizer_all",
@@ -227,7 +235,7 @@ var E_SizerAll = &proto.ExtensionDesc{
} }
var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{ var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63021, Field: 63021,
Name: "gogoproto.goproto_enum_stringer_all", Name: "gogoproto.goproto_enum_stringer_all",
@@ -236,7 +244,7 @@ var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{
} }
var E_EnumStringerAll = &proto.ExtensionDesc{ var E_EnumStringerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63022, Field: 63022,
Name: "gogoproto.enum_stringer_all", Name: "gogoproto.enum_stringer_all",
@@ -245,7 +253,7 @@ var E_EnumStringerAll = &proto.ExtensionDesc{
} }
var E_UnsafeMarshalerAll = &proto.ExtensionDesc{ var E_UnsafeMarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63023, Field: 63023,
Name: "gogoproto.unsafe_marshaler_all", Name: "gogoproto.unsafe_marshaler_all",
@@ -254,7 +262,7 @@ var E_UnsafeMarshalerAll = &proto.ExtensionDesc{
} }
var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{ var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63024, Field: 63024,
Name: "gogoproto.unsafe_unmarshaler_all", Name: "gogoproto.unsafe_unmarshaler_all",
@@ -263,7 +271,7 @@ var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{
} }
var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{ var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63025, Field: 63025,
Name: "gogoproto.goproto_extensions_map_all", Name: "gogoproto.goproto_extensions_map_all",
@@ -272,7 +280,7 @@ var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{
} }
var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{ var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63026, Field: 63026,
Name: "gogoproto.goproto_unrecognized_all", Name: "gogoproto.goproto_unrecognized_all",
@@ -281,7 +289,7 @@ var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{
} }
var E_GogoprotoImport = &proto.ExtensionDesc{ var E_GogoprotoImport = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63027, Field: 63027,
Name: "gogoproto.gogoproto_import", Name: "gogoproto.gogoproto_import",
@@ -290,7 +298,7 @@ var E_GogoprotoImport = &proto.ExtensionDesc{
} }
var E_ProtosizerAll = &proto.ExtensionDesc{ var E_ProtosizerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63028, Field: 63028,
Name: "gogoproto.protosizer_all", Name: "gogoproto.protosizer_all",
@@ -299,7 +307,7 @@ var E_ProtosizerAll = &proto.ExtensionDesc{
} }
var E_CompareAll = &proto.ExtensionDesc{ var E_CompareAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63029, Field: 63029,
Name: "gogoproto.compare_all", Name: "gogoproto.compare_all",
@@ -308,7 +316,7 @@ var E_CompareAll = &proto.ExtensionDesc{
} }
var E_TypedeclAll = &proto.ExtensionDesc{ var E_TypedeclAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63030, Field: 63030,
Name: "gogoproto.typedecl_all", Name: "gogoproto.typedecl_all",
@@ -317,7 +325,7 @@ var E_TypedeclAll = &proto.ExtensionDesc{
} }
var E_EnumdeclAll = &proto.ExtensionDesc{ var E_EnumdeclAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63031, Field: 63031,
Name: "gogoproto.enumdecl_all", Name: "gogoproto.enumdecl_all",
@@ -326,7 +334,7 @@ var E_EnumdeclAll = &proto.ExtensionDesc{
} }
var E_GoprotoRegistration = &proto.ExtensionDesc{ var E_GoprotoRegistration = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil), ExtendedType: (*google_protobuf.FileOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 63032, Field: 63032,
Name: "gogoproto.goproto_registration", Name: "gogoproto.goproto_registration",
@@ -334,35 +342,8 @@ var E_GoprotoRegistration = &proto.ExtensionDesc{
Filename: "gogo.proto", Filename: "gogo.proto",
} }
var E_MessagenameAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63033,
Name: "gogoproto.messagename_all",
Tag: "varint,63033,opt,name=messagename_all,json=messagenameAll",
Filename: "gogo.proto",
}
var E_GoprotoSizecacheAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63034,
Name: "gogoproto.goproto_sizecache_all",
Tag: "varint,63034,opt,name=goproto_sizecache_all,json=goprotoSizecacheAll",
Filename: "gogo.proto",
}
var E_GoprotoUnkeyedAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63035,
Name: "gogoproto.goproto_unkeyed_all",
Tag: "varint,63035,opt,name=goproto_unkeyed_all,json=goprotoUnkeyedAll",
Filename: "gogo.proto",
}
var E_GoprotoGetters = &proto.ExtensionDesc{ var E_GoprotoGetters = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64001, Field: 64001,
Name: "gogoproto.goproto_getters", Name: "gogoproto.goproto_getters",
@@ -371,7 +352,7 @@ var E_GoprotoGetters = &proto.ExtensionDesc{
} }
var E_GoprotoStringer = &proto.ExtensionDesc{ var E_GoprotoStringer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64003, Field: 64003,
Name: "gogoproto.goproto_stringer", Name: "gogoproto.goproto_stringer",
@@ -380,7 +361,7 @@ var E_GoprotoStringer = &proto.ExtensionDesc{
} }
var E_VerboseEqual = &proto.ExtensionDesc{ var E_VerboseEqual = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64004, Field: 64004,
Name: "gogoproto.verbose_equal", Name: "gogoproto.verbose_equal",
@@ -389,7 +370,7 @@ var E_VerboseEqual = &proto.ExtensionDesc{
} }
var E_Face = &proto.ExtensionDesc{ var E_Face = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64005, Field: 64005,
Name: "gogoproto.face", Name: "gogoproto.face",
@@ -398,7 +379,7 @@ var E_Face = &proto.ExtensionDesc{
} }
var E_Gostring = &proto.ExtensionDesc{ var E_Gostring = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64006, Field: 64006,
Name: "gogoproto.gostring", Name: "gogoproto.gostring",
@@ -407,7 +388,7 @@ var E_Gostring = &proto.ExtensionDesc{
} }
var E_Populate = &proto.ExtensionDesc{ var E_Populate = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64007, Field: 64007,
Name: "gogoproto.populate", Name: "gogoproto.populate",
@@ -416,7 +397,7 @@ var E_Populate = &proto.ExtensionDesc{
} }
var E_Stringer = &proto.ExtensionDesc{ var E_Stringer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 67008, Field: 67008,
Name: "gogoproto.stringer", Name: "gogoproto.stringer",
@@ -425,7 +406,7 @@ var E_Stringer = &proto.ExtensionDesc{
} }
var E_Onlyone = &proto.ExtensionDesc{ var E_Onlyone = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64009, Field: 64009,
Name: "gogoproto.onlyone", Name: "gogoproto.onlyone",
@@ -434,7 +415,7 @@ var E_Onlyone = &proto.ExtensionDesc{
} }
var E_Equal = &proto.ExtensionDesc{ var E_Equal = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64013, Field: 64013,
Name: "gogoproto.equal", Name: "gogoproto.equal",
@@ -443,7 +424,7 @@ var E_Equal = &proto.ExtensionDesc{
} }
var E_Description = &proto.ExtensionDesc{ var E_Description = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64014, Field: 64014,
Name: "gogoproto.description", Name: "gogoproto.description",
@@ -452,7 +433,7 @@ var E_Description = &proto.ExtensionDesc{
} }
var E_Testgen = &proto.ExtensionDesc{ var E_Testgen = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64015, Field: 64015,
Name: "gogoproto.testgen", Name: "gogoproto.testgen",
@@ -461,7 +442,7 @@ var E_Testgen = &proto.ExtensionDesc{
} }
var E_Benchgen = &proto.ExtensionDesc{ var E_Benchgen = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64016, Field: 64016,
Name: "gogoproto.benchgen", Name: "gogoproto.benchgen",
@@ -470,7 +451,7 @@ var E_Benchgen = &proto.ExtensionDesc{
} }
var E_Marshaler = &proto.ExtensionDesc{ var E_Marshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64017, Field: 64017,
Name: "gogoproto.marshaler", Name: "gogoproto.marshaler",
@@ -479,7 +460,7 @@ var E_Marshaler = &proto.ExtensionDesc{
} }
var E_Unmarshaler = &proto.ExtensionDesc{ var E_Unmarshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64018, Field: 64018,
Name: "gogoproto.unmarshaler", Name: "gogoproto.unmarshaler",
@@ -488,7 +469,7 @@ var E_Unmarshaler = &proto.ExtensionDesc{
} }
var E_StableMarshaler = &proto.ExtensionDesc{ var E_StableMarshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64019, Field: 64019,
Name: "gogoproto.stable_marshaler", Name: "gogoproto.stable_marshaler",
@@ -497,7 +478,7 @@ var E_StableMarshaler = &proto.ExtensionDesc{
} }
var E_Sizer = &proto.ExtensionDesc{ var E_Sizer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64020, Field: 64020,
Name: "gogoproto.sizer", Name: "gogoproto.sizer",
@@ -506,7 +487,7 @@ var E_Sizer = &proto.ExtensionDesc{
} }
var E_UnsafeMarshaler = &proto.ExtensionDesc{ var E_UnsafeMarshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64023, Field: 64023,
Name: "gogoproto.unsafe_marshaler", Name: "gogoproto.unsafe_marshaler",
@@ -515,7 +496,7 @@ var E_UnsafeMarshaler = &proto.ExtensionDesc{
} }
var E_UnsafeUnmarshaler = &proto.ExtensionDesc{ var E_UnsafeUnmarshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64024, Field: 64024,
Name: "gogoproto.unsafe_unmarshaler", Name: "gogoproto.unsafe_unmarshaler",
@@ -524,7 +505,7 @@ var E_UnsafeUnmarshaler = &proto.ExtensionDesc{
} }
var E_GoprotoExtensionsMap = &proto.ExtensionDesc{ var E_GoprotoExtensionsMap = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64025, Field: 64025,
Name: "gogoproto.goproto_extensions_map", Name: "gogoproto.goproto_extensions_map",
@@ -533,7 +514,7 @@ var E_GoprotoExtensionsMap = &proto.ExtensionDesc{
} }
var E_GoprotoUnrecognized = &proto.ExtensionDesc{ var E_GoprotoUnrecognized = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64026, Field: 64026,
Name: "gogoproto.goproto_unrecognized", Name: "gogoproto.goproto_unrecognized",
@@ -542,7 +523,7 @@ var E_GoprotoUnrecognized = &proto.ExtensionDesc{
} }
var E_Protosizer = &proto.ExtensionDesc{ var E_Protosizer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64028, Field: 64028,
Name: "gogoproto.protosizer", Name: "gogoproto.protosizer",
@@ -551,7 +532,7 @@ var E_Protosizer = &proto.ExtensionDesc{
} }
var E_Compare = &proto.ExtensionDesc{ var E_Compare = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64029, Field: 64029,
Name: "gogoproto.compare", Name: "gogoproto.compare",
@@ -560,7 +541,7 @@ var E_Compare = &proto.ExtensionDesc{
} }
var E_Typedecl = &proto.ExtensionDesc{ var E_Typedecl = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil), ExtendedType: (*google_protobuf.MessageOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 64030, Field: 64030,
Name: "gogoproto.typedecl", Name: "gogoproto.typedecl",
@@ -568,35 +549,8 @@ var E_Typedecl = &proto.ExtensionDesc{
Filename: "gogo.proto", Filename: "gogo.proto",
} }
var E_Messagename = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64033,
Name: "gogoproto.messagename",
Tag: "varint,64033,opt,name=messagename",
Filename: "gogo.proto",
}
var E_GoprotoSizecache = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64034,
Name: "gogoproto.goproto_sizecache",
Tag: "varint,64034,opt,name=goproto_sizecache,json=goprotoSizecache",
Filename: "gogo.proto",
}
var E_GoprotoUnkeyed = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64035,
Name: "gogoproto.goproto_unkeyed",
Tag: "varint,64035,opt,name=goproto_unkeyed,json=goprotoUnkeyed",
Filename: "gogo.proto",
}
var E_Nullable = &proto.ExtensionDesc{ var E_Nullable = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 65001, Field: 65001,
Name: "gogoproto.nullable", Name: "gogoproto.nullable",
@@ -605,7 +559,7 @@ var E_Nullable = &proto.ExtensionDesc{
} }
var E_Embed = &proto.ExtensionDesc{ var E_Embed = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 65002, Field: 65002,
Name: "gogoproto.embed", Name: "gogoproto.embed",
@@ -614,7 +568,7 @@ var E_Embed = &proto.ExtensionDesc{
} }
var E_Customtype = &proto.ExtensionDesc{ var E_Customtype = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 65003, Field: 65003,
Name: "gogoproto.customtype", Name: "gogoproto.customtype",
@@ -623,7 +577,7 @@ var E_Customtype = &proto.ExtensionDesc{
} }
var E_Customname = &proto.ExtensionDesc{ var E_Customname = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 65004, Field: 65004,
Name: "gogoproto.customname", Name: "gogoproto.customname",
@@ -632,7 +586,7 @@ var E_Customname = &proto.ExtensionDesc{
} }
var E_Jsontag = &proto.ExtensionDesc{ var E_Jsontag = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 65005, Field: 65005,
Name: "gogoproto.jsontag", Name: "gogoproto.jsontag",
@@ -641,7 +595,7 @@ var E_Jsontag = &proto.ExtensionDesc{
} }
var E_Moretags = &proto.ExtensionDesc{ var E_Moretags = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 65006, Field: 65006,
Name: "gogoproto.moretags", Name: "gogoproto.moretags",
@@ -650,7 +604,7 @@ var E_Moretags = &proto.ExtensionDesc{
} }
var E_Casttype = &proto.ExtensionDesc{ var E_Casttype = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 65007, Field: 65007,
Name: "gogoproto.casttype", Name: "gogoproto.casttype",
@@ -659,7 +613,7 @@ var E_Casttype = &proto.ExtensionDesc{
} }
var E_Castkey = &proto.ExtensionDesc{ var E_Castkey = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 65008, Field: 65008,
Name: "gogoproto.castkey", Name: "gogoproto.castkey",
@@ -668,7 +622,7 @@ var E_Castkey = &proto.ExtensionDesc{
} }
var E_Castvalue = &proto.ExtensionDesc{ var E_Castvalue = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*string)(nil),
Field: 65009, Field: 65009,
Name: "gogoproto.castvalue", Name: "gogoproto.castvalue",
@@ -677,7 +631,7 @@ var E_Castvalue = &proto.ExtensionDesc{
} }
var E_Stdtime = &proto.ExtensionDesc{ var E_Stdtime = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 65010, Field: 65010,
Name: "gogoproto.stdtime", Name: "gogoproto.stdtime",
@@ -686,7 +640,7 @@ var E_Stdtime = &proto.ExtensionDesc{
} }
var E_Stdduration = &proto.ExtensionDesc{ var E_Stdduration = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil), ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*bool)(nil), ExtensionType: (*bool)(nil),
Field: 65011, Field: 65011,
Name: "gogoproto.stdduration", Name: "gogoproto.stdduration",
@@ -694,15 +648,6 @@ var E_Stdduration = &proto.ExtensionDesc{
Filename: "gogo.proto", Filename: "gogo.proto",
} }
var E_Wktpointer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 65012,
Name: "gogoproto.wktpointer",
Tag: "varint,65012,opt,name=wktpointer",
Filename: "gogo.proto",
}
func init() { func init() {
proto.RegisterExtension(E_GoprotoEnumPrefix) proto.RegisterExtension(E_GoprotoEnumPrefix)
proto.RegisterExtension(E_GoprotoEnumStringer) proto.RegisterExtension(E_GoprotoEnumStringer)
@@ -739,9 +684,6 @@ func init() {
proto.RegisterExtension(E_TypedeclAll) proto.RegisterExtension(E_TypedeclAll)
proto.RegisterExtension(E_EnumdeclAll) proto.RegisterExtension(E_EnumdeclAll)
proto.RegisterExtension(E_GoprotoRegistration) proto.RegisterExtension(E_GoprotoRegistration)
proto.RegisterExtension(E_MessagenameAll)
proto.RegisterExtension(E_GoprotoSizecacheAll)
proto.RegisterExtension(E_GoprotoUnkeyedAll)
proto.RegisterExtension(E_GoprotoGetters) proto.RegisterExtension(E_GoprotoGetters)
proto.RegisterExtension(E_GoprotoStringer) proto.RegisterExtension(E_GoprotoStringer)
proto.RegisterExtension(E_VerboseEqual) proto.RegisterExtension(E_VerboseEqual)
@@ -765,9 +707,6 @@ func init() {
proto.RegisterExtension(E_Protosizer) proto.RegisterExtension(E_Protosizer)
proto.RegisterExtension(E_Compare) proto.RegisterExtension(E_Compare)
proto.RegisterExtension(E_Typedecl) proto.RegisterExtension(E_Typedecl)
proto.RegisterExtension(E_Messagename)
proto.RegisterExtension(E_GoprotoSizecache)
proto.RegisterExtension(E_GoprotoUnkeyed)
proto.RegisterExtension(E_Nullable) proto.RegisterExtension(E_Nullable)
proto.RegisterExtension(E_Embed) proto.RegisterExtension(E_Embed)
proto.RegisterExtension(E_Customtype) proto.RegisterExtension(E_Customtype)
@@ -779,94 +718,86 @@ func init() {
proto.RegisterExtension(E_Castvalue) proto.RegisterExtension(E_Castvalue)
proto.RegisterExtension(E_Stdtime) proto.RegisterExtension(E_Stdtime)
proto.RegisterExtension(E_Stdduration) proto.RegisterExtension(E_Stdduration)
proto.RegisterExtension(E_Wktpointer)
} }
func init() { proto.RegisterFile("gogo.proto", fileDescriptor_gogo_b95f77e237336c7c) } func init() { proto.RegisterFile("gogo.proto", fileDescriptorGogo) }
var fileDescriptor_gogo_b95f77e237336c7c = []byte{ var fileDescriptorGogo = []byte{
// 1328 bytes of a gzipped FileDescriptorProto // 1201 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0x49, 0x6f, 0x1c, 0x45, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0xcb, 0x6f, 0x1c, 0x45,
0x14, 0x80, 0x85, 0x48, 0x64, 0x4f, 0x79, 0x8b, 0xc7, 0xc6, 0x84, 0x08, 0x44, 0xe0, 0xc4, 0xc9, 0x13, 0xc0, 0xf5, 0xe9, 0x73, 0x64, 0x6f, 0xf9, 0x85, 0xd7, 0xc6, 0x84, 0x08, 0x44, 0x72, 0xe3,
0x3e, 0x45, 0x28, 0x65, 0x45, 0x96, 0x63, 0x39, 0x56, 0x10, 0x0e, 0xc6, 0x89, 0xc3, 0x76, 0x18, 0xe4, 0x9c, 0x22, 0x94, 0xb6, 0x22, 0xcb, 0xb1, 0x1c, 0x2b, 0x11, 0x06, 0x63, 0xe2, 0x00, 0xe2,
0xf5, 0xf4, 0x94, 0xdb, 0x8d, 0xbb, 0xbb, 0x9a, 0xee, 0xea, 0x10, 0xe7, 0x86, 0xc2, 0x22, 0x84, 0xb0, 0x9a, 0xdd, 0x6d, 0x4f, 0x06, 0x66, 0xa6, 0x87, 0x99, 0x9e, 0x28, 0xce, 0x0d, 0x85, 0x87,
0xd8, 0x91, 0x20, 0x21, 0x09, 0x04, 0xc4, 0xbe, 0x86, 0x7d, 0xb9, 0x70, 0x61, 0xb9, 0xf2, 0x1f, 0x10, 0xe2, 0x8d, 0x04, 0x09, 0x49, 0x80, 0x03, 0xef, 0x67, 0x78, 0x1f, 0xb9, 0xf0, 0xb8, 0xf2,
0xb8, 0x00, 0x66, 0xf7, 0xcd, 0x17, 0xf4, 0xba, 0xdf, 0xeb, 0xa9, 0x69, 0x8f, 0x54, 0x35, 0xb7, 0x3f, 0x70, 0x01, 0xcc, 0xdb, 0x37, 0x5f, 0x50, 0xcd, 0x56, 0xcd, 0xf6, 0xac, 0x57, 0xea, 0xde,
0xf6, 0xb8, 0xbe, 0x6f, 0xaa, 0xdf, 0xeb, 0x7a, 0xef, 0x4d, 0x33, 0xe6, 0x49, 0x4f, 0x4e, 0xc6, 0xdb, 0xec, 0xba, 0x7f, 0xbf, 0xad, 0xa9, 0x9a, 0xae, 0xea, 0x31, 0x80, 0xaf, 0x7c, 0x35, 0x97,
0x89, 0x54, 0xb2, 0x5e, 0x83, 0xeb, 0xfc, 0x72, 0xdf, 0x7e, 0x4f, 0x4a, 0x2f, 0x10, 0x53, 0xf9, 0xa4, 0x4a, 0xab, 0x7a, 0x0d, 0xaf, 0x8b, 0xcb, 0x03, 0x07, 0x7d, 0xa5, 0xfc, 0x50, 0x1e, 0x2e,
0x5f, 0xcd, 0x6c, 0x75, 0xaa, 0x25, 0x52, 0x37, 0xf1, 0x63, 0x25, 0x93, 0x62, 0x31, 0x3f, 0xc6, 0x3e, 0x35, 0xf3, 0xcd, 0xc3, 0x6d, 0x99, 0xb5, 0xd2, 0x20, 0xd1, 0x2a, 0xed, 0x2c, 0x16, 0x77,
0xc6, 0x70, 0x71, 0x43, 0x44, 0x59, 0xd8, 0x88, 0x13, 0xb1, 0xea, 0x9f, 0xae, 0x5f, 0x3f, 0x59, 0xc1, 0x34, 0x2d, 0x6e, 0xc8, 0x38, 0x8f, 0x1a, 0x49, 0x2a, 0x37, 0x83, 0xf3, 0xf5, 0x5b, 0xe6,
0x90, 0x93, 0x44, 0x4e, 0xce, 0x47, 0x59, 0x78, 0x47, 0xac, 0x7c, 0x19, 0xa5, 0x7b, 0xaf, 0xfc, 0x3a, 0xe4, 0x1c, 0x93, 0x73, 0xcb, 0x71, 0x1e, 0xdd, 0x9d, 0xe8, 0x40, 0xc5, 0xd9, 0xfe, 0xeb,
0x72, 0xf5, 0xfe, 0xab, 0x6e, 0xe9, 0x5f, 0x1e, 0x45, 0x14, 0xfe, 0xb7, 0x94, 0x83, 0x7c, 0x99, 0x3f, 0xff, 0xff, 0xe0, 0xff, 0x6e, 0x1f, 0x59, 0x9f, 0x22, 0x14, 0xff, 0xb6, 0x56, 0x80, 0x62,
0x5d, 0xd3, 0xe1, 0x4b, 0x55, 0xe2, 0x47, 0x9e, 0x48, 0x0c, 0xc6, 0xef, 0xd1, 0x38, 0xa6, 0x19, 0x1d, 0x6e, 0xac, 0xf8, 0x32, 0x9d, 0x06, 0xb1, 0x2f, 0x53, 0x8b, 0xf1, 0x3b, 0x32, 0x4e, 0x1b,
0x8f, 0x23, 0xca, 0xe7, 0xd8, 0x50, 0x2f, 0xae, 0x1f, 0xd0, 0x35, 0x28, 0x74, 0xc9, 0x02, 0x1b, 0xc6, 0x7b, 0x09, 0x15, 0x4b, 0x30, 0x3e, 0x88, 0xeb, 0x7b, 0x72, 0x8d, 0x49, 0x53, 0xb2, 0x02,
0xc9, 0x25, 0x6e, 0x96, 0x2a, 0x19, 0x46, 0x4e, 0x28, 0x0c, 0x9a, 0x1f, 0x73, 0x4d, 0x6d, 0x79, 0x93, 0x85, 0xa4, 0x95, 0x67, 0x5a, 0x45, 0xb1, 0x17, 0x49, 0x8b, 0xe6, 0x87, 0x42, 0x53, 0x5b,
0x18, 0xb0, 0xb9, 0x92, 0xe2, 0x9c, 0xf5, 0xc3, 0x27, 0x2d, 0xe1, 0x06, 0x06, 0xc3, 0x4f, 0xb8, 0x9f, 0x40, 0x6c, 0xa9, 0xa4, 0x84, 0x80, 0x11, 0xfc, 0xa6, 0x2d, 0x5b, 0xa1, 0xc5, 0xf0, 0x23,
0x91, 0x72, 0x3d, 0x3f, 0xc9, 0xc6, 0xe1, 0xfa, 0x94, 0x13, 0x64, 0x42, 0xdf, 0xc9, 0x4d, 0x5d, 0x05, 0x52, 0xae, 0x17, 0x67, 0x60, 0x06, 0xaf, 0xcf, 0x79, 0x61, 0x2e, 0xcd, 0x48, 0x0e, 0xf5,
0x3d, 0x27, 0x61, 0x19, 0xc9, 0x7e, 0x3e, 0xbb, 0x2b, 0xdf, 0xce, 0x58, 0x29, 0xd0, 0xf6, 0xa4, 0xf5, 0x9c, 0xc1, 0x65, 0x2c, 0xfb, 0xe9, 0xe2, 0x50, 0x11, 0xce, 0x74, 0x29, 0x30, 0x62, 0x32,
0x65, 0xd1, 0x13, 0x4a, 0x89, 0x24, 0x6d, 0x38, 0x41, 0xb7, 0xed, 0x1d, 0xf1, 0x83, 0xd2, 0x78, 0xaa, 0xe8, 0x4b, 0xad, 0x65, 0x9a, 0x35, 0xbc, 0xb0, 0x5f, 0x78, 0x27, 0x82, 0xb0, 0x34, 0x5e,
0x6e, 0xb3, 0x33, 0x8b, 0x0b, 0x05, 0x39, 0x1b, 0x04, 0x7c, 0x85, 0x5d, 0xdb, 0xe5, 0xa9, 0xb0, 0xda, 0xae, 0x56, 0x71, 0xa5, 0x43, 0x2e, 0x86, 0xa1, 0xd8, 0x80, 0x9b, 0xfa, 0x3c, 0x15, 0x0e,
0x70, 0x9e, 0x47, 0xe7, 0xf8, 0x8e, 0x27, 0x03, 0xb4, 0x4b, 0x8c, 0x3e, 0x2f, 0x73, 0x69, 0xe1, 0xce, 0xcb, 0xe4, 0x9c, 0xd9, 0xf3, 0x64, 0xa0, 0x76, 0x0d, 0xf8, 0xfb, 0xb2, 0x96, 0x0e, 0xce,
0x7c, 0x19, 0x9d, 0x75, 0x64, 0x29, 0xa5, 0x60, 0xbc, 0x8d, 0x8d, 0x9e, 0x12, 0x49, 0x53, 0xa6, 0xd7, 0xc8, 0x59, 0x27, 0x96, 0x4b, 0x8a, 0xc6, 0x53, 0x30, 0x75, 0x4e, 0xa6, 0x4d, 0x95, 0xc9,
0xa2, 0x21, 0x1e, 0xc8, 0x9c, 0xc0, 0x42, 0x77, 0x01, 0x75, 0x23, 0x08, 0xce, 0x03, 0x07, 0xae, 0x86, 0x7c, 0x24, 0xf7, 0x42, 0x07, 0xdd, 0x15, 0xd2, 0x4d, 0x12, 0xb8, 0x8c, 0x1c, 0xba, 0x8e,
0x83, 0xac, 0x7f, 0xd5, 0x71, 0x85, 0x85, 0xe2, 0x22, 0x2a, 0xfa, 0x60, 0x3d, 0xa0, 0xb3, 0x6c, 0xc2, 0xc8, 0xa6, 0xd7, 0x92, 0x0e, 0x8a, 0xab, 0xa4, 0x18, 0xc6, 0xf5, 0x88, 0x2e, 0xc2, 0x98,
0xd0, 0x93, 0xc5, 0x2d, 0x59, 0xe0, 0x97, 0x10, 0x1f, 0x20, 0x06, 0x15, 0xb1, 0x8c, 0xb3, 0xc0, 0xaf, 0x3a, 0xb7, 0xe4, 0x80, 0x5f, 0x23, 0x7c, 0x94, 0x19, 0x52, 0x24, 0x2a, 0xc9, 0x43, 0x4f,
0x51, 0x36, 0x3b, 0x78, 0x85, 0x14, 0xc4, 0xa0, 0xa2, 0x87, 0xb0, 0xbe, 0x4a, 0x8a, 0x54, 0x8b, 0xbb, 0x44, 0xf0, 0x3a, 0x2b, 0x98, 0x21, 0xc5, 0x00, 0x69, 0x7d, 0x83, 0x15, 0x99, 0x91, 0xcf,
0xe7, 0x0c, 0x1b, 0x90, 0x51, 0xb0, 0x21, 0x23, 0x9b, 0x4d, 0x5c, 0x46, 0x03, 0x43, 0x04, 0x04, 0x05, 0x18, 0x55, 0x71, 0xb8, 0xa5, 0x62, 0x97, 0x20, 0xde, 0x24, 0x03, 0x10, 0x82, 0x82, 0x79,
0xd3, 0xac, 0x66, 0x9b, 0x88, 0x37, 0x36, 0xe9, 0x78, 0x50, 0x06, 0x16, 0xd8, 0x08, 0x15, 0x28, 0xa8, 0xb9, 0x16, 0xe2, 0xad, 0x6d, 0xde, 0x1e, 0x5c, 0x81, 0x15, 0x98, 0xe4, 0x06, 0x15, 0xa8,
0x5f, 0x46, 0x16, 0x8a, 0x37, 0x51, 0x31, 0xac, 0x61, 0x78, 0x1b, 0x4a, 0xa4, 0xca, 0x13, 0x36, 0xd8, 0x41, 0xf1, 0x36, 0x29, 0x26, 0x0c, 0x8c, 0x6e, 0x43, 0xcb, 0x4c, 0xfb, 0xd2, 0x45, 0xf2,
0x92, 0xb7, 0xe8, 0x36, 0x10, 0xc1, 0x50, 0x36, 0x45, 0xe4, 0xae, 0xd9, 0x19, 0xde, 0xa6, 0x50, 0x0e, 0xdf, 0x06, 0x21, 0x94, 0xca, 0xa6, 0x8c, 0x5b, 0x67, 0xdd, 0x0c, 0xef, 0x72, 0x2a, 0x99,
0x12, 0x03, 0x8a, 0x39, 0x36, 0x14, 0x3a, 0x49, 0xba, 0xe6, 0x04, 0x56, 0xe9, 0x78, 0x07, 0x1d, 0x41, 0xc5, 0x12, 0x8c, 0x47, 0x5e, 0x9a, 0x9d, 0xf5, 0x42, 0xa7, 0x72, 0xbc, 0x47, 0x8e, 0xb1,
0x83, 0x25, 0x84, 0x11, 0xc9, 0xa2, 0x5e, 0x34, 0xef, 0x52, 0x44, 0x34, 0x0c, 0x8f, 0x5e, 0xaa, 0x12, 0xa2, 0x8c, 0xe4, 0xf1, 0x20, 0x9a, 0xf7, 0x39, 0x23, 0x06, 0x46, 0x5b, 0x2f, 0xd3, 0x5e,
0x9c, 0x66, 0x20, 0x1a, 0xbd, 0xd8, 0xde, 0xa3, 0xa3, 0x57, 0xb0, 0x8b, 0xba, 0x71, 0x9a, 0xd5, 0x33, 0x94, 0x8d, 0x41, 0x6c, 0x1f, 0xf0, 0xd6, 0xeb, 0xb0, 0xab, 0xa6, 0x71, 0x1e, 0x6a, 0x59,
0x52, 0xff, 0x8c, 0x95, 0xe6, 0x7d, 0xca, 0x74, 0x0e, 0x00, 0x7c, 0x0f, 0xbb, 0xae, 0x6b, 0x9b, 0x70, 0xc1, 0x49, 0xf3, 0x21, 0x57, 0xba, 0x00, 0x10, 0x7e, 0x00, 0x6e, 0xee, 0x3b, 0x26, 0x1c,
0xb0, 0x90, 0x7d, 0x80, 0xb2, 0x89, 0x2e, 0xad, 0x02, 0x4b, 0x42, 0xaf, 0xca, 0x0f, 0xa9, 0x24, 0x64, 0x1f, 0x91, 0x6c, 0xb6, 0xcf, 0xa8, 0xa0, 0x96, 0x30, 0xa8, 0xf2, 0x63, 0x6e, 0x09, 0xb2,
0x88, 0x8a, 0x6b, 0x89, 0x8d, 0x67, 0x51, 0xea, 0xac, 0xf6, 0x16, 0xb5, 0x8f, 0x28, 0x6a, 0x05, 0xc7, 0xb5, 0x06, 0x33, 0x79, 0x9c, 0x79, 0x9b, 0x83, 0x65, 0xed, 0x13, 0xce, 0x5a, 0x87, 0xad,
0xdb, 0x11, 0xb5, 0x13, 0x6c, 0x02, 0x8d, 0xbd, 0xe5, 0xf5, 0x63, 0x2a, 0xac, 0x05, 0xbd, 0xd2, 0x64, 0xed, 0x34, 0xcc, 0x92, 0x71, 0xb0, 0xba, 0x7e, 0xca, 0x8d, 0xb5, 0x43, 0x6f, 0x54, 0xab,
0x99, 0xdd, 0xfb, 0xd8, 0xbe, 0x32, 0x9c, 0xa7, 0x95, 0x88, 0x52, 0x60, 0x1a, 0xa1, 0x13, 0x5b, 0xfb, 0x20, 0x1c, 0x28, 0xd3, 0x79, 0x5e, 0xcb, 0x38, 0x43, 0xa6, 0x11, 0x79, 0x89, 0x83, 0xf9,
0x98, 0xaf, 0xa0, 0x99, 0x2a, 0xfe, 0x7c, 0x29, 0x58, 0x74, 0x62, 0x90, 0xdf, 0xcd, 0xf6, 0x92, 0x3a, 0x99, 0xb9, 0xe3, 0x2f, 0x97, 0x82, 0x55, 0x2f, 0x41, 0xf9, 0xfd, 0xb0, 0x9f, 0xe5, 0x79,
0x3c, 0x8b, 0x12, 0xe1, 0x4a, 0x2f, 0xf2, 0xcf, 0x88, 0x96, 0x85, 0xfa, 0x93, 0x4a, 0xaa, 0x56, 0x9c, 0xca, 0x96, 0xf2, 0xe3, 0xe0, 0x82, 0x6c, 0x3b, 0xa8, 0x3f, 0xeb, 0x29, 0xd5, 0x86, 0x81,
0x34, 0x1c, 0xcc, 0x47, 0xd9, 0x9e, 0x72, 0x56, 0x69, 0xf8, 0x61, 0x2c, 0x13, 0x65, 0x30, 0x7e, 0xa3, 0xf9, 0x24, 0xdc, 0x50, 0x9e, 0x55, 0x1a, 0x41, 0x94, 0xa8, 0x54, 0x5b, 0x8c, 0x9f, 0x73,
0x4a, 0x99, 0x2a, 0xb9, 0xa3, 0x39, 0xc6, 0xe7, 0xd9, 0x70, 0xfe, 0xa7, 0xed, 0x23, 0xf9, 0x19, 0xa5, 0x4a, 0xee, 0x64, 0x81, 0x89, 0x65, 0x98, 0x28, 0x3e, 0xba, 0x3e, 0x92, 0x5f, 0x90, 0x68,
0x8a, 0x86, 0xda, 0x14, 0x16, 0x0e, 0x57, 0x86, 0xb1, 0x93, 0xd8, 0xd4, 0xbf, 0xcf, 0xa9, 0x70, 0xbc, 0x4b, 0x51, 0xe3, 0x68, 0xa9, 0x28, 0xf1, 0x52, 0x97, 0xfe, 0xf7, 0x25, 0x37, 0x0e, 0x42,
0x20, 0x82, 0x85, 0x43, 0x6d, 0xc4, 0x02, 0xba, 0xbd, 0x85, 0xe1, 0x0b, 0x2a, 0x1c, 0xc4, 0xa0, 0xa8, 0x71, 0xe8, 0xad, 0x44, 0xe2, 0xb4, 0x77, 0x30, 0x7c, 0xc5, 0x8d, 0x83, 0x19, 0x52, 0xf0,
0x82, 0x06, 0x06, 0x0b, 0xc5, 0x97, 0xa4, 0x20, 0x06, 0x14, 0x77, 0xb6, 0x1b, 0x6d, 0x22, 0x3c, 0x81, 0xc1, 0x41, 0xf1, 0x35, 0x2b, 0x98, 0x41, 0xc5, 0x3d, 0xdd, 0x41, 0x9b, 0x4a, 0x3f, 0xc8,
0x3f, 0x55, 0x89, 0x03, 0xab, 0x0d, 0xaa, 0xaf, 0x36, 0x3b, 0x87, 0xb0, 0x65, 0x0d, 0x85, 0x4a, 0x74, 0xea, 0xe1, 0x6a, 0x8b, 0xea, 0x9b, 0xed, 0xea, 0x21, 0x6c, 0xdd, 0x40, 0xc5, 0x29, 0x98,
0x14, 0x8a, 0x34, 0x75, 0x3c, 0x01, 0x13, 0x87, 0xc5, 0xc6, 0xbe, 0xa6, 0x4a, 0xa4, 0x61, 0xb0, 0xec, 0x39, 0x62, 0xd4, 0x6f, 0xdb, 0x63, 0x5b, 0x95, 0x59, 0xe6, 0xf9, 0xa5, 0xf0, 0xd1, 0x1d,
0x37, 0x6d, 0x42, 0x84, 0xb0, 0xbb, 0x8e, 0xbb, 0x66, 0xa3, 0xfb, 0xa6, 0xb2, 0xb9, 0xe3, 0xc4, 0x6a, 0x46, 0xd5, 0x13, 0x86, 0xb8, 0x13, 0xeb, 0x5e, 0x3d, 0x07, 0xd8, 0x65, 0x17, 0x77, 0xca,
0x82, 0x53, 0x9b, 0x7f, 0xb2, 0x68, 0x5d, 0x6c, 0x58, 0x3d, 0x9d, 0xdf, 0x56, 0xe6, 0x9f, 0x95, 0xd2, 0x57, 0x8e, 0x01, 0xe2, 0x04, 0x8c, 0x57, 0xce, 0x00, 0x76, 0xd5, 0x63, 0xa4, 0x1a, 0x33,
0x82, 0x2c, 0x6a, 0xc8, 0x48, 0x65, 0x9e, 0xaa, 0xdf, 0xb8, 0xc3, 0xb5, 0x58, 0xdc, 0x17, 0xe9, 0x8f, 0x00, 0xe2, 0x08, 0x0c, 0xe1, 0x3c, 0xb7, 0xe3, 0x8f, 0x13, 0x5e, 0x2c, 0x17, 0xc7, 0x60,
0x1e, 0xda, 0xc2, 0xfb, 0xed, 0x1c, 0xa7, 0xf8, 0xed, 0xf0, 0x90, 0x77, 0x0e, 0x3d, 0x66, 0xd9, 0x84, 0xe7, 0xb8, 0x1d, 0x7d, 0x82, 0xd0, 0x12, 0x41, 0x9c, 0x67, 0xb8, 0x1d, 0x7f, 0x92, 0x71,
0xd9, 0xad, 0xf2, 0x39, 0xef, 0x98, 0x79, 0xf8, 0x11, 0x36, 0xd4, 0x31, 0xf0, 0x98, 0x55, 0x0f, 0x46, 0x10, 0x77, 0x4f, 0xe1, 0xb7, 0x4f, 0x0f, 0x51, 0x1f, 0xe6, 0xdc, 0xcd, 0xc3, 0x30, 0x0d,
0xa3, 0x6a, 0x50, 0x9f, 0x77, 0xf8, 0x01, 0xb6, 0x0b, 0x86, 0x17, 0x33, 0xfe, 0x08, 0xe2, 0xf9, 0x6f, 0x3b, 0xfd, 0x14, 0xfd, 0x38, 0x13, 0xe2, 0x0e, 0xd8, 0xe7, 0x98, 0xf0, 0x67, 0x08, 0xed,
0x72, 0x7e, 0x88, 0xf5, 0xd3, 0xd0, 0x62, 0x46, 0x1f, 0x45, 0xb4, 0x44, 0x00, 0xa7, 0x81, 0xc5, 0xac, 0x17, 0x4b, 0x30, 0x6a, 0x0c, 0x6c, 0x3b, 0xfe, 0x2c, 0xe1, 0x26, 0x85, 0xa1, 0xd3, 0xc0,
0x8c, 0x3f, 0x46, 0x38, 0x21, 0x80, 0xdb, 0x87, 0xf0, 0xbb, 0x27, 0x76, 0x61, 0xd3, 0xa1, 0xd8, 0xb6, 0x0b, 0x9e, 0xe3, 0xd0, 0x89, 0xc0, 0xb4, 0xf1, 0xac, 0xb6, 0xd3, 0xcf, 0x73, 0xd6, 0x19,
0x4d, 0xb3, 0x3e, 0x9c, 0x54, 0xcc, 0xf4, 0xe3, 0xf8, 0xe5, 0x44, 0xf0, 0x5b, 0xd9, 0x6e, 0xcb, 0x11, 0x0b, 0x50, 0x2b, 0xfb, 0xaf, 0x9d, 0x7f, 0x81, 0xf8, 0x2e, 0x83, 0x19, 0x30, 0xfa, 0xbf,
0x80, 0x3f, 0x89, 0x68, 0xb1, 0x9e, 0xcf, 0xb1, 0x01, 0x6d, 0x3a, 0x31, 0xe3, 0x4f, 0x21, 0xae, 0x5d, 0xf1, 0x22, 0x67, 0xc0, 0xa0, 0x70, 0x1b, 0xf5, 0xce, 0x74, 0xbb, 0xe9, 0x25, 0xde, 0x46,
0x53, 0xb0, 0x75, 0x9c, 0x4e, 0xcc, 0x82, 0xa7, 0x69, 0xeb, 0x48, 0x40, 0xd8, 0x68, 0x30, 0x31, 0x3d, 0x23, 0x1d, 0xab, 0x59, 0xb4, 0x41, 0xbb, 0xe2, 0x65, 0xae, 0x66, 0xb1, 0x1e, 0xc3, 0xe8,
0xd3, 0xcf, 0x50, 0xd4, 0x09, 0xe1, 0x33, 0xac, 0x56, 0x36, 0x1b, 0x33, 0xff, 0x2c, 0xf2, 0x6d, 0x1d, 0x92, 0x76, 0xc7, 0x2b, 0x1c, 0x46, 0xcf, 0x8c, 0x14, 0x6b, 0x50, 0xdf, 0x3b, 0x20, 0xed,
0x06, 0x22, 0xa0, 0x35, 0x3b, 0xb3, 0xe2, 0x39, 0x8a, 0x80, 0x46, 0xc1, 0x31, 0xaa, 0x0e, 0x30, 0xbe, 0x57, 0xc9, 0x37, 0xb5, 0x67, 0x3e, 0x8a, 0xfb, 0x60, 0xb6, 0xff, 0x70, 0xb4, 0x5b, 0x2f,
0x66, 0xd3, 0xf3, 0x74, 0x8c, 0x2a, 0xf3, 0x0b, 0x64, 0x33, 0xaf, 0xf9, 0x66, 0xc5, 0x0b, 0x94, 0xed, 0xf4, 0xbc, 0xce, 0x98, 0xb3, 0x51, 0x9c, 0xee, 0x76, 0x59, 0x73, 0x30, 0xda, 0xb5, 0x97,
0xcd, 0x7c, 0x3d, 0x6c, 0xa3, 0x3a, 0x11, 0x98, 0x1d, 0x2f, 0xd2, 0x36, 0x2a, 0x03, 0x01, 0x5f, 0x77, 0xaa, 0x8d, 0xd6, 0x9c, 0x8b, 0x62, 0x11, 0xa0, 0x3b, 0x93, 0xec, 0xae, 0x2b, 0xe4, 0x32,
0x62, 0xf5, 0x9d, 0xd3, 0x80, 0xd9, 0xf7, 0x12, 0xfa, 0x46, 0x77, 0x0c, 0x03, 0xfc, 0x2e, 0x36, 0x20, 0xdc, 0x1a, 0x34, 0x92, 0xec, 0xfc, 0x55, 0xde, 0x1a, 0x44, 0xe0, 0xd6, 0xe0, 0x69, 0x64,
0xd1, 0x7d, 0x12, 0x30, 0x5b, 0xcf, 0x6d, 0x55, 0x7e, 0xbb, 0xe9, 0x83, 0x00, 0x3f, 0xd1, 0x6e, 0xa7, 0xaf, 0xf1, 0xd6, 0x60, 0x44, 0xcc, 0xc3, 0x48, 0x9c, 0x87, 0x21, 0x3e, 0x5b, 0xf5, 0x5b,
0x29, 0xfa, 0x14, 0x60, 0xd6, 0x9e, 0xdf, 0xea, 0x2c, 0xdc, 0xfa, 0x10, 0xc0, 0x67, 0x19, 0x6b, 0xfb, 0x8c, 0x1b, 0x19, 0xb6, 0x19, 0xfe, 0x65, 0x97, 0x60, 0x06, 0xc4, 0x11, 0xd8, 0x27, 0xa3,
0x37, 0x60, 0xb3, 0xeb, 0x02, 0xba, 0x34, 0x08, 0x8e, 0x06, 0xf6, 0x5f, 0x33, 0x7f, 0x91, 0x8e, 0xa6, 0x6c, 0xdb, 0xc8, 0x5f, 0x77, 0xb9, 0x9f, 0xe0, 0x6a, 0xb1, 0x00, 0xd0, 0x79, 0x99, 0xc6,
0x06, 0x12, 0x70, 0x34, 0xa8, 0xf5, 0x9a, 0xe9, 0x4b, 0x74, 0x34, 0x08, 0x81, 0x27, 0x5b, 0xeb, 0x28, 0x6c, 0xec, 0x6f, 0xbb, 0x9d, 0xf7, 0x7a, 0x03, 0xe9, 0x0a, 0x8a, 0xb7, 0x71, 0x8b, 0x60,
0x6e, 0x66, 0xc3, 0x65, 0x7a, 0xb2, 0x35, 0x8a, 0x1f, 0x63, 0xa3, 0x3b, 0x1a, 0xa2, 0x59, 0xf5, 0xbb, 0x2a, 0x28, 0x5e, 0xc0, 0x8f, 0xc2, 0xf0, 0x43, 0x99, 0x8a, 0xb5, 0xe7, 0xdb, 0xe8, 0xdf,
0x1a, 0xaa, 0xf6, 0x54, 0xfb, 0xa1, 0xde, 0xbc, 0xb0, 0x19, 0x9a, 0x6d, 0xaf, 0x57, 0x9a, 0x17, 0x89, 0xe6, 0xf5, 0x98, 0xb0, 0x48, 0xa5, 0x52, 0x7b, 0x7e, 0x66, 0x63, 0xff, 0x20, 0xb6, 0x04,
0xf6, 0x42, 0x3e, 0xcd, 0xfa, 0xa3, 0x2c, 0x08, 0xe0, 0xf0, 0xd4, 0x6f, 0xe8, 0xd2, 0x4d, 0x45, 0x10, 0x6e, 0x79, 0x99, 0x76, 0xb9, 0xef, 0x3f, 0x19, 0x66, 0x00, 0x83, 0xc6, 0xeb, 0x87, 0xe5,
0xd0, 0x22, 0xc5, 0xaf, 0xdb, 0x18, 0x1d, 0x02, 0xf8, 0x01, 0xb6, 0x5b, 0x84, 0x4d, 0xd1, 0x32, 0x96, 0x8d, 0xfd, 0x8b, 0x83, 0xa6, 0xf5, 0xe2, 0x18, 0xd4, 0xf0, 0xb2, 0xf8, 0x3f, 0x84, 0x0d,
0x91, 0xbf, 0x6d, 0x53, 0xc1, 0x84, 0xd5, 0x7c, 0x86, 0xb1, 0xe2, 0xd5, 0x08, 0x84, 0xd9, 0xc4, 0xfe, 0x9b, 0xe0, 0x2e, 0x81, 0xbf, 0x9c, 0xe9, 0xb6, 0x0e, 0xec, 0xc9, 0xfe, 0x87, 0x2a, 0xcd,
0xfe, 0xbe, 0x5d, 0xbc, 0xa5, 0xd1, 0x90, 0xb6, 0x20, 0x4f, 0x8a, 0x41, 0xb0, 0xd9, 0x29, 0xc8, 0xeb, 0xc5, 0x22, 0x8c, 0x66, 0xba, 0xdd, 0xce, 0xe9, 0x44, 0x63, 0xc1, 0xff, 0xdd, 0x2d, 0x5f,
0x33, 0x72, 0x90, 0xf5, 0xdd, 0x9f, 0xca, 0x48, 0x39, 0x9e, 0x89, 0xfe, 0x03, 0x69, 0x5a, 0x0f, 0x72, 0x4b, 0xe6, 0xf8, 0x21, 0x98, 0x6e, 0xa9, 0xa8, 0x17, 0x3c, 0x0e, 0x2b, 0x6a, 0x45, 0xad,
0x01, 0x0b, 0x65, 0x22, 0x94, 0xe3, 0xa5, 0x26, 0xf6, 0x4f, 0x64, 0x4b, 0x00, 0x60, 0xd7, 0x49, 0x15, 0xbb, 0xe8, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0a, 0x9c, 0xec, 0xd8, 0x50, 0x13, 0x00,
0x95, 0xcd, 0x7d, 0xff, 0x45, 0x30, 0x01, 0xb0, 0x69, 0xb8, 0x5e, 0x17, 0x1b, 0x26, 0xf6, 0x6f, 0x00,
0xda, 0x34, 0xae, 0xe7, 0x87, 0x58, 0x0d, 0x2e, 0xf3, 0xb7, 0x4a, 0x26, 0xf8, 0x1f, 0x84, 0xdb,
0x04, 0x7c, 0x73, 0xaa, 0x5a, 0xca, 0x37, 0x07, 0xfb, 0x5f, 0xcc, 0x34, 0xad, 0xe7, 0xb3, 0x6c,
0x20, 0x55, 0xad, 0x56, 0x86, 0xf3, 0xa9, 0x01, 0xff, 0x6f, 0xbb, 0x7c, 0x65, 0x51, 0x32, 0x90,
0xed, 0x07, 0xd7, 0x55, 0x2c, 0xfd, 0x48, 0x89, 0xc4, 0x64, 0xd8, 0x42, 0x83, 0x86, 0x1c, 0x9e,
0x67, 0x63, 0xae, 0x0c, 0xab, 0xdc, 0x61, 0xb6, 0x20, 0x17, 0xe4, 0x52, 0x5e, 0x67, 0xee, 0xbd,
0xd9, 0xf3, 0xd5, 0x5a, 0xd6, 0x9c, 0x74, 0x65, 0x38, 0x05, 0xbf, 0x3c, 0xda, 0x2f, 0x54, 0xcb,
0xdf, 0x21, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xaf, 0x70, 0x4e, 0x83, 0x15, 0x00, 0x00,
} }

View File

@@ -47,55 +47,6 @@ func IsStdDuration(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Stdduration, false) return proto.GetBoolExtension(field.Options, E_Stdduration, false)
} }
func IsStdDouble(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.DoubleValue"
}
func IsStdFloat(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.FloatValue"
}
func IsStdInt64(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.Int64Value"
}
func IsStdUInt64(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.UInt64Value"
}
func IsStdInt32(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.Int32Value"
}
func IsStdUInt32(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.UInt32Value"
}
func IsStdBool(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.BoolValue"
}
func IsStdString(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.StringValue"
}
func IsStdBytes(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.BytesValue"
}
func IsStdType(field *google_protobuf.FieldDescriptorProto) bool {
return (IsStdTime(field) || IsStdDuration(field) ||
IsStdDouble(field) || IsStdFloat(field) ||
IsStdInt64(field) || IsStdUInt64(field) ||
IsStdInt32(field) || IsStdUInt32(field) ||
IsStdBool(field) ||
IsStdString(field) || IsStdBytes(field))
}
func IsWktPtr(field *google_protobuf.FieldDescriptorProto) bool {
return proto.GetBoolExtension(field.Options, E_Wktpointer, false)
}
func NeedsNilCheck(proto3 bool, field *google_protobuf.FieldDescriptorProto) bool { func NeedsNilCheck(proto3 bool, field *google_protobuf.FieldDescriptorProto) bool {
nullable := IsNullable(field) nullable := IsNullable(field)
if field.IsMessage() || IsCustomType(field) { if field.IsMessage() || IsCustomType(field) {
@@ -383,6 +334,9 @@ func HasExtensionsMap(file *google_protobuf.FileDescriptorProto, message *google
} }
func HasUnrecognized(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool { func HasUnrecognized(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
if IsProto3(file) {
return false
}
return proto.GetBoolExtension(message.Options, E_GoprotoUnrecognized, proto.GetBoolExtension(file.Options, E_GoprotoUnrecognizedAll, true)) return proto.GetBoolExtension(message.Options, E_GoprotoUnrecognized, proto.GetBoolExtension(file.Options, E_GoprotoUnrecognizedAll, true))
} }
@@ -401,15 +355,3 @@ func HasCompare(file *google_protobuf.FileDescriptorProto, message *google_proto
func RegistersGolangProto(file *google_protobuf.FileDescriptorProto) bool { func RegistersGolangProto(file *google_protobuf.FileDescriptorProto) bool {
return proto.GetBoolExtension(file.Options, E_GoprotoRegistration, false) return proto.GetBoolExtension(file.Options, E_GoprotoRegistration, false)
} }
func HasMessageName(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
return proto.GetBoolExtension(message.Options, E_Messagename, proto.GetBoolExtension(file.Options, E_MessagenameAll, false))
}
func HasSizecache(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
return proto.GetBoolExtension(message.Options, E_GoprotoSizecache, proto.GetBoolExtension(file.Options, E_GoprotoSizecacheAll, true))
}
func HasUnkeyed(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
return proto.GetBoolExtension(message.Options, E_GoprotoUnkeyed, proto.GetBoolExtension(file.Options, E_GoprotoUnkeyedAll, true))
}

View File

@@ -35,39 +35,22 @@
package proto package proto
import ( import (
"fmt"
"log" "log"
"reflect" "reflect"
"strings" "strings"
) )
// Clone returns a deep copy of a protocol buffer. // Clone returns a deep copy of a protocol buffer.
func Clone(src Message) Message { func Clone(pb Message) Message {
in := reflect.ValueOf(src) in := reflect.ValueOf(pb)
if in.IsNil() { if in.IsNil() {
return src return pb
} }
out := reflect.New(in.Type().Elem()) out := reflect.New(in.Type().Elem())
dst := out.Interface().(Message) // out is empty so a merge is a deep copy.
Merge(dst, src) mergeStruct(out.Elem(), in.Elem())
return dst return out.Interface().(Message)
}
// Merger is the interface representing objects that can merge messages of the same type.
type Merger interface {
// Merge merges src into this message.
// Required and optional fields that are set in src will be set to that value in dst.
// Elements of repeated fields will be appended.
//
// Merge may panic if called with a different argument type than the receiver.
Merge(src Message)
}
// generatedMerger is the custom merge method that generated protos will have.
// We must add this method since a generate Merge method will conflict with
// many existing protos that have a Merge data field already defined.
type generatedMerger interface {
XXX_Merge(src Message)
} }
// Merge merges src into dst. // Merge merges src into dst.
@@ -75,24 +58,17 @@ type generatedMerger interface {
// Elements of repeated fields will be appended. // Elements of repeated fields will be appended.
// Merge panics if src and dst are not the same type, or if dst is nil. // Merge panics if src and dst are not the same type, or if dst is nil.
func Merge(dst, src Message) { func Merge(dst, src Message) {
if m, ok := dst.(Merger); ok {
m.Merge(src)
return
}
in := reflect.ValueOf(src) in := reflect.ValueOf(src)
out := reflect.ValueOf(dst) out := reflect.ValueOf(dst)
if out.IsNil() { if out.IsNil() {
panic("proto: nil destination") panic("proto: nil destination")
} }
if in.Type() != out.Type() { if in.Type() != out.Type() {
panic(fmt.Sprintf("proto.Merge(%T, %T) type mismatch", dst, src)) // Explicit test prior to mergeStruct so that mistyped nils will fail
panic("proto: type mismatch")
} }
if in.IsNil() { if in.IsNil() {
return // Merge from nil src is a noop // Merging nil into non-nil is a quiet no-op
}
if m, ok := dst.(generatedMerger); ok {
m.XXX_Merge(src)
return return
} }
mergeStruct(out.Elem(), in.Elem()) mergeStruct(out.Elem(), in.Elem())
@@ -113,7 +89,7 @@ func mergeStruct(out, in reflect.Value) {
bIn := emIn.GetExtensions() bIn := emIn.GetExtensions()
bOut := emOut.GetExtensions() bOut := emOut.GetExtensions()
*bOut = append(*bOut, *bIn...) *bOut = append(*bOut, *bIn...)
} else if emIn, err := extendable(in.Addr().Interface()); err == nil { } else if emIn, ok := extendable(in.Addr().Interface()); ok {
emOut, _ := extendable(out.Addr().Interface()) emOut, _ := extendable(out.Addr().Interface())
mIn, muIn := emIn.extensionsRead() mIn, muIn := emIn.extensionsRead()
if mIn != nil { if mIn != nil {

View File

@@ -1,39 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import "reflect"
type custom interface {
Marshal() ([]byte, error)
Unmarshal(data []byte) error
Size() int
}
var customType = reflect.TypeOf((*custom)(nil)).Elem()

View File

@@ -39,6 +39,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"os"
"reflect"
) )
// errOverflow is returned when an integer is too large to be represented. // errOverflow is returned when an integer is too large to be represented.
@@ -48,6 +50,10 @@ var errOverflow = errors.New("proto: integer overflow")
// wire type is encountered. It does not get returned to user code. // wire type is encountered. It does not get returned to user code.
var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")
// The fundamental decoders that interpret bytes on the wire.
// Those that take integer types all return uint64 and are
// therefore of type valueDecoder.
// DecodeVarint reads a varint-encoded integer from the slice. // DecodeVarint reads a varint-encoded integer from the slice.
// It returns the integer and the number of bytes consumed, or // It returns the integer and the number of bytes consumed, or
// zero if there is not enough. // zero if there is not enough.
@@ -261,6 +267,9 @@ func (p *Buffer) DecodeZigzag32() (x uint64, err error) {
return return
} }
// These are not ValueDecoders: they produce an array of bytes or a string.
// bytes, embedded messages
// DecodeRawBytes reads a count-delimited byte buffer from the Buffer. // DecodeRawBytes reads a count-delimited byte buffer from the Buffer.
// This is the format used for the bytes protocol buffer // This is the format used for the bytes protocol buffer
// type and for embedded messages. // type and for embedded messages.
@@ -302,27 +311,79 @@ func (p *Buffer) DecodeStringBytes() (s string, err error) {
return string(buf), nil return string(buf), nil
} }
// Unmarshaler is the interface representing objects that can // Skip the next item in the buffer. Its wire type is decoded and presented as an argument.
// unmarshal themselves. The argument points to data that may be // If the protocol buffer has extensions, and the field matches, add it as an extension.
// overwritten, so implementations should not keep references to the // Otherwise, if the XXX_unrecognized field exists, append the skipped data there.
// buffer. func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error {
// Unmarshal implementations should not clear the receiver. oi := o.index
// Any unmarshaled data should be merged into the receiver.
// Callers of Unmarshal that do not want to retain existing data err := o.skip(t, tag, wire)
// should Reset the receiver before calling Unmarshal. if err != nil {
type Unmarshaler interface { return err
Unmarshal([]byte) error }
if !unrecField.IsValid() {
return nil
}
ptr := structPointer_Bytes(base, unrecField)
// Add the skipped field to struct field
obuf := o.buf
o.buf = *ptr
o.EncodeVarint(uint64(tag<<3 | wire))
*ptr = append(o.buf, obuf[oi:o.index]...)
o.buf = obuf
return nil
} }
// newUnmarshaler is the interface representing objects that can // Skip the next item in the buffer. Its wire type is decoded and presented as an argument.
// unmarshal themselves. The semantics are identical to Unmarshaler. func (o *Buffer) skip(t reflect.Type, tag, wire int) error {
//
// This exists to support protoc-gen-go generated messages. var u uint64
// The proto package will stop type-asserting to this interface in the future. var err error
//
// DO NOT DEPEND ON THIS. switch wire {
type newUnmarshaler interface { case WireVarint:
XXX_Unmarshal([]byte) error _, err = o.DecodeVarint()
case WireFixed64:
_, err = o.DecodeFixed64()
case WireBytes:
_, err = o.DecodeRawBytes(false)
case WireFixed32:
_, err = o.DecodeFixed32()
case WireStartGroup:
for {
u, err = o.DecodeVarint()
if err != nil {
break
}
fwire := int(u & 0x7)
if fwire == WireEndGroup {
break
}
ftag := int(u >> 3)
err = o.skip(t, ftag, fwire)
if err != nil {
break
}
}
default:
err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t)
}
return err
}
// Unmarshaler is the interface representing objects that can
// unmarshal themselves. The method should reset the receiver before
// decoding starts. The argument points to data that may be
// overwritten, so implementations should not keep references to the
// buffer.
type Unmarshaler interface {
Unmarshal([]byte) error
} }
// Unmarshal parses the protocol buffer representation in buf and places the // Unmarshal parses the protocol buffer representation in buf and places the
@@ -334,13 +395,7 @@ type newUnmarshaler interface {
// to preserve and append to existing data. // to preserve and append to existing data.
func Unmarshal(buf []byte, pb Message) error { func Unmarshal(buf []byte, pb Message) error {
pb.Reset() pb.Reset()
if u, ok := pb.(newUnmarshaler); ok { return UnmarshalMerge(buf, pb)
return u.XXX_Unmarshal(buf)
}
if u, ok := pb.(Unmarshaler); ok {
return u.Unmarshal(buf)
}
return NewBuffer(buf).Unmarshal(pb)
} }
// UnmarshalMerge parses the protocol buffer representation in buf and // UnmarshalMerge parses the protocol buffer representation in buf and
@@ -350,16 +405,8 @@ func Unmarshal(buf []byte, pb Message) error {
// UnmarshalMerge merges into existing data in pb. // UnmarshalMerge merges into existing data in pb.
// Most code should use Unmarshal instead. // Most code should use Unmarshal instead.
func UnmarshalMerge(buf []byte, pb Message) error { func UnmarshalMerge(buf []byte, pb Message) error {
if u, ok := pb.(newUnmarshaler); ok { // If the object can unmarshal itself, let it.
return u.XXX_Unmarshal(buf)
}
if u, ok := pb.(Unmarshaler); ok { if u, ok := pb.(Unmarshaler); ok {
// NOTE: The history of proto have unfortunately been inconsistent
// whether Unmarshaler should or should not implicitly clear itself.
// Some implementations do, most do not.
// Thus, calling this here may or may not do what people want.
//
// See https://github.com/golang/protobuf/issues/424
return u.Unmarshal(buf) return u.Unmarshal(buf)
} }
return NewBuffer(buf).Unmarshal(pb) return NewBuffer(buf).Unmarshal(pb)
@@ -375,17 +422,12 @@ func (p *Buffer) DecodeMessage(pb Message) error {
} }
// DecodeGroup reads a tag-delimited group from the Buffer. // DecodeGroup reads a tag-delimited group from the Buffer.
// StartGroup tag is already consumed. This function consumes
// EndGroup tag.
func (p *Buffer) DecodeGroup(pb Message) error { func (p *Buffer) DecodeGroup(pb Message) error {
b := p.buf[p.index:] typ, base, err := getbase(pb)
x, y := findEndGroup(b) if err != nil {
if x < 0 { return err
return io.ErrUnexpectedEOF
} }
err := Unmarshal(b[:x], pb) return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base)
p.index += y
return err
} }
// Unmarshal parses the protocol buffer representation in the // Unmarshal parses the protocol buffer representation in the
@@ -396,33 +438,541 @@ func (p *Buffer) DecodeGroup(pb Message) error {
// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal. // Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal.
func (p *Buffer) Unmarshal(pb Message) error { func (p *Buffer) Unmarshal(pb Message) error {
// If the object can unmarshal itself, let it. // If the object can unmarshal itself, let it.
if u, ok := pb.(newUnmarshaler); ok {
err := u.XXX_Unmarshal(p.buf[p.index:])
p.index = len(p.buf)
return err
}
if u, ok := pb.(Unmarshaler); ok { if u, ok := pb.(Unmarshaler); ok {
// NOTE: The history of proto have unfortunately been inconsistent
// whether Unmarshaler should or should not implicitly clear itself.
// Some implementations do, most do not.
// Thus, calling this here may or may not do what people want.
//
// See https://github.com/golang/protobuf/issues/424
err := u.Unmarshal(p.buf[p.index:]) err := u.Unmarshal(p.buf[p.index:])
p.index = len(p.buf) p.index = len(p.buf)
return err return err
} }
// Slow workaround for messages that aren't Unmarshalers. typ, base, err := getbase(pb)
// This includes some hand-coded .pb.go files and if err != nil {
// bootstrap protos. return err
// TODO: fix all of those and then add Unmarshal to }
// the Message interface. Then:
// The cast above and code below can be deleted. err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base)
// The old unmarshaler can be deleted.
// Clients can call Unmarshal directly (can already do that, actually). if collectStats {
var info InternalMessageInfo stats.Decode++
err := info.Unmarshal(pb, p.buf[p.index:]) }
p.index = len(p.buf)
return err
}
// unmarshalType does the work of unmarshaling a structure.
func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error {
var state errorState
required, reqFields := prop.reqCount, uint64(0)
var err error
for err == nil && o.index < len(o.buf) {
oi := o.index
var u uint64
u, err = o.DecodeVarint()
if err != nil {
break
}
wire := int(u & 0x7)
if wire == WireEndGroup {
if is_group {
if required > 0 {
// Not enough information to determine the exact field.
// (See below.)
return &RequiredNotSetError{"{Unknown}"}
}
return nil // input is satisfied
}
return fmt.Errorf("proto: %s: wiretype end group for non-group", st)
}
tag := int(u >> 3)
if tag <= 0 {
return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire)
}
fieldnum, ok := prop.decoderTags.get(tag)
if !ok {
// Maybe it's an extension?
if prop.extendable {
if e, eok := structPointer_Interface(base, st).(extensionsBytes); eok {
if isExtensionField(e, int32(tag)) {
if err = o.skip(st, tag, wire); err == nil {
ext := e.GetExtensions()
*ext = append(*ext, o.buf[oi:o.index]...)
}
continue
}
} else if e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) {
if err = o.skip(st, tag, wire); err == nil {
extmap := e.extensionsWrite()
ext := extmap[int32(tag)] // may be missing
ext.enc = append(ext.enc, o.buf[oi:o.index]...)
extmap[int32(tag)] = ext
}
continue
}
}
// Maybe it's a oneof?
if prop.oneofUnmarshaler != nil {
m := structPointer_Interface(base, st).(Message)
// First return value indicates whether tag is a oneof field.
ok, err = prop.oneofUnmarshaler(m, tag, wire, o)
if err == ErrInternalBadWireType {
// Map the error to something more descriptive.
// Do the formatting here to save generated code space.
err = fmt.Errorf("bad wiretype for oneof field in %T", m)
}
if ok {
continue
}
}
err = o.skipAndSave(st, tag, wire, base, prop.unrecField)
continue
}
p := prop.Prop[fieldnum]
if p.dec == nil {
fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name)
continue
}
dec := p.dec
if wire != WireStartGroup && wire != p.WireType {
if wire == WireBytes && p.packedDec != nil {
// a packable field
dec = p.packedDec
} else {
err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType)
continue
}
}
decErr := dec(o, p, base)
if decErr != nil && !state.shouldContinue(decErr, p) {
err = decErr
}
if err == nil && p.Required {
// Successfully decoded a required field.
if tag <= 64 {
// use bitmap for fields 1-64 to catch field reuse.
var mask uint64 = 1 << uint64(tag-1)
if reqFields&mask == 0 {
// new required field
reqFields |= mask
required--
}
} else {
// This is imprecise. It can be fooled by a required field
// with a tag > 64 that is encoded twice; that's very rare.
// A fully correct implementation would require allocating
// a data structure, which we would like to avoid.
required--
}
}
}
if err == nil {
if is_group {
return io.ErrUnexpectedEOF
}
if state.err != nil {
return state.err
}
if required > 0 {
// Not enough information to determine the exact field. If we use extra
// CPU, we could determine the field only if the missing required field
// has a tag <= 64 and we check reqFields.
return &RequiredNotSetError{"{Unknown}"}
}
}
return err
}
// Individual type decoders
// For each,
// u is the decoded value,
// v is a pointer to the field (pointer) in the struct
// Sizes of the pools to allocate inside the Buffer.
// The goal is modest amortization and allocation
// on at least 16-byte boundaries.
const (
boolPoolSize = 16
uint32PoolSize = 8
uint64PoolSize = 4
)
// Decode a bool.
func (o *Buffer) dec_bool(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
if len(o.bools) == 0 {
o.bools = make([]bool, boolPoolSize)
}
o.bools[0] = u != 0
*structPointer_Bool(base, p.field) = &o.bools[0]
o.bools = o.bools[1:]
return nil
}
func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
*structPointer_BoolVal(base, p.field) = u != 0
return nil
}
// Decode an int32.
func (o *Buffer) dec_int32(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
word32_Set(structPointer_Word32(base, p.field), o, uint32(u))
return nil
}
func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u))
return nil
}
// Decode an int64.
func (o *Buffer) dec_int64(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
word64_Set(structPointer_Word64(base, p.field), o, u)
return nil
}
func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
word64Val_Set(structPointer_Word64Val(base, p.field), o, u)
return nil
}
// Decode a string.
func (o *Buffer) dec_string(p *Properties, base structPointer) error {
s, err := o.DecodeStringBytes()
if err != nil {
return err
}
*structPointer_String(base, p.field) = &s
return nil
}
func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error {
s, err := o.DecodeStringBytes()
if err != nil {
return err
}
*structPointer_StringVal(base, p.field) = s
return nil
}
// Decode a slice of bytes ([]byte).
func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
*structPointer_Bytes(base, p.field) = b
return nil
}
// Decode a slice of bools ([]bool).
func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
v := structPointer_BoolSlice(base, p.field)
*v = append(*v, u != 0)
return nil
}
// Decode a slice of bools ([]bool) in packed format.
func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error {
v := structPointer_BoolSlice(base, p.field)
nn, err := o.DecodeVarint()
if err != nil {
return err
}
nb := int(nn) // number of bytes of encoded bools
fin := o.index + nb
if fin < o.index {
return errOverflow
}
y := *v
for o.index < fin {
u, err := p.valDec(o)
if err != nil {
return err
}
y = append(y, u != 0)
}
*v = y
return nil
}
// Decode a slice of int32s ([]int32).
func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
structPointer_Word32Slice(base, p.field).Append(uint32(u))
return nil
}
// Decode a slice of int32s ([]int32) in packed format.
func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error {
v := structPointer_Word32Slice(base, p.field)
nn, err := o.DecodeVarint()
if err != nil {
return err
}
nb := int(nn) // number of bytes of encoded int32s
fin := o.index + nb
if fin < o.index {
return errOverflow
}
for o.index < fin {
u, err := p.valDec(o)
if err != nil {
return err
}
v.Append(uint32(u))
}
return nil
}
// Decode a slice of int64s ([]int64).
func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
structPointer_Word64Slice(base, p.field).Append(u)
return nil
}
// Decode a slice of int64s ([]int64) in packed format.
func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error {
v := structPointer_Word64Slice(base, p.field)
nn, err := o.DecodeVarint()
if err != nil {
return err
}
nb := int(nn) // number of bytes of encoded int64s
fin := o.index + nb
if fin < o.index {
return errOverflow
}
for o.index < fin {
u, err := p.valDec(o)
if err != nil {
return err
}
v.Append(u)
}
return nil
}
// Decode a slice of strings ([]string).
func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error {
s, err := o.DecodeStringBytes()
if err != nil {
return err
}
v := structPointer_StringSlice(base, p.field)
*v = append(*v, s)
return nil
}
// Decode a slice of slice of bytes ([][]byte).
func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
v := structPointer_BytesSlice(base, p.field)
*v = append(*v, b)
return nil
}
// Decode a map field.
func (o *Buffer) dec_new_map(p *Properties, base structPointer) error {
raw, err := o.DecodeRawBytes(false)
if err != nil {
return err
}
oi := o.index // index at the end of this map entry
o.index -= len(raw) // move buffer back to start of map entry
mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V
if mptr.Elem().IsNil() {
mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem()))
}
v := mptr.Elem() // map[K]V
// Prepare addressable doubly-indirect placeholders for the key and value types.
// See enc_new_map for why.
keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K
keybase := toStructPointer(keyptr.Addr()) // **K
var valbase structPointer
var valptr reflect.Value
switch p.mtype.Elem().Kind() {
case reflect.Slice:
// []byte
var dummy []byte
valptr = reflect.ValueOf(&dummy) // *[]byte
valbase = toStructPointer(valptr) // *[]byte
case reflect.Ptr:
// message; valptr is **Msg; need to allocate the intermediate pointer
valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V
valptr.Set(reflect.New(valptr.Type().Elem()))
valbase = toStructPointer(valptr)
default:
// everything else
valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V
valbase = toStructPointer(valptr.Addr()) // **V
}
// Decode.
// This parses a restricted wire format, namely the encoding of a message
// with two fields. See enc_new_map for the format.
for o.index < oi {
// tagcode for key and value properties are always a single byte
// because they have tags 1 and 2.
tagcode := o.buf[o.index]
o.index++
switch tagcode {
case p.mkeyprop.tagcode[0]:
if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil {
return err
}
case p.mvalprop.tagcode[0]:
if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil {
return err
}
default:
// TODO: Should we silently skip this instead?
return fmt.Errorf("proto: bad map data tag %d", raw[0])
}
}
keyelem, valelem := keyptr.Elem(), valptr.Elem()
if !keyelem.IsValid() {
keyelem = reflect.Zero(p.mtype.Key())
}
if !valelem.IsValid() {
valelem = reflect.Zero(p.mtype.Elem())
}
v.SetMapIndex(keyelem, valelem)
return nil
}
// Decode a group.
func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error {
bas := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(bas) {
// allocate new nested message
bas = toStructPointer(reflect.New(p.stype))
structPointer_SetStructPointer(base, p.field, bas)
}
return o.unmarshalType(p.stype, p.sprop, true, bas)
}
// Decode an embedded message.
func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) {
raw, e := o.DecodeRawBytes(false)
if e != nil {
return e
}
bas := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(bas) {
// allocate new nested message
bas = toStructPointer(reflect.New(p.stype))
structPointer_SetStructPointer(base, p.field, bas)
}
// If the object can unmarshal itself, let it.
if p.isUnmarshaler {
iv := structPointer_Interface(bas, p.stype)
return iv.(Unmarshaler).Unmarshal(raw)
}
obuf := o.buf
oi := o.index
o.buf = raw
o.index = 0
err = o.unmarshalType(p.stype, p.sprop, false, bas)
o.buf = obuf
o.index = oi
return err
}
// Decode a slice of embedded messages.
func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error {
return o.dec_slice_struct(p, false, base)
}
// Decode a slice of embedded groups.
func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error {
return o.dec_slice_struct(p, true, base)
}
// Decode a slice of structs ([]*struct).
func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error {
v := reflect.New(p.stype)
bas := toStructPointer(v)
structPointer_StructPointerSlice(base, p.field).Append(bas)
if is_group {
err := o.unmarshalType(p.stype, p.sprop, is_group, bas)
return err
}
raw, err := o.DecodeRawBytes(false)
if err != nil {
return err
}
// If the object can unmarshal itself, let it.
if p.isUnmarshaler {
iv := v.Interface()
return iv.(Unmarshaler).Unmarshal(raw)
}
obuf := o.buf
oi := o.index
o.buf = raw
o.index = 0
err = o.unmarshalType(p.stype, p.sprop, is_group, bas)
o.buf = obuf
o.index = oi
return err return err
} }

172
vendor/github.com/gogo/protobuf/proto/decode_gogo.go generated vendored Normal file
View File

@@ -0,0 +1,172 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"reflect"
)
// Decode a reference to a struct pointer.
func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) {
raw, e := o.DecodeRawBytes(false)
if e != nil {
return e
}
// If the object can unmarshal itself, let it.
if p.isUnmarshaler {
panic("not supported, since this is a pointer receiver")
}
obuf := o.buf
oi := o.index
o.buf = raw
o.index = 0
bas := structPointer_FieldPointer(base, p.field)
err = o.unmarshalType(p.stype, p.sprop, false, bas)
o.buf = obuf
o.index = oi
return err
}
// Decode a slice of references to struct pointers ([]struct).
func (o *Buffer) dec_slice_ref_struct(p *Properties, is_group bool, base structPointer) error {
newBas := appendStructPointer(base, p.field, p.sstype)
if is_group {
panic("not supported, maybe in future, if requested.")
}
raw, err := o.DecodeRawBytes(false)
if err != nil {
return err
}
// If the object can unmarshal itself, let it.
if p.isUnmarshaler {
panic("not supported, since this is not a pointer receiver.")
}
obuf := o.buf
oi := o.index
o.buf = raw
o.index = 0
err = o.unmarshalType(p.stype, p.sprop, is_group, newBas)
o.buf = obuf
o.index = oi
return err
}
// Decode a slice of references to struct pointers.
func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error {
return o.dec_slice_ref_struct(p, false, base)
}
func setPtrCustomType(base structPointer, f field, v interface{}) {
if v == nil {
return
}
structPointer_SetStructPointer(base, f, toStructPointer(reflect.ValueOf(v)))
}
func setCustomType(base structPointer, f field, value interface{}) {
if value == nil {
return
}
v := reflect.ValueOf(value).Elem()
t := reflect.TypeOf(value).Elem()
kind := t.Kind()
switch kind {
case reflect.Slice:
slice := reflect.MakeSlice(t, v.Len(), v.Cap())
reflect.Copy(slice, v)
oldHeader := structPointer_GetSliceHeader(base, f)
oldHeader.Data = slice.Pointer()
oldHeader.Len = v.Len()
oldHeader.Cap = v.Cap()
default:
size := reflect.TypeOf(value).Elem().Size()
structPointer_Copy(toStructPointer(reflect.ValueOf(value)), structPointer_Add(base, f), int(size))
}
}
func (o *Buffer) dec_custom_bytes(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
i := reflect.New(p.ctype.Elem()).Interface()
custom := (i).(Unmarshaler)
if err := custom.Unmarshal(b); err != nil {
return err
}
setPtrCustomType(base, p.field, custom)
return nil
}
func (o *Buffer) dec_custom_ref_bytes(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
i := reflect.New(p.ctype).Interface()
custom := (i).(Unmarshaler)
if err := custom.Unmarshal(b); err != nil {
return err
}
if custom != nil {
setCustomType(base, p.field, custom)
}
return nil
}
// Decode a slice of bytes ([]byte) into a slice of custom types.
func (o *Buffer) dec_custom_slice_bytes(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
i := reflect.New(p.ctype.Elem()).Interface()
custom := (i).(Unmarshaler)
if err := custom.Unmarshal(b); err != nil {
return err
}
newBas := appendStructPointer(base, p.field, p.ctype)
var zero field
setCustomType(newBas, zero, custom)
return nil
}

View File

@@ -1,350 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2017 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"reflect"
"strings"
"sync"
"sync/atomic"
)
type generatedDiscarder interface {
XXX_DiscardUnknown()
}
// DiscardUnknown recursively discards all unknown fields from this message
// and all embedded messages.
//
// When unmarshaling a message with unrecognized fields, the tags and values
// of such fields are preserved in the Message. This allows a later call to
// marshal to be able to produce a message that continues to have those
// unrecognized fields. To avoid this, DiscardUnknown is used to
// explicitly clear the unknown fields after unmarshaling.
//
// For proto2 messages, the unknown fields of message extensions are only
// discarded from messages that have been accessed via GetExtension.
func DiscardUnknown(m Message) {
if m, ok := m.(generatedDiscarder); ok {
m.XXX_DiscardUnknown()
return
}
// TODO: Dynamically populate a InternalMessageInfo for legacy messages,
// but the master branch has no implementation for InternalMessageInfo,
// so it would be more work to replicate that approach.
discardLegacy(m)
}
// DiscardUnknown recursively discards all unknown fields.
func (a *InternalMessageInfo) DiscardUnknown(m Message) {
di := atomicLoadDiscardInfo(&a.discard)
if di == nil {
di = getDiscardInfo(reflect.TypeOf(m).Elem())
atomicStoreDiscardInfo(&a.discard, di)
}
di.discard(toPointer(&m))
}
type discardInfo struct {
typ reflect.Type
initialized int32 // 0: only typ is valid, 1: everything is valid
lock sync.Mutex
fields []discardFieldInfo
unrecognized field
}
type discardFieldInfo struct {
field field // Offset of field, guaranteed to be valid
discard func(src pointer)
}
var (
discardInfoMap = map[reflect.Type]*discardInfo{}
discardInfoLock sync.Mutex
)
func getDiscardInfo(t reflect.Type) *discardInfo {
discardInfoLock.Lock()
defer discardInfoLock.Unlock()
di := discardInfoMap[t]
if di == nil {
di = &discardInfo{typ: t}
discardInfoMap[t] = di
}
return di
}
func (di *discardInfo) discard(src pointer) {
if src.isNil() {
return // Nothing to do.
}
if atomic.LoadInt32(&di.initialized) == 0 {
di.computeDiscardInfo()
}
for _, fi := range di.fields {
sfp := src.offset(fi.field)
fi.discard(sfp)
}
// For proto2 messages, only discard unknown fields in message extensions
// that have been accessed via GetExtension.
if em, err := extendable(src.asPointerTo(di.typ).Interface()); err == nil {
// Ignore lock since DiscardUnknown is not concurrency safe.
emm, _ := em.extensionsRead()
for _, mx := range emm {
if m, ok := mx.value.(Message); ok {
DiscardUnknown(m)
}
}
}
if di.unrecognized.IsValid() {
*src.offset(di.unrecognized).toBytes() = nil
}
}
func (di *discardInfo) computeDiscardInfo() {
di.lock.Lock()
defer di.lock.Unlock()
if di.initialized != 0 {
return
}
t := di.typ
n := t.NumField()
for i := 0; i < n; i++ {
f := t.Field(i)
if strings.HasPrefix(f.Name, "XXX_") {
continue
}
dfi := discardFieldInfo{field: toField(&f)}
tf := f.Type
// Unwrap tf to get its most basic type.
var isPointer, isSlice bool
if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
isSlice = true
tf = tf.Elem()
}
if tf.Kind() == reflect.Ptr {
isPointer = true
tf = tf.Elem()
}
if isPointer && isSlice && tf.Kind() != reflect.Struct {
panic(fmt.Sprintf("%v.%s cannot be a slice of pointers to primitive types", t, f.Name))
}
switch tf.Kind() {
case reflect.Struct:
switch {
case !isPointer:
panic(fmt.Sprintf("%v.%s cannot be a direct struct value", t, f.Name))
case isSlice: // E.g., []*pb.T
discardInfo := getDiscardInfo(tf)
dfi.discard = func(src pointer) {
sps := src.getPointerSlice()
for _, sp := range sps {
if !sp.isNil() {
discardInfo.discard(sp)
}
}
}
default: // E.g., *pb.T
discardInfo := getDiscardInfo(tf)
dfi.discard = func(src pointer) {
sp := src.getPointer()
if !sp.isNil() {
discardInfo.discard(sp)
}
}
}
case reflect.Map:
switch {
case isPointer || isSlice:
panic(fmt.Sprintf("%v.%s cannot be a pointer to a map or a slice of map values", t, f.Name))
default: // E.g., map[K]V
if tf.Elem().Kind() == reflect.Ptr { // Proto struct (e.g., *T)
dfi.discard = func(src pointer) {
sm := src.asPointerTo(tf).Elem()
if sm.Len() == 0 {
return
}
for _, key := range sm.MapKeys() {
val := sm.MapIndex(key)
DiscardUnknown(val.Interface().(Message))
}
}
} else {
dfi.discard = func(pointer) {} // Noop
}
}
case reflect.Interface:
// Must be oneof field.
switch {
case isPointer || isSlice:
panic(fmt.Sprintf("%v.%s cannot be a pointer to a interface or a slice of interface values", t, f.Name))
default: // E.g., interface{}
// TODO: Make this faster?
dfi.discard = func(src pointer) {
su := src.asPointerTo(tf).Elem()
if !su.IsNil() {
sv := su.Elem().Elem().Field(0)
if sv.Kind() == reflect.Ptr && sv.IsNil() {
return
}
switch sv.Type().Kind() {
case reflect.Ptr: // Proto struct (e.g., *T)
DiscardUnknown(sv.Interface().(Message))
}
}
}
}
default:
continue
}
di.fields = append(di.fields, dfi)
}
di.unrecognized = invalidField
if f, ok := t.FieldByName("XXX_unrecognized"); ok {
if f.Type != reflect.TypeOf([]byte{}) {
panic("expected XXX_unrecognized to be of type []byte")
}
di.unrecognized = toField(&f)
}
atomic.StoreInt32(&di.initialized, 1)
}
func discardLegacy(m Message) {
v := reflect.ValueOf(m)
if v.Kind() != reflect.Ptr || v.IsNil() {
return
}
v = v.Elem()
if v.Kind() != reflect.Struct {
return
}
t := v.Type()
for i := 0; i < v.NumField(); i++ {
f := t.Field(i)
if strings.HasPrefix(f.Name, "XXX_") {
continue
}
vf := v.Field(i)
tf := f.Type
// Unwrap tf to get its most basic type.
var isPointer, isSlice bool
if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
isSlice = true
tf = tf.Elem()
}
if tf.Kind() == reflect.Ptr {
isPointer = true
tf = tf.Elem()
}
if isPointer && isSlice && tf.Kind() != reflect.Struct {
panic(fmt.Sprintf("%T.%s cannot be a slice of pointers to primitive types", m, f.Name))
}
switch tf.Kind() {
case reflect.Struct:
switch {
case !isPointer:
panic(fmt.Sprintf("%T.%s cannot be a direct struct value", m, f.Name))
case isSlice: // E.g., []*pb.T
for j := 0; j < vf.Len(); j++ {
discardLegacy(vf.Index(j).Interface().(Message))
}
default: // E.g., *pb.T
discardLegacy(vf.Interface().(Message))
}
case reflect.Map:
switch {
case isPointer || isSlice:
panic(fmt.Sprintf("%T.%s cannot be a pointer to a map or a slice of map values", m, f.Name))
default: // E.g., map[K]V
tv := vf.Type().Elem()
if tv.Kind() == reflect.Ptr && tv.Implements(protoMessageType) { // Proto struct (e.g., *T)
for _, key := range vf.MapKeys() {
val := vf.MapIndex(key)
discardLegacy(val.Interface().(Message))
}
}
}
case reflect.Interface:
// Must be oneof field.
switch {
case isPointer || isSlice:
panic(fmt.Sprintf("%T.%s cannot be a pointer to a interface or a slice of interface values", m, f.Name))
default: // E.g., test_proto.isCommunique_Union interface
if !vf.IsNil() && f.Tag.Get("protobuf_oneof") != "" {
vf = vf.Elem() // E.g., *test_proto.Communique_Msg
if !vf.IsNil() {
vf = vf.Elem() // E.g., test_proto.Communique_Msg
vf = vf.Field(0) // E.g., Proto struct (e.g., *T) or primitive value
if vf.Kind() == reflect.Ptr {
discardLegacy(vf.Interface().(Message))
}
}
}
}
}
}
if vf := v.FieldByName("XXX_unrecognized"); vf.IsValid() {
if vf.Type() != reflect.TypeOf([]byte{}) {
panic("expected XXX_unrecognized to be of type []byte")
}
vf.Set(reflect.ValueOf([]byte(nil)))
}
// For proto2 messages, only discard unknown fields in message extensions
// that have been accessed via GetExtension.
if em, err := extendable(m); err == nil {
// Ignore lock since discardLegacy is not concurrency safe.
emm, _ := em.extensionsRead()
for _, mx := range emm {
if m, ok := mx.value.(Message); ok {
discardLegacy(m)
}
}
}
}

View File

@@ -47,3 +47,157 @@ func (*duration) String() string { return "duration<string>" }
func init() { func init() {
RegisterType((*duration)(nil), "gogo.protobuf.proto.duration") RegisterType((*duration)(nil), "gogo.protobuf.proto.duration")
} }
func (o *Buffer) decDuration() (time.Duration, error) {
b, err := o.DecodeRawBytes(true)
if err != nil {
return 0, err
}
dproto := &duration{}
if err := Unmarshal(b, dproto); err != nil {
return 0, err
}
return durationFromProto(dproto)
}
func (o *Buffer) dec_duration(p *Properties, base structPointer) error {
d, err := o.decDuration()
if err != nil {
return err
}
word64_Set(structPointer_Word64(base, p.field), o, uint64(d))
return nil
}
func (o *Buffer) dec_ref_duration(p *Properties, base structPointer) error {
d, err := o.decDuration()
if err != nil {
return err
}
word64Val_Set(structPointer_Word64Val(base, p.field), o, uint64(d))
return nil
}
func (o *Buffer) dec_slice_duration(p *Properties, base structPointer) error {
d, err := o.decDuration()
if err != nil {
return err
}
newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType)))
var zero field
setPtrCustomType(newBas, zero, &d)
return nil
}
func (o *Buffer) dec_slice_ref_duration(p *Properties, base structPointer) error {
d, err := o.decDuration()
if err != nil {
return err
}
structPointer_Word64Slice(base, p.field).Append(uint64(d))
return nil
}
func size_duration(p *Properties, base structPointer) (n int) {
structp := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return 0
}
dur := structPointer_Interface(structp, durationType).(*time.Duration)
d := durationProto(*dur)
size := Size(d)
return size + sizeVarint(uint64(size)) + len(p.tagcode)
}
func (o *Buffer) enc_duration(p *Properties, base structPointer) error {
structp := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return ErrNil
}
dur := structPointer_Interface(structp, durationType).(*time.Duration)
d := durationProto(*dur)
data, err := Marshal(d)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_ref_duration(p *Properties, base structPointer) (n int) {
dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration)
d := durationProto(*dur)
size := Size(d)
return size + sizeVarint(uint64(size)) + len(p.tagcode)
}
func (o *Buffer) enc_ref_duration(p *Properties, base structPointer) error {
dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration)
d := durationProto(*dur)
data, err := Marshal(d)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_slice_duration(p *Properties, base structPointer) (n int) {
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration)
durs := *pdurs
for i := 0; i < len(durs); i++ {
if durs[i] == nil {
return 0
}
dproto := durationProto(*durs[i])
size := Size(dproto)
n += len(p.tagcode) + size + sizeVarint(uint64(size))
}
return n
}
func (o *Buffer) enc_slice_duration(p *Properties, base structPointer) error {
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration)
durs := *pdurs
for i := 0; i < len(durs); i++ {
if durs[i] == nil {
return errRepeatedHasNil
}
dproto := durationProto(*durs[i])
data, err := Marshal(dproto)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}
func size_slice_ref_duration(p *Properties, base structPointer) (n int) {
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration)
durs := *pdurs
for i := 0; i < len(durs); i++ {
dproto := durationProto(durs[i])
size := Size(dproto)
n += len(p.tagcode) + size + sizeVarint(uint64(size))
}
return n
}
func (o *Buffer) enc_slice_ref_duration(p *Properties, base structPointer) error {
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration)
durs := *pdurs
for i := 0; i < len(durs); i++ {
dproto := durationProto(durs[i])
data, err := Marshal(dproto)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,11 @@
// Copyright (c) 2013, The GoGo Authors. All rights reserved. // Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf // http://github.com/gogo/protobuf
// //
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// http://github.com/golang/protobuf/
//
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
@@ -13,6 +18,9 @@
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -28,6 +36,315 @@
package proto package proto
import (
"reflect"
)
func NewRequiredNotSetError(field string) *RequiredNotSetError { func NewRequiredNotSetError(field string) *RequiredNotSetError {
return &RequiredNotSetError{field} return &RequiredNotSetError{field}
} }
type Sizer interface {
Size() int
}
func (o *Buffer) enc_ext_slice_byte(p *Properties, base structPointer) error {
s := *structPointer_Bytes(base, p.field)
if s == nil {
return ErrNil
}
o.buf = append(o.buf, s...)
return nil
}
func size_ext_slice_byte(p *Properties, base structPointer) (n int) {
s := *structPointer_Bytes(base, p.field)
if s == nil {
return 0
}
n += len(s)
return
}
// Encode a reference to bool pointer.
func (o *Buffer) enc_ref_bool(p *Properties, base structPointer) error {
v := *structPointer_BoolVal(base, p.field)
x := 0
if v {
x = 1
}
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, uint64(x))
return nil
}
func size_ref_bool(p *Properties, base structPointer) int {
return len(p.tagcode) + 1 // each bool takes exactly one byte
}
// Encode a reference to int32 pointer.
func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error {
v := structPointer_Word32Val(base, p.field)
x := int32(word32Val_Get(v))
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, uint64(x))
return nil
}
func size_ref_int32(p *Properties, base structPointer) (n int) {
v := structPointer_Word32Val(base, p.field)
x := int32(word32Val_Get(v))
n += len(p.tagcode)
n += p.valSize(uint64(x))
return
}
func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error {
v := structPointer_Word32Val(base, p.field)
x := word32Val_Get(v)
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, uint64(x))
return nil
}
func size_ref_uint32(p *Properties, base structPointer) (n int) {
v := structPointer_Word32Val(base, p.field)
x := word32Val_Get(v)
n += len(p.tagcode)
n += p.valSize(uint64(x))
return
}
// Encode a reference to an int64 pointer.
func (o *Buffer) enc_ref_int64(p *Properties, base structPointer) error {
v := structPointer_Word64Val(base, p.field)
x := word64Val_Get(v)
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, x)
return nil
}
func size_ref_int64(p *Properties, base structPointer) (n int) {
v := structPointer_Word64Val(base, p.field)
x := word64Val_Get(v)
n += len(p.tagcode)
n += p.valSize(x)
return
}
// Encode a reference to a string pointer.
func (o *Buffer) enc_ref_string(p *Properties, base structPointer) error {
v := *structPointer_StringVal(base, p.field)
o.buf = append(o.buf, p.tagcode...)
o.EncodeStringBytes(v)
return nil
}
func size_ref_string(p *Properties, base structPointer) (n int) {
v := *structPointer_StringVal(base, p.field)
n += len(p.tagcode)
n += sizeStringBytes(v)
return
}
// Encode a reference to a message struct.
func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error {
var state errorState
structp := structPointer_GetRefStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return ErrNil
}
// Can the object marshal itself?
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, err := m.Marshal()
if err != nil && !state.shouldContinue(err, nil) {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
o.buf = append(o.buf, p.tagcode...)
return o.enc_len_struct(p.sprop, structp, &state)
}
//TODO this is only copied, please fix this
func size_ref_struct_message(p *Properties, base structPointer) int {
structp := structPointer_GetRefStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return 0
}
// Can the object marshal itself?
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, _ := m.Marshal()
n0 := len(p.tagcode)
n1 := sizeRawBytes(data)
return n0 + n1
}
n0 := len(p.tagcode)
n1 := size_struct(p.sprop, structp)
n2 := sizeVarint(uint64(n1)) // size of encoded length
return n0 + n1 + n2
}
// Encode a slice of references to message struct pointers ([]struct).
func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer) error {
var state errorState
ss := structPointer_StructRefSlice(base, p.field, p.stype.Size())
l := ss.Len()
for i := 0; i < l; i++ {
structp := ss.Index(i)
if structPointer_IsNil(structp) {
return errRepeatedHasNil
}
// Can the object marshal itself?
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, err := m.Marshal()
if err != nil && !state.shouldContinue(err, nil) {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
continue
}
o.buf = append(o.buf, p.tagcode...)
err := o.enc_len_struct(p.sprop, structp, &state)
if err != nil && !state.shouldContinue(err, nil) {
if err == ErrNil {
return errRepeatedHasNil
}
return err
}
}
return state.err
}
//TODO this is only copied, please fix this
func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) {
ss := structPointer_StructRefSlice(base, p.field, p.stype.Size())
l := ss.Len()
n += l * len(p.tagcode)
for i := 0; i < l; i++ {
structp := ss.Index(i)
if structPointer_IsNil(structp) {
return // return the size up to this point
}
// Can the object marshal itself?
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, _ := m.Marshal()
n += len(p.tagcode)
n += sizeRawBytes(data)
continue
}
n0 := size_struct(p.sprop, structp)
n1 := sizeVarint(uint64(n0)) // size of encoded length
n += n0 + n1
}
return
}
func (o *Buffer) enc_custom_bytes(p *Properties, base structPointer) error {
i := structPointer_InterfaceRef(base, p.field, p.ctype)
if i == nil {
return ErrNil
}
custom := i.(Marshaler)
data, err := custom.Marshal()
if err != nil {
return err
}
if data == nil {
return ErrNil
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_custom_bytes(p *Properties, base structPointer) (n int) {
n += len(p.tagcode)
i := structPointer_InterfaceRef(base, p.field, p.ctype)
if i == nil {
return 0
}
custom := i.(Marshaler)
data, _ := custom.Marshal()
n += sizeRawBytes(data)
return
}
func (o *Buffer) enc_custom_ref_bytes(p *Properties, base structPointer) error {
custom := structPointer_InterfaceAt(base, p.field, p.ctype).(Marshaler)
data, err := custom.Marshal()
if err != nil {
return err
}
if data == nil {
return ErrNil
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_custom_ref_bytes(p *Properties, base structPointer) (n int) {
n += len(p.tagcode)
i := structPointer_InterfaceAt(base, p.field, p.ctype)
if i == nil {
return 0
}
custom := i.(Marshaler)
data, _ := custom.Marshal()
n += sizeRawBytes(data)
return
}
func (o *Buffer) enc_custom_slice_bytes(p *Properties, base structPointer) error {
inter := structPointer_InterfaceRef(base, p.field, p.ctype)
if inter == nil {
return ErrNil
}
slice := reflect.ValueOf(inter)
l := slice.Len()
for i := 0; i < l; i++ {
v := slice.Index(i)
custom := v.Interface().(Marshaler)
data, err := custom.Marshal()
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}
func size_custom_slice_bytes(p *Properties, base structPointer) (n int) {
inter := structPointer_InterfaceRef(base, p.field, p.ctype)
if inter == nil {
return 0
}
slice := reflect.ValueOf(inter)
l := slice.Len()
n += l * len(p.tagcode)
for i := 0; i < l; i++ {
v := slice.Index(i)
custom := v.Interface().(Marshaler)
data, _ := custom.Marshal()
n += sizeRawBytes(data)
}
return
}

View File

@@ -109,6 +109,15 @@ func equalStruct(v1, v2 reflect.Value) bool {
// set/unset mismatch // set/unset mismatch
return false return false
} }
b1, ok := f1.Interface().(raw)
if ok {
b2 := f2.Interface().(raw)
// RawMessage
if !bytes.Equal(b1.Bytes(), b2.Bytes()) {
return false
}
continue
}
f1, f2 = f1.Elem(), f2.Elem() f1, f2 = f1.Elem(), f2.Elem()
} }
if !equalAny(f1, f2, sprop.Prop[i]) { if !equalAny(f1, f2, sprop.Prop[i]) {
@@ -137,7 +146,11 @@ func equalStruct(v1, v2 reflect.Value) bool {
u1 := uf.Bytes() u1 := uf.Bytes()
u2 := v2.FieldByName("XXX_unrecognized").Bytes() u2 := v2.FieldByName("XXX_unrecognized").Bytes()
return bytes.Equal(u1, u2) if !bytes.Equal(u1, u2) {
return false
}
return true
} }
// v1 and v2 are known to have the same type. // v1 and v2 are known to have the same type.
@@ -248,15 +261,6 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {
m1, m2 := e1.value, e2.value m1, m2 := e1.value, e2.value
if m1 == nil && m2 == nil {
// Both have only encoded form.
if bytes.Equal(e1.enc, e2.enc) {
continue
}
// The bytes are different, but the extensions might still be
// equal. We need to decode them to compare.
}
if m1 != nil && m2 != nil { if m1 != nil && m2 != nil {
// Both are unencoded. // Both are unencoded.
if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {
@@ -272,12 +276,8 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {
desc = m[extNum] desc = m[extNum]
} }
if desc == nil { if desc == nil {
// If both have only encoded form and the bytes are the same,
// it is handled above. We get here when the bytes are different.
// We don't know how to decode it, so just compare them as byte
// slices.
log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) log.Printf("proto: don't know how to compare extension %d of %v", extNum, base)
return false continue
} }
var err error var err error
if m1 == nil { if m1 == nil {

View File

@@ -38,7 +38,6 @@ package proto
import ( import (
"errors" "errors"
"fmt" "fmt"
"io"
"reflect" "reflect"
"strconv" "strconv"
"sync" "sync"
@@ -70,6 +69,12 @@ type extendableProtoV1 interface {
ExtensionMap() map[int32]Extension ExtensionMap() map[int32]Extension
} }
type extensionsBytes interface {
Message
ExtensionRangeArray() []ExtensionRange
GetExtensions() *[]byte
}
// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto. // extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto.
type extensionAdapter struct { type extensionAdapter struct {
extendableProtoV1 extendableProtoV1
@@ -92,31 +97,14 @@ func (n notLocker) Unlock() {}
// extendable returns the extendableProto interface for the given generated proto message. // extendable returns the extendableProto interface for the given generated proto message.
// If the proto message has the old extension format, it returns a wrapper that implements // If the proto message has the old extension format, it returns a wrapper that implements
// the extendableProto interface. // the extendableProto interface.
func extendable(p interface{}) (extendableProto, error) { func extendable(p interface{}) (extendableProto, bool) {
switch p := p.(type) { if ep, ok := p.(extendableProto); ok {
case extendableProto: return ep, ok
if isNilPtr(p) {
return nil, fmt.Errorf("proto: nil %T is not extendable", p)
}
return p, nil
case extendableProtoV1:
if isNilPtr(p) {
return nil, fmt.Errorf("proto: nil %T is not extendable", p)
}
return extensionAdapter{p}, nil
case extensionsBytes:
return slowExtensionAdapter{p}, nil
} }
// Don't allocate a specific error containing %T: if ep, ok := p.(extendableProtoV1); ok {
// this is the hot path for Clone and MarshalText. return extensionAdapter{ep}, ok
return nil, errNotExtendable }
} return nil, false
var errNotExtendable = errors.New("proto: not an extendable proto.Message")
func isNilPtr(x interface{}) bool {
v := reflect.ValueOf(x)
return v.Kind() == reflect.Ptr && v.IsNil()
} }
// XXX_InternalExtensions is an internal representation of proto extensions. // XXX_InternalExtensions is an internal representation of proto extensions.
@@ -161,6 +149,16 @@ func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Loc
return e.p.extensionMap, &e.p.mu return e.p.extensionMap, &e.p.mu
} }
type extensionRange interface {
Message
ExtensionRangeArray() []ExtensionRange
}
var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem()
var extendableProtoV1Type = reflect.TypeOf((*extendableProtoV1)(nil)).Elem()
var extendableBytesType = reflect.TypeOf((*extensionsBytes)(nil)).Elem()
var extensionRangeType = reflect.TypeOf((*extensionRange)(nil)).Elem()
// ExtensionDesc represents an extension specification. // ExtensionDesc represents an extension specification.
// Used in generated code from the protocol compiler. // Used in generated code from the protocol compiler.
type ExtensionDesc struct { type ExtensionDesc struct {
@@ -200,8 +198,8 @@ func SetRawExtension(base Message, id int32, b []byte) {
*ext = append(*ext, b...) *ext = append(*ext, b...)
return return
} }
epb, err := extendable(base) epb, ok := extendable(base)
if err != nil { if !ok {
return return
} }
extmap := epb.extensionsWrite() extmap := epb.extensionsWrite()
@@ -209,7 +207,7 @@ func SetRawExtension(base Message, id int32, b []byte) {
} }
// isExtensionField returns true iff the given field number is in an extension range. // isExtensionField returns true iff the given field number is in an extension range.
func isExtensionField(pb extendableProto, field int32) bool { func isExtensionField(pb extensionRange, field int32) bool {
for _, er := range pb.ExtensionRangeArray() { for _, er := range pb.ExtensionRangeArray() {
if er.Start <= field && field <= er.End { if er.Start <= field && field <= er.End {
return true return true
@@ -225,11 +223,8 @@ func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error {
if ea, ok := pbi.(extensionAdapter); ok { if ea, ok := pbi.(extensionAdapter); ok {
pbi = ea.extendableProtoV1 pbi = ea.extendableProtoV1
} }
if ea, ok := pbi.(slowExtensionAdapter); ok {
pbi = ea.extensionsBytes
}
if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b { if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {
return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a) return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String())
} }
// Check the range. // Check the range.
if !isExtensionField(pb, extension.Field) { if !isExtensionField(pb, extension.Field) {
@@ -274,6 +269,80 @@ func extensionProperties(ed *ExtensionDesc) *Properties {
return prop return prop
} }
// encode encodes any unmarshaled (unencoded) extensions in e.
func encodeExtensions(e *XXX_InternalExtensions) error {
m, mu := e.extensionsRead()
if m == nil {
return nil // fast path
}
mu.Lock()
defer mu.Unlock()
return encodeExtensionsMap(m)
}
// encode encodes any unmarshaled (unencoded) extensions in e.
func encodeExtensionsMap(m map[int32]Extension) error {
for k, e := range m {
if e.value == nil || e.desc == nil {
// Extension is only in its encoded form.
continue
}
// We don't skip extensions that have an encoded form set,
// because the extension value may have been mutated after
// the last time this function was called.
et := reflect.TypeOf(e.desc.ExtensionType)
props := extensionProperties(e.desc)
p := NewBuffer(nil)
// If e.value has type T, the encoder expects a *struct{ X T }.
// Pass a *T with a zero field and hope it all works out.
x := reflect.New(et)
x.Elem().Set(reflect.ValueOf(e.value))
if err := props.enc(p, props, toStructPointer(x)); err != nil {
return err
}
e.enc = p.buf
m[k] = e
}
return nil
}
func extensionsSize(e *XXX_InternalExtensions) (n int) {
m, mu := e.extensionsRead()
if m == nil {
return 0
}
mu.Lock()
defer mu.Unlock()
return extensionsMapSize(m)
}
func extensionsMapSize(m map[int32]Extension) (n int) {
for _, e := range m {
if e.value == nil || e.desc == nil {
// Extension is only in its encoded form.
n += len(e.enc)
continue
}
// We don't skip extensions that have an encoded form set,
// because the extension value may have been mutated after
// the last time this function was called.
et := reflect.TypeOf(e.desc.ExtensionType)
props := extensionProperties(e.desc)
// If e.value has type T, the encoder expects a *struct{ X T }.
// Pass a *T with a zero field and hope it all works out.
x := reflect.New(et)
x.Elem().Set(reflect.ValueOf(e.value))
n += props.size(props, toStructPointer(x))
}
return
}
// HasExtension returns whether the given extension is present in pb. // HasExtension returns whether the given extension is present in pb.
func HasExtension(pb Message, extension *ExtensionDesc) bool { func HasExtension(pb Message, extension *ExtensionDesc) bool {
if epb, doki := pb.(extensionsBytes); doki { if epb, doki := pb.(extensionsBytes); doki {
@@ -297,8 +366,8 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool {
return false return false
} }
// TODO: Check types, field numbers, etc.? // TODO: Check types, field numbers, etc.?
epb, err := extendable(pb) epb, ok := extendable(pb)
if err != nil { if !ok {
return false return false
} }
extmap, mu := epb.extensionsRead() extmap, mu := epb.extensionsRead()
@@ -306,26 +375,46 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool {
return false return false
} }
mu.Lock() mu.Lock()
_, ok := extmap[extension.Field] _, ok = extmap[extension.Field]
mu.Unlock() mu.Unlock()
return ok return ok
} }
func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int {
ext := pb.GetExtensions()
for offset < len(*ext) {
tag, n1 := DecodeVarint((*ext)[offset:])
fieldNum := int32(tag >> 3)
wireType := int(tag & 0x7)
n2, err := size((*ext)[offset+n1:], wireType)
if err != nil {
panic(err)
}
newOffset := offset + n1 + n2
if fieldNum == theFieldNum {
*ext = append((*ext)[:offset], (*ext)[newOffset:]...)
return offset
}
offset = newOffset
}
return -1
}
// ClearExtension removes the given extension from pb. // ClearExtension removes the given extension from pb.
func ClearExtension(pb Message, extension *ExtensionDesc) { func ClearExtension(pb Message, extension *ExtensionDesc) {
clearExtension(pb, extension.Field) clearExtension(pb, extension.Field)
} }
func clearExtension(pb Message, fieldNum int32) { func clearExtension(pb Message, fieldNum int32) {
if epb, ok := pb.(extensionsBytes); ok { if epb, doki := pb.(extensionsBytes); doki {
offset := 0 offset := 0
for offset != -1 { for offset != -1 {
offset = deleteExtension(epb, fieldNum, offset) offset = deleteExtension(epb, fieldNum, offset)
} }
return return
} }
epb, err := extendable(pb) epb, ok := extendable(pb)
if err != nil { if !ok {
return return
} }
// TODO: Check types, field numbers, etc.? // TODO: Check types, field numbers, etc.?
@@ -333,31 +422,37 @@ func clearExtension(pb Message, fieldNum int32) {
delete(extmap, fieldNum) delete(extmap, fieldNum)
} }
// GetExtension retrieves a proto2 extended field from pb. // GetExtension parses and returns the given extension of pb.
// // If the extension is not present and has no default value it returns ErrMissingExtension.
// If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil),
// then GetExtension parses the encoded field and returns a Go value of the specified type.
// If the field is not present, then the default value is returned (if one is specified),
// otherwise ErrMissingExtension is reported.
//
// If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil),
// then GetExtension returns the raw encoded bytes of the field extension.
func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
if epb, doki := pb.(extensionsBytes); doki { if epb, doki := pb.(extensionsBytes); doki {
ext := epb.GetExtensions() ext := epb.GetExtensions()
return decodeExtensionFromBytes(extension, *ext) o := 0
} for o < len(*ext) {
tag, n := DecodeVarint((*ext)[o:])
epb, err := extendable(pb) fieldNum := int32(tag >> 3)
if err != nil { wireType := int(tag & 0x7)
return nil, err l, err := size((*ext)[o+n:], wireType)
} if err != nil {
return nil, err
if extension.ExtendedType != nil { }
// can only check type if this is a complete descriptor if int32(fieldNum) == extension.Field {
if cerr := checkExtensionTypes(epb, extension); cerr != nil { v, err := decodeExtension((*ext)[o:o+n+l], extension)
return nil, cerr if err != nil {
return nil, err
}
return v, nil
}
o += n + l
} }
return defaultExtensionValue(extension)
}
epb, ok := extendable(pb)
if !ok {
return nil, errors.New("proto: not an extendable proto")
}
if err := checkExtensionTypes(epb, extension); err != nil {
return nil, err
} }
emap, mu := epb.extensionsRead() emap, mu := epb.extensionsRead()
@@ -384,11 +479,6 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
return e.value, nil return e.value, nil
} }
if extension.ExtensionType == nil {
// incomplete descriptor
return e.enc, nil
}
v, err := decodeExtension(e.enc, extension) v, err := decodeExtension(e.enc, extension)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -406,11 +496,6 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
// defaultExtensionValue returns the default value for extension. // defaultExtensionValue returns the default value for extension.
// If no default for an extension is defined ErrMissingExtension is returned. // If no default for an extension is defined ErrMissingExtension is returned.
func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
if extension.ExtensionType == nil {
// incomplete descriptor, so no default
return nil, ErrMissingExtension
}
t := reflect.TypeOf(extension.ExtensionType) t := reflect.TypeOf(extension.ExtensionType)
props := extensionProperties(extension) props := extensionProperties(extension)
@@ -445,28 +530,31 @@ func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
// decodeExtension decodes an extension encoded in b. // decodeExtension decodes an extension encoded in b.
func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
o := NewBuffer(b)
t := reflect.TypeOf(extension.ExtensionType) t := reflect.TypeOf(extension.ExtensionType)
unmarshal := typeUnmarshaler(t, extension.Tag)
props := extensionProperties(extension)
// t is a pointer to a struct, pointer to basic type or a slice. // t is a pointer to a struct, pointer to basic type or a slice.
// Allocate space to store the pointer/slice. // Allocate a "field" to store the pointer/slice itself; the
// pointer/slice will be stored here. We pass
// the address of this field to props.dec.
// This passes a zero field and a *t and lets props.dec
// interpret it as a *struct{ x t }.
value := reflect.New(t).Elem() value := reflect.New(t).Elem()
var err error
for { for {
x, n := decodeVarint(b) // Discard wire type and field number varint. It isn't needed.
if n == 0 { if _, err := o.DecodeVarint(); err != nil {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
wire := int(x) & 7
b, err = unmarshal(b, valToPointer(value.Addr()), wire)
if err != nil {
return nil, err return nil, err
} }
if len(b) == 0 { if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil {
return nil, err
}
if o.index >= len(o.buf) {
break break
} }
} }
@@ -476,13 +564,9 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
// GetExtensions returns a slice of the extensions present in pb that are also listed in es. // GetExtensions returns a slice of the extensions present in pb that are also listed in es.
// The returned slice has the same length as es; missing extensions will appear as nil elements. // The returned slice has the same length as es; missing extensions will appear as nil elements.
func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {
epb, err := extendable(pb)
if err != nil {
return nil, err
}
extensions = make([]interface{}, len(es)) extensions = make([]interface{}, len(es))
for i, e := range es { for i, e := range es {
extensions[i], err = GetExtension(epb, e) extensions[i], err = GetExtension(pb, e)
if err == ErrMissingExtension { if err == ErrMissingExtension {
err = nil err = nil
} }
@@ -497,9 +581,9 @@ func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, e
// For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing // For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing
// just the Field field, which defines the extension's field number. // just the Field field, which defines the extension's field number.
func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
epb, err := extendable(pb) epb, ok := extendable(pb)
if err != nil { if !ok {
return nil, err return nil, fmt.Errorf("proto: %T is not an extendable proto.Message", pb)
} }
registeredExtensions := RegisteredExtensions(pb) registeredExtensions := RegisteredExtensions(pb)
@@ -526,18 +610,23 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
// SetExtension sets the specified extension of pb to the specified value. // SetExtension sets the specified extension of pb to the specified value.
func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error {
if epb, ok := pb.(extensionsBytes); ok { if epb, doki := pb.(extensionsBytes); doki {
newb, err := encodeExtension(extension, value) ClearExtension(pb, extension)
if err != nil { ext := epb.GetExtensions()
et := reflect.TypeOf(extension.ExtensionType)
props := extensionProperties(extension)
p := NewBuffer(nil)
x := reflect.New(et)
x.Elem().Set(reflect.ValueOf(value))
if err := props.enc(p, props, toStructPointer(x)); err != nil {
return err return err
} }
bb := epb.GetExtensions() *ext = append(*ext, p.buf...)
*bb = append(*bb, newb...)
return nil return nil
} }
epb, err := extendable(pb) epb, ok := extendable(pb)
if err != nil { if !ok {
return err return errors.New("proto: not an extendable proto")
} }
if err := checkExtensionTypes(epb, extension); err != nil { if err := checkExtensionTypes(epb, extension); err != nil {
return err return err
@@ -567,8 +656,8 @@ func ClearAllExtensions(pb Message) {
*ext = []byte{} *ext = []byte{}
return return
} }
epb, err := extendable(pb) epb, ok := extendable(pb)
if err != nil { if !ok {
return return
} }
m := epb.extensionsWrite() m := epb.extensionsWrite()

View File

@@ -32,36 +32,12 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"io"
"reflect" "reflect"
"sort" "sort"
"strings" "strings"
"sync" "sync"
) )
type extensionsBytes interface {
Message
ExtensionRangeArray() []ExtensionRange
GetExtensions() *[]byte
}
type slowExtensionAdapter struct {
extensionsBytes
}
func (s slowExtensionAdapter) extensionsWrite() map[int32]Extension {
panic("Please report a bug to github.com/gogo/protobuf if you see this message: Writing extensions is not supported for extensions stored in a byte slice field.")
}
func (s slowExtensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) {
b := s.GetExtensions()
m, err := BytesToExtensionsMap(*b)
if err != nil {
panic(err)
}
return m, notLocker{}
}
func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool { func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool {
if reflect.ValueOf(pb).IsNil() { if reflect.ValueOf(pb).IsNil() {
return ifnotset return ifnotset
@@ -80,28 +56,19 @@ func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool
} }
func (this *Extension) Equal(that *Extension) bool { func (this *Extension) Equal(that *Extension) bool {
if err := this.Encode(); err != nil {
return false
}
if err := that.Encode(); err != nil {
return false
}
return bytes.Equal(this.enc, that.enc) return bytes.Equal(this.enc, that.enc)
} }
func (this *Extension) Compare(that *Extension) int { func (this *Extension) Compare(that *Extension) int {
if err := this.Encode(); err != nil {
return 1
}
if err := that.Encode(); err != nil {
return -1
}
return bytes.Compare(this.enc, that.enc) return bytes.Compare(this.enc, that.enc)
} }
func SizeOfInternalExtension(m extendableProto) (n int) { func SizeOfInternalExtension(m extendableProto) (n int) {
info := getMarshalInfo(reflect.TypeOf(m)) return SizeOfExtensionMap(m.extensionsWrite())
return info.sizeV1Extensions(m.extensionsWrite()) }
func SizeOfExtensionMap(m map[int32]Extension) (n int) {
return extensionsMapSize(m)
} }
type sortableMapElem struct { type sortableMapElem struct {
@@ -155,26 +122,28 @@ func EncodeInternalExtension(m extendableProto, data []byte) (n int, err error)
} }
func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) { func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) {
o := 0 if err := encodeExtensionsMap(m); err != nil {
for _, e := range m { return 0, err
if err := e.Encode(); err != nil {
return 0, err
}
n := copy(data[o:], e.enc)
if n != len(e.enc) {
return 0, io.ErrShortBuffer
}
o += n
} }
return o, nil keys := make([]int, 0, len(m))
for k := range m {
keys = append(keys, int(k))
}
sort.Ints(keys)
for _, k := range keys {
n += copy(data[n:], m[int32(k)].enc)
}
return n, nil
} }
func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) { func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) {
e := m[id] if m[id].value == nil || m[id].desc == nil {
if err := e.Encode(); err != nil { return m[id].enc, nil
}
if err := encodeExtensionsMap(m); err != nil {
return nil, err return nil, err
} }
return e.enc, nil return m[id].enc, nil
} }
func size(buf []byte, wire int) (int, error) { func size(buf []byte, wire int) (int, error) {
@@ -249,58 +218,35 @@ func AppendExtension(e Message, tag int32, buf []byte) {
} }
} }
func encodeExtension(extension *ExtensionDesc, value interface{}) ([]byte, error) { func encodeExtension(e *Extension) error {
u := getMarshalInfo(reflect.TypeOf(extension.ExtendedType)) if e.value == nil || e.desc == nil {
ei := u.getExtElemInfo(extension) // Extension is only in its encoded form.
v := value return nil
p := toAddrPointer(&v, ei.isptr)
siz := ei.sizer(p, SizeVarint(ei.wiretag))
buf := make([]byte, 0, siz)
return ei.marshaler(buf, p, ei.wiretag, false)
}
func decodeExtensionFromBytes(extension *ExtensionDesc, buf []byte) (interface{}, error) {
o := 0
for o < len(buf) {
tag, n := DecodeVarint((buf)[o:])
fieldNum := int32(tag >> 3)
wireType := int(tag & 0x7)
if o+n > len(buf) {
return nil, fmt.Errorf("unable to decode extension")
}
l, err := size((buf)[o+n:], wireType)
if err != nil {
return nil, err
}
if int32(fieldNum) == extension.Field {
if o+n+l > len(buf) {
return nil, fmt.Errorf("unable to decode extension")
}
v, err := decodeExtension((buf)[o:o+n+l], extension)
if err != nil {
return nil, err
}
return v, nil
}
o += n + l
} }
return defaultExtensionValue(extension) // We don't skip extensions that have an encoded form set,
} // because the extension value may have been mutated after
// the last time this function was called.
func (this *Extension) Encode() error { et := reflect.TypeOf(e.desc.ExtensionType)
if this.enc == nil { props := extensionProperties(e.desc)
var err error
this.enc, err = encodeExtension(this.desc, this.value) p := NewBuffer(nil)
if err != nil { // If e.value has type T, the encoder expects a *struct{ X T }.
return err // Pass a *T with a zero field and hope it all works out.
} x := reflect.New(et)
x.Elem().Set(reflect.ValueOf(e.value))
if err := props.enc(p, props, toStructPointer(x)); err != nil {
return err
} }
e.enc = p.buf
return nil return nil
} }
func (this Extension) GoString() string { func (this Extension) GoString() string {
if err := this.Encode(); err != nil { if this.enc == nil {
return fmt.Sprintf("error encoding extension: %v", err) if err := encodeExtension(&this); err != nil {
panic(err)
}
} }
return fmt.Sprintf("proto.NewExtension(%#v)", this.enc) return fmt.Sprintf("proto.NewExtension(%#v)", this.enc)
} }
@@ -346,23 +292,3 @@ func GetUnsafeExtensionsMap(extendable Message) map[int32]Extension {
pb := extendable.(extendableProto) pb := extendable.(extendableProto)
return pb.extensionsWrite() return pb.extensionsWrite()
} }
func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int {
ext := pb.GetExtensions()
for offset < len(*ext) {
tag, n1 := DecodeVarint((*ext)[offset:])
fieldNum := int32(tag >> 3)
wireType := int(tag & 0x7)
n2, err := size((*ext)[offset+n1:], wireType)
if err != nil {
panic(err)
}
newOffset := offset + n1 + n2
if fieldNum == theFieldNum {
*ext = append((*ext)[:offset], (*ext)[newOffset:]...)
return offset
}
offset = newOffset
}
return -1
}

View File

@@ -273,67 +273,6 @@ import (
"sync" "sync"
) )
// RequiredNotSetError is an error type returned by either Marshal or Unmarshal.
// Marshal reports this when a required field is not initialized.
// Unmarshal reports this when a required field is missing from the wire data.
type RequiredNotSetError struct{ field string }
func (e *RequiredNotSetError) Error() string {
if e.field == "" {
return fmt.Sprintf("proto: required field not set")
}
return fmt.Sprintf("proto: required field %q not set", e.field)
}
func (e *RequiredNotSetError) RequiredNotSet() bool {
return true
}
type invalidUTF8Error struct{ field string }
func (e *invalidUTF8Error) Error() string {
if e.field == "" {
return "proto: invalid UTF-8 detected"
}
return fmt.Sprintf("proto: field %q contains invalid UTF-8", e.field)
}
func (e *invalidUTF8Error) InvalidUTF8() bool {
return true
}
// errInvalidUTF8 is a sentinel error to identify fields with invalid UTF-8.
// This error should not be exposed to the external API as such errors should
// be recreated with the field information.
var errInvalidUTF8 = &invalidUTF8Error{}
// isNonFatal reports whether the error is either a RequiredNotSet error
// or a InvalidUTF8 error.
func isNonFatal(err error) bool {
if re, ok := err.(interface{ RequiredNotSet() bool }); ok && re.RequiredNotSet() {
return true
}
if re, ok := err.(interface{ InvalidUTF8() bool }); ok && re.InvalidUTF8() {
return true
}
return false
}
type nonFatal struct{ E error }
// Merge merges err into nf and reports whether it was successful.
// Otherwise it returns false for any fatal non-nil errors.
func (nf *nonFatal) Merge(err error) (ok bool) {
if err == nil {
return true // not an error
}
if !isNonFatal(err) {
return false // fatal error
}
if nf.E == nil {
nf.E = err // store first instance of non-fatal error
}
return true
}
// Message is implemented by generated protocol buffer messages. // Message is implemented by generated protocol buffer messages.
type Message interface { type Message interface {
Reset() Reset()
@@ -370,7 +309,16 @@ type Buffer struct {
buf []byte // encode/decode byte stream buf []byte // encode/decode byte stream
index int // read point index int // read point
deterministic bool // pools of basic types to amortize allocation.
bools []bool
uint32s []uint32
uint64s []uint64
// extra pools, only used with pointer_reflect.go
int32s []int32
int64s []int64
float32s []float32
float64s []float64
} }
// NewBuffer allocates a new Buffer and initializes its internal data to // NewBuffer allocates a new Buffer and initializes its internal data to
@@ -395,30 +343,6 @@ func (p *Buffer) SetBuf(s []byte) {
// Bytes returns the contents of the Buffer. // Bytes returns the contents of the Buffer.
func (p *Buffer) Bytes() []byte { return p.buf } func (p *Buffer) Bytes() []byte { return p.buf }
// SetDeterministic sets whether to use deterministic serialization.
//
// Deterministic serialization guarantees that for a given binary, equal
// messages will always be serialized to the same bytes. This implies:
//
// - Repeated serialization of a message will return the same bytes.
// - Different processes of the same binary (which may be executing on
// different machines) will serialize equal messages to the same bytes.
//
// Note that the deterministic serialization is NOT canonical across
// languages. It is not guaranteed to remain stable over time. It is unstable
// across different builds with schema changes due to unknown fields.
// Users who need canonical serialization (e.g., persistent storage in a
// canonical form, fingerprinting, etc.) should define their own
// canonicalization specification and implement their own serializer rather
// than relying on this API.
//
// If deterministic serialization is requested, map entries will be sorted
// by keys in lexographical order. This is an implementation detail and
// subject to change.
func (p *Buffer) SetDeterministic(deterministic bool) {
p.deterministic = deterministic
}
/* /*
* Helper routines for simplifying the creation of optional fields of basic type. * Helper routines for simplifying the creation of optional fields of basic type.
*/ */
@@ -628,11 +552,9 @@ func SetDefaults(pb Message) {
setDefaults(reflect.ValueOf(pb), true, false) setDefaults(reflect.ValueOf(pb), true, false)
} }
// v is a struct. // v is a pointer to a struct.
func setDefaults(v reflect.Value, recur, zeros bool) { func setDefaults(v reflect.Value, recur, zeros bool) {
if v.Kind() == reflect.Ptr { v = v.Elem()
v = v.Elem()
}
defaultMu.RLock() defaultMu.RLock()
dm, ok := defaults[v.Type()] dm, ok := defaults[v.Type()]
@@ -734,11 +656,8 @@ func setDefaults(v reflect.Value, recur, zeros bool) {
for _, ni := range dm.nested { for _, ni := range dm.nested {
f := v.Field(ni) f := v.Field(ni)
// f is *T or T or []*T or []T // f is *T or []*T or map[T]*T
switch f.Kind() { switch f.Kind() {
case reflect.Struct:
setDefaults(f, recur, zeros)
case reflect.Ptr: case reflect.Ptr:
if f.IsNil() { if f.IsNil() {
continue continue
@@ -748,7 +667,7 @@ func setDefaults(v reflect.Value, recur, zeros bool) {
case reflect.Slice: case reflect.Slice:
for i := 0; i < f.Len(); i++ { for i := 0; i < f.Len(); i++ {
e := f.Index(i) e := f.Index(i)
if e.Kind() == reflect.Ptr && e.IsNil() { if e.IsNil() {
continue continue
} }
setDefaults(e, recur, zeros) setDefaults(e, recur, zeros)
@@ -820,9 +739,6 @@ func buildDefaultMessage(t reflect.Type) (dm defaultMessage) {
func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) { func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) {
var canHaveDefault bool var canHaveDefault bool
switch ft.Kind() { switch ft.Kind() {
case reflect.Struct:
nestedMessage = true // non-nullable
case reflect.Ptr: case reflect.Ptr:
if ft.Elem().Kind() == reflect.Struct { if ft.Elem().Kind() == reflect.Struct {
nestedMessage = true nestedMessage = true
@@ -832,7 +748,7 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes
case reflect.Slice: case reflect.Slice:
switch ft.Elem().Kind() { switch ft.Elem().Kind() {
case reflect.Ptr, reflect.Struct: case reflect.Ptr:
nestedMessage = true // repeated message nestedMessage = true // repeated message
case reflect.Uint8: case reflect.Uint8:
canHaveDefault = true // bytes field canHaveDefault = true // bytes field
@@ -915,12 +831,22 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes
return sf, false, nil return sf, false, nil
} }
// mapKeys returns a sort.Interface to be used for sorting the map keys.
// Map fields may have key types of non-float scalars, strings and enums. // Map fields may have key types of non-float scalars, strings and enums.
func mapKeys(vs []reflect.Value) sort.Interface { // The easiest way to sort them in some deterministic order is to use fmt.
s := mapKeySorter{vs: vs} // If this turns out to be inefficient we can always consider other options,
// such as doing a Schwartzian transform.
// Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps. func mapKeys(vs []reflect.Value) sort.Interface {
s := mapKeySorter{
vs: vs,
// default Less function: textual comparison
less: func(a, b reflect.Value) bool {
return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface())
},
}
// Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps;
// numeric keys are sorted numerically.
if len(vs) == 0 { if len(vs) == 0 {
return s return s
} }
@@ -929,12 +855,6 @@ func mapKeys(vs []reflect.Value) sort.Interface {
s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() }
case reflect.Uint32, reflect.Uint64: case reflect.Uint32, reflect.Uint64:
s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() }
case reflect.Bool:
s.less = func(a, b reflect.Value) bool { return !a.Bool() && b.Bool() } // false < true
case reflect.String:
s.less = func(a, b reflect.Value) bool { return a.String() < b.String() }
default:
panic(fmt.Sprintf("unsupported map key type: %v", vs[0].Kind()))
} }
return s return s
@@ -975,13 +895,3 @@ const GoGoProtoPackageIsVersion2 = true
// ProtoPackageIsVersion1 is referenced from generated protocol buffer files // ProtoPackageIsVersion1 is referenced from generated protocol buffer files
// to assert that that code is compatible with this version of the proto package. // to assert that that code is compatible with this version of the proto package.
const GoGoProtoPackageIsVersion1 = true const GoGoProtoPackageIsVersion1 = true
// InternalMessageInfo is a type used internally by generated .pb.go files.
// This type is not intended to be used by non-generated code.
// This type is not subject to any compatibility guarantee.
type InternalMessageInfo struct {
marshal *marshalInfo
unmarshal *unmarshalInfo
merge *mergeInfo
discard *discardInfo
}

View File

@@ -33,14 +33,6 @@ import (
"strconv" "strconv"
) )
type Sizer interface {
Size() int
}
type ProtoSizer interface {
ProtoSize() int
}
func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) { func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) {
s, ok := m[value] s, ok := m[value]
if !ok { if !ok {

View File

@@ -42,7 +42,6 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"sort" "sort"
"sync"
) )
// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. // errNoMessageTypeID occurs when a protocol buffer does not have a message type ID.
@@ -95,7 +94,10 @@ func (ms *messageSet) find(pb Message) *_MessageSet_Item {
} }
func (ms *messageSet) Has(pb Message) bool { func (ms *messageSet) Has(pb Message) bool {
return ms.find(pb) != nil if ms.find(pb) != nil {
return true
}
return false
} }
func (ms *messageSet) Unmarshal(pb Message) error { func (ms *messageSet) Unmarshal(pb Message) error {
@@ -148,42 +150,46 @@ func skipVarint(buf []byte) []byte {
// MarshalMessageSet encodes the extension map represented by m in the message set wire format. // MarshalMessageSet encodes the extension map represented by m in the message set wire format.
// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. // It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option.
func MarshalMessageSet(exts interface{}) ([]byte, error) { func MarshalMessageSet(exts interface{}) ([]byte, error) {
return marshalMessageSet(exts, false) var m map[int32]Extension
}
// marshaMessageSet implements above function, with the opt to turn on / off deterministic during Marshal.
func marshalMessageSet(exts interface{}, deterministic bool) ([]byte, error) {
switch exts := exts.(type) { switch exts := exts.(type) {
case *XXX_InternalExtensions: case *XXX_InternalExtensions:
var u marshalInfo if err := encodeExtensions(exts); err != nil {
siz := u.sizeMessageSet(exts) return nil, err
b := make([]byte, 0, siz)
return u.appendMessageSet(b, exts, deterministic)
case map[int32]Extension:
// This is an old-style extension map.
// Wrap it in a new-style XXX_InternalExtensions.
ie := XXX_InternalExtensions{
p: &struct {
mu sync.Mutex
extensionMap map[int32]Extension
}{
extensionMap: exts,
},
} }
m, _ = exts.extensionsRead()
var u marshalInfo case map[int32]Extension:
siz := u.sizeMessageSet(&ie) if err := encodeExtensionsMap(exts); err != nil {
b := make([]byte, 0, siz) return nil, err
return u.appendMessageSet(b, &ie, deterministic) }
m = exts
default: default:
return nil, errors.New("proto: not an extension map") return nil, errors.New("proto: not an extension map")
} }
// Sort extension IDs to provide a deterministic encoding.
// See also enc_map in encode.go.
ids := make([]int, 0, len(m))
for id := range m {
ids = append(ids, int(id))
}
sort.Ints(ids)
ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))}
for _, id := range ids {
e := m[int32(id)]
// Remove the wire type and field number varint, as well as the length varint.
msg := skipVarint(skipVarint(e.enc))
ms.Item = append(ms.Item, &_MessageSet_Item{
TypeId: Int32(int32(id)),
Message: msg,
})
}
return Marshal(ms)
} }
// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. // UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format.
// It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. // It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option.
func UnmarshalMessageSet(buf []byte, exts interface{}) error { func UnmarshalMessageSet(buf []byte, exts interface{}) error {
var m map[int32]Extension var m map[int32]Extension
switch exts := exts.(type) { switch exts := exts.(type) {
@@ -229,15 +235,7 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) {
var m map[int32]Extension var m map[int32]Extension
switch exts := exts.(type) { switch exts := exts.(type) {
case *XXX_InternalExtensions: case *XXX_InternalExtensions:
var mu sync.Locker m, _ = exts.extensionsRead()
m, mu = exts.extensionsRead()
if m != nil {
// Keep the extensions map locked until we're done marshaling to prevent
// races between marshaling and unmarshaling the lazily-{en,de}coded
// values.
mu.Lock()
defer mu.Unlock()
}
case map[int32]Extension: case map[int32]Extension:
m = exts m = exts
default: default:
@@ -255,16 +253,15 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) {
for i, id := range ids { for i, id := range ids {
ext := m[id] ext := m[id]
if i > 0 {
b.WriteByte(',')
}
msd, ok := messageSetMap[id] msd, ok := messageSetMap[id]
if !ok { if !ok {
// Unknown type; we can't render it, so skip it. // Unknown type; we can't render it, so skip it.
continue continue
} }
if i > 0 && b.Len() > 1 {
b.WriteByte(',')
}
fmt.Fprintf(&b, `"[%s]":`, msd.name) fmt.Fprintf(&b, `"[%s]":`, msd.name)
x := ext.value x := ext.value

View File

@@ -29,7 +29,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build purego appengine js // +build appengine js
// This file contains an implementation of proto field accesses using package reflect. // This file contains an implementation of proto field accesses using package reflect.
// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
@@ -38,13 +38,32 @@
package proto package proto
import ( import (
"math"
"reflect" "reflect"
"sync"
) )
const unsafeAllowed = false // A structPointer is a pointer to a struct.
type structPointer struct {
v reflect.Value
}
// A field identifies a field in a struct, accessible from a pointer. // toStructPointer returns a structPointer equivalent to the given reflect value.
// The reflect value must itself be a pointer to a struct.
func toStructPointer(v reflect.Value) structPointer {
return structPointer{v}
}
// IsNil reports whether p is nil.
func structPointer_IsNil(p structPointer) bool {
return p.v.IsNil()
}
// Interface returns the struct pointer as an interface value.
func structPointer_Interface(p structPointer, _ reflect.Type) interface{} {
return p.v.Interface()
}
// A field identifies a field in a struct, accessible from a structPointer.
// In this implementation, a field is identified by the sequence of field indices // In this implementation, a field is identified by the sequence of field indices
// passed to reflect's FieldByIndex. // passed to reflect's FieldByIndex.
type field []int type field []int
@@ -57,301 +76,409 @@ func toField(f *reflect.StructField) field {
// invalidField is an invalid field identifier. // invalidField is an invalid field identifier.
var invalidField = field(nil) var invalidField = field(nil)
// zeroField is a noop when calling pointer.offset.
var zeroField = field([]int{})
// IsValid reports whether the field identifier is valid. // IsValid reports whether the field identifier is valid.
func (f field) IsValid() bool { return f != nil } func (f field) IsValid() bool { return f != nil }
// The pointer type is for the table-driven decoder. // field returns the given field in the struct as a reflect value.
// The implementation here uses a reflect.Value of pointer type to func structPointer_field(p structPointer, f field) reflect.Value {
// create a generic pointer. In pointer_unsafe.go we use unsafe // Special case: an extension map entry with a value of type T
// instead of reflect to implement the same (but faster) interface. // passes a *T to the struct-handling code with a zero field,
type pointer struct { // expecting that it will be treated as equivalent to *struct{ X T },
// which has the same memory layout. We have to handle that case
// specially, because reflect will panic if we call FieldByIndex on a
// non-struct.
if f == nil {
return p.v.Elem()
}
return p.v.Elem().FieldByIndex(f)
}
// ifield returns the given field in the struct as an interface value.
func structPointer_ifield(p structPointer, f field) interface{} {
return structPointer_field(p, f).Addr().Interface()
}
// Bytes returns the address of a []byte field in the struct.
func structPointer_Bytes(p structPointer, f field) *[]byte {
return structPointer_ifield(p, f).(*[]byte)
}
// BytesSlice returns the address of a [][]byte field in the struct.
func structPointer_BytesSlice(p structPointer, f field) *[][]byte {
return structPointer_ifield(p, f).(*[][]byte)
}
// Bool returns the address of a *bool field in the struct.
func structPointer_Bool(p structPointer, f field) **bool {
return structPointer_ifield(p, f).(**bool)
}
// BoolVal returns the address of a bool field in the struct.
func structPointer_BoolVal(p structPointer, f field) *bool {
return structPointer_ifield(p, f).(*bool)
}
// BoolSlice returns the address of a []bool field in the struct.
func structPointer_BoolSlice(p structPointer, f field) *[]bool {
return structPointer_ifield(p, f).(*[]bool)
}
// String returns the address of a *string field in the struct.
func structPointer_String(p structPointer, f field) **string {
return structPointer_ifield(p, f).(**string)
}
// StringVal returns the address of a string field in the struct.
func structPointer_StringVal(p structPointer, f field) *string {
return structPointer_ifield(p, f).(*string)
}
// StringSlice returns the address of a []string field in the struct.
func structPointer_StringSlice(p structPointer, f field) *[]string {
return structPointer_ifield(p, f).(*[]string)
}
// Extensions returns the address of an extension map field in the struct.
func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {
return structPointer_ifield(p, f).(*XXX_InternalExtensions)
}
// ExtMap returns the address of an extension map field in the struct.
func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
return structPointer_ifield(p, f).(*map[int32]Extension)
}
// NewAt returns the reflect.Value for a pointer to a field in the struct.
func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
return structPointer_field(p, f).Addr()
}
// SetStructPointer writes a *struct field in the struct.
func structPointer_SetStructPointer(p structPointer, f field, q structPointer) {
structPointer_field(p, f).Set(q.v)
}
// GetStructPointer reads a *struct field in the struct.
func structPointer_GetStructPointer(p structPointer, f field) structPointer {
return structPointer{structPointer_field(p, f)}
}
// StructPointerSlice the address of a []*struct field in the struct.
func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice {
return structPointerSlice{structPointer_field(p, f)}
}
// A structPointerSlice represents the address of a slice of pointers to structs
// (themselves messages or groups). That is, v.Type() is *[]*struct{...}.
type structPointerSlice struct {
v reflect.Value v reflect.Value
} }
// toPointer converts an interface of pointer type to a pointer func (p structPointerSlice) Len() int { return p.v.Len() }
// that points to the same target. func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} }
func toPointer(i *Message) pointer { func (p structPointerSlice) Append(q structPointer) {
return pointer{v: reflect.ValueOf(*i)} p.v.Set(reflect.Append(p.v, q.v))
} }
// toAddrPointer converts an interface to a pointer that points to var (
// the interface data. int32Type = reflect.TypeOf(int32(0))
func toAddrPointer(i *interface{}, isptr bool) pointer { uint32Type = reflect.TypeOf(uint32(0))
v := reflect.ValueOf(*i) float32Type = reflect.TypeOf(float32(0))
u := reflect.New(v.Type()) int64Type = reflect.TypeOf(int64(0))
u.Elem().Set(v) uint64Type = reflect.TypeOf(uint64(0))
return pointer{v: u} float64Type = reflect.TypeOf(float64(0))
)
// A word32 represents a field of type *int32, *uint32, *float32, or *enum.
// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable.
type word32 struct {
v reflect.Value
} }
// valToPointer converts v to a pointer. v must be of pointer type. // IsNil reports whether p is nil.
func valToPointer(v reflect.Value) pointer { func word32_IsNil(p word32) bool {
return pointer{v: v}
}
// offset converts from a pointer to a structure to a pointer to
// one of its fields.
func (p pointer) offset(f field) pointer {
return pointer{v: p.v.Elem().FieldByIndex(f).Addr()}
}
func (p pointer) isNil() bool {
return p.v.IsNil() return p.v.IsNil()
} }
// grow updates the slice s in place to make it one element longer. // Set sets p to point at a newly allocated word with bits set to x.
// s must be addressable. func word32_Set(p word32, o *Buffer, x uint32) {
// Returns the (addressable) new element. t := p.v.Type().Elem()
func grow(s reflect.Value) reflect.Value { switch t {
n, m := s.Len(), s.Cap() case int32Type:
if len(o.int32s) == 0 {
o.int32s = make([]int32, uint32PoolSize)
}
o.int32s[0] = int32(x)
p.v.Set(reflect.ValueOf(&o.int32s[0]))
o.int32s = o.int32s[1:]
return
case uint32Type:
if len(o.uint32s) == 0 {
o.uint32s = make([]uint32, uint32PoolSize)
}
o.uint32s[0] = x
p.v.Set(reflect.ValueOf(&o.uint32s[0]))
o.uint32s = o.uint32s[1:]
return
case float32Type:
if len(o.float32s) == 0 {
o.float32s = make([]float32, uint32PoolSize)
}
o.float32s[0] = math.Float32frombits(x)
p.v.Set(reflect.ValueOf(&o.float32s[0]))
o.float32s = o.float32s[1:]
return
}
// must be enum
p.v.Set(reflect.New(t))
p.v.Elem().SetInt(int64(int32(x)))
}
// Get gets the bits pointed at by p, as a uint32.
func word32_Get(p word32) uint32 {
elem := p.v.Elem()
switch elem.Kind() {
case reflect.Int32:
return uint32(elem.Int())
case reflect.Uint32:
return uint32(elem.Uint())
case reflect.Float32:
return math.Float32bits(float32(elem.Float()))
}
panic("unreachable")
}
// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct.
func structPointer_Word32(p structPointer, f field) word32 {
return word32{structPointer_field(p, f)}
}
// A word32Val represents a field of type int32, uint32, float32, or enum.
// That is, v.Type() is int32, uint32, float32, or enum and v is assignable.
type word32Val struct {
v reflect.Value
}
// Set sets *p to x.
func word32Val_Set(p word32Val, x uint32) {
switch p.v.Type() {
case int32Type:
p.v.SetInt(int64(x))
return
case uint32Type:
p.v.SetUint(uint64(x))
return
case float32Type:
p.v.SetFloat(float64(math.Float32frombits(x)))
return
}
// must be enum
p.v.SetInt(int64(int32(x)))
}
// Get gets the bits pointed at by p, as a uint32.
func word32Val_Get(p word32Val) uint32 {
elem := p.v
switch elem.Kind() {
case reflect.Int32:
return uint32(elem.Int())
case reflect.Uint32:
return uint32(elem.Uint())
case reflect.Float32:
return math.Float32bits(float32(elem.Float()))
}
panic("unreachable")
}
// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct.
func structPointer_Word32Val(p structPointer, f field) word32Val {
return word32Val{structPointer_field(p, f)}
}
// A word32Slice is a slice of 32-bit values.
// That is, v.Type() is []int32, []uint32, []float32, or []enum.
type word32Slice struct {
v reflect.Value
}
func (p word32Slice) Append(x uint32) {
n, m := p.v.Len(), p.v.Cap()
if n < m { if n < m {
s.SetLen(n + 1) p.v.SetLen(n + 1)
} else { } else {
s.Set(reflect.Append(s, reflect.Zero(s.Type().Elem()))) t := p.v.Type().Elem()
p.v.Set(reflect.Append(p.v, reflect.Zero(t)))
} }
return s.Index(n) elem := p.v.Index(n)
} switch elem.Kind() {
case reflect.Int32:
func (p pointer) toInt64() *int64 { elem.SetInt(int64(int32(x)))
return p.v.Interface().(*int64) case reflect.Uint32:
} elem.SetUint(uint64(x))
func (p pointer) toInt64Ptr() **int64 { case reflect.Float32:
return p.v.Interface().(**int64) elem.SetFloat(float64(math.Float32frombits(x)))
}
func (p pointer) toInt64Slice() *[]int64 {
return p.v.Interface().(*[]int64)
}
var int32ptr = reflect.TypeOf((*int32)(nil))
func (p pointer) toInt32() *int32 {
return p.v.Convert(int32ptr).Interface().(*int32)
}
// The toInt32Ptr/Slice methods don't work because of enums.
// Instead, we must use set/get methods for the int32ptr/slice case.
/*
func (p pointer) toInt32Ptr() **int32 {
return p.v.Interface().(**int32)
}
func (p pointer) toInt32Slice() *[]int32 {
return p.v.Interface().(*[]int32)
}
*/
func (p pointer) getInt32Ptr() *int32 {
if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
// raw int32 type
return p.v.Elem().Interface().(*int32)
} }
// an enum
return p.v.Elem().Convert(int32PtrType).Interface().(*int32)
}
func (p pointer) setInt32Ptr(v int32) {
// Allocate value in a *int32. Possibly convert that to a *enum.
// Then assign it to a **int32 or **enum.
// Note: we can convert *int32 to *enum, but we can't convert
// **int32 to **enum!
p.v.Elem().Set(reflect.ValueOf(&v).Convert(p.v.Type().Elem()))
} }
// getInt32Slice copies []int32 from p as a new slice. func (p word32Slice) Len() int {
// This behavior differs from the implementation in pointer_unsafe.go. return p.v.Len()
func (p pointer) getInt32Slice() []int32 {
if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
// raw int32 type
return p.v.Elem().Interface().([]int32)
}
// an enum
// Allocate a []int32, then assign []enum's values into it.
// Note: we can't convert []enum to []int32.
slice := p.v.Elem()
s := make([]int32, slice.Len())
for i := 0; i < slice.Len(); i++ {
s[i] = int32(slice.Index(i).Int())
}
return s
} }
// setInt32Slice copies []int32 into p as a new slice. func (p word32Slice) Index(i int) uint32 {
// This behavior differs from the implementation in pointer_unsafe.go. elem := p.v.Index(i)
func (p pointer) setInt32Slice(v []int32) { switch elem.Kind() {
if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { case reflect.Int32:
// raw int32 type return uint32(elem.Int())
p.v.Elem().Set(reflect.ValueOf(v)) case reflect.Uint32:
return uint32(elem.Uint())
case reflect.Float32:
return math.Float32bits(float32(elem.Float()))
}
panic("unreachable")
}
// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct.
func structPointer_Word32Slice(p structPointer, f field) word32Slice {
return word32Slice{structPointer_field(p, f)}
}
// word64 is like word32 but for 64-bit values.
type word64 struct {
v reflect.Value
}
func word64_Set(p word64, o *Buffer, x uint64) {
t := p.v.Type().Elem()
switch t {
case int64Type:
if len(o.int64s) == 0 {
o.int64s = make([]int64, uint64PoolSize)
}
o.int64s[0] = int64(x)
p.v.Set(reflect.ValueOf(&o.int64s[0]))
o.int64s = o.int64s[1:]
return
case uint64Type:
if len(o.uint64s) == 0 {
o.uint64s = make([]uint64, uint64PoolSize)
}
o.uint64s[0] = x
p.v.Set(reflect.ValueOf(&o.uint64s[0]))
o.uint64s = o.uint64s[1:]
return
case float64Type:
if len(o.float64s) == 0 {
o.float64s = make([]float64, uint64PoolSize)
}
o.float64s[0] = math.Float64frombits(x)
p.v.Set(reflect.ValueOf(&o.float64s[0]))
o.float64s = o.float64s[1:]
return return
} }
// an enum panic("unreachable")
// Allocate a []enum, then assign []int32's values into it.
// Note: we can't convert []enum to []int32.
slice := reflect.MakeSlice(p.v.Type().Elem(), len(v), cap(v))
for i, x := range v {
slice.Index(i).SetInt(int64(x))
}
p.v.Elem().Set(slice)
}
func (p pointer) appendInt32Slice(v int32) {
grow(p.v.Elem()).SetInt(int64(v))
} }
func (p pointer) toUint64() *uint64 { func word64_IsNil(p word64) bool {
return p.v.Interface().(*uint64) return p.v.IsNil()
}
func (p pointer) toUint64Ptr() **uint64 {
return p.v.Interface().(**uint64)
}
func (p pointer) toUint64Slice() *[]uint64 {
return p.v.Interface().(*[]uint64)
}
func (p pointer) toUint32() *uint32 {
return p.v.Interface().(*uint32)
}
func (p pointer) toUint32Ptr() **uint32 {
return p.v.Interface().(**uint32)
}
func (p pointer) toUint32Slice() *[]uint32 {
return p.v.Interface().(*[]uint32)
}
func (p pointer) toBool() *bool {
return p.v.Interface().(*bool)
}
func (p pointer) toBoolPtr() **bool {
return p.v.Interface().(**bool)
}
func (p pointer) toBoolSlice() *[]bool {
return p.v.Interface().(*[]bool)
}
func (p pointer) toFloat64() *float64 {
return p.v.Interface().(*float64)
}
func (p pointer) toFloat64Ptr() **float64 {
return p.v.Interface().(**float64)
}
func (p pointer) toFloat64Slice() *[]float64 {
return p.v.Interface().(*[]float64)
}
func (p pointer) toFloat32() *float32 {
return p.v.Interface().(*float32)
}
func (p pointer) toFloat32Ptr() **float32 {
return p.v.Interface().(**float32)
}
func (p pointer) toFloat32Slice() *[]float32 {
return p.v.Interface().(*[]float32)
}
func (p pointer) toString() *string {
return p.v.Interface().(*string)
}
func (p pointer) toStringPtr() **string {
return p.v.Interface().(**string)
}
func (p pointer) toStringSlice() *[]string {
return p.v.Interface().(*[]string)
}
func (p pointer) toBytes() *[]byte {
return p.v.Interface().(*[]byte)
}
func (p pointer) toBytesSlice() *[][]byte {
return p.v.Interface().(*[][]byte)
}
func (p pointer) toExtensions() *XXX_InternalExtensions {
return p.v.Interface().(*XXX_InternalExtensions)
}
func (p pointer) toOldExtensions() *map[int32]Extension {
return p.v.Interface().(*map[int32]Extension)
}
func (p pointer) getPointer() pointer {
return pointer{v: p.v.Elem()}
}
func (p pointer) setPointer(q pointer) {
p.v.Elem().Set(q.v)
}
func (p pointer) appendPointer(q pointer) {
grow(p.v.Elem()).Set(q.v)
} }
// getPointerSlice copies []*T from p as a new []pointer. func word64_Get(p word64) uint64 {
// This behavior differs from the implementation in pointer_unsafe.go. elem := p.v.Elem()
func (p pointer) getPointerSlice() []pointer { switch elem.Kind() {
if p.v.IsNil() { case reflect.Int64:
return nil return uint64(elem.Int())
case reflect.Uint64:
return elem.Uint()
case reflect.Float64:
return math.Float64bits(elem.Float())
} }
n := p.v.Elem().Len() panic("unreachable")
s := make([]pointer, n)
for i := 0; i < n; i++ {
s[i] = pointer{v: p.v.Elem().Index(i)}
}
return s
} }
// setPointerSlice copies []pointer into p as a new []*T. func structPointer_Word64(p structPointer, f field) word64 {
// This behavior differs from the implementation in pointer_unsafe.go. return word64{structPointer_field(p, f)}
func (p pointer) setPointerSlice(v []pointer) { }
if v == nil {
p.v.Elem().Set(reflect.New(p.v.Elem().Type()).Elem()) // word64Val is like word32Val but for 64-bit values.
type word64Val struct {
v reflect.Value
}
func word64Val_Set(p word64Val, o *Buffer, x uint64) {
switch p.v.Type() {
case int64Type:
p.v.SetInt(int64(x))
return
case uint64Type:
p.v.SetUint(x)
return
case float64Type:
p.v.SetFloat(math.Float64frombits(x))
return return
} }
s := reflect.MakeSlice(p.v.Elem().Type(), 0, len(v)) panic("unreachable")
for _, p := range v { }
s = reflect.Append(s, p.v)
func word64Val_Get(p word64Val) uint64 {
elem := p.v
switch elem.Kind() {
case reflect.Int64:
return uint64(elem.Int())
case reflect.Uint64:
return elem.Uint()
case reflect.Float64:
return math.Float64bits(elem.Float())
} }
p.v.Elem().Set(s) panic("unreachable")
} }
// getInterfacePointer returns a pointer that points to the func structPointer_Word64Val(p structPointer, f field) word64Val {
// interface data of the interface pointed by p. return word64Val{structPointer_field(p, f)}
func (p pointer) getInterfacePointer() pointer { }
if p.v.Elem().IsNil() {
return pointer{v: p.v.Elem()} type word64Slice struct {
v reflect.Value
}
func (p word64Slice) Append(x uint64) {
n, m := p.v.Len(), p.v.Cap()
if n < m {
p.v.SetLen(n + 1)
} else {
t := p.v.Type().Elem()
p.v.Set(reflect.Append(p.v, reflect.Zero(t)))
}
elem := p.v.Index(n)
switch elem.Kind() {
case reflect.Int64:
elem.SetInt(int64(int64(x)))
case reflect.Uint64:
elem.SetUint(uint64(x))
case reflect.Float64:
elem.SetFloat(float64(math.Float64frombits(x)))
} }
return pointer{v: p.v.Elem().Elem().Elem().Field(0).Addr()} // *interface -> interface -> *struct -> struct
} }
func (p pointer) asPointerTo(t reflect.Type) reflect.Value { func (p word64Slice) Len() int {
// TODO: check that p.v.Type().Elem() == t? return p.v.Len()
return p.v
} }
func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo { func (p word64Slice) Index(i int) uint64 {
atomicLock.Lock() elem := p.v.Index(i)
defer atomicLock.Unlock() switch elem.Kind() {
return *p case reflect.Int64:
} return uint64(elem.Int())
func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) { case reflect.Uint64:
atomicLock.Lock() return uint64(elem.Uint())
defer atomicLock.Unlock() case reflect.Float64:
*p = v return math.Float64bits(float64(elem.Float()))
} }
func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo { panic("unreachable")
atomicLock.Lock()
defer atomicLock.Unlock()
return *p
}
func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) {
atomicLock.Lock()
defer atomicLock.Unlock()
*p = v
}
func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo {
atomicLock.Lock()
defer atomicLock.Unlock()
return *p
}
func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
atomicLock.Lock()
defer atomicLock.Unlock()
*p = v
}
func atomicLoadDiscardInfo(p **discardInfo) *discardInfo {
atomicLock.Lock()
defer atomicLock.Unlock()
return *p
}
func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) {
atomicLock.Lock()
defer atomicLock.Unlock()
*p = v
} }
var atomicLock sync.Mutex func structPointer_Word64Slice(p structPointer, f field) word64Slice {
return word64Slice{structPointer_field(p, f)}
}

View File

@@ -1,6 +1,6 @@
// Protocol Buffers for Go with Gadgets // Protocol Buffers for Go with Gadgets
// //
// Copyright (c) 2018, The GoGo Authors. All rights reserved. // Copyright (c) 2016, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf // http://github.com/gogo/protobuf
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
@@ -26,11 +26,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build purego appengine js // +build appengine js
// This file contains an implementation of proto field accesses using package reflect.
// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
// be used on App Engine.
package proto package proto
@@ -38,22 +34,52 @@ import (
"reflect" "reflect"
) )
// TODO: untested, so probably incorrect. func structPointer_FieldPointer(p structPointer, f field) structPointer {
panic("not implemented")
func (p pointer) getRef() pointer {
return pointer{v: p.v.Addr()}
} }
func (p pointer) appendRef(v pointer, typ reflect.Type) { func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer {
slice := p.getSlice(typ) panic("not implemented")
elem := v.asPointerTo(typ).Elem()
newSlice := reflect.Append(slice, elem)
slice.Set(newSlice)
} }
func (p pointer) getSlice(typ reflect.Type) reflect.Value { func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} {
sliceTyp := reflect.SliceOf(typ) panic("not implemented")
slice := p.asPointerTo(sliceTyp) }
slice = slice.Elem()
return slice func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} {
panic("not implemented")
}
func structPointer_GetRefStructPointer(p structPointer, f field) structPointer {
panic("not implemented")
}
func structPointer_Add(p structPointer, size field) structPointer {
panic("not implemented")
}
func structPointer_Len(p structPointer, f field) int {
panic("not implemented")
}
func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader {
panic("not implemented")
}
func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) {
panic("not implemented")
}
func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice {
panic("not implemented")
}
type structRefSlice struct{}
func (v *structRefSlice) Len() int {
panic("not implemented")
}
func (v *structRefSlice) Index(i int) structPointer {
panic("not implemented")
} }

View File

@@ -29,7 +29,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build !purego,!appengine,!js // +build !appengine,!js
// This file contains the implementation of the proto field accesses using package unsafe. // This file contains the implementation of the proto field accesses using package unsafe.
@@ -37,13 +37,38 @@ package proto
import ( import (
"reflect" "reflect"
"sync/atomic"
"unsafe" "unsafe"
) )
const unsafeAllowed = true // NOTE: These type_Foo functions would more idiomatically be methods,
// but Go does not allow methods on pointer types, and we must preserve
// some pointer type for the garbage collector. We use these
// funcs with clunky names as our poor approximation to methods.
//
// An alternative would be
// type structPointer struct { p unsafe.Pointer }
// but that does not registerize as well.
// A field identifies a field in a struct, accessible from a pointer. // A structPointer is a pointer to a struct.
type structPointer unsafe.Pointer
// toStructPointer returns a structPointer equivalent to the given reflect value.
func toStructPointer(v reflect.Value) structPointer {
return structPointer(unsafe.Pointer(v.Pointer()))
}
// IsNil reports whether p is nil.
func structPointer_IsNil(p structPointer) bool {
return p == nil
}
// Interface returns the struct pointer, assumed to have element type t,
// as an interface value.
func structPointer_Interface(p structPointer, t reflect.Type) interface{} {
return reflect.NewAt(t, unsafe.Pointer(p)).Interface()
}
// A field identifies a field in a struct, accessible from a structPointer.
// In this implementation, a field is identified by its byte offset from the start of the struct. // In this implementation, a field is identified by its byte offset from the start of the struct.
type field uintptr type field uintptr
@@ -55,254 +80,191 @@ func toField(f *reflect.StructField) field {
// invalidField is an invalid field identifier. // invalidField is an invalid field identifier.
const invalidField = ^field(0) const invalidField = ^field(0)
// zeroField is a noop when calling pointer.offset.
const zeroField = field(0)
// IsValid reports whether the field identifier is valid. // IsValid reports whether the field identifier is valid.
func (f field) IsValid() bool { func (f field) IsValid() bool {
return f != invalidField return f != ^field(0)
} }
// The pointer type below is for the new table-driven encoder/decoder. // Bytes returns the address of a []byte field in the struct.
// The implementation here uses unsafe.Pointer to create a generic pointer. func structPointer_Bytes(p structPointer, f field) *[]byte {
// In pointer_reflect.go we use reflect instead of unsafe to implement return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))
// the same (but slower) interface.
type pointer struct {
p unsafe.Pointer
} }
// size of pointer // BytesSlice returns the address of a [][]byte field in the struct.
var ptrSize = unsafe.Sizeof(uintptr(0)) func structPointer_BytesSlice(p structPointer, f field) *[][]byte {
return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))
// toPointer converts an interface of pointer type to a pointer
// that points to the same target.
func toPointer(i *Message) pointer {
// Super-tricky - read pointer out of data word of interface value.
// Saves ~25ns over the equivalent:
// return valToPointer(reflect.ValueOf(*i))
return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
} }
// toAddrPointer converts an interface to a pointer that points to // Bool returns the address of a *bool field in the struct.
// the interface data. func structPointer_Bool(p structPointer, f field) **bool {
func toAddrPointer(i *interface{}, isptr bool) pointer { return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
// Super-tricky - read or get the address of data word of interface value. }
if isptr {
// The interface is of pointer type, thus it is a direct interface. // BoolVal returns the address of a bool field in the struct.
// The data word is the pointer data itself. We take its address. func structPointer_BoolVal(p structPointer, f field) *bool {
return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// BoolSlice returns the address of a []bool field in the struct.
func structPointer_BoolSlice(p structPointer, f field) *[]bool {
return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// String returns the address of a *string field in the struct.
func structPointer_String(p structPointer, f field) **string {
return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// StringVal returns the address of a string field in the struct.
func structPointer_StringVal(p structPointer, f field) *string {
return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// StringSlice returns the address of a []string field in the struct.
func structPointer_StringSlice(p structPointer, f field) *[]string {
return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// ExtMap returns the address of an extension map field in the struct.
func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {
return (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// NewAt returns the reflect.Value for a pointer to a field in the struct.
func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f)))
}
// SetStructPointer writes a *struct field in the struct.
func structPointer_SetStructPointer(p structPointer, f field, q structPointer) {
*(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q
}
// GetStructPointer reads a *struct field in the struct.
func structPointer_GetStructPointer(p structPointer, f field) structPointer {
return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// StructPointerSlice the address of a []*struct field in the struct.
func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice {
return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups).
type structPointerSlice []structPointer
func (v *structPointerSlice) Len() int { return len(*v) }
func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] }
func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) }
// A word32 is the address of a "pointer to 32-bit value" field.
type word32 **uint32
// IsNil reports whether *v is nil.
func word32_IsNil(p word32) bool {
return *p == nil
}
// Set sets *v to point at a newly allocated word set to x.
func word32_Set(p word32, o *Buffer, x uint32) {
if len(o.uint32s) == 0 {
o.uint32s = make([]uint32, uint32PoolSize)
} }
// The interface is not of pointer type. The data word is the pointer o.uint32s[0] = x
// to the data. *p = &o.uint32s[0]
return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} o.uint32s = o.uint32s[1:]
} }
// valToPointer converts v to a pointer. v must be of pointer type. // Get gets the value pointed at by *v.
func valToPointer(v reflect.Value) pointer { func word32_Get(p word32) uint32 {
return pointer{p: unsafe.Pointer(v.Pointer())} return **p
} }
// offset converts from a pointer to a structure to a pointer to // Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct.
// one of its fields. func structPointer_Word32(p structPointer, f field) word32 {
func (p pointer) offset(f field) pointer { return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))
// For safety, we should panic if !f.IsValid, however calling panic causes
// this to no longer be inlineable, which is a serious performance cost.
/*
if !f.IsValid() {
panic("invalid field")
}
*/
return pointer{p: unsafe.Pointer(uintptr(p.p) + uintptr(f))}
} }
func (p pointer) isNil() bool { // A word32Val is the address of a 32-bit value field.
return p.p == nil type word32Val *uint32
// Set sets *p to x.
func word32Val_Set(p word32Val, x uint32) {
*p = x
} }
func (p pointer) toInt64() *int64 { // Get gets the value pointed at by p.
return (*int64)(p.p) func word32Val_Get(p word32Val) uint32 {
} return *p
func (p pointer) toInt64Ptr() **int64 {
return (**int64)(p.p)
}
func (p pointer) toInt64Slice() *[]int64 {
return (*[]int64)(p.p)
}
func (p pointer) toInt32() *int32 {
return (*int32)(p.p)
} }
// See pointer_reflect.go for why toInt32Ptr/Slice doesn't exist. // Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct.
/* func structPointer_Word32Val(p structPointer, f field) word32Val {
func (p pointer) toInt32Ptr() **int32 { return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))
return (**int32)(p.p) }
// A word32Slice is a slice of 32-bit values.
type word32Slice []uint32
func (v *word32Slice) Append(x uint32) { *v = append(*v, x) }
func (v *word32Slice) Len() int { return len(*v) }
func (v *word32Slice) Index(i int) uint32 { return (*v)[i] }
// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct.
func structPointer_Word32Slice(p structPointer, f field) *word32Slice {
return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// word64 is like word32 but for 64-bit values.
type word64 **uint64
func word64_Set(p word64, o *Buffer, x uint64) {
if len(o.uint64s) == 0 {
o.uint64s = make([]uint64, uint64PoolSize)
} }
func (p pointer) toInt32Slice() *[]int32 { o.uint64s[0] = x
return (*[]int32)(p.p) *p = &o.uint64s[0]
} o.uint64s = o.uint64s[1:]
*/
func (p pointer) getInt32Ptr() *int32 {
return *(**int32)(p.p)
}
func (p pointer) setInt32Ptr(v int32) {
*(**int32)(p.p) = &v
} }
// getInt32Slice loads a []int32 from p. func word64_IsNil(p word64) bool {
// The value returned is aliased with the original slice. return *p == nil
// This behavior differs from the implementation in pointer_reflect.go.
func (p pointer) getInt32Slice() []int32 {
return *(*[]int32)(p.p)
} }
// setInt32Slice stores a []int32 to p. func word64_Get(p word64) uint64 {
// The value set is aliased with the input slice. return **p
// This behavior differs from the implementation in pointer_reflect.go.
func (p pointer) setInt32Slice(v []int32) {
*(*[]int32)(p.p) = v
} }
// TODO: Can we get rid of appendInt32Slice and use setInt32Slice instead? func structPointer_Word64(p structPointer, f field) word64 {
func (p pointer) appendInt32Slice(v int32) { return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))
s := (*[]int32)(p.p)
*s = append(*s, v)
} }
func (p pointer) toUint64() *uint64 { // word64Val is like word32Val but for 64-bit values.
return (*uint64)(p.p) type word64Val *uint64
}
func (p pointer) toUint64Ptr() **uint64 { func word64Val_Set(p word64Val, o *Buffer, x uint64) {
return (**uint64)(p.p) *p = x
}
func (p pointer) toUint64Slice() *[]uint64 {
return (*[]uint64)(p.p)
}
func (p pointer) toUint32() *uint32 {
return (*uint32)(p.p)
}
func (p pointer) toUint32Ptr() **uint32 {
return (**uint32)(p.p)
}
func (p pointer) toUint32Slice() *[]uint32 {
return (*[]uint32)(p.p)
}
func (p pointer) toBool() *bool {
return (*bool)(p.p)
}
func (p pointer) toBoolPtr() **bool {
return (**bool)(p.p)
}
func (p pointer) toBoolSlice() *[]bool {
return (*[]bool)(p.p)
}
func (p pointer) toFloat64() *float64 {
return (*float64)(p.p)
}
func (p pointer) toFloat64Ptr() **float64 {
return (**float64)(p.p)
}
func (p pointer) toFloat64Slice() *[]float64 {
return (*[]float64)(p.p)
}
func (p pointer) toFloat32() *float32 {
return (*float32)(p.p)
}
func (p pointer) toFloat32Ptr() **float32 {
return (**float32)(p.p)
}
func (p pointer) toFloat32Slice() *[]float32 {
return (*[]float32)(p.p)
}
func (p pointer) toString() *string {
return (*string)(p.p)
}
func (p pointer) toStringPtr() **string {
return (**string)(p.p)
}
func (p pointer) toStringSlice() *[]string {
return (*[]string)(p.p)
}
func (p pointer) toBytes() *[]byte {
return (*[]byte)(p.p)
}
func (p pointer) toBytesSlice() *[][]byte {
return (*[][]byte)(p.p)
}
func (p pointer) toExtensions() *XXX_InternalExtensions {
return (*XXX_InternalExtensions)(p.p)
}
func (p pointer) toOldExtensions() *map[int32]Extension {
return (*map[int32]Extension)(p.p)
} }
// getPointerSlice loads []*T from p as a []pointer. func word64Val_Get(p word64Val) uint64 {
// The value returned is aliased with the original slice. return *p
// This behavior differs from the implementation in pointer_reflect.go.
func (p pointer) getPointerSlice() []pointer {
// Super-tricky - p should point to a []*T where T is a
// message type. We load it as []pointer.
return *(*[]pointer)(p.p)
} }
// setPointerSlice stores []pointer into p as a []*T. func structPointer_Word64Val(p structPointer, f field) word64Val {
// The value set is aliased with the input slice. return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))
// This behavior differs from the implementation in pointer_reflect.go.
func (p pointer) setPointerSlice(v []pointer) {
// Super-tricky - p should point to a []*T where T is a
// message type. We store it as []pointer.
*(*[]pointer)(p.p) = v
} }
// getPointer loads the pointer at p and returns it. // word64Slice is like word32Slice but for 64-bit values.
func (p pointer) getPointer() pointer { type word64Slice []uint64
return pointer{p: *(*unsafe.Pointer)(p.p)}
}
// setPointer stores the pointer q at p. func (v *word64Slice) Append(x uint64) { *v = append(*v, x) }
func (p pointer) setPointer(q pointer) { func (v *word64Slice) Len() int { return len(*v) }
*(*unsafe.Pointer)(p.p) = q.p func (v *word64Slice) Index(i int) uint64 { return (*v)[i] }
}
// append q to the slice pointed to by p. func structPointer_Word64Slice(p structPointer, f field) *word64Slice {
func (p pointer) appendPointer(q pointer) { return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
s := (*[]unsafe.Pointer)(p.p)
*s = append(*s, q.p)
}
// getInterfacePointer returns a pointer that points to the
// interface data of the interface pointed by p.
func (p pointer) getInterfacePointer() pointer {
// Super-tricky - read pointer out of data word of interface value.
return pointer{p: (*(*[2]unsafe.Pointer)(p.p))[1]}
}
// asPointerTo returns a reflect.Value that is a pointer to an
// object of type t stored at p.
func (p pointer) asPointerTo(t reflect.Type) reflect.Value {
return reflect.NewAt(t, p.p)
}
func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo {
return (*unmarshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
}
func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) {
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
}
func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo {
return (*marshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
}
func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) {
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
}
func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo {
return (*mergeInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
}
func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
}
func atomicLoadDiscardInfo(p **discardInfo) *discardInfo {
return (*discardInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
}
func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) {
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
} }

View File

@@ -1,6 +1,6 @@
// Protocol Buffers for Go with Gadgets // Protocol Buffers for Go with Gadgets
// //
// Copyright (c) 2018, The GoGo Authors. All rights reserved. // Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf // http://github.com/gogo/protobuf
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build !purego,!appengine,!js // +build !appengine,!js
// This file contains the implementation of the proto field accesses using package unsafe. // This file contains the implementation of the proto field accesses using package unsafe.
@@ -37,20 +37,92 @@ import (
"unsafe" "unsafe"
) )
func (p pointer) getRef() pointer { func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} {
return pointer{p: (unsafe.Pointer)(&p.p)} point := unsafe.Pointer(uintptr(p) + uintptr(f))
r := reflect.NewAt(t, point)
return r.Interface()
} }
func (p pointer) appendRef(v pointer, typ reflect.Type) { func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} {
slice := p.getSlice(typ) point := unsafe.Pointer(uintptr(p) + uintptr(f))
elem := v.asPointerTo(typ).Elem() r := reflect.NewAt(t, point)
newSlice := reflect.Append(slice, elem) if r.Elem().IsNil() {
slice.Set(newSlice) return nil
}
return r.Elem().Interface()
} }
func (p pointer) getSlice(typ reflect.Type) reflect.Value { func copyUintPtr(oldptr, newptr uintptr, size int) {
sliceTyp := reflect.SliceOf(typ) oldbytes := make([]byte, 0)
slice := p.asPointerTo(sliceTyp) oldslice := (*reflect.SliceHeader)(unsafe.Pointer(&oldbytes))
slice = slice.Elem() oldslice.Data = oldptr
return slice oldslice.Len = size
oldslice.Cap = size
newbytes := make([]byte, 0)
newslice := (*reflect.SliceHeader)(unsafe.Pointer(&newbytes))
newslice.Data = newptr
newslice.Len = size
newslice.Cap = size
copy(newbytes, oldbytes)
}
func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) {
copyUintPtr(uintptr(oldptr), uintptr(newptr), size)
}
func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer {
size := typ.Elem().Size()
oldHeader := structPointer_GetSliceHeader(base, f)
oldSlice := reflect.NewAt(typ, unsafe.Pointer(oldHeader)).Elem()
newLen := oldHeader.Len + 1
newSlice := reflect.MakeSlice(typ, newLen, newLen)
reflect.Copy(newSlice, oldSlice)
bas := toStructPointer(newSlice)
oldHeader.Data = uintptr(bas)
oldHeader.Len = newLen
oldHeader.Cap = newLen
return structPointer(unsafe.Pointer(uintptr(unsafe.Pointer(bas)) + uintptr(uintptr(newLen-1)*size)))
}
func structPointer_FieldPointer(p structPointer, f field) structPointer {
return structPointer(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
func structPointer_GetRefStructPointer(p structPointer, f field) structPointer {
return structPointer((*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader {
return (*reflect.SliceHeader)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
func structPointer_Add(p structPointer, size field) structPointer {
return structPointer(unsafe.Pointer(uintptr(p) + uintptr(size)))
}
func structPointer_Len(p structPointer, f field) int {
return len(*(*[]interface{})(unsafe.Pointer(structPointer_GetRefStructPointer(p, f))))
}
func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice {
return &structRefSlice{p: p, f: f, size: size}
}
// A structRefSlice represents a slice of structs (themselves submessages or groups).
type structRefSlice struct {
p structPointer
f field
size uintptr
}
func (v *structRefSlice) Len() int {
return structPointer_Len(v.p, v.f)
}
func (v *structRefSlice) Index(i int) structPointer {
ss := structPointer_GetStructPointer(v.p, v.f)
ss1 := structPointer_GetRefStructPointer(ss, 0)
return structPointer_Add(ss1, field(uintptr(i)*v.size))
} }

View File

@@ -63,6 +63,42 @@ const (
WireFixed32 = 5 WireFixed32 = 5
) )
const startSize = 10 // initial slice/string sizes
// Encoders are defined in encode.go
// An encoder outputs the full representation of a field, including its
// tag and encoder type.
type encoder func(p *Buffer, prop *Properties, base structPointer) error
// A valueEncoder encodes a single integer in a particular encoding.
type valueEncoder func(o *Buffer, x uint64) error
// Sizers are defined in encode.go
// A sizer returns the encoded size of a field, including its tag and encoder
// type.
type sizer func(prop *Properties, base structPointer) int
// A valueSizer returns the encoded size of a single integer in a particular
// encoding.
type valueSizer func(x uint64) int
// Decoders are defined in decode.go
// A decoder creates a value from its wire representation.
// Unrecognized subelements are saved in unrec.
type decoder func(p *Buffer, prop *Properties, base structPointer) error
// A valueDecoder decodes a single integer in a particular encoding.
type valueDecoder func(o *Buffer) (x uint64, err error)
// A oneofMarshaler does the marshaling for all oneof fields in a message.
type oneofMarshaler func(Message, *Buffer) error
// A oneofUnmarshaler does the unmarshaling for a oneof field in a message.
type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error)
// A oneofSizer does the sizing for all oneof fields in a message.
type oneofSizer func(Message) int
// tagMap is an optimization over map[int]int for typical protocol buffer // tagMap is an optimization over map[int]int for typical protocol buffer
// use-cases. Encoded protocol buffers are often in tag order with small tag // use-cases. Encoded protocol buffers are often in tag order with small tag
// numbers. // numbers.
@@ -109,6 +145,13 @@ type StructProperties struct {
decoderTags tagMap // map from proto tag to struct field number decoderTags tagMap // map from proto tag to struct field number
decoderOrigNames map[string]int // map from original name to struct field number decoderOrigNames map[string]int // map from original name to struct field number
order []int // list of struct field numbers in tag order order []int // list of struct field numbers in tag order
unrecField field // field id of the XXX_unrecognized []byte field
extendable bool // is this an extendable proto
oneofMarshaler oneofMarshaler
oneofUnmarshaler oneofUnmarshaler
oneofSizer oneofSizer
stype reflect.Type
// OneofTypes contains information about the oneof fields in this message. // OneofTypes contains information about the oneof fields in this message.
// It is keyed by the original name of a field. // It is keyed by the original name of a field.
@@ -144,7 +187,7 @@ type Properties struct {
Repeated bool Repeated bool
Packed bool // relevant for repeated primitives only Packed bool // relevant for repeated primitives only
Enum string // set for enum types only Enum string // set for enum types only
proto3 bool // whether this is known to be a proto3 field proto3 bool // whether this is known to be a proto3 field; set for []byte only
oneof bool // whether this is a oneof field oneof bool // whether this is a oneof field
Default string // default value Default string // default value
@@ -153,21 +196,37 @@ type Properties struct {
CastType string CastType string
StdTime bool StdTime bool
StdDuration bool StdDuration bool
WktPointer bool
stype reflect.Type // set for struct types only enc encoder
ctype reflect.Type // set for custom types only valEnc valueEncoder // set for bool and numeric types only
sprop *StructProperties // set for struct types only field field
tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType)
tagbuf [8]byte
stype reflect.Type // set for struct types only
sstype reflect.Type // set for slices of structs types only
ctype reflect.Type // set for custom types only
sprop *StructProperties // set for struct types only
isMarshaler bool
isUnmarshaler bool
mtype reflect.Type // set for map types only mtype reflect.Type // set for map types only
MapKeyProp *Properties // set for map types only mkeyprop *Properties // set for map types only
MapValProp *Properties // set for map types only mvalprop *Properties // set for map types only
size sizer
valSize valueSizer // set for bool and numeric types only
dec decoder
valDec valueDecoder // set for bool and numeric types only
// If this is a packable field, this will be the decoder for the packed version of the field.
packedDec decoder
} }
// String formats the properties in the protobuf struct field tag style. // String formats the properties in the protobuf struct field tag style.
func (p *Properties) String() string { func (p *Properties) String() string {
s := p.Wire s := p.Wire
s += "," s = ","
s += strconv.Itoa(p.Tag) s += strconv.Itoa(p.Tag)
if p.Required { if p.Required {
s += ",req" s += ",req"
@@ -213,14 +272,29 @@ func (p *Properties) Parse(s string) {
switch p.Wire { switch p.Wire {
case "varint": case "varint":
p.WireType = WireVarint p.WireType = WireVarint
p.valEnc = (*Buffer).EncodeVarint
p.valDec = (*Buffer).DecodeVarint
p.valSize = sizeVarint
case "fixed32": case "fixed32":
p.WireType = WireFixed32 p.WireType = WireFixed32
p.valEnc = (*Buffer).EncodeFixed32
p.valDec = (*Buffer).DecodeFixed32
p.valSize = sizeFixed32
case "fixed64": case "fixed64":
p.WireType = WireFixed64 p.WireType = WireFixed64
p.valEnc = (*Buffer).EncodeFixed64
p.valDec = (*Buffer).DecodeFixed64
p.valSize = sizeFixed64
case "zigzag32": case "zigzag32":
p.WireType = WireVarint p.WireType = WireVarint
p.valEnc = (*Buffer).EncodeZigzag32
p.valDec = (*Buffer).DecodeZigzag32
p.valSize = sizeZigzag32
case "zigzag64": case "zigzag64":
p.WireType = WireVarint p.WireType = WireVarint
p.valEnc = (*Buffer).EncodeZigzag64
p.valDec = (*Buffer).DecodeZigzag64
p.valSize = sizeZigzag64
case "bytes", "group": case "bytes", "group":
p.WireType = WireBytes p.WireType = WireBytes
// no numeric converter for non-numeric types // no numeric converter for non-numeric types
@@ -235,7 +309,6 @@ func (p *Properties) Parse(s string) {
return return
} }
outer:
for i := 2; i < len(fields); i++ { for i := 2; i < len(fields); i++ {
f := fields[i] f := fields[i]
switch { switch {
@@ -263,7 +336,7 @@ outer:
if i+1 < len(fields) { if i+1 < len(fields) {
// Commas aren't escaped, and def is always last. // Commas aren't escaped, and def is always last.
p.Default += "," + strings.Join(fields[i+1:], ",") p.Default += "," + strings.Join(fields[i+1:], ",")
break outer break
} }
case strings.HasPrefix(f, "embedded="): case strings.HasPrefix(f, "embedded="):
p.OrigName = strings.Split(f, "=")[1] p.OrigName = strings.Split(f, "=")[1]
@@ -275,58 +348,301 @@ outer:
p.StdTime = true p.StdTime = true
case f == "stdduration": case f == "stdduration":
p.StdDuration = true p.StdDuration = true
case f == "wktptr":
p.WktPointer = true
} }
} }
} }
func logNoSliceEnc(t1, t2 reflect.Type) {
fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2)
}
var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem()
// setFieldProps initializes the field properties for submessages and maps. // Initialize the fields for encoding and decoding.
func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) {
p.enc = nil
p.dec = nil
p.size = nil
isMap := typ.Kind() == reflect.Map isMap := typ.Kind() == reflect.Map
if len(p.CustomType) > 0 && !isMap { if len(p.CustomType) > 0 && !isMap {
p.ctype = typ p.setCustomEncAndDec(typ)
p.setTag(lockGetProp) p.setTag(lockGetProp)
return return
} }
if p.StdTime && !isMap { if p.StdTime && !isMap {
p.setTimeEncAndDec(typ)
p.setTag(lockGetProp) p.setTag(lockGetProp)
return return
} }
if p.StdDuration && !isMap { if p.StdDuration && !isMap {
p.setTag(lockGetProp) p.setDurationEncAndDec(typ)
return
}
if p.WktPointer && !isMap {
p.setTag(lockGetProp) p.setTag(lockGetProp)
return return
} }
switch t1 := typ; t1.Kind() { switch t1 := typ; t1.Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1)
// proto3 scalar types
case reflect.Bool:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_bool
p.dec = (*Buffer).dec_proto3_bool
p.size = size_proto3_bool
} else {
p.enc = (*Buffer).enc_ref_bool
p.dec = (*Buffer).dec_proto3_bool
p.size = size_ref_bool
}
case reflect.Int32:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_int32
p.dec = (*Buffer).dec_proto3_int32
p.size = size_proto3_int32
} else {
p.enc = (*Buffer).enc_ref_int32
p.dec = (*Buffer).dec_proto3_int32
p.size = size_ref_int32
}
case reflect.Uint32:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_uint32
p.dec = (*Buffer).dec_proto3_int32 // can reuse
p.size = size_proto3_uint32
} else {
p.enc = (*Buffer).enc_ref_uint32
p.dec = (*Buffer).dec_proto3_int32 // can reuse
p.size = size_ref_uint32
}
case reflect.Int64, reflect.Uint64:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_int64
p.dec = (*Buffer).dec_proto3_int64
p.size = size_proto3_int64
} else {
p.enc = (*Buffer).enc_ref_int64
p.dec = (*Buffer).dec_proto3_int64
p.size = size_ref_int64
}
case reflect.Float32:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits
p.dec = (*Buffer).dec_proto3_int32
p.size = size_proto3_uint32
} else {
p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits
p.dec = (*Buffer).dec_proto3_int32
p.size = size_ref_uint32
}
case reflect.Float64:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits
p.dec = (*Buffer).dec_proto3_int64
p.size = size_proto3_int64
} else {
p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits
p.dec = (*Buffer).dec_proto3_int64
p.size = size_ref_int64
}
case reflect.String:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_string
p.dec = (*Buffer).dec_proto3_string
p.size = size_proto3_string
} else {
p.enc = (*Buffer).enc_ref_string
p.dec = (*Buffer).dec_proto3_string
p.size = size_ref_string
}
case reflect.Struct: case reflect.Struct:
p.stype = typ p.stype = typ
case reflect.Ptr: p.isMarshaler = isMarshaler(typ)
if t1.Elem().Kind() == reflect.Struct { p.isUnmarshaler = isUnmarshaler(typ)
p.stype = t1.Elem() if p.Wire == "bytes" {
p.enc = (*Buffer).enc_ref_struct_message
p.dec = (*Buffer).dec_ref_struct_message
p.size = size_ref_struct_message
} else {
fmt.Fprintf(os.Stderr, "proto: no coders for struct %T\n", typ)
} }
case reflect.Ptr:
switch t2 := t1.Elem(); t2.Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2)
break
case reflect.Bool:
p.enc = (*Buffer).enc_bool
p.dec = (*Buffer).dec_bool
p.size = size_bool
case reflect.Int32:
p.enc = (*Buffer).enc_int32
p.dec = (*Buffer).dec_int32
p.size = size_int32
case reflect.Uint32:
p.enc = (*Buffer).enc_uint32
p.dec = (*Buffer).dec_int32 // can reuse
p.size = size_uint32
case reflect.Int64, reflect.Uint64:
p.enc = (*Buffer).enc_int64
p.dec = (*Buffer).dec_int64
p.size = size_int64
case reflect.Float32:
p.enc = (*Buffer).enc_uint32 // can just treat them as bits
p.dec = (*Buffer).dec_int32
p.size = size_uint32
case reflect.Float64:
p.enc = (*Buffer).enc_int64 // can just treat them as bits
p.dec = (*Buffer).dec_int64
p.size = size_int64
case reflect.String:
p.enc = (*Buffer).enc_string
p.dec = (*Buffer).dec_string
p.size = size_string
case reflect.Struct:
p.stype = t1.Elem()
p.isMarshaler = isMarshaler(t1)
p.isUnmarshaler = isUnmarshaler(t1)
if p.Wire == "bytes" {
p.enc = (*Buffer).enc_struct_message
p.dec = (*Buffer).dec_struct_message
p.size = size_struct_message
} else {
p.enc = (*Buffer).enc_struct_group
p.dec = (*Buffer).dec_struct_group
p.size = size_struct_group
}
}
case reflect.Slice: case reflect.Slice:
switch t2 := t1.Elem(); t2.Kind() { switch t2 := t1.Elem(); t2.Kind() {
default:
logNoSliceEnc(t1, t2)
break
case reflect.Bool:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_bool
p.size = size_slice_packed_bool
} else {
p.enc = (*Buffer).enc_slice_bool
p.size = size_slice_bool
}
p.dec = (*Buffer).dec_slice_bool
p.packedDec = (*Buffer).dec_slice_packed_bool
case reflect.Int32:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int32
p.size = size_slice_packed_int32
} else {
p.enc = (*Buffer).enc_slice_int32
p.size = size_slice_int32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case reflect.Uint32:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_uint32
p.size = size_slice_packed_uint32
} else {
p.enc = (*Buffer).enc_slice_uint32
p.size = size_slice_uint32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case reflect.Int64, reflect.Uint64:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int64
p.size = size_slice_packed_int64
} else {
p.enc = (*Buffer).enc_slice_int64
p.size = size_slice_int64
}
p.dec = (*Buffer).dec_slice_int64
p.packedDec = (*Buffer).dec_slice_packed_int64
case reflect.Uint8:
p.dec = (*Buffer).dec_slice_byte
if p.proto3 {
p.enc = (*Buffer).enc_proto3_slice_byte
p.size = size_proto3_slice_byte
} else {
p.enc = (*Buffer).enc_slice_byte
p.size = size_slice_byte
}
case reflect.Float32, reflect.Float64:
switch t2.Bits() {
case 32:
// can just treat them as bits
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_uint32
p.size = size_slice_packed_uint32
} else {
p.enc = (*Buffer).enc_slice_uint32
p.size = size_slice_uint32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case 64:
// can just treat them as bits
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int64
p.size = size_slice_packed_int64
} else {
p.enc = (*Buffer).enc_slice_int64
p.size = size_slice_int64
}
p.dec = (*Buffer).dec_slice_int64
p.packedDec = (*Buffer).dec_slice_packed_int64
default:
logNoSliceEnc(t1, t2)
break
}
case reflect.String:
p.enc = (*Buffer).enc_slice_string
p.dec = (*Buffer).dec_slice_string
p.size = size_slice_string
case reflect.Ptr: case reflect.Ptr:
switch t3 := t2.Elem(); t3.Kind() { switch t3 := t2.Elem(); t3.Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3)
break
case reflect.Struct: case reflect.Struct:
p.stype = t3 p.stype = t2.Elem()
p.isMarshaler = isMarshaler(t2)
p.isUnmarshaler = isUnmarshaler(t2)
if p.Wire == "bytes" {
p.enc = (*Buffer).enc_slice_struct_message
p.dec = (*Buffer).dec_slice_struct_message
p.size = size_slice_struct_message
} else {
p.enc = (*Buffer).enc_slice_struct_group
p.dec = (*Buffer).dec_slice_struct_group
p.size = size_slice_struct_group
}
}
case reflect.Slice:
switch t2.Elem().Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem())
break
case reflect.Uint8:
p.enc = (*Buffer).enc_slice_slice_byte
p.dec = (*Buffer).dec_slice_slice_byte
p.size = size_slice_slice_byte
} }
case reflect.Struct: case reflect.Struct:
p.stype = t2 p.setSliceOfNonPointerStructs(t1)
} }
case reflect.Map: case reflect.Map:
p.enc = (*Buffer).enc_new_map
p.dec = (*Buffer).dec_new_map
p.size = size_new_map
p.mtype = t1 p.mtype = t1
p.MapKeyProp = &Properties{} p.mkeyprop = &Properties{}
p.MapKeyProp.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
p.MapValProp = &Properties{} p.mvalprop = &Properties{}
vtype := p.mtype.Elem() vtype := p.mtype.Elem()
if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice { if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {
// The value type is not a message (*T) or bytes ([]byte), // The value type is not a message (*T) or bytes ([]byte),
@@ -334,16 +650,29 @@ func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, loc
vtype = reflect.PtrTo(vtype) vtype = reflect.PtrTo(vtype)
} }
p.MapValProp.CustomType = p.CustomType p.mvalprop.CustomType = p.CustomType
p.MapValProp.StdDuration = p.StdDuration p.mvalprop.StdDuration = p.StdDuration
p.MapValProp.StdTime = p.StdTime p.mvalprop.StdTime = p.StdTime
p.MapValProp.WktPointer = p.WktPointer p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
p.MapValProp.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
} }
p.setTag(lockGetProp) p.setTag(lockGetProp)
} }
func (p *Properties) setTag(lockGetProp bool) { func (p *Properties) setTag(lockGetProp bool) {
// precalculate tag code
wire := p.WireType
if p.Packed {
wire = WireBytes
}
x := uint32(p.Tag)<<3 | uint32(wire)
i := 0
for i = 0; x > 127; i++ {
p.tagbuf[i] = 0x80 | uint8(x&0x7F)
x >>= 7
}
p.tagbuf[i] = uint8(x)
p.tagcode = p.tagbuf[0 : i+1]
if p.stype != nil { if p.stype != nil {
if lockGetProp { if lockGetProp {
p.sprop = GetProperties(p.stype) p.sprop = GetProperties(p.stype)
@@ -354,9 +683,20 @@ func (p *Properties) setTag(lockGetProp bool) {
} }
var ( var (
marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem()
) )
// isMarshaler reports whether type t implements Marshaler.
func isMarshaler(t reflect.Type) bool {
return t.Implements(marshalerType)
}
// isUnmarshaler reports whether type t implements Unmarshaler.
func isUnmarshaler(t reflect.Type) bool {
return t.Implements(unmarshalerType)
}
// Init populates the properties from a protocol buffer struct tag. // Init populates the properties from a protocol buffer struct tag.
func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) {
p.init(typ, name, tag, f, true) p.init(typ, name, tag, f, true)
@@ -366,11 +706,14 @@ func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructF
// "bytes,49,opt,def=hello!" // "bytes,49,opt,def=hello!"
p.Name = name p.Name = name
p.OrigName = name p.OrigName = name
if f != nil {
p.field = toField(f)
}
if tag == "" { if tag == "" {
return return
} }
p.Parse(tag) p.Parse(tag)
p.setFieldProps(typ, f, lockGetProp) p.setEncAndDec(typ, f, lockGetProp)
} }
var ( var (
@@ -420,6 +763,10 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
propertiesMap[t] = prop propertiesMap[t] = prop
// build properties // build properties
prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) ||
reflect.PtrTo(t).Implements(extendableProtoV1Type) ||
reflect.PtrTo(t).Implements(extendableBytesType)
prop.unrecField = invalidField
prop.Prop = make([]*Properties, t.NumField()) prop.Prop = make([]*Properties, t.NumField())
prop.order = make([]int, t.NumField()) prop.order = make([]int, t.NumField())
@@ -430,6 +777,23 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
name := f.Name name := f.Name
p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false)
if f.Name == "XXX_InternalExtensions" { // special case
p.enc = (*Buffer).enc_exts
p.dec = nil // not needed
p.size = size_exts
} else if f.Name == "XXX_extensions" { // special case
if len(f.Tag.Get("protobuf")) > 0 {
p.enc = (*Buffer).enc_ext_slice_byte
p.dec = nil // not needed
p.size = size_ext_slice_byte
} else {
p.enc = (*Buffer).enc_map
p.dec = nil // not needed
p.size = size_map
}
} else if f.Name == "XXX_unrecognized" { // special case
prop.unrecField = toField(&f)
}
oneof := f.Tag.Get("protobuf_oneof") // special case oneof := f.Tag.Get("protobuf_oneof") // special case
if oneof != "" { if oneof != "" {
isOneofMessage = true isOneofMessage = true
@@ -445,6 +809,9 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
} }
print("\n") print("\n")
} }
if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" {
fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]")
}
} }
// Re-order prop.order. // Re-order prop.order.
@@ -455,7 +822,8 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
} }
if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok { if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok {
var oots []interface{} var oots []interface{}
_, _, _, oots = om.XXX_OneofFuncs() prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs()
prop.stype = t
// Interpret oneof metadata. // Interpret oneof metadata.
prop.OneofTypes = make(map[string]*OneofProperties) prop.OneofTypes = make(map[string]*OneofProperties)
@@ -505,6 +873,30 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
return prop return prop
} }
// Return the Properties object for the x[0]'th field of the structure.
func propByIndex(t reflect.Type, x []int) *Properties {
if len(x) != 1 {
fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t)
return nil
}
prop := GetProperties(t)
return prop.Prop[x[0]]
}
// Get the address and type of a pointer to a struct from an interface.
func getbase(pb Message) (t reflect.Type, b structPointer, err error) {
if pb == nil {
err = ErrNil
return
}
// get the reflect type of the pointer to the struct.
t = reflect.TypeOf(pb)
// get the address of the struct.
value := reflect.ValueOf(pb)
b = toStructPointer(value)
return
}
// A global registry of enum types. // A global registry of enum types.
// The generated code will register the generated maps by calling RegisterEnum. // The generated code will register the generated maps by calling RegisterEnum.
@@ -533,42 +925,20 @@ func EnumValueMap(enumType string) map[string]int32 {
// A registry of all linked message types. // A registry of all linked message types.
// The string is a fully-qualified proto name ("pkg.Message"). // The string is a fully-qualified proto name ("pkg.Message").
var ( var (
protoTypedNils = make(map[string]Message) // a map from proto names to typed nil pointers protoTypes = make(map[string]reflect.Type)
protoMapTypes = make(map[string]reflect.Type) // a map from proto names to map types revProtoTypes = make(map[reflect.Type]string)
revProtoTypes = make(map[reflect.Type]string)
) )
// RegisterType is called from generated code and maps from the fully qualified // RegisterType is called from generated code and maps from the fully qualified
// proto name to the type (pointer to struct) of the protocol buffer. // proto name to the type (pointer to struct) of the protocol buffer.
func RegisterType(x Message, name string) { func RegisterType(x Message, name string) {
if _, ok := protoTypedNils[name]; ok { if _, ok := protoTypes[name]; ok {
// TODO: Some day, make this a panic. // TODO: Some day, make this a panic.
log.Printf("proto: duplicate proto type registered: %s", name) log.Printf("proto: duplicate proto type registered: %s", name)
return return
} }
t := reflect.TypeOf(x) t := reflect.TypeOf(x)
if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 { protoTypes[name] = t
// Generated code always calls RegisterType with nil x.
// This check is just for extra safety.
protoTypedNils[name] = x
} else {
protoTypedNils[name] = reflect.Zero(t).Interface().(Message)
}
revProtoTypes[t] = name
}
// RegisterMapType is called from generated code and maps from the fully qualified
// proto name to the native map type of the proto map definition.
func RegisterMapType(x interface{}, name string) {
if reflect.TypeOf(x).Kind() != reflect.Map {
panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name))
}
if _, ok := protoMapTypes[name]; ok {
log.Printf("proto: duplicate proto type registered: %s", name)
return
}
t := reflect.TypeOf(x)
protoMapTypes[name] = t
revProtoTypes[t] = name revProtoTypes[t] = name
} }
@@ -584,14 +954,7 @@ func MessageName(x Message) string {
} }
// MessageType returns the message type (pointer to struct) for a named message. // MessageType returns the message type (pointer to struct) for a named message.
// The type is not guaranteed to implement proto.Message if the name refers to a func MessageType(name string) reflect.Type { return protoTypes[name] }
// map entry.
func MessageType(name string) reflect.Type {
if t, ok := protoTypedNils[name]; ok {
return reflect.TypeOf(t)
}
return protoMapTypes[name]
}
// A registry of all linked proto files. // A registry of all linked proto files.
var ( var (

View File

@@ -1,6 +1,6 @@
// Protocol Buffers for Go with Gadgets // Protocol Buffers for Go with Gadgets
// //
// Copyright (c) 2018, The GoGo Authors. All rights reserved. // Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf // http://github.com/gogo/protobuf
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
@@ -29,8 +29,83 @@
package proto package proto
import ( import (
"fmt"
"os"
"reflect" "reflect"
) )
var sizerType = reflect.TypeOf((*Sizer)(nil)).Elem() func (p *Properties) setCustomEncAndDec(typ reflect.Type) {
var protosizerType = reflect.TypeOf((*ProtoSizer)(nil)).Elem() p.ctype = typ
if p.Repeated {
p.enc = (*Buffer).enc_custom_slice_bytes
p.dec = (*Buffer).dec_custom_slice_bytes
p.size = size_custom_slice_bytes
} else if typ.Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_custom_bytes
p.dec = (*Buffer).dec_custom_bytes
p.size = size_custom_bytes
} else {
p.enc = (*Buffer).enc_custom_ref_bytes
p.dec = (*Buffer).dec_custom_ref_bytes
p.size = size_custom_ref_bytes
}
}
func (p *Properties) setDurationEncAndDec(typ reflect.Type) {
if p.Repeated {
if typ.Elem().Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_slice_duration
p.dec = (*Buffer).dec_slice_duration
p.size = size_slice_duration
} else {
p.enc = (*Buffer).enc_slice_ref_duration
p.dec = (*Buffer).dec_slice_ref_duration
p.size = size_slice_ref_duration
}
} else if typ.Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_duration
p.dec = (*Buffer).dec_duration
p.size = size_duration
} else {
p.enc = (*Buffer).enc_ref_duration
p.dec = (*Buffer).dec_ref_duration
p.size = size_ref_duration
}
}
func (p *Properties) setTimeEncAndDec(typ reflect.Type) {
if p.Repeated {
if typ.Elem().Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_slice_time
p.dec = (*Buffer).dec_slice_time
p.size = size_slice_time
} else {
p.enc = (*Buffer).enc_slice_ref_time
p.dec = (*Buffer).dec_slice_ref_time
p.size = size_slice_ref_time
}
} else if typ.Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_time
p.dec = (*Buffer).dec_time
p.size = size_time
} else {
p.enc = (*Buffer).enc_ref_time
p.dec = (*Buffer).dec_ref_time
p.size = size_ref_time
}
}
func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) {
t2 := typ.Elem()
p.sstype = typ
p.stype = t2
p.isMarshaler = isMarshaler(t2)
p.isUnmarshaler = isUnmarshaler(t2)
p.enc = (*Buffer).enc_slice_ref_struct_message
p.dec = (*Buffer).dec_slice_ref_struct_message
p.size = size_slice_ref_struct_message
if p.Wire != "bytes" {
fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2)
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,388 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"reflect"
"time"
)
// makeMessageRefMarshaler differs a bit from makeMessageMarshaler
// It marshal a message T instead of a *T
func makeMessageRefMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
siz := u.size(ptr)
return siz + SizeVarint(uint64(siz)) + tagsize
},
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
b = appendVarint(b, wiretag)
siz := u.cachedsize(ptr)
b = appendVarint(b, uint64(siz))
return u.marshal(b, ptr, deterministic)
}
}
// makeMessageRefSliceMarshaler differs quite a lot from makeMessageSliceMarshaler
// It marshals a slice of messages []T instead of []*T
func makeMessageRefSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
s := ptr.getSlice(u.typ)
n := 0
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
e := elem.Interface()
v := toAddrPointer(&e, false)
siz := u.size(v)
n += siz + SizeVarint(uint64(siz)) + tagsize
}
return n
},
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
s := ptr.getSlice(u.typ)
var err, errreq error
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
e := elem.Interface()
v := toAddrPointer(&e, false)
b = appendVarint(b, wiretag)
siz := u.size(v)
b = appendVarint(b, uint64(siz))
b, err = u.marshal(b, v, deterministic)
if err != nil {
if _, ok := err.(*RequiredNotSetError); ok {
// Required field in submessage is not set.
// We record the error but keep going, to give a complete marshaling.
if errreq == nil {
errreq = err
}
continue
}
if err == ErrNil {
err = errRepeatedHasNil
}
return b, err
}
}
return b, errreq
}
}
func makeCustomPtrMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
if ptr.isNil() {
return 0
}
m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom)
siz := m.Size()
return tagsize + SizeVarint(uint64(siz)) + siz
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
if ptr.isNil() {
return b, nil
}
m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom)
siz := m.Size()
buf, err := m.Marshal()
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(siz))
b = append(b, buf...)
return b, nil
}
}
func makeCustomMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
m := ptr.asPointerTo(u.typ).Interface().(custom)
siz := m.Size()
return tagsize + SizeVarint(uint64(siz)) + siz
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
m := ptr.asPointerTo(u.typ).Interface().(custom)
siz := m.Size()
buf, err := m.Marshal()
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(siz))
b = append(b, buf...)
return b, nil
}
}
func makeTimeMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
t := ptr.asPointerTo(u.typ).Interface().(*time.Time)
ts, err := timestampProto(*t)
if err != nil {
return 0
}
siz := Size(ts)
return tagsize + SizeVarint(uint64(siz)) + siz
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
t := ptr.asPointerTo(u.typ).Interface().(*time.Time)
ts, err := timestampProto(*t)
if err != nil {
return nil, err
}
buf, err := Marshal(ts)
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(len(buf)))
b = append(b, buf...)
return b, nil
}
}
func makeTimePtrMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
if ptr.isNil() {
return 0
}
t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time)
ts, err := timestampProto(*t)
if err != nil {
return 0
}
siz := Size(ts)
return tagsize + SizeVarint(uint64(siz)) + siz
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
if ptr.isNil() {
return b, nil
}
t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time)
ts, err := timestampProto(*t)
if err != nil {
return nil, err
}
buf, err := Marshal(ts)
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(len(buf)))
b = append(b, buf...)
return b, nil
}
}
func makeTimeSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
s := ptr.getSlice(u.typ)
n := 0
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
t := elem.Interface().(time.Time)
ts, err := timestampProto(t)
if err != nil {
return 0
}
siz := Size(ts)
n += siz + SizeVarint(uint64(siz)) + tagsize
}
return n
},
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
s := ptr.getSlice(u.typ)
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
t := elem.Interface().(time.Time)
ts, err := timestampProto(t)
if err != nil {
return nil, err
}
siz := Size(ts)
buf, err := Marshal(ts)
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(siz))
b = append(b, buf...)
}
return b, nil
}
}
func makeTimePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
s := ptr.getSlice(reflect.PtrTo(u.typ))
n := 0
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
t := elem.Interface().(*time.Time)
ts, err := timestampProto(*t)
if err != nil {
return 0
}
siz := Size(ts)
n += siz + SizeVarint(uint64(siz)) + tagsize
}
return n
},
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
s := ptr.getSlice(reflect.PtrTo(u.typ))
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
t := elem.Interface().(*time.Time)
ts, err := timestampProto(*t)
if err != nil {
return nil, err
}
siz := Size(ts)
buf, err := Marshal(ts)
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(siz))
b = append(b, buf...)
}
return b, nil
}
}
func makeDurationMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
d := ptr.asPointerTo(u.typ).Interface().(*time.Duration)
dur := durationProto(*d)
siz := Size(dur)
return tagsize + SizeVarint(uint64(siz)) + siz
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
d := ptr.asPointerTo(u.typ).Interface().(*time.Duration)
dur := durationProto(*d)
buf, err := Marshal(dur)
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(len(buf)))
b = append(b, buf...)
return b, nil
}
}
func makeDurationPtrMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
if ptr.isNil() {
return 0
}
d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration)
dur := durationProto(*d)
siz := Size(dur)
return tagsize + SizeVarint(uint64(siz)) + siz
}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
if ptr.isNil() {
return b, nil
}
d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration)
dur := durationProto(*d)
buf, err := Marshal(dur)
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(len(buf)))
b = append(b, buf...)
return b, nil
}
}
func makeDurationSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
s := ptr.getSlice(u.typ)
n := 0
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
d := elem.Interface().(time.Duration)
dur := durationProto(d)
siz := Size(dur)
n += siz + SizeVarint(uint64(siz)) + tagsize
}
return n
},
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
s := ptr.getSlice(u.typ)
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
d := elem.Interface().(time.Duration)
dur := durationProto(d)
siz := Size(dur)
buf, err := Marshal(dur)
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(siz))
b = append(b, buf...)
}
return b, nil
}
}
func makeDurationPtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
return func(ptr pointer, tagsize int) int {
s := ptr.getSlice(reflect.PtrTo(u.typ))
n := 0
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
d := elem.Interface().(*time.Duration)
dur := durationProto(*d)
siz := Size(dur)
n += siz + SizeVarint(uint64(siz)) + tagsize
}
return n
},
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
s := ptr.getSlice(reflect.PtrTo(u.typ))
for i := 0; i < s.Len(); i++ {
elem := s.Index(i)
d := elem.Interface().(*time.Duration)
dur := durationProto(*d)
siz := Size(dur)
buf, err := Marshal(dur)
if err != nil {
return nil, err
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(siz))
b = append(b, buf...)
}
return b, nil
}
}

View File

@@ -1,657 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2016 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"reflect"
"strings"
"sync"
"sync/atomic"
)
// Merge merges the src message into dst.
// This assumes that dst and src of the same type and are non-nil.
func (a *InternalMessageInfo) Merge(dst, src Message) {
mi := atomicLoadMergeInfo(&a.merge)
if mi == nil {
mi = getMergeInfo(reflect.TypeOf(dst).Elem())
atomicStoreMergeInfo(&a.merge, mi)
}
mi.merge(toPointer(&dst), toPointer(&src))
}
type mergeInfo struct {
typ reflect.Type
initialized int32 // 0: only typ is valid, 1: everything is valid
lock sync.Mutex
fields []mergeFieldInfo
unrecognized field // Offset of XXX_unrecognized
}
type mergeFieldInfo struct {
field field // Offset of field, guaranteed to be valid
// isPointer reports whether the value in the field is a pointer.
// This is true for the following situations:
// * Pointer to struct
// * Pointer to basic type (proto2 only)
// * Slice (first value in slice header is a pointer)
// * String (first value in string header is a pointer)
isPointer bool
// basicWidth reports the width of the field assuming that it is directly
// embedded in the struct (as is the case for basic types in proto3).
// The possible values are:
// 0: invalid
// 1: bool
// 4: int32, uint32, float32
// 8: int64, uint64, float64
basicWidth int
// Where dst and src are pointers to the types being merged.
merge func(dst, src pointer)
}
var (
mergeInfoMap = map[reflect.Type]*mergeInfo{}
mergeInfoLock sync.Mutex
)
func getMergeInfo(t reflect.Type) *mergeInfo {
mergeInfoLock.Lock()
defer mergeInfoLock.Unlock()
mi := mergeInfoMap[t]
if mi == nil {
mi = &mergeInfo{typ: t}
mergeInfoMap[t] = mi
}
return mi
}
// merge merges src into dst assuming they are both of type *mi.typ.
func (mi *mergeInfo) merge(dst, src pointer) {
if dst.isNil() {
panic("proto: nil destination")
}
if src.isNil() {
return // Nothing to do.
}
if atomic.LoadInt32(&mi.initialized) == 0 {
mi.computeMergeInfo()
}
for _, fi := range mi.fields {
sfp := src.offset(fi.field)
// As an optimization, we can avoid the merge function call cost
// if we know for sure that the source will have no effect
// by checking if it is the zero value.
if unsafeAllowed {
if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string
continue
}
if fi.basicWidth > 0 {
switch {
case fi.basicWidth == 1 && !*sfp.toBool():
continue
case fi.basicWidth == 4 && *sfp.toUint32() == 0:
continue
case fi.basicWidth == 8 && *sfp.toUint64() == 0:
continue
}
}
}
dfp := dst.offset(fi.field)
fi.merge(dfp, sfp)
}
// TODO: Make this faster?
out := dst.asPointerTo(mi.typ).Elem()
in := src.asPointerTo(mi.typ).Elem()
if emIn, err := extendable(in.Addr().Interface()); err == nil {
emOut, _ := extendable(out.Addr().Interface())
mIn, muIn := emIn.extensionsRead()
if mIn != nil {
mOut := emOut.extensionsWrite()
muIn.Lock()
mergeExtension(mOut, mIn)
muIn.Unlock()
}
}
if mi.unrecognized.IsValid() {
if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 {
*dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...)
}
}
}
func (mi *mergeInfo) computeMergeInfo() {
mi.lock.Lock()
defer mi.lock.Unlock()
if mi.initialized != 0 {
return
}
t := mi.typ
n := t.NumField()
props := GetProperties(t)
for i := 0; i < n; i++ {
f := t.Field(i)
if strings.HasPrefix(f.Name, "XXX_") {
continue
}
mfi := mergeFieldInfo{field: toField(&f)}
tf := f.Type
// As an optimization, we can avoid the merge function call cost
// if we know for sure that the source will have no effect
// by checking if it is the zero value.
if unsafeAllowed {
switch tf.Kind() {
case reflect.Ptr, reflect.Slice, reflect.String:
// As a special case, we assume slices and strings are pointers
// since we know that the first field in the SliceSlice or
// StringHeader is a data pointer.
mfi.isPointer = true
case reflect.Bool:
mfi.basicWidth = 1
case reflect.Int32, reflect.Uint32, reflect.Float32:
mfi.basicWidth = 4
case reflect.Int64, reflect.Uint64, reflect.Float64:
mfi.basicWidth = 8
}
}
// Unwrap tf to get at its most basic type.
var isPointer, isSlice bool
if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
isSlice = true
tf = tf.Elem()
}
if tf.Kind() == reflect.Ptr {
isPointer = true
tf = tf.Elem()
}
if isPointer && isSlice && tf.Kind() != reflect.Struct {
panic("both pointer and slice for basic type in " + tf.Name())
}
switch tf.Kind() {
case reflect.Int32:
switch {
case isSlice: // E.g., []int32
mfi.merge = func(dst, src pointer) {
// NOTE: toInt32Slice is not defined (see pointer_reflect.go).
/*
sfsp := src.toInt32Slice()
if *sfsp != nil {
dfsp := dst.toInt32Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []int64{}
}
}
*/
sfs := src.getInt32Slice()
if sfs != nil {
dfs := dst.getInt32Slice()
dfs = append(dfs, sfs...)
if dfs == nil {
dfs = []int32{}
}
dst.setInt32Slice(dfs)
}
}
case isPointer: // E.g., *int32
mfi.merge = func(dst, src pointer) {
// NOTE: toInt32Ptr is not defined (see pointer_reflect.go).
/*
sfpp := src.toInt32Ptr()
if *sfpp != nil {
dfpp := dst.toInt32Ptr()
if *dfpp == nil {
*dfpp = Int32(**sfpp)
} else {
**dfpp = **sfpp
}
}
*/
sfp := src.getInt32Ptr()
if sfp != nil {
dfp := dst.getInt32Ptr()
if dfp == nil {
dst.setInt32Ptr(*sfp)
} else {
*dfp = *sfp
}
}
}
default: // E.g., int32
mfi.merge = func(dst, src pointer) {
if v := *src.toInt32(); v != 0 {
*dst.toInt32() = v
}
}
}
case reflect.Int64:
switch {
case isSlice: // E.g., []int64
mfi.merge = func(dst, src pointer) {
sfsp := src.toInt64Slice()
if *sfsp != nil {
dfsp := dst.toInt64Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []int64{}
}
}
}
case isPointer: // E.g., *int64
mfi.merge = func(dst, src pointer) {
sfpp := src.toInt64Ptr()
if *sfpp != nil {
dfpp := dst.toInt64Ptr()
if *dfpp == nil {
*dfpp = Int64(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., int64
mfi.merge = func(dst, src pointer) {
if v := *src.toInt64(); v != 0 {
*dst.toInt64() = v
}
}
}
case reflect.Uint32:
switch {
case isSlice: // E.g., []uint32
mfi.merge = func(dst, src pointer) {
sfsp := src.toUint32Slice()
if *sfsp != nil {
dfsp := dst.toUint32Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []uint32{}
}
}
}
case isPointer: // E.g., *uint32
mfi.merge = func(dst, src pointer) {
sfpp := src.toUint32Ptr()
if *sfpp != nil {
dfpp := dst.toUint32Ptr()
if *dfpp == nil {
*dfpp = Uint32(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., uint32
mfi.merge = func(dst, src pointer) {
if v := *src.toUint32(); v != 0 {
*dst.toUint32() = v
}
}
}
case reflect.Uint64:
switch {
case isSlice: // E.g., []uint64
mfi.merge = func(dst, src pointer) {
sfsp := src.toUint64Slice()
if *sfsp != nil {
dfsp := dst.toUint64Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []uint64{}
}
}
}
case isPointer: // E.g., *uint64
mfi.merge = func(dst, src pointer) {
sfpp := src.toUint64Ptr()
if *sfpp != nil {
dfpp := dst.toUint64Ptr()
if *dfpp == nil {
*dfpp = Uint64(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., uint64
mfi.merge = func(dst, src pointer) {
if v := *src.toUint64(); v != 0 {
*dst.toUint64() = v
}
}
}
case reflect.Float32:
switch {
case isSlice: // E.g., []float32
mfi.merge = func(dst, src pointer) {
sfsp := src.toFloat32Slice()
if *sfsp != nil {
dfsp := dst.toFloat32Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []float32{}
}
}
}
case isPointer: // E.g., *float32
mfi.merge = func(dst, src pointer) {
sfpp := src.toFloat32Ptr()
if *sfpp != nil {
dfpp := dst.toFloat32Ptr()
if *dfpp == nil {
*dfpp = Float32(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., float32
mfi.merge = func(dst, src pointer) {
if v := *src.toFloat32(); v != 0 {
*dst.toFloat32() = v
}
}
}
case reflect.Float64:
switch {
case isSlice: // E.g., []float64
mfi.merge = func(dst, src pointer) {
sfsp := src.toFloat64Slice()
if *sfsp != nil {
dfsp := dst.toFloat64Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []float64{}
}
}
}
case isPointer: // E.g., *float64
mfi.merge = func(dst, src pointer) {
sfpp := src.toFloat64Ptr()
if *sfpp != nil {
dfpp := dst.toFloat64Ptr()
if *dfpp == nil {
*dfpp = Float64(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., float64
mfi.merge = func(dst, src pointer) {
if v := *src.toFloat64(); v != 0 {
*dst.toFloat64() = v
}
}
}
case reflect.Bool:
switch {
case isSlice: // E.g., []bool
mfi.merge = func(dst, src pointer) {
sfsp := src.toBoolSlice()
if *sfsp != nil {
dfsp := dst.toBoolSlice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []bool{}
}
}
}
case isPointer: // E.g., *bool
mfi.merge = func(dst, src pointer) {
sfpp := src.toBoolPtr()
if *sfpp != nil {
dfpp := dst.toBoolPtr()
if *dfpp == nil {
*dfpp = Bool(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., bool
mfi.merge = func(dst, src pointer) {
if v := *src.toBool(); v {
*dst.toBool() = v
}
}
}
case reflect.String:
switch {
case isSlice: // E.g., []string
mfi.merge = func(dst, src pointer) {
sfsp := src.toStringSlice()
if *sfsp != nil {
dfsp := dst.toStringSlice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []string{}
}
}
}
case isPointer: // E.g., *string
mfi.merge = func(dst, src pointer) {
sfpp := src.toStringPtr()
if *sfpp != nil {
dfpp := dst.toStringPtr()
if *dfpp == nil {
*dfpp = String(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., string
mfi.merge = func(dst, src pointer) {
if v := *src.toString(); v != "" {
*dst.toString() = v
}
}
}
case reflect.Slice:
isProto3 := props.Prop[i].proto3
switch {
case isPointer:
panic("bad pointer in byte slice case in " + tf.Name())
case tf.Elem().Kind() != reflect.Uint8:
panic("bad element kind in byte slice case in " + tf.Name())
case isSlice: // E.g., [][]byte
mfi.merge = func(dst, src pointer) {
sbsp := src.toBytesSlice()
if *sbsp != nil {
dbsp := dst.toBytesSlice()
for _, sb := range *sbsp {
if sb == nil {
*dbsp = append(*dbsp, nil)
} else {
*dbsp = append(*dbsp, append([]byte{}, sb...))
}
}
if *dbsp == nil {
*dbsp = [][]byte{}
}
}
}
default: // E.g., []byte
mfi.merge = func(dst, src pointer) {
sbp := src.toBytes()
if *sbp != nil {
dbp := dst.toBytes()
if !isProto3 || len(*sbp) > 0 {
*dbp = append([]byte{}, *sbp...)
}
}
}
}
case reflect.Struct:
switch {
case !isPointer:
mergeInfo := getMergeInfo(tf)
mfi.merge = func(dst, src pointer) {
mergeInfo.merge(dst, src)
}
case isSlice: // E.g., []*pb.T
mergeInfo := getMergeInfo(tf)
mfi.merge = func(dst, src pointer) {
sps := src.getPointerSlice()
if sps != nil {
dps := dst.getPointerSlice()
for _, sp := range sps {
var dp pointer
if !sp.isNil() {
dp = valToPointer(reflect.New(tf))
mergeInfo.merge(dp, sp)
}
dps = append(dps, dp)
}
if dps == nil {
dps = []pointer{}
}
dst.setPointerSlice(dps)
}
}
default: // E.g., *pb.T
mergeInfo := getMergeInfo(tf)
mfi.merge = func(dst, src pointer) {
sp := src.getPointer()
if !sp.isNil() {
dp := dst.getPointer()
if dp.isNil() {
dp = valToPointer(reflect.New(tf))
dst.setPointer(dp)
}
mergeInfo.merge(dp, sp)
}
}
}
case reflect.Map:
switch {
case isPointer || isSlice:
panic("bad pointer or slice in map case in " + tf.Name())
default: // E.g., map[K]V
mfi.merge = func(dst, src pointer) {
sm := src.asPointerTo(tf).Elem()
if sm.Len() == 0 {
return
}
dm := dst.asPointerTo(tf).Elem()
if dm.IsNil() {
dm.Set(reflect.MakeMap(tf))
}
switch tf.Elem().Kind() {
case reflect.Ptr: // Proto struct (e.g., *T)
for _, key := range sm.MapKeys() {
val := sm.MapIndex(key)
val = reflect.ValueOf(Clone(val.Interface().(Message)))
dm.SetMapIndex(key, val)
}
case reflect.Slice: // E.g. Bytes type (e.g., []byte)
for _, key := range sm.MapKeys() {
val := sm.MapIndex(key)
val = reflect.ValueOf(append([]byte{}, val.Bytes()...))
dm.SetMapIndex(key, val)
}
default: // Basic type (e.g., string)
for _, key := range sm.MapKeys() {
val := sm.MapIndex(key)
dm.SetMapIndex(key, val)
}
}
}
}
case reflect.Interface:
// Must be oneof field.
switch {
case isPointer || isSlice:
panic("bad pointer or slice in interface case in " + tf.Name())
default: // E.g., interface{}
// TODO: Make this faster?
mfi.merge = func(dst, src pointer) {
su := src.asPointerTo(tf).Elem()
if !su.IsNil() {
du := dst.asPointerTo(tf).Elem()
typ := su.Elem().Type()
if du.IsNil() || du.Elem().Type() != typ {
du.Set(reflect.New(typ.Elem())) // Initialize interface if empty
}
sv := su.Elem().Elem().Field(0)
if sv.Kind() == reflect.Ptr && sv.IsNil() {
return
}
dv := du.Elem().Elem().Field(0)
if dv.Kind() == reflect.Ptr && dv.IsNil() {
dv.Set(reflect.New(sv.Type().Elem())) // Initialize proto message if empty
}
switch sv.Type().Kind() {
case reflect.Ptr: // Proto struct (e.g., *T)
Merge(dv.Interface().(Message), sv.Interface().(Message))
case reflect.Slice: // E.g. Bytes type (e.g., []byte)
dv.Set(reflect.ValueOf(append([]byte{}, sv.Bytes()...)))
default: // Basic type (e.g., string)
dv.Set(sv)
}
}
}
}
default:
panic(fmt.Sprintf("merger not found for type:%s", tf))
}
mi.fields = append(mi.fields, mfi)
}
mi.unrecognized = invalidField
if f, ok := t.FieldByName("XXX_unrecognized"); ok {
if f.Type != reflect.TypeOf([]byte{}) {
panic("expected XXX_unrecognized to be of type []byte")
}
mi.unrecognized = toField(&f)
}
atomic.StoreInt32(&mi.initialized, 1)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,385 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"io"
"reflect"
)
func makeUnmarshalMessage(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
// First read the message field to see if something is there.
// The semantics of multiple submessages are weird. Instead of
// the last one winning (as it is for all other fields), multiple
// submessages are merged.
v := f // gogo: changed from v := f.getPointer()
if v.isNil() {
v = valToPointer(reflect.New(sub.typ))
f.setPointer(v)
}
err := sub.unmarshal(v, b[:x])
if err != nil {
if r, ok := err.(*RequiredNotSetError); ok {
r.field = name + "." + r.field
} else {
return nil, err
}
}
return b[x:], err
}
}
func makeUnmarshalMessageSlice(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
v := valToPointer(reflect.New(sub.typ))
err := sub.unmarshal(v, b[:x])
if err != nil {
if r, ok := err.(*RequiredNotSetError); ok {
r.field = name + "." + r.field
} else {
return nil, err
}
}
f.appendRef(v, sub.typ) // gogo: changed from f.appendPointer(v)
return b[x:], err
}
}
func makeUnmarshalCustomPtr(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
s.Set(reflect.New(sub.typ))
m := s.Interface().(custom)
if err := m.Unmarshal(b[:x]); err != nil {
return nil, err
}
return b[x:], nil
}
}
func makeUnmarshalCustomSlice(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := reflect.New(sub.typ)
c := m.Interface().(custom)
if err := c.Unmarshal(b[:x]); err != nil {
return nil, err
}
v := valToPointer(m)
f.appendRef(v, sub.typ)
return b[x:], nil
}
}
func makeUnmarshalCustom(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := f.asPointerTo(sub.typ).Interface().(custom)
if err := m.Unmarshal(b[:x]); err != nil {
return nil, err
}
return b[x:], nil
}
}
func makeUnmarshalTime(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := &timestamp{}
if err := Unmarshal(b[:x], m); err != nil {
return nil, err
}
t, err := timestampFromProto(m)
if err != nil {
return nil, err
}
s := f.asPointerTo(sub.typ).Elem()
s.Set(reflect.ValueOf(t))
return b[x:], nil
}
}
func makeUnmarshalTimePtr(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := &timestamp{}
if err := Unmarshal(b[:x], m); err != nil {
return nil, err
}
t, err := timestampFromProto(m)
if err != nil {
return nil, err
}
s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
s.Set(reflect.ValueOf(&t))
return b[x:], nil
}
}
func makeUnmarshalTimePtrSlice(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := &timestamp{}
if err := Unmarshal(b[:x], m); err != nil {
return nil, err
}
t, err := timestampFromProto(m)
if err != nil {
return nil, err
}
slice := f.getSlice(reflect.PtrTo(sub.typ))
newSlice := reflect.Append(slice, reflect.ValueOf(&t))
slice.Set(newSlice)
return b[x:], nil
}
}
func makeUnmarshalTimeSlice(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := &timestamp{}
if err := Unmarshal(b[:x], m); err != nil {
return nil, err
}
t, err := timestampFromProto(m)
if err != nil {
return nil, err
}
slice := f.getSlice(sub.typ)
newSlice := reflect.Append(slice, reflect.ValueOf(t))
slice.Set(newSlice)
return b[x:], nil
}
}
func makeUnmarshalDurationPtr(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := &duration{}
if err := Unmarshal(b[:x], m); err != nil {
return nil, err
}
d, err := durationFromProto(m)
if err != nil {
return nil, err
}
s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
s.Set(reflect.ValueOf(&d))
return b[x:], nil
}
}
func makeUnmarshalDuration(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := &duration{}
if err := Unmarshal(b[:x], m); err != nil {
return nil, err
}
d, err := durationFromProto(m)
if err != nil {
return nil, err
}
s := f.asPointerTo(sub.typ).Elem()
s.Set(reflect.ValueOf(d))
return b[x:], nil
}
}
func makeUnmarshalDurationPtrSlice(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := &duration{}
if err := Unmarshal(b[:x], m); err != nil {
return nil, err
}
d, err := durationFromProto(m)
if err != nil {
return nil, err
}
slice := f.getSlice(reflect.PtrTo(sub.typ))
newSlice := reflect.Append(slice, reflect.ValueOf(&d))
slice.Set(newSlice)
return b[x:], nil
}
}
func makeUnmarshalDurationSlice(sub *unmarshalInfo, name string) unmarshaler {
return func(b []byte, f pointer, w int) ([]byte, error) {
if w != WireBytes {
return nil, errInternalBadWireType
}
x, n := decodeVarint(b)
if n == 0 {
return nil, io.ErrUnexpectedEOF
}
b = b[n:]
if x > uint64(len(b)) {
return nil, io.ErrUnexpectedEOF
}
m := &duration{}
if err := Unmarshal(b[:x], m); err != nil {
return nil, err
}
d, err := durationFromProto(m)
if err != nil {
return nil, err
}
slice := f.getSlice(sub.typ)
newSlice := reflect.Append(slice, reflect.ValueOf(d))
slice.Set(newSlice)
return b[x:], nil
}
}

View File

@@ -57,6 +57,7 @@ import (
var ( var (
newline = []byte("\n") newline = []byte("\n")
spaces = []byte(" ") spaces = []byte(" ")
gtNewline = []byte(">\n")
endBraceNewline = []byte("}\n") endBraceNewline = []byte("}\n")
backslashN = []byte{'\\', 'n'} backslashN = []byte{'\\', 'n'}
backslashR = []byte{'\\', 'r'} backslashR = []byte{'\\', 'r'}
@@ -176,6 +177,11 @@ func writeName(w *textWriter, props *Properties) error {
return nil return nil
} }
// raw is the interface satisfied by RawMessage.
type raw interface {
Bytes() []byte
}
func requiresQuotes(u string) bool { func requiresQuotes(u string) bool {
// When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted. // When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted.
for _, ch := range u { for _, ch := range u {
@@ -270,10 +276,6 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
props := sprops.Prop[i] props := sprops.Prop[i]
name := st.Field(i).Name name := st.Field(i).Name
if name == "XXX_NoUnkeyedLiteral" {
continue
}
if strings.HasPrefix(name, "XXX_") { if strings.HasPrefix(name, "XXX_") {
// There are two XXX_ fields: // There are two XXX_ fields:
// XXX_unrecognized []byte // XXX_unrecognized []byte
@@ -364,7 +366,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return err return err
} }
} }
if err := tm.writeAny(w, key, props.MapKeyProp); err != nil { if err := tm.writeAny(w, key, props.mkeyprop); err != nil {
return err return err
} }
if err := w.WriteByte('\n'); err != nil { if err := w.WriteByte('\n'); err != nil {
@@ -381,7 +383,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return err return err
} }
} }
if err := tm.writeAny(w, val, props.MapValProp); err != nil { if err := tm.writeAny(w, val, props.mvalprop); err != nil {
return err return err
} }
if err := w.WriteByte('\n'); err != nil { if err := w.WriteByte('\n'); err != nil {
@@ -445,6 +447,12 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return err return err
} }
} }
if b, ok := fv.Interface().(raw); ok {
if err := writeRaw(w, b.Bytes()); err != nil {
return err
}
continue
}
if len(props.Enum) > 0 { if len(props.Enum) > 0 {
if err := tm.writeEnum(w, fv, props); err != nil { if err := tm.writeEnum(w, fv, props); err != nil {
@@ -467,7 +475,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
pv = reflect.New(sv.Type()) pv = reflect.New(sv.Type())
pv.Elem().Set(sv) pv.Elem().Set(sv)
} }
if _, err := extendable(pv.Interface()); err == nil { if pv.Type().Implements(extensionRangeType) {
if err := tm.writeExtensions(w, pv); err != nil { if err := tm.writeExtensions(w, pv); err != nil {
return err return err
} }
@@ -476,6 +484,27 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return nil return nil
} }
// writeRaw writes an uninterpreted raw message.
func writeRaw(w *textWriter, b []byte) error {
if err := w.WriteByte('<'); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte('\n'); err != nil {
return err
}
}
w.indent()
if err := writeUnknownStruct(w, b); err != nil {
return err
}
w.unindent()
if err := w.WriteByte('>'); err != nil {
return err
}
return nil
}
// writeAny writes an arbitrary field. // writeAny writes an arbitrary field.
func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error { func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
v = reflect.Indirect(v) v = reflect.Indirect(v)
@@ -576,19 +605,6 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
} }
} }
w.indent() w.indent()
if v.CanAddr() {
// Calling v.Interface on a struct causes the reflect package to
// copy the entire struct. This is racy with the new Marshaler
// since we atomically update the XXX_sizecache.
//
// Thus, we retrieve a pointer to the struct if possible to avoid
// a race since v.Interface on the pointer doesn't copy the struct.
//
// If v is not addressable, then we are not worried about a race
// since it implies that the binary Marshaler cannot possibly be
// mutating this value.
v = v.Addr()
}
if etm, ok := v.Interface().(encoding.TextMarshaler); ok { if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
text, err := etm.MarshalText() text, err := etm.MarshalText()
if err != nil { if err != nil {
@@ -597,13 +613,8 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
if _, err = w.Write(text); err != nil { if _, err = w.Write(text); err != nil {
return err return err
} }
} else { } else if err := tm.writeStruct(w, v); err != nil {
if v.Kind() == reflect.Ptr { return err
v = v.Elem()
}
if err := tm.writeStruct(w, v); err != nil {
return err
}
} }
w.unindent() w.unindent()
if err := w.WriteByte(ket); err != nil { if err := w.WriteByte(ket); err != nil {

View File

@@ -212,6 +212,7 @@ func (p *textParser) advance() {
var ( var (
errBadUTF8 = errors.New("proto: bad UTF-8") errBadUTF8 = errors.New("proto: bad UTF-8")
errBadHex = errors.New("proto: bad hexadecimal")
) )
func unquoteC(s string, quote rune) (string, error) { func unquoteC(s string, quote rune) (string, error) {
@@ -282,47 +283,60 @@ func unescape(s string) (ch string, tail string, err error) {
return "?", s, nil // trigraph workaround return "?", s, nil // trigraph workaround
case '\'', '"', '\\': case '\'', '"', '\\':
return string(r), s, nil return string(r), s, nil
case '0', '1', '2', '3', '4', '5', '6', '7': case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X':
if len(s) < 2 { if len(s) < 2 {
return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) return "", "", fmt.Errorf(`\%c requires 2 following digits`, r)
} }
ss := string(r) + s[:2] base := 8
ss := s[:2]
s = s[2:] s = s[2:]
i, err := strconv.ParseUint(ss, 8, 8) if r == 'x' || r == 'X' {
base = 16
} else {
ss = string(r) + ss
}
i, err := strconv.ParseUint(ss, base, 8)
if err != nil { if err != nil {
return "", "", fmt.Errorf(`\%s contains non-octal digits`, ss) return "", "", err
} }
return string([]byte{byte(i)}), s, nil return string([]byte{byte(i)}), s, nil
case 'x', 'X', 'u', 'U': case 'u', 'U':
var n int n := 4
switch r { if r == 'U' {
case 'x', 'X':
n = 2
case 'u':
n = 4
case 'U':
n = 8 n = 8
} }
if len(s) < n { if len(s) < n {
return "", "", fmt.Errorf(`\%c requires %d following digits`, r, n) return "", "", fmt.Errorf(`\%c requires %d digits`, r, n)
}
bs := make([]byte, n/2)
for i := 0; i < n; i += 2 {
a, ok1 := unhex(s[i])
b, ok2 := unhex(s[i+1])
if !ok1 || !ok2 {
return "", "", errBadHex
}
bs[i/2] = a<<4 | b
} }
ss := s[:n]
s = s[n:] s = s[n:]
i, err := strconv.ParseUint(ss, 16, 64) return string(bs), s, nil
if err != nil {
return "", "", fmt.Errorf(`\%c%s contains non-hexadecimal digits`, r, ss)
}
if r == 'x' || r == 'X' {
return string([]byte{byte(i)}), s, nil
}
if i > utf8.MaxRune {
return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss)
}
return string(i), s, nil
} }
return "", "", fmt.Errorf(`unknown escape \%c`, r) return "", "", fmt.Errorf(`unknown escape \%c`, r)
} }
// Adapted from src/pkg/strconv/quote.go.
func unhex(b byte) (v byte, ok bool) {
switch {
case '0' <= b && b <= '9':
return b - '0', true
case 'a' <= b && b <= 'f':
return b - 'a' + 10, true
case 'A' <= b && b <= 'F':
return b - 'A' + 10, true
}
return 0, false
}
// Back off the parser by one token. Can only be done between calls to next(). // Back off the parser by one token. Can only be done between calls to next().
// It makes the next advance() a no-op. // It makes the next advance() a no-op.
func (p *textParser) back() { p.backed = true } func (p *textParser) back() { p.backed = true }
@@ -636,17 +650,17 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
if err := p.consumeToken(":"); err != nil { if err := p.consumeToken(":"); err != nil {
return err return err
} }
if err := p.readAny(key, props.MapKeyProp); err != nil { if err := p.readAny(key, props.mkeyprop); err != nil {
return err return err
} }
if err := p.consumeOptionalSeparator(); err != nil { if err := p.consumeOptionalSeparator(); err != nil {
return err return err
} }
case "value": case "value":
if err := p.checkForColon(props.MapValProp, dst.Type().Elem()); err != nil { if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil {
return err return err
} }
if err := p.readAny(val, props.MapValProp); err != nil { if err := p.readAny(val, props.mvalprop); err != nil {
return err return err
} }
if err := p.consumeOptionalSeparator(); err != nil { if err := p.consumeOptionalSeparator(); err != nil {
@@ -720,9 +734,6 @@ func (p *textParser) consumeExtName() (string, error) {
if tok.err != nil { if tok.err != nil {
return "", p.errorf("unrecognized type_url or extension name: %s", tok.err) return "", p.errorf("unrecognized type_url or extension name: %s", tok.err)
} }
if p.done && tok.value != "]" {
return "", p.errorf("unclosed type_url or extension name")
}
} }
return strings.Join(parts, ""), nil return strings.Join(parts, ""), nil
} }
@@ -923,16 +934,6 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
fv.SetFloat(f) fv.SetFloat(f)
return nil return nil
} }
case reflect.Int8:
if x, err := strconv.ParseInt(tok.value, 0, 8); err == nil {
fv.SetInt(x)
return nil
}
case reflect.Int16:
if x, err := strconv.ParseInt(tok.value, 0, 16); err == nil {
fv.SetInt(x)
return nil
}
case reflect.Int32: case reflect.Int32:
if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil { if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil {
fv.SetInt(x) fv.SetInt(x)
@@ -980,19 +981,9 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
} }
// TODO: Handle nested messages which implement encoding.TextUnmarshaler. // TODO: Handle nested messages which implement encoding.TextUnmarshaler.
return p.readStruct(fv, terminator) return p.readStruct(fv, terminator)
case reflect.Uint8:
if x, err := strconv.ParseUint(tok.value, 0, 8); err == nil {
fv.SetUint(x)
return nil
}
case reflect.Uint16:
if x, err := strconv.ParseUint(tok.value, 0, 16); err == nil {
fv.SetUint(x)
return nil
}
case reflect.Uint32: case reflect.Uint32:
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
fv.SetUint(uint64(x)) fv.SetUint(x)
return nil return nil
} }
case reflect.Uint64: case reflect.Uint64:
@@ -1010,9 +1001,13 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
// UnmarshalText returns *RequiredNotSetError. // UnmarshalText returns *RequiredNotSetError.
func UnmarshalText(s string, pb Message) error { func UnmarshalText(s string, pb Message) error {
if um, ok := pb.(encoding.TextUnmarshaler); ok { if um, ok := pb.(encoding.TextUnmarshaler); ok {
return um.UnmarshalText([]byte(s)) err := um.UnmarshalText([]byte(s))
return err
} }
pb.Reset() pb.Reset()
v := reflect.ValueOf(pb) v := reflect.ValueOf(pb)
return newTextParser(s).readStruct(v.Elem(), "") if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil {
return pe
}
return nil
} }

View File

@@ -47,3 +47,183 @@ func (*timestamp) String() string { return "timestamp<string>" }
func init() { func init() {
RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp") RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp")
} }
func (o *Buffer) decTimestamp() (time.Time, error) {
b, err := o.DecodeRawBytes(true)
if err != nil {
return time.Time{}, err
}
tproto := &timestamp{}
if err := Unmarshal(b, tproto); err != nil {
return time.Time{}, err
}
return timestampFromProto(tproto)
}
func (o *Buffer) dec_time(p *Properties, base structPointer) error {
t, err := o.decTimestamp()
if err != nil {
return err
}
setPtrCustomType(base, p.field, &t)
return nil
}
func (o *Buffer) dec_ref_time(p *Properties, base structPointer) error {
t, err := o.decTimestamp()
if err != nil {
return err
}
setCustomType(base, p.field, &t)
return nil
}
func (o *Buffer) dec_slice_time(p *Properties, base structPointer) error {
t, err := o.decTimestamp()
if err != nil {
return err
}
newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType)))
var zero field
setPtrCustomType(newBas, zero, &t)
return nil
}
func (o *Buffer) dec_slice_ref_time(p *Properties, base structPointer) error {
t, err := o.decTimestamp()
if err != nil {
return err
}
newBas := appendStructPointer(base, p.field, reflect.SliceOf(timeType))
var zero field
setCustomType(newBas, zero, &t)
return nil
}
func size_time(p *Properties, base structPointer) (n int) {
structp := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return 0
}
tim := structPointer_Interface(structp, timeType).(*time.Time)
t, err := timestampProto(*tim)
if err != nil {
return 0
}
size := Size(t)
return size + sizeVarint(uint64(size)) + len(p.tagcode)
}
func (o *Buffer) enc_time(p *Properties, base structPointer) error {
structp := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return ErrNil
}
tim := structPointer_Interface(structp, timeType).(*time.Time)
t, err := timestampProto(*tim)
if err != nil {
return err
}
data, err := Marshal(t)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_ref_time(p *Properties, base structPointer) (n int) {
tim := structPointer_InterfaceAt(base, p.field, timeType).(*time.Time)
t, err := timestampProto(*tim)
if err != nil {
return 0
}
size := Size(t)
return size + sizeVarint(uint64(size)) + len(p.tagcode)
}
func (o *Buffer) enc_ref_time(p *Properties, base structPointer) error {
tim := structPointer_InterfaceAt(base, p.field, timeType).(*time.Time)
t, err := timestampProto(*tim)
if err != nil {
return err
}
data, err := Marshal(t)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_slice_time(p *Properties, base structPointer) (n int) {
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType))).(*[]*time.Time)
tims := *ptims
for i := 0; i < len(tims); i++ {
if tims[i] == nil {
return 0
}
tproto, err := timestampProto(*tims[i])
if err != nil {
return 0
}
size := Size(tproto)
n += len(p.tagcode) + size + sizeVarint(uint64(size))
}
return n
}
func (o *Buffer) enc_slice_time(p *Properties, base structPointer) error {
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType))).(*[]*time.Time)
tims := *ptims
for i := 0; i < len(tims); i++ {
if tims[i] == nil {
return errRepeatedHasNil
}
tproto, err := timestampProto(*tims[i])
if err != nil {
return err
}
data, err := Marshal(tproto)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}
func size_slice_ref_time(p *Properties, base structPointer) (n int) {
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(timeType)).(*[]time.Time)
tims := *ptims
for i := 0; i < len(tims); i++ {
tproto, err := timestampProto(tims[i])
if err != nil {
return 0
}
size := Size(tproto)
n += len(p.tagcode) + size + sizeVarint(uint64(size))
}
return n
}
func (o *Buffer) enc_slice_ref_time(p *Properties, base structPointer) error {
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(timeType)).(*[]time.Time)
tims := *ptims
for i := 0; i < len(tims); i++ {
tproto, err := timestampProto(tims[i])
if err != nil {
return err
}
data, err := Marshal(tproto)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,113 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
type float64Value struct {
Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *float64Value) Reset() { *m = float64Value{} }
func (*float64Value) ProtoMessage() {}
func (*float64Value) String() string { return "float64<string>" }
type float32Value struct {
Value float32 `protobuf:"fixed32,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *float32Value) Reset() { *m = float32Value{} }
func (*float32Value) ProtoMessage() {}
func (*float32Value) String() string { return "float32<string>" }
type int64Value struct {
Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *int64Value) Reset() { *m = int64Value{} }
func (*int64Value) ProtoMessage() {}
func (*int64Value) String() string { return "int64<string>" }
type uint64Value struct {
Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *uint64Value) Reset() { *m = uint64Value{} }
func (*uint64Value) ProtoMessage() {}
func (*uint64Value) String() string { return "uint64<string>" }
type int32Value struct {
Value int32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *int32Value) Reset() { *m = int32Value{} }
func (*int32Value) ProtoMessage() {}
func (*int32Value) String() string { return "int32<string>" }
type uint32Value struct {
Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *uint32Value) Reset() { *m = uint32Value{} }
func (*uint32Value) ProtoMessage() {}
func (*uint32Value) String() string { return "uint32<string>" }
type boolValue struct {
Value bool `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *boolValue) Reset() { *m = boolValue{} }
func (*boolValue) ProtoMessage() {}
func (*boolValue) String() string { return "bool<string>" }
type stringValue struct {
Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *stringValue) Reset() { *m = stringValue{} }
func (*stringValue) ProtoMessage() {}
func (*stringValue) String() string { return "string<string>" }
type bytesValue struct {
Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *bytesValue) Reset() { *m = bytesValue{} }
func (*bytesValue) ProtoMessage() {}
func (*bytesValue) String() string { return "[]byte<string>" }
func init() {
RegisterType((*float64Value)(nil), "gogo.protobuf.proto.DoubleValue")
RegisterType((*float32Value)(nil), "gogo.protobuf.proto.FloatValue")
RegisterType((*int64Value)(nil), "gogo.protobuf.proto.Int64Value")
RegisterType((*uint64Value)(nil), "gogo.protobuf.proto.UInt64Value")
RegisterType((*int32Value)(nil), "gogo.protobuf.proto.Int32Value")
RegisterType((*uint32Value)(nil), "gogo.protobuf.proto.UInt32Value")
RegisterType((*boolValue)(nil), "gogo.protobuf.proto.BoolValue")
RegisterType((*stringValue)(nil), "gogo.protobuf.proto.StringValue")
RegisterType((*bytesValue)(nil), "gogo.protobuf.proto.BytesValue")
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,35 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: descriptor.proto // source: descriptor.proto
/*
Package descriptor is a generated protocol buffer package.
It is generated from these files:
descriptor.proto
It has these top-level messages:
FileDescriptorSet
FileDescriptorProto
DescriptorProto
ExtensionRangeOptions
FieldDescriptorProto
OneofDescriptorProto
EnumDescriptorProto
EnumValueDescriptorProto
ServiceDescriptorProto
MethodDescriptorProto
FileOptions
MessageOptions
FieldOptions
OneofOptions
EnumOptions
EnumValueOptions
ServiceOptions
MethodOptions
UninterpretedOption
SourceCodeInfo
GeneratedCodeInfo
*/
package descriptor package descriptor
import fmt "fmt" import fmt "fmt"
@@ -241,7 +270,7 @@ func (this *EnumDescriptorProto) GoString() string {
if this == nil { if this == nil {
return "nil" return "nil"
} }
s := make([]string, 0, 9) s := make([]string, 0, 7)
s = append(s, "&descriptor.EnumDescriptorProto{") s = append(s, "&descriptor.EnumDescriptorProto{")
if this.Name != nil { if this.Name != nil {
s = append(s, "Name: "+valueToGoStringDescriptor(this.Name, "string")+",\n") s = append(s, "Name: "+valueToGoStringDescriptor(this.Name, "string")+",\n")
@@ -252,30 +281,6 @@ func (this *EnumDescriptorProto) GoString() string {
if this.Options != nil { if this.Options != nil {
s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n")
} }
if this.ReservedRange != nil {
s = append(s, "ReservedRange: "+fmt.Sprintf("%#v", this.ReservedRange)+",\n")
}
if this.ReservedName != nil {
s = append(s, "ReservedName: "+fmt.Sprintf("%#v", this.ReservedName)+",\n")
}
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func (this *EnumDescriptorProto_EnumReservedRange) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 6)
s = append(s, "&descriptor.EnumDescriptorProto_EnumReservedRange{")
if this.Start != nil {
s = append(s, "Start: "+valueToGoStringDescriptor(this.Start, "int32")+",\n")
}
if this.End != nil {
s = append(s, "End: "+valueToGoStringDescriptor(this.End, "int32")+",\n")
}
if this.XXX_unrecognized != nil { if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
} }

View File

@@ -129,12 +129,10 @@ func UnmarshalAny(any *Any, pb proto.Message) error {
// Is returns true if any value contains a given message type. // Is returns true if any value contains a given message type.
func Is(any *Any, pb proto.Message) bool { func Is(any *Any, pb proto.Message) bool {
// The following is equivalent to AnyMessageName(any) == proto.MessageName(pb), aname, err := AnyMessageName(any)
// but it avoids scanning TypeUrl for the slash. if err != nil {
if any == nil {
return false return false
} }
name := proto.MessageName(pb)
prefix := len(any.TypeUrl) - len(name) return aname == proto.MessageName(pb)
return prefix >= 1 && any.TypeUrl[prefix-1] == '/' && any.TypeUrl[prefix:] == name
} }

View File

@@ -1,6 +1,15 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: google/protobuf/any.proto // source: any.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
any.proto
It has these top-level messages:
Any
*/
package types package types
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
@@ -106,18 +115,17 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// } // }
// //
type Any struct { type Any struct {
// A URL/resource name that uniquely identifies the type of the serialized // A URL/resource name whose content describes the type of the
// protocol buffer message. The last segment of the URL's path must represent // serialized protocol buffer message.
// the fully qualified name of the type (as in
// `path/google.protobuf.Duration`). The name should be in a canonical form
// (e.g., leading "." is not accepted).
// //
// In practice, teams usually precompile into the binary all types that they // For URLs which use the scheme `http`, `https`, or no scheme, the
// expect it to use in the context of Any. However, for URLs which use the // following restrictions and interpretations apply:
// scheme `http`, `https`, or no scheme, one can optionally set up a type
// server that maps type URLs to message definitions as follows:
// //
// * If no scheme is provided, `https` is assumed. // * If no scheme is provided, `https` is assumed.
// * The last segment of the URL's path must represent the fully
// qualified name of the type (as in `path/google.protobuf.Duration`).
// The name should be in a canonical form (e.g., leading "." is
// not accepted).
// * An HTTP GET on the URL must yield a [google.protobuf.Type][] // * An HTTP GET on the URL must yield a [google.protobuf.Type][]
// value in binary format, or produce an error. // value in binary format, or produce an error.
// * Applications are allowed to cache lookup results based on the // * Applications are allowed to cache lookup results based on the
@@ -126,53 +134,18 @@ type Any struct {
// on changes to types. (Use versioned type names to manage // on changes to types. (Use versioned type names to manage
// breaking changes.) // breaking changes.)
// //
// Note: this functionality is not currently available in the official
// protobuf release, and it is not used for type URLs beginning with
// type.googleapis.com.
//
// Schemes other than `http`, `https` (or the empty scheme) might be // Schemes other than `http`, `https` (or the empty scheme) might be
// used with implementation specific semantics. // used with implementation specific semantics.
// //
TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"` TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"`
// Must be a valid serialized protocol buffer of the above specified type. // Must be a valid serialized protocol buffer of the above specified type.
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Any) Reset() { *m = Any{} } func (m *Any) Reset() { *m = Any{} }
func (*Any) ProtoMessage() {} func (*Any) ProtoMessage() {}
func (*Any) Descriptor() ([]byte, []int) { func (*Any) Descriptor() ([]byte, []int) { return fileDescriptorAny, []int{0} }
return fileDescriptor_any_f098d1a3c592d16a, []int{0} func (*Any) XXX_WellKnownType() string { return "Any" }
}
func (*Any) XXX_WellKnownType() string { return "Any" }
func (m *Any) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Any) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Any.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *Any) XXX_Merge(src proto.Message) {
xxx_messageInfo_Any.Merge(dst, src)
}
func (m *Any) XXX_Size() int {
return m.Size()
}
func (m *Any) XXX_DiscardUnknown() {
xxx_messageInfo_Any.DiscardUnknown(m)
}
var xxx_messageInfo_Any proto.InternalMessageInfo
func (m *Any) GetTypeUrl() string { func (m *Any) GetTypeUrl() string {
if m != nil { if m != nil {
@@ -188,9 +161,6 @@ func (m *Any) GetValue() []byte {
return nil return nil
} }
func (*Any) XXX_MessageName() string {
return "google.protobuf.Any"
}
func init() { func init() {
proto.RegisterType((*Any)(nil), "google.protobuf.Any") proto.RegisterType((*Any)(nil), "google.protobuf.Any")
} }
@@ -228,14 +198,14 @@ func (this *Any) Compare(that interface{}) int {
if c := bytes.Compare(this.Value, that1.Value); c != 0 { if c := bytes.Compare(this.Value, that1.Value); c != 0 {
return c return c
} }
if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
return c
}
return 0 return 0
} }
func (this *Any) Equal(that interface{}) bool { func (this *Any) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Any) that1, ok := that.(*Any)
@@ -248,7 +218,10 @@ func (this *Any) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -258,9 +231,6 @@ func (this *Any) Equal(that interface{}) bool {
if !bytes.Equal(this.Value, that1.Value) { if !bytes.Equal(this.Value, that1.Value) {
return false return false
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *Any) GoString() string { func (this *Any) GoString() string {
@@ -271,9 +241,6 @@ func (this *Any) GoString() string {
s = append(s, "&types.Any{") s = append(s, "&types.Any{")
s = append(s, "TypeUrl: "+fmt.Sprintf("%#v", this.TypeUrl)+",\n") s = append(s, "TypeUrl: "+fmt.Sprintf("%#v", this.TypeUrl)+",\n")
s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n")
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}") s = append(s, "}")
return strings.Join(s, "") return strings.Join(s, "")
} }
@@ -312,9 +279,6 @@ func (m *Any) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintAny(dAtA, i, uint64(len(m.Value))) i = encodeVarintAny(dAtA, i, uint64(len(m.Value)))
i += copy(dAtA[i:], m.Value) i += copy(dAtA[i:], m.Value)
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -336,7 +300,6 @@ func NewPopulatedAny(r randyAny, easy bool) *Any {
this.Value[i] = byte(r.Intn(256)) this.Value[i] = byte(r.Intn(256))
} }
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedAny(r, 3)
} }
return this return this
} }
@@ -414,9 +377,6 @@ func encodeVarintPopulateAny(dAtA []byte, v uint64) []byte {
return dAtA return dAtA
} }
func (m *Any) Size() (n int) { func (m *Any) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.TypeUrl) l = len(m.TypeUrl)
@@ -427,9 +387,6 @@ func (m *Any) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovAny(uint64(l)) n += 1 + l + sovAny(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -453,7 +410,6 @@ func (this *Any) String() string {
s := strings.Join([]string{`&Any{`, s := strings.Join([]string{`&Any{`,
`TypeUrl:` + fmt.Sprintf("%v", this.TypeUrl) + `,`, `TypeUrl:` + fmt.Sprintf("%v", this.TypeUrl) + `,`,
`Value:` + fmt.Sprintf("%v", this.Value) + `,`, `Value:` + fmt.Sprintf("%v", this.Value) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -567,7 +523,6 @@ func (m *Any) Unmarshal(dAtA []byte) error {
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -682,22 +637,21 @@ var (
ErrIntOverflowAny = fmt.Errorf("proto: integer overflow") ErrIntOverflowAny = fmt.Errorf("proto: integer overflow")
) )
func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor_any_f098d1a3c592d16a) } func init() { proto.RegisterFile("any.proto", fileDescriptorAny) }
var fileDescriptor_any_f098d1a3c592d16a = []byte{ var fileDescriptorAny = []byte{
// 211 bytes of a gzipped FileDescriptorProto // 204 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcf, 0xcf, 0x4f, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0xcc, 0xab, 0xd4,
0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcc, 0xab, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4f, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0x85, 0xf0, 0x92,
0x03, 0x73, 0x84, 0xf8, 0x21, 0x52, 0x7a, 0x30, 0x29, 0x25, 0x33, 0x2e, 0x66, 0xc7, 0xbc, 0x4a, 0x4a, 0xd3, 0x94, 0xcc, 0xb8, 0x98, 0x1d, 0xf3, 0x2a, 0x85, 0x24, 0xb9, 0x38, 0x4a, 0x2a, 0x0b,
0x21, 0x49, 0x2e, 0x8e, 0x92, 0xca, 0x82, 0xd4, 0xf8, 0xd2, 0xa2, 0x1c, 0x09, 0x46, 0x05, 0x46, 0x52, 0xe3, 0x4b, 0x8b, 0x72, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xd8, 0x41, 0xfc, 0xd0,
0x0d, 0xce, 0x20, 0x76, 0x10, 0x3f, 0xb4, 0x28, 0x47, 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0xa2, 0x1c, 0x21, 0x11, 0x2e, 0xd6, 0xb2, 0xc4, 0x9c, 0xd2, 0x54, 0x09, 0x26, 0x05, 0x46, 0x0d,
0x34, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc2, 0x71, 0xaa, 0xbf, 0xf1, 0x50, 0x8e, 0x9e, 0x20, 0x08, 0xc7, 0xa9, 0xfe, 0xc2, 0x43, 0x39, 0x86, 0x1b, 0x0f, 0xe5, 0x18, 0x3e, 0x3c,
0xe1, 0xc3, 0x43, 0x39, 0xc6, 0x1f, 0x0f, 0xe5, 0x18, 0x1b, 0x1e, 0xc9, 0x31, 0xae, 0x78, 0x24, 0x94, 0x63, 0xfc, 0xf1, 0x50, 0x8e, 0xb1, 0xe1, 0x91, 0x1c, 0xe3, 0x8a, 0x47, 0x72, 0x8c, 0x27,
0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0xbe, 0x78, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x8b, 0x47, 0x72, 0x0c,
0x24, 0xc7, 0xf0, 0x01, 0x24, 0xfe, 0x58, 0x8e, 0xf1, 0xc4, 0x63, 0x39, 0x46, 0x2e, 0xe1, 0xe4, 0x1f, 0x40, 0xe2, 0x8f, 0xe5, 0x18, 0xb9, 0x84, 0x93, 0xf3, 0x73, 0xf5, 0xd0, 0xac, 0x77, 0xe2,
0xfc, 0x5c, 0x3d, 0x34, 0xeb, 0x9d, 0x38, 0x1c, 0xf3, 0x2a, 0x03, 0x40, 0x9c, 0x00, 0xc6, 0x28, 0x70, 0xcc, 0xab, 0x0c, 0x00, 0x71, 0x02, 0x18, 0xa3, 0x58, 0x41, 0x36, 0x16, 0x2f, 0x62, 0x62,
0x56, 0x90, 0x8d, 0xc5, 0x8b, 0x98, 0x98, 0xdd, 0x03, 0x9c, 0x56, 0x31, 0xc9, 0xb9, 0x43, 0x94, 0x76, 0x0f, 0x70, 0x5a, 0xc5, 0x24, 0xe7, 0x0e, 0x51, 0x1a, 0x00, 0x55, 0xaa, 0x17, 0x9e, 0x9a,
0x06, 0x40, 0x95, 0xea, 0x85, 0xa7, 0xe6, 0xe4, 0x78, 0xe7, 0xe5, 0x97, 0xe7, 0x85, 0x80, 0x94, 0x93, 0xe3, 0x9d, 0x97, 0x5f, 0x9e, 0x17, 0x02, 0x52, 0x96, 0xc4, 0x06, 0x36, 0xc3, 0x18, 0x10,
0x25, 0xb1, 0x81, 0xcd, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x81, 0x82, 0xd3, 0xed, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x39, 0x2f, 0x89, 0xdd, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,21 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: google/protobuf/duration.proto // source: duration.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
duration.proto
It has these top-level messages:
Duration
*/
package types package types
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
import fmt "fmt" import fmt "fmt"
import math "math" import math "math"
import bytes "bytes"
import strings "strings" import strings "strings"
import reflect "reflect" import reflect "reflect"
@@ -96,44 +103,13 @@ type Duration struct {
// of one second or more, a non-zero value for the `nanos` field must be // of one second or more, a non-zero value for the `nanos` field must be
// of the same sign as the `seconds` field. Must be from -999,999,999 // of the same sign as the `seconds` field. Must be from -999,999,999
// to +999,999,999 inclusive. // to +999,999,999 inclusive.
Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Duration) Reset() { *m = Duration{} } func (m *Duration) Reset() { *m = Duration{} }
func (*Duration) ProtoMessage() {} func (*Duration) ProtoMessage() {}
func (*Duration) Descriptor() ([]byte, []int) { func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptorDuration, []int{0} }
return fileDescriptor_duration_187e4d5f80a83848, []int{0} func (*Duration) XXX_WellKnownType() string { return "Duration" }
}
func (*Duration) XXX_WellKnownType() string { return "Duration" }
func (m *Duration) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Duration.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *Duration) XXX_Merge(src proto.Message) {
xxx_messageInfo_Duration.Merge(dst, src)
}
func (m *Duration) XXX_Size() int {
return m.Size()
}
func (m *Duration) XXX_DiscardUnknown() {
xxx_messageInfo_Duration.DiscardUnknown(m)
}
var xxx_messageInfo_Duration proto.InternalMessageInfo
func (m *Duration) GetSeconds() int64 { func (m *Duration) GetSeconds() int64 {
if m != nil { if m != nil {
@@ -149,9 +125,6 @@ func (m *Duration) GetNanos() int32 {
return 0 return 0
} }
func (*Duration) XXX_MessageName() string {
return "google.protobuf.Duration"
}
func init() { func init() {
proto.RegisterType((*Duration)(nil), "google.protobuf.Duration") proto.RegisterType((*Duration)(nil), "google.protobuf.Duration")
} }
@@ -192,14 +165,14 @@ func (this *Duration) Compare(that interface{}) int {
} }
return 1 return 1
} }
if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
return c
}
return 0 return 0
} }
func (this *Duration) Equal(that interface{}) bool { func (this *Duration) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Duration) that1, ok := that.(*Duration)
@@ -212,7 +185,10 @@ func (this *Duration) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -222,9 +198,6 @@ func (this *Duration) Equal(that interface{}) bool {
if this.Nanos != that1.Nanos { if this.Nanos != that1.Nanos {
return false return false
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *Duration) GoString() string { func (this *Duration) GoString() string {
@@ -235,9 +208,6 @@ func (this *Duration) GoString() string {
s = append(s, "&types.Duration{") s = append(s, "&types.Duration{")
s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n") s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n")
s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n") s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n")
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}") s = append(s, "}")
return strings.Join(s, "") return strings.Join(s, "")
} }
@@ -274,9 +244,6 @@ func (m *Duration) MarshalTo(dAtA []byte) (int, error) {
i++ i++
i = encodeVarintDuration(dAtA, i, uint64(m.Nanos)) i = encodeVarintDuration(dAtA, i, uint64(m.Nanos))
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -290,9 +257,6 @@ func encodeVarintDuration(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *Duration) Size() (n int) { func (m *Duration) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if m.Seconds != 0 { if m.Seconds != 0 {
@@ -301,9 +265,6 @@ func (m *Duration) Size() (n int) {
if m.Nanos != 0 { if m.Nanos != 0 {
n += 1 + sovDuration(uint64(m.Nanos)) n += 1 + sovDuration(uint64(m.Nanos))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -399,7 +360,6 @@ func (m *Duration) Unmarshal(dAtA []byte) error {
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -514,24 +474,21 @@ var (
ErrIntOverflowDuration = fmt.Errorf("proto: integer overflow") ErrIntOverflowDuration = fmt.Errorf("proto: integer overflow")
) )
func init() { func init() { proto.RegisterFile("duration.proto", fileDescriptorDuration) }
proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_duration_187e4d5f80a83848)
}
var fileDescriptor_duration_187e4d5f80a83848 = []byte{ var fileDescriptorDuration = []byte{
// 209 bytes of a gzipped FileDescriptorProto // 203 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0x29, 0x2d, 0x4a,
0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4f, 0xcf, 0xcf, 0x4f,
0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0x56, 0xcf, 0x49, 0x85, 0xf0, 0x92, 0x4a, 0xd3, 0x94, 0xac, 0xb8, 0x38, 0x5c, 0xa0, 0x4a, 0x84, 0x24,
0x5c, 0x1c, 0x2e, 0x50, 0x25, 0x42, 0x12, 0x5c, 0xec, 0xc5, 0xa9, 0xc9, 0xf9, 0x79, 0x29, 0xc5, 0xb8, 0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83,
0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x30, 0xae, 0x90, 0x08, 0x17, 0x6b, 0x5e, 0x62, 0x5e, 0x60, 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d,
0x7e, 0xb1, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x6b, 0x10, 0x84, 0xe3, 0x54, 0x7f, 0xe3, 0xa1, 0x1c, 0xd6, 0x20, 0x08, 0xc7, 0xa9, 0xfe, 0xc2, 0x43, 0x39, 0x86, 0x1b, 0x0f, 0xe5, 0x18, 0x3e, 0x3c,
0xc3, 0x87, 0x87, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x94, 0x63, 0x5c, 0xf1, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f,
0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x2f, 0x1e, 0xc9, 0x31, 0x7c, 0x78, 0x24, 0xc7, 0xb8, 0xe2, 0x3c, 0x92, 0x63, 0x7c, 0xf1, 0x48, 0x8e, 0xe1, 0xc3, 0x23, 0x39, 0xc6, 0x15, 0x8f, 0xe5, 0x18,
0xb1, 0x1c, 0xe3, 0x89, 0xc7, 0x72, 0x8c, 0x5c, 0xc2, 0xc9, 0xf9, 0xb9, 0x7a, 0x68, 0x56, 0x3b, 0xb9, 0x84, 0x93, 0xf3, 0x73, 0xf5, 0xd0, 0xac, 0x76, 0xe2, 0x85, 0x59, 0x1c, 0x00, 0x12, 0x09,
0xf1, 0xc2, 0x2c, 0x0e, 0x00, 0x89, 0x04, 0x30, 0x46, 0xb1, 0x96, 0x54, 0x16, 0xa4, 0x16, 0xff, 0x60, 0x8c, 0x62, 0x2d, 0xa9, 0x2c, 0x48, 0x2d, 0xfe, 0xc1, 0xc8, 0xb8, 0x88, 0x89, 0xd9, 0x3d,
0x60, 0x64, 0x5c, 0xc4, 0xc4, 0xec, 0x1e, 0xe0, 0xb4, 0x8a, 0x49, 0xce, 0x1d, 0xa2, 0x25, 0x00, 0xc0, 0x69, 0x15, 0x93, 0x9c, 0x3b, 0x44, 0x4b, 0x00, 0x54, 0x8b, 0x5e, 0x78, 0x6a, 0x4e, 0x8e,
0xaa, 0x45, 0x2f, 0x3c, 0x35, 0x27, 0xc7, 0x3b, 0x2f, 0xbf, 0x3c, 0x2f, 0x04, 0xa4, 0x32, 0x89, 0x77, 0x5e, 0x7e, 0x79, 0x5e, 0x08, 0x48, 0x65, 0x12, 0x1b, 0xd8, 0x2c, 0x63, 0x40, 0x00, 0x00,
0x0d, 0x6c, 0x96, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x1c, 0x64, 0x4e, 0xf6, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9d, 0x5a, 0x25, 0xa5, 0xe6, 0x00, 0x00, 0x00,
0x00,
} }

View File

@@ -1,14 +1,21 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: google/protobuf/empty.proto // source: empty.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
empty.proto
It has these top-level messages:
Empty
*/
package types package types
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
import fmt "fmt" import fmt "fmt"
import math "math" import math "math"
import bytes "bytes"
import strings "strings" import strings "strings"
import reflect "reflect" import reflect "reflect"
@@ -35,47 +42,13 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// //
// The JSON representation for `Empty` is empty JSON object `{}`. // The JSON representation for `Empty` is empty JSON object `{}`.
type Empty struct { type Empty struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Empty) Reset() { *m = Empty{} } func (m *Empty) Reset() { *m = Empty{} }
func (*Empty) ProtoMessage() {} func (*Empty) ProtoMessage() {}
func (*Empty) Descriptor() ([]byte, []int) { func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptorEmpty, []int{0} }
return fileDescriptor_empty_b366a5cbb7c614df, []int{0} func (*Empty) XXX_WellKnownType() string { return "Empty" }
}
func (*Empty) XXX_WellKnownType() string { return "Empty" }
func (m *Empty) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Empty.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *Empty) XXX_Merge(src proto.Message) {
xxx_messageInfo_Empty.Merge(dst, src)
}
func (m *Empty) XXX_Size() int {
return m.Size()
}
func (m *Empty) XXX_DiscardUnknown() {
xxx_messageInfo_Empty.DiscardUnknown(m)
}
var xxx_messageInfo_Empty proto.InternalMessageInfo
func (*Empty) XXX_MessageName() string {
return "google.protobuf.Empty"
}
func init() { func init() {
proto.RegisterType((*Empty)(nil), "google.protobuf.Empty") proto.RegisterType((*Empty)(nil), "google.protobuf.Empty")
} }
@@ -104,14 +77,14 @@ func (this *Empty) Compare(that interface{}) int {
} else if this == nil { } else if this == nil {
return -1 return -1
} }
if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
return c
}
return 0 return 0
} }
func (this *Empty) Equal(that interface{}) bool { func (this *Empty) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Empty) that1, ok := that.(*Empty)
@@ -124,11 +97,11 @@ func (this *Empty) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
} else if this == nil { return true
}
return false return false
} } else if this == nil {
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false return false
} }
return true return true
@@ -139,9 +112,6 @@ func (this *Empty) GoString() string {
} }
s := make([]string, 0, 4) s := make([]string, 0, 4)
s = append(s, "&types.Empty{") s = append(s, "&types.Empty{")
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}") s = append(s, "}")
return strings.Join(s, "") return strings.Join(s, "")
} }
@@ -168,9 +138,6 @@ func (m *Empty) MarshalTo(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -186,7 +153,6 @@ func encodeVarintEmpty(dAtA []byte, offset int, v uint64) int {
func NewPopulatedEmpty(r randyEmpty, easy bool) *Empty { func NewPopulatedEmpty(r randyEmpty, easy bool) *Empty {
this := &Empty{} this := &Empty{}
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedEmpty(r, 1)
} }
return this return this
} }
@@ -264,14 +230,8 @@ func encodeVarintPopulateEmpty(dAtA []byte, v uint64) []byte {
return dAtA return dAtA
} }
func (m *Empty) Size() (n int) { func (m *Empty) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -293,7 +253,6 @@ func (this *Empty) String() string {
return "nil" return "nil"
} }
s := strings.Join([]string{`&Empty{`, s := strings.Join([]string{`&Empty{`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -347,7 +306,6 @@ func (m *Empty) Unmarshal(dAtA []byte) error {
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -462,19 +420,19 @@ var (
ErrIntOverflowEmpty = fmt.Errorf("proto: integer overflow") ErrIntOverflowEmpty = fmt.Errorf("proto: integer overflow")
) )
func init() { proto.RegisterFile("google/protobuf/empty.proto", fileDescriptor_empty_b366a5cbb7c614df) } func init() { proto.RegisterFile("empty.proto", fileDescriptorEmpty) }
var fileDescriptor_empty_b366a5cbb7c614df = []byte{ var fileDescriptorEmpty = []byte{
// 176 bytes of a gzipped FileDescriptorProto // 169 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xcf, 0xcf, 0x4f, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4e, 0xcd, 0x2d, 0x28,
0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcd, 0x2d, 0x28, 0xa9, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4f, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0x85,
0xa9, 0xd4, 0x03, 0x73, 0x85, 0xf8, 0x21, 0x92, 0x7a, 0x30, 0x49, 0x25, 0x76, 0x2e, 0x56, 0x57, 0xf0, 0x92, 0x4a, 0xd3, 0x94, 0xd8, 0xb9, 0x58, 0x5d, 0x41, 0xf2, 0x4e, 0x2d, 0x8c, 0x17, 0x1e,
0x90, 0xbc, 0x53, 0x0b, 0xe3, 0x8d, 0x87, 0x72, 0x0c, 0x1f, 0x1e, 0xca, 0x31, 0xfe, 0x78, 0x28, 0xca, 0x31, 0xdc, 0x78, 0x28, 0xc7, 0xf0, 0xe1, 0xa1, 0x1c, 0xe3, 0x8f, 0x87, 0x72, 0x8c, 0x0d,
0xc7, 0xd8, 0xf0, 0x48, 0x8e, 0x71, 0xc5, 0x23, 0x39, 0xc6, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x8f, 0xe4, 0x18, 0x57, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6,
0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0xf1, 0xc5, 0x23, 0x39, 0x86, 0x0f, 0x20, 0xf1, 0xc7, 0x72, 0x07, 0x8f, 0xe4, 0x18, 0x5f, 0x3c, 0x92, 0x63, 0xf8, 0x00, 0x12, 0x7f, 0x2c, 0xc7, 0xc8, 0x25,
0x8c, 0x27, 0x1e, 0xcb, 0x31, 0x72, 0x09, 0x27, 0xe7, 0xe7, 0xea, 0xa1, 0x19, 0xe8, 0xc4, 0x05, 0x9c, 0x9c, 0x9f, 0xab, 0x87, 0x66, 0xa0, 0x13, 0x17, 0xd8, 0xb8, 0x00, 0x10, 0x37, 0x80, 0x31,
0x36, 0x2e, 0x00, 0xc4, 0x0d, 0x60, 0x8c, 0x62, 0x2d, 0xa9, 0x2c, 0x48, 0x2d, 0xfe, 0xc1, 0xc8, 0x8a, 0xb5, 0xa4, 0xb2, 0x20, 0xb5, 0xf8, 0x07, 0x23, 0xe3, 0x22, 0x26, 0x66, 0xf7, 0x00, 0xa7,
0xb8, 0x88, 0x89, 0xd9, 0x3d, 0xc0, 0x69, 0x15, 0x93, 0x9c, 0x3b, 0x44, 0x7d, 0x00, 0x54, 0xbd, 0x55, 0x4c, 0x72, 0xee, 0x10, 0xf5, 0x01, 0x50, 0xf5, 0x7a, 0xe1, 0xa9, 0x39, 0x39, 0xde, 0x79,
0x5e, 0x78, 0x6a, 0x4e, 0x8e, 0x77, 0x5e, 0x7e, 0x79, 0x5e, 0x08, 0x48, 0x65, 0x12, 0x1b, 0xd8, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x95, 0x49, 0x6c, 0x60, 0x83, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff,
0x20, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x21, 0xbe, 0xb6, 0x31, 0xc6, 0x00, 0x00, 0x00, 0xff, 0x7c, 0xa8, 0xf0, 0xc4, 0xb6, 0x00, 0x00, 0x00,
} }

View File

@@ -1,14 +1,21 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: google/protobuf/field_mask.proto // source: field_mask.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
field_mask.proto
It has these top-level messages:
FieldMask
*/
package types package types
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
import fmt "fmt" import fmt "fmt"
import math "math" import math "math"
import bytes "bytes"
import strings "strings" import strings "strings"
import reflect "reflect" import reflect "reflect"
@@ -226,51 +233,14 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// //
// Note that oneof type names ("test_oneof" in this case) cannot be used in // Note that oneof type names ("test_oneof" in this case) cannot be used in
// paths. // paths.
//
// ## Field Mask Verification
//
// The implementation of the all the API methods, which have any FieldMask type
// field in the request, should verify the included field paths, and return
// `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
type FieldMask struct { type FieldMask struct {
// The set of field mask paths. // The set of field mask paths.
Paths []string `protobuf:"bytes,1,rep,name=paths,proto3" json:"paths,omitempty"` Paths []string `protobuf:"bytes,1,rep,name=paths" json:"paths,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *FieldMask) Reset() { *m = FieldMask{} } func (m *FieldMask) Reset() { *m = FieldMask{} }
func (*FieldMask) ProtoMessage() {} func (*FieldMask) ProtoMessage() {}
func (*FieldMask) Descriptor() ([]byte, []int) { func (*FieldMask) Descriptor() ([]byte, []int) { return fileDescriptorFieldMask, []int{0} }
return fileDescriptor_field_mask_f1676d06eb3d88ba, []int{0}
}
func (m *FieldMask) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *FieldMask) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_FieldMask.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *FieldMask) XXX_Merge(src proto.Message) {
xxx_messageInfo_FieldMask.Merge(dst, src)
}
func (m *FieldMask) XXX_Size() int {
return m.Size()
}
func (m *FieldMask) XXX_DiscardUnknown() {
xxx_messageInfo_FieldMask.DiscardUnknown(m)
}
var xxx_messageInfo_FieldMask proto.InternalMessageInfo
func (m *FieldMask) GetPaths() []string { func (m *FieldMask) GetPaths() []string {
if m != nil { if m != nil {
@@ -279,9 +249,6 @@ func (m *FieldMask) GetPaths() []string {
return nil return nil
} }
func (*FieldMask) XXX_MessageName() string {
return "google.protobuf.FieldMask"
}
func init() { func init() {
proto.RegisterType((*FieldMask)(nil), "google.protobuf.FieldMask") proto.RegisterType((*FieldMask)(nil), "google.protobuf.FieldMask")
} }
@@ -324,14 +291,14 @@ func (this *FieldMask) Compare(that interface{}) int {
return 1 return 1
} }
} }
if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
return c
}
return 0 return 0
} }
func (this *FieldMask) Equal(that interface{}) bool { func (this *FieldMask) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*FieldMask) that1, ok := that.(*FieldMask)
@@ -344,7 +311,10 @@ func (this *FieldMask) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -356,9 +326,6 @@ func (this *FieldMask) Equal(that interface{}) bool {
return false return false
} }
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *FieldMask) GoString() string { func (this *FieldMask) GoString() string {
@@ -368,9 +335,6 @@ func (this *FieldMask) GoString() string {
s := make([]string, 0, 5) s := make([]string, 0, 5)
s = append(s, "&types.FieldMask{") s = append(s, "&types.FieldMask{")
s = append(s, "Paths: "+fmt.Sprintf("%#v", this.Paths)+",\n") s = append(s, "Paths: "+fmt.Sprintf("%#v", this.Paths)+",\n")
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}") s = append(s, "}")
return strings.Join(s, "") return strings.Join(s, "")
} }
@@ -412,9 +376,6 @@ func (m *FieldMask) MarshalTo(dAtA []byte) (int, error) {
i += copy(dAtA[i:], s) i += copy(dAtA[i:], s)
} }
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -435,7 +396,6 @@ func NewPopulatedFieldMask(r randyFieldMask, easy bool) *FieldMask {
this.Paths[i] = string(randStringFieldMask(r)) this.Paths[i] = string(randStringFieldMask(r))
} }
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedFieldMask(r, 2)
} }
return this return this
} }
@@ -513,9 +473,6 @@ func encodeVarintPopulateFieldMask(dAtA []byte, v uint64) []byte {
return dAtA return dAtA
} }
func (m *FieldMask) Size() (n int) { func (m *FieldMask) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if len(m.Paths) > 0 { if len(m.Paths) > 0 {
@@ -524,9 +481,6 @@ func (m *FieldMask) Size() (n int) {
n += 1 + l + sovFieldMask(uint64(l)) n += 1 + l + sovFieldMask(uint64(l))
} }
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -549,7 +503,6 @@ func (this *FieldMask) String() string {
} }
s := strings.Join([]string{`&FieldMask{`, s := strings.Join([]string{`&FieldMask{`,
`Paths:` + fmt.Sprintf("%v", this.Paths) + `,`, `Paths:` + fmt.Sprintf("%v", this.Paths) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -632,7 +585,6 @@ func (m *FieldMask) Unmarshal(dAtA []byte) error {
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -747,23 +699,21 @@ var (
ErrIntOverflowFieldMask = fmt.Errorf("proto: integer overflow") ErrIntOverflowFieldMask = fmt.Errorf("proto: integer overflow")
) )
func init() { func init() { proto.RegisterFile("field_mask.proto", fileDescriptorFieldMask) }
proto.RegisterFile("google/protobuf/field_mask.proto", fileDescriptor_field_mask_f1676d06eb3d88ba)
}
var fileDescriptor_field_mask_f1676d06eb3d88ba = []byte{ var fileDescriptorFieldMask = []byte{
// 200 bytes of a gzipped FileDescriptorProto // 193 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xcf, 0xcf, 0x4f, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x48, 0xcb, 0x4c, 0xcd,
0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcb, 0x4c, 0xcd, 0x49, 0x89, 0xcf, 0x4d, 0x2c, 0xce, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4f, 0xcf,
0x49, 0x89, 0xcf, 0x4d, 0x2c, 0xce, 0xd6, 0x03, 0x8b, 0x09, 0xf1, 0x43, 0x54, 0xe8, 0xc1, 0x54, 0xcf, 0x4f, 0xcf, 0x49, 0x85, 0xf0, 0x92, 0x4a, 0xd3, 0x94, 0x14, 0xb9, 0x38, 0xdd, 0x40, 0x8a,
0x28, 0x29, 0x72, 0x71, 0xba, 0x81, 0x14, 0xf9, 0x26, 0x16, 0x67, 0x0b, 0x89, 0x70, 0xb1, 0x16, 0x7c, 0x13, 0x8b, 0xb3, 0x85, 0x44, 0xb8, 0x58, 0x0b, 0x12, 0x4b, 0x32, 0x8a, 0x25, 0x18, 0x15,
0x24, 0x96, 0x64, 0x14, 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x06, 0x41, 0x38, 0x4e, 0xad, 0x8c, 0x98, 0x35, 0x38, 0x83, 0x20, 0x1c, 0xa7, 0x56, 0xc6, 0x0b, 0x0f, 0xe5, 0x18, 0x6e, 0x3c, 0x94,
0x37, 0x1e, 0xca, 0x31, 0x7c, 0x78, 0x28, 0xc7, 0xf8, 0xe3, 0xa1, 0x1c, 0x63, 0xc3, 0x23, 0x39, 0x63, 0xf8, 0xf0, 0x50, 0x8e, 0xf1, 0xc7, 0x43, 0x39, 0xc6, 0x86, 0x47, 0x72, 0x8c, 0x2b, 0x1e,
0xc6, 0x15, 0x8f, 0xe4, 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x2f,
0x39, 0xc6, 0x17, 0x8f, 0xe4, 0x18, 0x3e, 0x80, 0xc4, 0x1f, 0xcb, 0x31, 0x9e, 0x78, 0x2c, 0xc7, 0x1e, 0xc9, 0x31, 0x7c, 0x00, 0x89, 0x3f, 0x96, 0x63, 0xe4, 0x12, 0x4e, 0xce, 0xcf, 0xd5, 0x43,
0xc8, 0x25, 0x9c, 0x9c, 0x9f, 0xab, 0x87, 0x66, 0x95, 0x13, 0x1f, 0xdc, 0xa2, 0x00, 0x90, 0x50, 0xb3, 0xca, 0x89, 0x0f, 0x6e, 0x51, 0x00, 0x48, 0x28, 0x80, 0x31, 0x8a, 0xb5, 0xa4, 0xb2, 0x20,
0x00, 0x63, 0x14, 0x6b, 0x49, 0x65, 0x41, 0x6a, 0xf1, 0x22, 0x26, 0x66, 0xf7, 0x00, 0xa7, 0x55, 0xb5, 0x78, 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0x86, 0x00, 0xa8,
0x4c, 0x72, 0xee, 0x10, 0x0d, 0x01, 0x50, 0x0d, 0x7a, 0xe1, 0xa9, 0x39, 0x39, 0xde, 0x79, 0xf9, 0x06, 0xbd, 0xf0, 0xd4, 0x9c, 0x1c, 0xef, 0xbc, 0xfc, 0xf2, 0xbc, 0x10, 0x90, 0xb2, 0x24, 0x36,
0xe5, 0x79, 0x21, 0x20, 0x65, 0x49, 0x6c, 0x60, 0x93, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x49, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x51, 0x31, 0x89, 0xb5, 0xd6, 0x00, 0x00,
0xcf, 0xae, 0x5b, 0xec, 0xe6, 0x00, 0x00, 0x00, 0x00,
} }

View File

@@ -1,34 +0,0 @@
package types
func (m *Any) ProtoSize() (n int) { return m.Size() }
func (m *Api) ProtoSize() (n int) { return m.Size() }
func (m *Method) ProtoSize() (n int) { return m.Size() }
func (m *Mixin) ProtoSize() (n int) { return m.Size() }
func (m *Duration) ProtoSize() (n int) { return m.Size() }
func (m *Empty) ProtoSize() (n int) { return m.Size() }
func (m *FieldMask) ProtoSize() (n int) { return m.Size() }
func (m *SourceContext) ProtoSize() (n int) { return m.Size() }
func (m *Struct) ProtoSize() (n int) { return m.Size() }
func (m *Value) ProtoSize() (n int) { return m.Size() }
func (m *Value_NullValue) ProtoSize() (n int) { return m.Size() }
func (m *Value_NumberValue) ProtoSize() (n int) { return m.Size() }
func (m *Value_StringValue) ProtoSize() (n int) { return m.Size() }
func (m *Value_BoolValue) ProtoSize() (n int) { return m.Size() }
func (m *Value_StructValue) ProtoSize() (n int) { return m.Size() }
func (m *Value_ListValue) ProtoSize() (n int) { return m.Size() }
func (m *ListValue) ProtoSize() (n int) { return m.Size() }
func (m *Timestamp) ProtoSize() (n int) { return m.Size() }
func (m *Type) ProtoSize() (n int) { return m.Size() }
func (m *Field) ProtoSize() (n int) { return m.Size() }
func (m *Enum) ProtoSize() (n int) { return m.Size() }
func (m *EnumValue) ProtoSize() (n int) { return m.Size() }
func (m *Option) ProtoSize() (n int) { return m.Size() }
func (m *DoubleValue) ProtoSize() (n int) { return m.Size() }
func (m *FloatValue) ProtoSize() (n int) { return m.Size() }
func (m *Int64Value) ProtoSize() (n int) { return m.Size() }
func (m *UInt64Value) ProtoSize() (n int) { return m.Size() }
func (m *Int32Value) ProtoSize() (n int) { return m.Size() }
func (m *UInt32Value) ProtoSize() (n int) { return m.Size() }
func (m *BoolValue) ProtoSize() (n int) { return m.Size() }
func (m *StringValue) ProtoSize() (n int) { return m.Size() }
func (m *BytesValue) ProtoSize() (n int) { return m.Size() }

View File

@@ -1,538 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: google/protobuf/source_context.proto
package types
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import bytes "bytes"
import strings "strings"
import reflect "reflect"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// `SourceContext` represents information about the source of a
// protobuf element, like the file in which it is defined.
type SourceContext struct {
// The path-qualified name of the .proto file that contained the associated
// protobuf element. For example: `"google/protobuf/source_context.proto"`.
FileName string `protobuf:"bytes,1,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SourceContext) Reset() { *m = SourceContext{} }
func (*SourceContext) ProtoMessage() {}
func (*SourceContext) Descriptor() ([]byte, []int) {
return fileDescriptor_source_context_b387e69fb08d10e5, []int{0}
}
func (m *SourceContext) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SourceContext) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SourceContext.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SourceContext) XXX_Merge(src proto.Message) {
xxx_messageInfo_SourceContext.Merge(dst, src)
}
func (m *SourceContext) XXX_Size() int {
return m.Size()
}
func (m *SourceContext) XXX_DiscardUnknown() {
xxx_messageInfo_SourceContext.DiscardUnknown(m)
}
var xxx_messageInfo_SourceContext proto.InternalMessageInfo
func (m *SourceContext) GetFileName() string {
if m != nil {
return m.FileName
}
return ""
}
func (*SourceContext) XXX_MessageName() string {
return "google.protobuf.SourceContext"
}
func init() {
proto.RegisterType((*SourceContext)(nil), "google.protobuf.SourceContext")
}
func (this *SourceContext) Compare(that interface{}) int {
if that == nil {
if this == nil {
return 0
}
return 1
}
that1, ok := that.(*SourceContext)
if !ok {
that2, ok := that.(SourceContext)
if ok {
that1 = &that2
} else {
return 1
}
}
if that1 == nil {
if this == nil {
return 0
}
return 1
} else if this == nil {
return -1
}
if this.FileName != that1.FileName {
if this.FileName < that1.FileName {
return -1
}
return 1
}
if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
return c
}
return 0
}
func (this *SourceContext) Equal(that interface{}) bool {
if that == nil {
return this == nil
}
that1, ok := that.(*SourceContext)
if !ok {
that2, ok := that.(SourceContext)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
return this == nil
} else if this == nil {
return false
}
if this.FileName != that1.FileName {
return false
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
func (this *SourceContext) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 5)
s = append(s, "&types.SourceContext{")
s = append(s, "FileName: "+fmt.Sprintf("%#v", this.FileName)+",\n")
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func valueToGoStringSourceContext(v interface{}, typ string) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
}
func (m *SourceContext) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SourceContext) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.FileName) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintSourceContext(dAtA, i, uint64(len(m.FileName)))
i += copy(dAtA[i:], m.FileName)
}
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil
}
func encodeVarintSourceContext(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func NewPopulatedSourceContext(r randySourceContext, easy bool) *SourceContext {
this := &SourceContext{}
this.FileName = string(randStringSourceContext(r))
if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedSourceContext(r, 2)
}
return this
}
type randySourceContext interface {
Float32() float32
Float64() float64
Int63() int64
Int31() int32
Uint32() uint32
Intn(n int) int
}
func randUTF8RuneSourceContext(r randySourceContext) rune {
ru := r.Intn(62)
if ru < 10 {
return rune(ru + 48)
} else if ru < 36 {
return rune(ru + 55)
}
return rune(ru + 61)
}
func randStringSourceContext(r randySourceContext) string {
v1 := r.Intn(100)
tmps := make([]rune, v1)
for i := 0; i < v1; i++ {
tmps[i] = randUTF8RuneSourceContext(r)
}
return string(tmps)
}
func randUnrecognizedSourceContext(r randySourceContext, maxFieldNumber int) (dAtA []byte) {
l := r.Intn(5)
for i := 0; i < l; i++ {
wire := r.Intn(4)
if wire == 3 {
wire = 5
}
fieldNumber := maxFieldNumber + r.Intn(100)
dAtA = randFieldSourceContext(dAtA, r, fieldNumber, wire)
}
return dAtA
}
func randFieldSourceContext(dAtA []byte, r randySourceContext, fieldNumber int, wire int) []byte {
key := uint32(fieldNumber)<<3 | uint32(wire)
switch wire {
case 0:
dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(key))
v2 := r.Int63()
if r.Intn(2) == 0 {
v2 *= -1
}
dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(v2))
case 1:
dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(key))
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
case 2:
dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(key))
ll := r.Intn(100)
dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(ll))
for j := 0; j < ll; j++ {
dAtA = append(dAtA, byte(r.Intn(256)))
}
default:
dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(key))
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
}
return dAtA
}
func encodeVarintPopulateSourceContext(dAtA []byte, v uint64) []byte {
for v >= 1<<7 {
dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
v >>= 7
}
dAtA = append(dAtA, uint8(v))
return dAtA
}
func (m *SourceContext) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.FileName)
if l > 0 {
n += 1 + l + sovSourceContext(uint64(l))
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func sovSourceContext(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozSourceContext(x uint64) (n int) {
return sovSourceContext(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *SourceContext) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&SourceContext{`,
`FileName:` + fmt.Sprintf("%v", this.FileName) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func valueToStringSourceContext(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
func (m *SourceContext) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSourceContext
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: SourceContext: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SourceContext: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field FileName", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSourceContext
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthSourceContext
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.FileName = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipSourceContext(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSourceContext
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipSourceContext(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSourceContext
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSourceContext
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSourceContext
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthSourceContext
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSourceContext
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipSourceContext(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthSourceContext = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowSourceContext = fmt.Errorf("proto: integer overflow")
)
func init() {
proto.RegisterFile("google/protobuf/source_context.proto", fileDescriptor_source_context_b387e69fb08d10e5)
}
var fileDescriptor_source_context_b387e69fb08d10e5 = []byte{
// 212 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xcf, 0xcf, 0x4f,
0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xce, 0x2f, 0x2d,
0x4a, 0x4e, 0x8d, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xad, 0x28, 0xd1, 0x03, 0x8b, 0x0b, 0xf1, 0x43,
0x54, 0xe9, 0xc1, 0x54, 0x29, 0xe9, 0x70, 0xf1, 0x06, 0x83, 0x15, 0x3a, 0x43, 0xd4, 0x09, 0x49,
0x73, 0x71, 0xa6, 0x65, 0xe6, 0xa4, 0xc6, 0xe7, 0x25, 0xe6, 0xa6, 0x4a, 0x30, 0x2a, 0x30, 0x6a,
0x70, 0x06, 0x71, 0x80, 0x04, 0xfc, 0x12, 0x73, 0x53, 0x9d, 0x3a, 0x19, 0x6f, 0x3c, 0x94, 0x63,
0xf8, 0xf0, 0x50, 0x8e, 0xf1, 0xc7, 0x43, 0x39, 0xc6, 0x86, 0x47, 0x72, 0x8c, 0x2b, 0x1e, 0xc9,
0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x2f, 0x1e,
0xc9, 0x31, 0x7c, 0x00, 0x89, 0x3f, 0x96, 0x63, 0x3c, 0xf1, 0x58, 0x8e, 0x91, 0x4b, 0x38, 0x39,
0x3f, 0x57, 0x0f, 0xcd, 0x56, 0x27, 0x21, 0x14, 0x3b, 0x03, 0x40, 0xc2, 0x01, 0x8c, 0x51, 0xac,
0x25, 0x95, 0x05, 0xa9, 0xc5, 0x8b, 0x98, 0x98, 0xdd, 0x03, 0x9c, 0x56, 0x31, 0xc9, 0xb9, 0x43,
0x34, 0x05, 0x40, 0x35, 0xe9, 0x85, 0xa7, 0xe6, 0xe4, 0x78, 0xe7, 0xe5, 0x97, 0xe7, 0x85, 0x80,
0x94, 0x25, 0xb1, 0x81, 0x4d, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x37, 0x2a, 0xa1,
0xf9, 0x00, 0x00, 0x00,
}

View File

@@ -1,6 +1,17 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: google/protobuf/struct.proto // source: struct.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
struct.proto
It has these top-level messages:
Struct
Value
ListValue
*/
package types package types
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
@@ -9,8 +20,6 @@ import math "math"
import strconv "strconv" import strconv "strconv"
import bytes "bytes"
import strings "strings" import strings "strings"
import reflect "reflect" import reflect "reflect"
import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
@@ -38,7 +47,7 @@ type NullValue int32
const ( const (
// Null value. // Null value.
NullValue_NULL_VALUE NullValue = 0 NULL_VALUE NullValue = 0
) )
var NullValue_name = map[int32]string{ var NullValue_name = map[int32]string{
@@ -48,10 +57,8 @@ var NullValue_value = map[string]int32{
"NULL_VALUE": 0, "NULL_VALUE": 0,
} }
func (NullValue) EnumDescriptor() ([]byte, []int) { func (NullValue) EnumDescriptor() ([]byte, []int) { return fileDescriptorStruct, []int{0} }
return fileDescriptor_struct_7f9d36853146434f, []int{0} func (NullValue) XXX_WellKnownType() string { return "NullValue" }
}
func (NullValue) XXX_WellKnownType() string { return "NullValue" }
// `Struct` represents a structured data value, consisting of fields // `Struct` represents a structured data value, consisting of fields
// which map to dynamically typed values. In some languages, `Struct` // which map to dynamically typed values. In some languages, `Struct`
@@ -63,44 +70,13 @@ func (NullValue) XXX_WellKnownType() string { return "NullValue" }
// The JSON representation for `Struct` is JSON object. // The JSON representation for `Struct` is JSON object.
type Struct struct { type Struct struct {
// Unordered map of dynamically typed values. // Unordered map of dynamically typed values.
Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields,proto3" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Struct) Reset() { *m = Struct{} } func (m *Struct) Reset() { *m = Struct{} }
func (*Struct) ProtoMessage() {} func (*Struct) ProtoMessage() {}
func (*Struct) Descriptor() ([]byte, []int) { func (*Struct) Descriptor() ([]byte, []int) { return fileDescriptorStruct, []int{0} }
return fileDescriptor_struct_7f9d36853146434f, []int{0} func (*Struct) XXX_WellKnownType() string { return "Struct" }
}
func (*Struct) XXX_WellKnownType() string { return "Struct" }
func (m *Struct) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Struct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Struct.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *Struct) XXX_Merge(src proto.Message) {
xxx_messageInfo_Struct.Merge(dst, src)
}
func (m *Struct) XXX_Size() int {
return m.Size()
}
func (m *Struct) XXX_DiscardUnknown() {
xxx_messageInfo_Struct.DiscardUnknown(m)
}
var xxx_messageInfo_Struct proto.InternalMessageInfo
func (m *Struct) GetFields() map[string]*Value { func (m *Struct) GetFields() map[string]*Value {
if m != nil { if m != nil {
@@ -109,10 +85,6 @@ func (m *Struct) GetFields() map[string]*Value {
return nil return nil
} }
func (*Struct) XXX_MessageName() string {
return "google.protobuf.Struct"
}
// `Value` represents a dynamically typed value which can be either // `Value` represents a dynamically typed value which can be either
// null, a number, a string, a boolean, a recursive struct value, or a // null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of that // list of values. A producer of value is expected to set one of that
@@ -129,44 +101,13 @@ type Value struct {
// *Value_BoolValue // *Value_BoolValue
// *Value_StructValue // *Value_StructValue
// *Value_ListValue // *Value_ListValue
Kind isValue_Kind `protobuf_oneof:"kind"` Kind isValue_Kind `protobuf_oneof:"kind"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Value) Reset() { *m = Value{} } func (m *Value) Reset() { *m = Value{} }
func (*Value) ProtoMessage() {} func (*Value) ProtoMessage() {}
func (*Value) Descriptor() ([]byte, []int) { func (*Value) Descriptor() ([]byte, []int) { return fileDescriptorStruct, []int{1} }
return fileDescriptor_struct_7f9d36853146434f, []int{1} func (*Value) XXX_WellKnownType() string { return "Value" }
}
func (*Value) XXX_WellKnownType() string { return "Value" }
func (m *Value) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Value.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *Value) XXX_Merge(src proto.Message) {
xxx_messageInfo_Value.Merge(dst, src)
}
func (m *Value) XXX_Size() int {
return m.Size()
}
func (m *Value) XXX_DiscardUnknown() {
xxx_messageInfo_Value.DiscardUnknown(m)
}
var xxx_messageInfo_Value proto.InternalMessageInfo
type isValue_Kind interface { type isValue_Kind interface {
isValue_Kind() isValue_Kind()
@@ -188,10 +129,10 @@ type Value_BoolValue struct {
BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"` BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"`
} }
type Value_StructValue struct { type Value_StructValue struct {
StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,proto3,oneof"` StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,oneof"`
} }
type Value_ListValue struct { type Value_ListValue struct {
ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,proto3,oneof"` ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,oneof"`
} }
func (*Value_NullValue) isValue_Kind() {} func (*Value_NullValue) isValue_Kind() {}
@@ -212,7 +153,7 @@ func (m *Value) GetNullValue() NullValue {
if x, ok := m.GetKind().(*Value_NullValue); ok { if x, ok := m.GetKind().(*Value_NullValue); ok {
return x.NullValue return x.NullValue
} }
return NullValue_NULL_VALUE return NULL_VALUE
} }
func (m *Value) GetNumberValue() float64 { func (m *Value) GetNumberValue() float64 {
@@ -356,26 +297,26 @@ func _Value_OneofSizer(msg proto.Message) (n int) {
// kind // kind
switch x := m.Kind.(type) { switch x := m.Kind.(type) {
case *Value_NullValue: case *Value_NullValue:
n += 1 // tag and wire n += proto.SizeVarint(1<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.NullValue)) n += proto.SizeVarint(uint64(x.NullValue))
case *Value_NumberValue: case *Value_NumberValue:
n += 1 // tag and wire n += proto.SizeVarint(2<<3 | proto.WireFixed64)
n += 8 n += 8
case *Value_StringValue: case *Value_StringValue:
n += 1 // tag and wire n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.StringValue))) n += proto.SizeVarint(uint64(len(x.StringValue)))
n += len(x.StringValue) n += len(x.StringValue)
case *Value_BoolValue: case *Value_BoolValue:
n += 1 // tag and wire n += proto.SizeVarint(4<<3 | proto.WireVarint)
n += 1 n += 1
case *Value_StructValue: case *Value_StructValue:
s := proto.Size(x.StructValue) s := proto.Size(x.StructValue)
n += 1 // tag and wire n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s)) n += proto.SizeVarint(uint64(s))
n += s n += s
case *Value_ListValue: case *Value_ListValue:
s := proto.Size(x.ListValue) s := proto.Size(x.ListValue)
n += 1 // tag and wire n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s)) n += proto.SizeVarint(uint64(s))
n += s n += s
case nil: case nil:
@@ -385,53 +326,18 @@ func _Value_OneofSizer(msg proto.Message) (n int) {
return n return n
} }
func (*Value) XXX_MessageName() string {
return "google.protobuf.Value"
}
// `ListValue` is a wrapper around a repeated field of values. // `ListValue` is a wrapper around a repeated field of values.
// //
// The JSON representation for `ListValue` is JSON array. // The JSON representation for `ListValue` is JSON array.
type ListValue struct { type ListValue struct {
// Repeated field of dynamically typed values. // Repeated field of dynamically typed values.
Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` Values []*Value `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ListValue) Reset() { *m = ListValue{} } func (m *ListValue) Reset() { *m = ListValue{} }
func (*ListValue) ProtoMessage() {} func (*ListValue) ProtoMessage() {}
func (*ListValue) Descriptor() ([]byte, []int) { func (*ListValue) Descriptor() ([]byte, []int) { return fileDescriptorStruct, []int{2} }
return fileDescriptor_struct_7f9d36853146434f, []int{2} func (*ListValue) XXX_WellKnownType() string { return "ListValue" }
}
func (*ListValue) XXX_WellKnownType() string { return "ListValue" }
func (m *ListValue) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ListValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ListValue.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *ListValue) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListValue.Merge(dst, src)
}
func (m *ListValue) XXX_Size() int {
return m.Size()
}
func (m *ListValue) XXX_DiscardUnknown() {
xxx_messageInfo_ListValue.DiscardUnknown(m)
}
var xxx_messageInfo_ListValue proto.InternalMessageInfo
func (m *ListValue) GetValues() []*Value { func (m *ListValue) GetValues() []*Value {
if m != nil { if m != nil {
@@ -440,12 +346,8 @@ func (m *ListValue) GetValues() []*Value {
return nil return nil
} }
func (*ListValue) XXX_MessageName() string {
return "google.protobuf.ListValue"
}
func init() { func init() {
proto.RegisterType((*Struct)(nil), "google.protobuf.Struct") proto.RegisterType((*Struct)(nil), "google.protobuf.Struct")
proto.RegisterMapType((map[string]*Value)(nil), "google.protobuf.Struct.FieldsEntry")
proto.RegisterType((*Value)(nil), "google.protobuf.Value") proto.RegisterType((*Value)(nil), "google.protobuf.Value")
proto.RegisterType((*ListValue)(nil), "google.protobuf.ListValue") proto.RegisterType((*ListValue)(nil), "google.protobuf.ListValue")
proto.RegisterEnum("google.protobuf.NullValue", NullValue_name, NullValue_value) proto.RegisterEnum("google.protobuf.NullValue", NullValue_name, NullValue_value)
@@ -459,7 +361,10 @@ func (x NullValue) String() string {
} }
func (this *Struct) Equal(that interface{}) bool { func (this *Struct) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Struct) that1, ok := that.(*Struct)
@@ -472,7 +377,10 @@ func (this *Struct) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -484,14 +392,14 @@ func (this *Struct) Equal(that interface{}) bool {
return false return false
} }
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *Value) Equal(that interface{}) bool { func (this *Value) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Value) that1, ok := that.(*Value)
@@ -504,7 +412,10 @@ func (this *Value) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -517,14 +428,14 @@ func (this *Value) Equal(that interface{}) bool {
} else if !this.Kind.Equal(that1.Kind) { } else if !this.Kind.Equal(that1.Kind) {
return false return false
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *Value_NullValue) Equal(that interface{}) bool { func (this *Value_NullValue) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Value_NullValue) that1, ok := that.(*Value_NullValue)
@@ -537,7 +448,10 @@ func (this *Value_NullValue) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -548,7 +462,10 @@ func (this *Value_NullValue) Equal(that interface{}) bool {
} }
func (this *Value_NumberValue) Equal(that interface{}) bool { func (this *Value_NumberValue) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Value_NumberValue) that1, ok := that.(*Value_NumberValue)
@@ -561,7 +478,10 @@ func (this *Value_NumberValue) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -572,7 +492,10 @@ func (this *Value_NumberValue) Equal(that interface{}) bool {
} }
func (this *Value_StringValue) Equal(that interface{}) bool { func (this *Value_StringValue) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Value_StringValue) that1, ok := that.(*Value_StringValue)
@@ -585,7 +508,10 @@ func (this *Value_StringValue) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -596,7 +522,10 @@ func (this *Value_StringValue) Equal(that interface{}) bool {
} }
func (this *Value_BoolValue) Equal(that interface{}) bool { func (this *Value_BoolValue) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Value_BoolValue) that1, ok := that.(*Value_BoolValue)
@@ -609,7 +538,10 @@ func (this *Value_BoolValue) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -620,7 +552,10 @@ func (this *Value_BoolValue) Equal(that interface{}) bool {
} }
func (this *Value_StructValue) Equal(that interface{}) bool { func (this *Value_StructValue) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Value_StructValue) that1, ok := that.(*Value_StructValue)
@@ -633,7 +568,10 @@ func (this *Value_StructValue) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -644,7 +582,10 @@ func (this *Value_StructValue) Equal(that interface{}) bool {
} }
func (this *Value_ListValue) Equal(that interface{}) bool { func (this *Value_ListValue) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Value_ListValue) that1, ok := that.(*Value_ListValue)
@@ -657,7 +598,10 @@ func (this *Value_ListValue) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -668,7 +612,10 @@ func (this *Value_ListValue) Equal(that interface{}) bool {
} }
func (this *ListValue) Equal(that interface{}) bool { func (this *ListValue) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*ListValue) that1, ok := that.(*ListValue)
@@ -681,7 +628,10 @@ func (this *ListValue) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -693,9 +643,6 @@ func (this *ListValue) Equal(that interface{}) bool {
return false return false
} }
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *Struct) GoString() string { func (this *Struct) GoString() string {
@@ -717,9 +664,6 @@ func (this *Struct) GoString() string {
if this.Fields != nil { if this.Fields != nil {
s = append(s, "Fields: "+mapStringForFields+",\n") s = append(s, "Fields: "+mapStringForFields+",\n")
} }
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}") s = append(s, "}")
return strings.Join(s, "") return strings.Join(s, "")
} }
@@ -732,9 +676,6 @@ func (this *Value) GoString() string {
if this.Kind != nil { if this.Kind != nil {
s = append(s, "Kind: "+fmt.Sprintf("%#v", this.Kind)+",\n") s = append(s, "Kind: "+fmt.Sprintf("%#v", this.Kind)+",\n")
} }
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}") s = append(s, "}")
return strings.Join(s, "") return strings.Join(s, "")
} }
@@ -795,9 +736,6 @@ func (this *ListValue) GoString() string {
if this.Values != nil { if this.Values != nil {
s = append(s, "Values: "+fmt.Sprintf("%#v", this.Values)+",\n") s = append(s, "Values: "+fmt.Sprintf("%#v", this.Values)+",\n")
} }
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}") s = append(s, "}")
return strings.Join(s, "") return strings.Join(s, "")
} }
@@ -852,9 +790,6 @@ func (m *Struct) MarshalTo(dAtA []byte) (int, error) {
} }
} }
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -880,9 +815,6 @@ func (m *Value) MarshalTo(dAtA []byte) (int, error) {
} }
i += nn2 i += nn2
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -976,9 +908,6 @@ func (m *ListValue) MarshalTo(dAtA []byte) (int, error) {
i += n i += n
} }
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -1001,7 +930,6 @@ func NewPopulatedStruct(r randyStruct, easy bool) *Struct {
} }
} }
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedStruct(r, 2)
} }
return this return this
} }
@@ -1024,7 +952,6 @@ func NewPopulatedValue(r randyStruct, easy bool) *Value {
this.Kind = NewPopulatedValue_ListValue(r, easy) this.Kind = NewPopulatedValue_ListValue(r, easy)
} }
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedStruct(r, 7)
} }
return this return this
} }
@@ -1072,7 +999,6 @@ func NewPopulatedListValue(r randyStruct, easy bool) *ListValue {
} }
} }
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedStruct(r, 2)
} }
return this return this
} }
@@ -1150,9 +1076,6 @@ func encodeVarintPopulateStruct(dAtA []byte, v uint64) []byte {
return dAtA return dAtA
} }
func (m *Struct) Size() (n int) { func (m *Struct) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if len(m.Fields) > 0 { if len(m.Fields) > 0 {
@@ -1168,49 +1091,31 @@ func (m *Struct) Size() (n int) {
n += mapEntrySize + 1 + sovStruct(uint64(mapEntrySize)) n += mapEntrySize + 1 + sovStruct(uint64(mapEntrySize))
} }
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *Value) Size() (n int) { func (m *Value) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if m.Kind != nil { if m.Kind != nil {
n += m.Kind.Size() n += m.Kind.Size()
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *Value_NullValue) Size() (n int) { func (m *Value_NullValue) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
n += 1 + sovStruct(uint64(m.NullValue)) n += 1 + sovStruct(uint64(m.NullValue))
return n return n
} }
func (m *Value_NumberValue) Size() (n int) { func (m *Value_NumberValue) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
n += 9 n += 9
return n return n
} }
func (m *Value_StringValue) Size() (n int) { func (m *Value_StringValue) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.StringValue) l = len(m.StringValue)
@@ -1218,18 +1123,12 @@ func (m *Value_StringValue) Size() (n int) {
return n return n
} }
func (m *Value_BoolValue) Size() (n int) { func (m *Value_BoolValue) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
n += 2 n += 2
return n return n
} }
func (m *Value_StructValue) Size() (n int) { func (m *Value_StructValue) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if m.StructValue != nil { if m.StructValue != nil {
@@ -1239,9 +1138,6 @@ func (m *Value_StructValue) Size() (n int) {
return n return n
} }
func (m *Value_ListValue) Size() (n int) { func (m *Value_ListValue) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if m.ListValue != nil { if m.ListValue != nil {
@@ -1251,9 +1147,6 @@ func (m *Value_ListValue) Size() (n int) {
return n return n
} }
func (m *ListValue) Size() (n int) { func (m *ListValue) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if len(m.Values) > 0 { if len(m.Values) > 0 {
@@ -1262,9 +1155,6 @@ func (m *ListValue) Size() (n int) {
n += 1 + l + sovStruct(uint64(l)) n += 1 + l + sovStruct(uint64(l))
} }
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -1297,7 +1187,6 @@ func (this *Struct) String() string {
mapStringForFields += "}" mapStringForFields += "}"
s := strings.Join([]string{`&Struct{`, s := strings.Join([]string{`&Struct{`,
`Fields:` + mapStringForFields + `,`, `Fields:` + mapStringForFields + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -1308,7 +1197,6 @@ func (this *Value) String() string {
} }
s := strings.Join([]string{`&Value{`, s := strings.Join([]string{`&Value{`,
`Kind:` + fmt.Sprintf("%v", this.Kind) + `,`, `Kind:` + fmt.Sprintf("%v", this.Kind) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -1379,7 +1267,6 @@ func (this *ListValue) String() string {
} }
s := strings.Join([]string{`&ListValue{`, s := strings.Join([]string{`&ListValue{`,
`Values:` + strings.Replace(fmt.Sprintf("%v", this.Values), "Value", "Value", 1) + `,`, `Values:` + strings.Replace(fmt.Sprintf("%v", this.Values), "Value", "Value", 1) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
@@ -1556,7 +1443,6 @@ func (m *Struct) Unmarshal(dAtA []byte) error {
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -1752,7 +1638,6 @@ func (m *Value) Unmarshal(dAtA []byte) error {
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -1834,7 +1719,6 @@ func (m *ListValue) Unmarshal(dAtA []byte) error {
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -1949,38 +1833,35 @@ var (
ErrIntOverflowStruct = fmt.Errorf("proto: integer overflow") ErrIntOverflowStruct = fmt.Errorf("proto: integer overflow")
) )
func init() { func init() { proto.RegisterFile("struct.proto", fileDescriptorStruct) }
proto.RegisterFile("google/protobuf/struct.proto", fileDescriptor_struct_7f9d36853146434f)
}
var fileDescriptor_struct_7f9d36853146434f = []byte{ var fileDescriptorStruct = []byte{
// 439 bytes of a gzipped FileDescriptorProto // 432 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xc1, 0x6b, 0xd4, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xb1, 0x6f, 0xd3, 0x40,
0x14, 0xc6, 0xf3, 0xb2, 0xdd, 0xe0, 0xbe, 0x48, 0x2d, 0x23, 0xe8, 0x52, 0x65, 0x5c, 0xb6, 0x97, 0x14, 0xc6, 0xfd, 0x9c, 0xc6, 0x22, 0xcf, 0x55, 0xa9, 0x0e, 0x09, 0xa2, 0x22, 0x1d, 0x51, 0xba,
0x45, 0x24, 0x85, 0xf5, 0x22, 0xae, 0x17, 0x17, 0x6a, 0x0b, 0x86, 0x12, 0xa3, 0xad, 0xe0, 0x65, 0x58, 0x08, 0x79, 0x08, 0x0b, 0x22, 0x2c, 0x58, 0x2a, 0xad, 0x84, 0x55, 0x19, 0x43, 0x8b, 0xc4,
0x31, 0x69, 0xba, 0x84, 0x4e, 0x67, 0x4a, 0x32, 0xa3, 0xec, 0x4d, 0xff, 0x0b, 0xcf, 0x9e, 0xc4, 0x12, 0xe1, 0xd4, 0x8d, 0xac, 0x5e, 0xef, 0x2a, 0xfb, 0x0c, 0xca, 0x06, 0xff, 0x05, 0x33, 0x13,
0xa3, 0x7f, 0x85, 0x47, 0x8f, 0x1e, 0xdd, 0x78, 0xf1, 0xd8, 0x63, 0x8f, 0x32, 0x33, 0x49, 0x94, 0x62, 0xe4, 0xaf, 0x60, 0xec, 0xc8, 0x88, 0x3d, 0x31, 0x76, 0xec, 0x88, 0xee, 0xce, 0x36, 0xa8,
0x2e, 0xbd, 0xe5, 0x7d, 0xf3, 0x7b, 0xdf, 0x7b, 0xdf, 0x0b, 0xde, 0x9d, 0x0b, 0x31, 0x67, 0xd9, 0x51, 0x36, 0xbf, 0xcf, 0xbf, 0xf7, 0xbd, 0xf7, 0xbd, 0xc3, 0xcd, 0x42, 0xe6, 0xe5, 0x5c, 0xfa,
0xf6, 0x59, 0x21, 0xa4, 0x48, 0xd4, 0xf1, 0x76, 0x29, 0x0b, 0x95, 0xca, 0xc0, 0xd4, 0xe4, 0x86, 0x17, 0xb9, 0x90, 0x82, 0xdc, 0x5e, 0x08, 0xb1, 0x60, 0xa9, 0xa9, 0x92, 0xf2, 0x74, 0xfc, 0x05,
0x7d, 0x0d, 0x9a, 0xd7, 0xe1, 0x27, 0x40, 0xef, 0xa5, 0x21, 0xc8, 0x04, 0xbd, 0xe3, 0x3c, 0x63, 0xd0, 0x79, 0xad, 0x09, 0x32, 0x45, 0xe7, 0x34, 0x4b, 0xd9, 0x49, 0x31, 0x84, 0x51, 0xcf, 0x73,
0x47, 0x65, 0x1f, 0x06, 0x9d, 0x91, 0x3f, 0xde, 0x0a, 0x2e, 0xc1, 0x81, 0x05, 0x83, 0x67, 0x86, 0x27, 0xbb, 0xfe, 0x0d, 0xd8, 0x37, 0xa0, 0xff, 0x42, 0x53, 0x7b, 0x5c, 0xe6, 0xcb, 0xb8, 0x69,
0xda, 0xe1, 0xb2, 0x58, 0xc4, 0x75, 0xcb, 0xe6, 0x0b, 0xf4, 0xff, 0x93, 0xc9, 0x06, 0x76, 0x4e, 0xd9, 0x79, 0x85, 0xee, 0x7f, 0x32, 0xd9, 0xc6, 0xde, 0x59, 0xba, 0x1c, 0xc2, 0x08, 0xbc, 0x41,
0xb2, 0x45, 0x1f, 0x06, 0x30, 0xea, 0xc5, 0xfa, 0x93, 0x3c, 0xc0, 0xee, 0xbb, 0xb7, 0x4c, 0x65, 0xac, 0x3e, 0xc9, 0x23, 0xec, 0x7f, 0x78, 0xcf, 0xca, 0x74, 0x68, 0x8f, 0xc0, 0x73, 0x27, 0x77,
0x7d, 0x77, 0x00, 0x23, 0x7f, 0x7c, 0x6b, 0xc5, 0xfc, 0x50, 0xbf, 0xc6, 0x16, 0x7a, 0xec, 0x3e, 0x57, 0xcc, 0x8f, 0xd5, 0xdf, 0xd8, 0x40, 0x4f, 0xed, 0x27, 0x30, 0xfe, 0x61, 0x63, 0x5f, 0x8b,
0x82, 0xe1, 0x37, 0x17, 0xbb, 0x46, 0x24, 0x13, 0x44, 0xae, 0x18, 0x9b, 0x59, 0x03, 0x6d, 0xba, 0x64, 0x8a, 0xc8, 0x4b, 0xc6, 0x66, 0xc6, 0x40, 0x99, 0x6e, 0x4d, 0x76, 0x56, 0x0c, 0x0e, 0x4b,
0x3e, 0xde, 0x5c, 0x31, 0xd8, 0x57, 0x8c, 0x19, 0x7e, 0xcf, 0x89, 0x7b, 0xbc, 0x29, 0xc8, 0x16, 0xc6, 0x34, 0x7f, 0x60, 0xc5, 0x03, 0xde, 0x16, 0x64, 0x17, 0x37, 0x79, 0x79, 0x9e, 0xa4, 0xf9,
0x5e, 0xe7, 0xea, 0x34, 0xc9, 0x8a, 0xd9, 0xbf, 0xf9, 0xb0, 0xe7, 0xc4, 0xbe, 0x55, 0x5b, 0xa8, 0xec, 0xdf, 0x7c, 0x38, 0xb0, 0x62, 0xd7, 0xa8, 0x1d, 0x54, 0xc8, 0x3c, 0xe3, 0x8b, 0x06, 0xea,
0x94, 0x45, 0xce, 0xe7, 0x35, 0xd4, 0xd1, 0x8b, 0x6b, 0xc8, 0xaa, 0x16, 0xba, 0x87, 0x98, 0x08, 0xa9, 0xc5, 0x15, 0x64, 0x54, 0x03, 0x3d, 0x40, 0x4c, 0x84, 0x68, 0xd7, 0xd8, 0x18, 0x81, 0x77,
0xd1, 0xac, 0xb1, 0x36, 0x80, 0xd1, 0x35, 0x3d, 0x4a, 0x6b, 0x16, 0x78, 0x62, 0x5c, 0x54, 0x2a, 0x4b, 0x8d, 0x52, 0x9a, 0x01, 0x9e, 0xb5, 0xd7, 0x6e, 0x90, 0xbe, 0x8e, 0x7a, 0x6f, 0xcd, 0x1d,
0x6b, 0xa4, 0x6b, 0xa2, 0xde, 0xbe, 0xe2, 0x8e, 0xb5, 0xbd, 0x4a, 0x65, 0x9b, 0x92, 0xe5, 0x65, 0x1b, 0xfb, 0x72, 0x2e, 0xbb, 0x94, 0x2c, 0x2b, 0xda, 0x5e, 0x47, 0xf7, 0xae, 0xa6, 0x0c, 0xb3,
0xd3, 0xeb, 0x99, 0xde, 0xd5, 0x94, 0x61, 0x5e, 0xca, 0x36, 0x25, 0x6b, 0x8a, 0xa9, 0x87, 0x6b, 0x42, 0x76, 0x29, 0x59, 0x5b, 0x04, 0x0e, 0x6e, 0x9c, 0x65, 0xfc, 0x64, 0x3c, 0xc5, 0x41, 0x47,
0x27, 0x39, 0x3f, 0x1a, 0x4e, 0xb0, 0xd7, 0x12, 0x24, 0x40, 0xcf, 0x98, 0x35, 0x7f, 0xf4, 0xaa, 0x10, 0x1f, 0x1d, 0x6d, 0xd6, 0xbe, 0xe8, 0xba, 0xa3, 0x37, 0xd4, 0xc3, 0xfb, 0x38, 0xe8, 0x8e,
0xa3, 0xd7, 0xd4, 0xfd, 0x3b, 0xd8, 0x6b, 0x8f, 0x48, 0xd6, 0x11, 0xf7, 0x0f, 0xc2, 0x70, 0x76, 0x48, 0xb6, 0x10, 0x0f, 0x8f, 0xc2, 0x70, 0x76, 0xfc, 0x3c, 0x3c, 0xda, 0xdb, 0xb6, 0x82, 0xcf,
0xf8, 0x34, 0x3c, 0xd8, 0xd9, 0x70, 0xa6, 0x1f, 0xe1, 0xe7, 0x92, 0x3a, 0xe7, 0x4b, 0x0a, 0x17, 0x70, 0x59, 0x51, 0xeb, 0x57, 0x45, 0xad, 0xab, 0x8a, 0xc2, 0x75, 0x45, 0xe1, 0x53, 0x4d, 0xe1,
0x4b, 0x0a, 0x1f, 0x2a, 0x0a, 0x5f, 0x2a, 0x0a, 0xdf, 0x2b, 0x0a, 0x3f, 0x2a, 0x0a, 0xbf, 0x2a, 0x5b, 0x4d, 0xe1, 0x67, 0x4d, 0xe1, 0xb2, 0xa6, 0xf0, 0xbb, 0xa6, 0xf0, 0xa7, 0xa6, 0xd6, 0x55,
0x0a, 0x7f, 0x2a, 0xea, 0x9c, 0x6b, 0xed, 0x37, 0x05, 0xbc, 0x99, 0x8a, 0xd3, 0xcb, 0xe3, 0xa6, 0x4d, 0x01, 0xef, 0xcc, 0xc5, 0xf9, 0xcd, 0x71, 0x81, 0x6b, 0x92, 0x47, 0xaa, 0x8e, 0xe0, 0x5d,
0xbe, 0x4d, 0x1e, 0xe9, 0x3a, 0x82, 0x37, 0x5d, 0xb9, 0x38, 0xcb, 0xca, 0x0b, 0x80, 0xcf, 0x6e, 0x5f, 0x2e, 0x2f, 0xd2, 0xe2, 0x1a, 0xe0, 0xab, 0xdd, 0xdb, 0x8f, 0x82, 0xef, 0x36, 0xdd, 0x37,
0x67, 0x37, 0x9a, 0x7e, 0x75, 0xe9, 0xae, 0x6d, 0x88, 0x9a, 0xfd, 0x5e, 0x67, 0x8c, 0x3d, 0xe7, 0x0d, 0x51, 0xbb, 0xdf, 0xdb, 0x94, 0xb1, 0x97, 0x5c, 0x7c, 0xe4, 0x6f, 0x14, 0x99, 0x38, 0xda,
0xe2, 0x3d, 0x7f, 0xa5, 0xc9, 0xc4, 0x33, 0x4e, 0x0f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xad, 0xe9, 0xf1, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x75, 0xc5, 0x1c, 0x3b, 0xd5, 0x02, 0x00, 0x00,
0x84, 0x08, 0xae, 0xe5, 0x02, 0x00, 0x00,
} }

View File

@@ -1,14 +1,21 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: google/protobuf/timestamp.proto // source: timestamp.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
timestamp.proto
It has these top-level messages:
Timestamp
*/
package types package types
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
import fmt "fmt" import fmt "fmt"
import math "math" import math "math"
import bytes "bytes"
import strings "strings" import strings "strings"
import reflect "reflect" import reflect "reflect"
@@ -88,9 +95,7 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
// is required. A proto3 JSON serializer should always use UTC (as indicated by // is required, though only UTC (as indicated by "Z") is presently supported.
// "Z") when printing the Timestamp type and a proto3 JSON parser should be
// able to accept both UTC and other timezones (as indicated by an offset).
// //
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
// 01:30 UTC on January 15, 2017. // 01:30 UTC on January 15, 2017.
@@ -101,8 +106,8 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
// can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( // can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime-- // http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
// ) to obtain a formatter capable of generating timestamps in this format. // to obtain a formatter capable of generating timestamps in this format.
// //
// //
type Timestamp struct { type Timestamp struct {
@@ -114,44 +119,13 @@ type Timestamp struct {
// second values with fractions must still have non-negative nanos values // second values with fractions must still have non-negative nanos values
// that count forward in time. Must be from 0 to 999,999,999 // that count forward in time. Must be from 0 to 999,999,999
// inclusive. // inclusive.
Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Timestamp) Reset() { *m = Timestamp{} } func (m *Timestamp) Reset() { *m = Timestamp{} }
func (*Timestamp) ProtoMessage() {} func (*Timestamp) ProtoMessage() {}
func (*Timestamp) Descriptor() ([]byte, []int) { func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptorTimestamp, []int{0} }
return fileDescriptor_timestamp_820f61227bd8f1e8, []int{0} func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" }
}
func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" }
func (m *Timestamp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Timestamp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *Timestamp) XXX_Merge(src proto.Message) {
xxx_messageInfo_Timestamp.Merge(dst, src)
}
func (m *Timestamp) XXX_Size() int {
return m.Size()
}
func (m *Timestamp) XXX_DiscardUnknown() {
xxx_messageInfo_Timestamp.DiscardUnknown(m)
}
var xxx_messageInfo_Timestamp proto.InternalMessageInfo
func (m *Timestamp) GetSeconds() int64 { func (m *Timestamp) GetSeconds() int64 {
if m != nil { if m != nil {
@@ -167,9 +141,6 @@ func (m *Timestamp) GetNanos() int32 {
return 0 return 0
} }
func (*Timestamp) XXX_MessageName() string {
return "google.protobuf.Timestamp"
}
func init() { func init() {
proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp")
} }
@@ -210,14 +181,14 @@ func (this *Timestamp) Compare(that interface{}) int {
} }
return 1 return 1
} }
if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
return c
}
return 0 return 0
} }
func (this *Timestamp) Equal(that interface{}) bool { func (this *Timestamp) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil if this == nil {
return true
}
return false
} }
that1, ok := that.(*Timestamp) that1, ok := that.(*Timestamp)
@@ -230,7 +201,10 @@ func (this *Timestamp) Equal(that interface{}) bool {
} }
} }
if that1 == nil { if that1 == nil {
return this == nil if this == nil {
return true
}
return false
} else if this == nil { } else if this == nil {
return false return false
} }
@@ -240,9 +214,6 @@ func (this *Timestamp) Equal(that interface{}) bool {
if this.Nanos != that1.Nanos { if this.Nanos != that1.Nanos {
return false return false
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *Timestamp) GoString() string { func (this *Timestamp) GoString() string {
@@ -253,9 +224,6 @@ func (this *Timestamp) GoString() string {
s = append(s, "&types.Timestamp{") s = append(s, "&types.Timestamp{")
s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n") s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n")
s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n") s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n")
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}") s = append(s, "}")
return strings.Join(s, "") return strings.Join(s, "")
} }
@@ -292,9 +260,6 @@ func (m *Timestamp) MarshalTo(dAtA []byte) (int, error) {
i++ i++
i = encodeVarintTimestamp(dAtA, i, uint64(m.Nanos)) i = encodeVarintTimestamp(dAtA, i, uint64(m.Nanos))
} }
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil return i, nil
} }
@@ -308,9 +273,6 @@ func encodeVarintTimestamp(dAtA []byte, offset int, v uint64) int {
return offset + 1 return offset + 1
} }
func (m *Timestamp) Size() (n int) { func (m *Timestamp) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if m.Seconds != 0 { if m.Seconds != 0 {
@@ -319,9 +281,6 @@ func (m *Timestamp) Size() (n int) {
if m.Nanos != 0 { if m.Nanos != 0 {
n += 1 + sovTimestamp(uint64(m.Nanos)) n += 1 + sovTimestamp(uint64(m.Nanos))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
@@ -417,7 +376,6 @@ func (m *Timestamp) Unmarshal(dAtA []byte) error {
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@@ -532,24 +490,21 @@ var (
ErrIntOverflowTimestamp = fmt.Errorf("proto: integer overflow") ErrIntOverflowTimestamp = fmt.Errorf("proto: integer overflow")
) )
func init() { func init() { proto.RegisterFile("timestamp.proto", fileDescriptorTimestamp) }
proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor_timestamp_820f61227bd8f1e8)
}
var fileDescriptor_timestamp_820f61227bd8f1e8 = []byte{ var fileDescriptorTimestamp = []byte{
// 212 bytes of a gzipped FileDescriptorProto // 205 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcf, 0xcf, 0x4f, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2f, 0xc9, 0xcc, 0x4d,
0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xc9, 0xcc, 0x4d, 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4f, 0xcf, 0xcf,
0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0xd0, 0x03, 0x0b, 0x09, 0xf1, 0x43, 0x14, 0xe8, 0xc1, 0x14, 0x28, 0x4f, 0xcf, 0x49, 0x85, 0xf0, 0x92, 0x4a, 0xd3, 0x94, 0xac, 0xb9, 0x38, 0x43, 0x60, 0x6a, 0x84,
0x59, 0x73, 0x71, 0x86, 0xc0, 0xd4, 0x08, 0x49, 0x70, 0xb1, 0x17, 0xa7, 0x26, 0xe7, 0xe7, 0xa5, 0x24, 0xb8, 0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98,
0x14, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0xc1, 0xb8, 0x42, 0x22, 0x5c, 0xac, 0x79, 0x89, 0x83, 0x60, 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46,
0x79, 0xf9, 0xc5, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0x10, 0x8e, 0x53, 0x03, 0xe3, 0x8d, 0x0d, 0xd6, 0x20, 0x08, 0xc7, 0xa9, 0x81, 0xf1, 0xc2, 0x43, 0x39, 0x86, 0x1b, 0x0f, 0xe5, 0x18,
0x87, 0x72, 0x0c, 0x1f, 0x1e, 0xca, 0x31, 0xae, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x3e, 0x3c, 0x94, 0x63, 0x5c, 0xf1, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4,
0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0xbe, 0x78, 0x24, 0xc7, 0xf0, 0xe1, 0x91, 0x1c, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x7c, 0xf1, 0x48, 0x8e, 0xe1, 0xc3, 0x23, 0x39, 0xc6, 0x15, 0x8f,
0xe3, 0x8a, 0xc7, 0x72, 0x8c, 0x27, 0x1e, 0xcb, 0x31, 0x72, 0x09, 0x27, 0xe7, 0xe7, 0xea, 0xa1, 0xe5, 0x18, 0xb9, 0x84, 0x93, 0xf3, 0x73, 0xf5, 0xd0, 0x2c, 0x77, 0xe2, 0x83, 0x5b, 0x1d, 0x00,
0x59, 0xee, 0xc4, 0x07, 0xb7, 0x3a, 0x00, 0x24, 0x14, 0xc0, 0x18, 0xc5, 0x5a, 0x52, 0x59, 0x90, 0x12, 0x0a, 0x60, 0x8c, 0x62, 0x2d, 0xa9, 0x2c, 0x48, 0x2d, 0xfe, 0xc1, 0xc8, 0xb8, 0x88, 0x89,
0x5a, 0xfc, 0x83, 0x91, 0x71, 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0xd9, 0x3d, 0xc0, 0x69, 0x15, 0x93, 0x9c, 0x3b, 0x44, 0x4f, 0x00, 0x54, 0x8f, 0x5e, 0x78, 0x6a,
0x9e, 0x00, 0xa8, 0x1e, 0xbd, 0xf0, 0xd4, 0x9c, 0x1c, 0xef, 0xbc, 0xfc, 0xf2, 0xbc, 0x10, 0x90, 0x4e, 0x8e, 0x77, 0x5e, 0x7e, 0x79, 0x5e, 0x08, 0x48, 0x65, 0x12, 0x1b, 0xd8, 0x30, 0x63, 0x40,
0xca, 0x24, 0x36, 0xb0, 0x61, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x23, 0x83, 0xdd, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xa2, 0x42, 0xda, 0xea, 0x00, 0x00, 0x00,
0xfa, 0x00, 0x00, 0x00,
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,300 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2018, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package types
func NewPopulatedStdDouble(r randyWrappers, easy bool) *float64 {
v := NewPopulatedDoubleValue(r, easy)
return &v.Value
}
func SizeOfStdDouble(v float64) int {
pv := &DoubleValue{Value: v}
return pv.Size()
}
func StdDoubleMarshal(v float64) ([]byte, error) {
size := SizeOfStdDouble(v)
buf := make([]byte, size)
_, err := StdDoubleMarshalTo(v, buf)
return buf, err
}
func StdDoubleMarshalTo(v float64, data []byte) (int, error) {
pv := &DoubleValue{Value: v}
return pv.MarshalTo(data)
}
func StdDoubleUnmarshal(v *float64, data []byte) error {
pv := &DoubleValue{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}
func NewPopulatedStdFloat(r randyWrappers, easy bool) *float32 {
v := NewPopulatedFloatValue(r, easy)
return &v.Value
}
func SizeOfStdFloat(v float32) int {
pv := &FloatValue{Value: v}
return pv.Size()
}
func StdFloatMarshal(v float32) ([]byte, error) {
size := SizeOfStdFloat(v)
buf := make([]byte, size)
_, err := StdFloatMarshalTo(v, buf)
return buf, err
}
func StdFloatMarshalTo(v float32, data []byte) (int, error) {
pv := &FloatValue{Value: v}
return pv.MarshalTo(data)
}
func StdFloatUnmarshal(v *float32, data []byte) error {
pv := &FloatValue{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}
func NewPopulatedStdInt64(r randyWrappers, easy bool) *int64 {
v := NewPopulatedInt64Value(r, easy)
return &v.Value
}
func SizeOfStdInt64(v int64) int {
pv := &Int64Value{Value: v}
return pv.Size()
}
func StdInt64Marshal(v int64) ([]byte, error) {
size := SizeOfStdInt64(v)
buf := make([]byte, size)
_, err := StdInt64MarshalTo(v, buf)
return buf, err
}
func StdInt64MarshalTo(v int64, data []byte) (int, error) {
pv := &Int64Value{Value: v}
return pv.MarshalTo(data)
}
func StdInt64Unmarshal(v *int64, data []byte) error {
pv := &Int64Value{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}
func NewPopulatedStdUInt64(r randyWrappers, easy bool) *uint64 {
v := NewPopulatedUInt64Value(r, easy)
return &v.Value
}
func SizeOfStdUInt64(v uint64) int {
pv := &UInt64Value{Value: v}
return pv.Size()
}
func StdUInt64Marshal(v uint64) ([]byte, error) {
size := SizeOfStdUInt64(v)
buf := make([]byte, size)
_, err := StdUInt64MarshalTo(v, buf)
return buf, err
}
func StdUInt64MarshalTo(v uint64, data []byte) (int, error) {
pv := &UInt64Value{Value: v}
return pv.MarshalTo(data)
}
func StdUInt64Unmarshal(v *uint64, data []byte) error {
pv := &UInt64Value{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}
func NewPopulatedStdInt32(r randyWrappers, easy bool) *int32 {
v := NewPopulatedInt32Value(r, easy)
return &v.Value
}
func SizeOfStdInt32(v int32) int {
pv := &Int32Value{Value: v}
return pv.Size()
}
func StdInt32Marshal(v int32) ([]byte, error) {
size := SizeOfStdInt32(v)
buf := make([]byte, size)
_, err := StdInt32MarshalTo(v, buf)
return buf, err
}
func StdInt32MarshalTo(v int32, data []byte) (int, error) {
pv := &Int32Value{Value: v}
return pv.MarshalTo(data)
}
func StdInt32Unmarshal(v *int32, data []byte) error {
pv := &Int32Value{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}
func NewPopulatedStdUInt32(r randyWrappers, easy bool) *uint32 {
v := NewPopulatedUInt32Value(r, easy)
return &v.Value
}
func SizeOfStdUInt32(v uint32) int {
pv := &UInt32Value{Value: v}
return pv.Size()
}
func StdUInt32Marshal(v uint32) ([]byte, error) {
size := SizeOfStdUInt32(v)
buf := make([]byte, size)
_, err := StdUInt32MarshalTo(v, buf)
return buf, err
}
func StdUInt32MarshalTo(v uint32, data []byte) (int, error) {
pv := &UInt32Value{Value: v}
return pv.MarshalTo(data)
}
func StdUInt32Unmarshal(v *uint32, data []byte) error {
pv := &UInt32Value{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}
func NewPopulatedStdBool(r randyWrappers, easy bool) *bool {
v := NewPopulatedBoolValue(r, easy)
return &v.Value
}
func SizeOfStdBool(v bool) int {
pv := &BoolValue{Value: v}
return pv.Size()
}
func StdBoolMarshal(v bool) ([]byte, error) {
size := SizeOfStdBool(v)
buf := make([]byte, size)
_, err := StdBoolMarshalTo(v, buf)
return buf, err
}
func StdBoolMarshalTo(v bool, data []byte) (int, error) {
pv := &BoolValue{Value: v}
return pv.MarshalTo(data)
}
func StdBoolUnmarshal(v *bool, data []byte) error {
pv := &BoolValue{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}
func NewPopulatedStdString(r randyWrappers, easy bool) *string {
v := NewPopulatedStringValue(r, easy)
return &v.Value
}
func SizeOfStdString(v string) int {
pv := &StringValue{Value: v}
return pv.Size()
}
func StdStringMarshal(v string) ([]byte, error) {
size := SizeOfStdString(v)
buf := make([]byte, size)
_, err := StdStringMarshalTo(v, buf)
return buf, err
}
func StdStringMarshalTo(v string, data []byte) (int, error) {
pv := &StringValue{Value: v}
return pv.MarshalTo(data)
}
func StdStringUnmarshal(v *string, data []byte) error {
pv := &StringValue{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}
func NewPopulatedStdBytes(r randyWrappers, easy bool) *[]byte {
v := NewPopulatedBytesValue(r, easy)
return &v.Value
}
func SizeOfStdBytes(v []byte) int {
pv := &BytesValue{Value: v}
return pv.Size()
}
func StdBytesMarshal(v []byte) ([]byte, error) {
size := SizeOfStdBytes(v)
buf := make([]byte, size)
_, err := StdBytesMarshalTo(v, buf)
return buf, err
}
func StdBytesMarshalTo(v []byte, data []byte) (int, error) {
pv := &BytesValue{Value: v}
return pv.MarshalTo(data)
}
func StdBytesUnmarshal(v *[]byte, data []byte) error {
pv := &BytesValue{}
if err := pv.Unmarshal(data); err != nil {
return err
}
*v = pv.Value
return nil
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,45 +3,75 @@
package vsock package vsock
import ( import (
"net"
"os"
"time"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
// newConn creates a Conn using a connFD, immediately setting the connFD to var _ net.Conn = &conn{}
// non-blocking mode for use with the runtime network poller.
func newConn(cfd connFD, local, remote *Addr) (*Conn, error) { // A conn is the net.Conn implementation for VM sockets.
// Note: if any calls fail after this point, cfd.Close should be invoked type conn struct {
// for cleanup because the socket is now non-blocking. file *os.File
if err := cfd.SetNonblocking(local.fileName()); err != nil { localAddr *Addr
remoteAddr *Addr
}
// Implement net.Conn for type conn.
func (c *conn) LocalAddr() net.Addr { return c.localAddr }
func (c *conn) RemoteAddr() net.Addr { return c.remoteAddr }
func (c *conn) SetDeadline(t time.Time) error { return c.file.SetDeadline(t) }
func (c *conn) SetReadDeadline(t time.Time) error { return c.file.SetReadDeadline(t) }
func (c *conn) SetWriteDeadline(t time.Time) error { return c.file.SetWriteDeadline(t) }
func (c *conn) Read(b []byte) (n int, err error) { return c.file.Read(b) }
func (c *conn) Write(b []byte) (n int, err error) { return c.file.Write(b) }
func (c *conn) Close() error { return c.file.Close() }
// newConn creates a conn using an fd with the specified file name, local, and
// remote addresses.
func newConn(cfd fd, file string, local, remote *Addr) (*conn, error) {
// Enable integration with runtime network poller for timeout support
// in Go 1.11+.
if err := cfd.SetNonblock(true); err != nil {
return nil, err return nil, err
} }
return &Conn{ return &conn{
fd: cfd, file: cfd.NewFile(file),
local: local, localAddr: local,
remote: remote, remoteAddr: remote,
}, nil }, nil
} }
// dial is the entry point for Dial on Linux. // dialStream is the entry point for DialStream on Linux.
func dial(cid, port uint32) (*Conn, error) { func dialStream(cid, port uint32) (net.Conn, error) {
cfd, err := newConnFD() fd, err := unix.Socket(unix.AF_VSOCK, unix.SOCK_STREAM, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return dialLinux(cfd, cid, port) cfd := &sysFD{fd: fd}
return dialStreamLinuxHandleError(cfd, cid, port)
} }
// dialLinux is the entry point for tests on Linux. // dialStreamLinuxHandleError ensures that any errors from dialStreamLinux result
func dialLinux(cfd connFD, cid, port uint32) (c *Conn, err error) { // in the socket being cleaned up properly.
defer func() { func dialStreamLinuxHandleError(cfd fd, cid, port uint32) (net.Conn, error) {
if err != nil { c, err := dialStreamLinux(cfd, cid, port)
// If any system calls fail during setup, the socket must be closed if err != nil {
// to avoid file descriptor leaks. // If any system calls fail during setup, the socket must be closed
_ = cfd.EarlyClose() // to avoid file descriptor leaks.
} _ = cfd.Close()
}() return nil, err
}
return c, nil
}
// dialStreamLinux is the entry point for tests on Linux.
func dialStreamLinux(cfd fd, cid, port uint32) (net.Conn, error) {
rsa := &unix.SockaddrVM{ rsa := &unix.SockaddrVM{
CID: cid, CID: cid,
Port: port, Port: port,
@@ -57,16 +87,16 @@ func dialLinux(cfd connFD, cid, port uint32) (c *Conn, err error) {
} }
lsavm := lsa.(*unix.SockaddrVM) lsavm := lsa.(*unix.SockaddrVM)
localAddr := &Addr{
local := &Addr{
ContextID: lsavm.CID, ContextID: lsavm.CID,
Port: lsavm.Port, Port: lsavm.Port,
} }
remote := &Addr{ remoteAddr := &Addr{
ContextID: cid, ContextID: cid,
Port: port, Port: port,
} }
return newConn(cfd, local, remote) // File name is the name of the local socket.
return newConn(cfd, localAddr.fileName(), localAddr, remoteAddr)
} }

View File

@@ -1,55 +0,0 @@
// Package vsock provides access to Linux VM sockets (AF_VSOCK) for
// communication between a hypervisor and its virtual machines.
//
// The types in this package implement interfaces provided by package net and
// may be used in applications that expect a net.Listener or net.Conn.
//
// - *Addr implements net.Addr
// - *Conn implements net.Conn
// - *Listener implements net.Listener
//
// Go version support
//
// This package supports varying levels of functionality depending on the version
// of Go used during compilation. The Listener and Conn types produced by this
// package are backed by non-blocking I/O, in order to integrate with Go's
// runtime network poller in Go 1.11+. Additional functionality is available
// starting in Go 1.12+.
//
// Go 1.12+ (recommended):
// - *Listener:
// - Accept blocks until a connection is received
// - Close can interrupt Accept and make it return a permanent error
// - SetDeadline can set timeouts which can interrupt Accept and make it return a
// temporary error
// - *Conn:
// - SetDeadline family of methods are fully supported
// - CloseRead and CloseWrite can close the reading or writing sides of a
// Conn, respectively
// - SyscallConn provides access to raw network control/read/write functionality
//
// Go 1.11 (not recommended):
// - *Listener:
// - Accept is non-blocking and should be called in a loop, checking for
// net.Error.Temporary() == true and sleeping for a short period to avoid wasteful
// CPU cycle consumption
// - Close makes Accept return a permanent error on the next loop iteration
// - SetDeadline is not supported and will always return an error
// - *Conn:
// - SetDeadline family of methods are fully supported
// - CloseRead and CloseWrite are not supported and will always return an error
// - SyscallConn is not supported and will always return an error
//
// Go 1.10 and below are not supported. The runtime network poller integration
// required by this package is not available in Go versions prior to Go 1.11.
// Unsupported versions of Go will produce a compilation error when trying to
// build this package.
//
// Stability
//
// At this time, package vsock is in a pre-v1.0.0 state. Changes are being made
// which may impact the exported API of this package and others in its ecosystem.
//
// If you depend on this package in your application, please use Go modules when
// building your application.
package vsock

View File

@@ -1,202 +1,45 @@
package vsock package vsock
import ( import (
"fmt"
"io"
"os" "os"
"syscall"
"time"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
// A listenFD is a type that wraps a file descriptor used to implement // A fd is an interface for a file descriptor, used to perform system
// net.Listener. // calls or swap them out for tests.
type listenFD interface { type fd interface {
io.Closer Accept4(flags int) (fd, unix.Sockaddr, error)
EarlyClose() error
Accept4(flags int) (connFD, unix.Sockaddr, error)
Bind(sa unix.Sockaddr) error Bind(sa unix.Sockaddr) error
Listen(n int) error Close() error
Connect(sa unix.Sockaddr) error
Getsockname() (unix.Sockaddr, error) Getsockname() (unix.Sockaddr, error)
SetNonblocking(name string) error Listen(n int) error
SetDeadline(t time.Time) error NewFile(name string) *os.File
SetNonblock(nonblocking bool) error
} }
var _ listenFD = &sysListenFD{} var _ fd = &sysFD{}
// A sysListenFD is the system call implementation of listenFD. // sysFD is the system call implementation of fd.
type sysListenFD struct { type sysFD struct {
// These fields should never be non-zero at the same time. fd int
fd int // Used in blocking mode.
f *os.File // Used in non-blocking mode.
} }
// newListenFD creates a sysListenFD in its default blocking mode. func (fd *sysFD) Accept4(flags int) (fd, unix.Sockaddr, error) {
func newListenFD() (*sysListenFD, error) { // Returns a regular file descriptor, must be wrapped in another
fd, err := unix.Socket(unix.AF_VSOCK, unix.SOCK_STREAM, 0) // sysFD for it to work properly.
if err != nil { nfd, sa, err := unix.Accept4(fd.fd, flags)
return nil, err
}
return &sysListenFD{
fd: fd,
}, nil
}
// Blocking mode methods.
func (lfd *sysListenFD) Bind(sa unix.Sockaddr) error { return unix.Bind(lfd.fd, sa) }
func (lfd *sysListenFD) Getsockname() (unix.Sockaddr, error) { return unix.Getsockname(lfd.fd) }
func (lfd *sysListenFD) Listen(n int) error { return unix.Listen(lfd.fd, n) }
func (lfd *sysListenFD) SetNonblocking(name string) error {
// From now on, we must perform non-blocking I/O, so that our
// net.Listener.Accept method can be interrupted by closing the socket.
if err := unix.SetNonblock(lfd.fd, true); err != nil {
return err
}
// Transition from blocking mode to non-blocking mode.
lfd.f = os.NewFile(uintptr(lfd.fd), name)
return nil
}
// EarlyClose is a blocking version of Close, only used for cleanup before
// entering non-blocking mode.
func (lfd *sysListenFD) EarlyClose() error { return unix.Close(lfd.fd) }
// Non-blocking mode methods.
func (lfd *sysListenFD) Accept4(flags int) (connFD, unix.Sockaddr, error) {
// Invoke Go version-specific logic for accept.
newFD, sa, err := lfd.accept4(flags)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
// Create a non-blocking connFD which will be used to implement net.Conn. return &sysFD{fd: nfd}, sa, nil
cfd := &sysConnFD{fd: newFD}
return cfd, sa, nil
}
func (lfd *sysListenFD) Close() error {
// In Go 1.12+, *os.File.Close will also close the runtime network poller
// file descriptor, so that net.Listener.Accept can stop blocking.
return lfd.f.Close()
}
func (lfd *sysListenFD) SetDeadline(t time.Time) error {
// Invoke Go version-specific logic for setDeadline.
return lfd.setDeadline(t)
}
// A connFD is a type that wraps a file descriptor used to implement net.Conn.
type connFD interface {
io.ReadWriteCloser
EarlyClose() error
Connect(sa unix.Sockaddr) error
Getsockname() (unix.Sockaddr, error)
Shutdown(how int) error
SetNonblocking(name string) error
SetDeadline(t time.Time, typ deadlineType) error
SyscallConn() (syscall.RawConn, error)
}
var _ connFD = &sysConnFD{}
// newConnFD creates a sysConnFD in its default blocking mode.
func newConnFD() (*sysConnFD, error) {
fd, err := unix.Socket(unix.AF_VSOCK, unix.SOCK_STREAM, 0)
if err != nil {
return nil, err
}
return &sysConnFD{
fd: fd,
}, nil
}
// A sysConnFD is the system call implementation of connFD.
type sysConnFD struct {
// These fields should never be non-zero at the same time.
fd int // Used in blocking mode.
f *os.File // Used in non-blocking mode.
}
// Blocking mode methods.
func (cfd *sysConnFD) Connect(sa unix.Sockaddr) error { return unix.Connect(cfd.fd, sa) }
func (cfd *sysConnFD) Getsockname() (unix.Sockaddr, error) { return unix.Getsockname(cfd.fd) }
// EarlyClose is a blocking version of Close, only used for cleanup before
// entering non-blocking mode.
func (cfd *sysConnFD) EarlyClose() error { return unix.Close(cfd.fd) }
func (cfd *sysConnFD) SetNonblocking(name string) error {
// From now on, we must perform non-blocking I/O, so that our deadline
// methods work, and the connection can be interrupted by net.Conn.Close.
if err := unix.SetNonblock(cfd.fd, true); err != nil {
return err
}
// Transition from blocking mode to non-blocking mode.
cfd.f = os.NewFile(uintptr(cfd.fd), name)
return nil
}
// Non-blocking mode methods.
func (cfd *sysConnFD) Close() error {
// *os.File.Close will also close the runtime network poller file descriptor,
// so that read/write can stop blocking.
return cfd.f.Close()
}
func (cfd *sysConnFD) Read(b []byte) (int, error) { return cfd.f.Read(b) }
func (cfd *sysConnFD) Write(b []byte) (int, error) { return cfd.f.Write(b) }
func (cfd *sysConnFD) Shutdown(how int) error {
switch how {
case unix.SHUT_RD, unix.SHUT_WR:
return cfd.shutdown(how)
default:
panicf("vsock: sysConnFD.Shutdown method invoked with invalid how constant: %d", how)
return nil
}
}
func (cfd *sysConnFD) SetDeadline(t time.Time, typ deadlineType) error {
switch typ {
case deadline:
return cfd.f.SetDeadline(t)
case readDeadline:
return cfd.f.SetReadDeadline(t)
case writeDeadline:
return cfd.f.SetWriteDeadline(t)
default:
panicf("vsock: sysConnFD.SetDeadline method invoked with invalid deadline type constant: %d", typ)
return nil
}
}
func (cfd *sysConnFD) SyscallConn() (syscall.RawConn, error) { return cfd.syscallConn() }
// isErrno determines if an error a matches UNIX error number.
func isErrno(err error, errno int) bool {
switch errno {
case ebadf:
return err == unix.EBADF
case enotconn:
return err == unix.ENOTCONN
default:
panicf("vsock: isErrno called with unhandled error number parameter: %d", errno)
return false
}
}
func panicf(format string, a ...interface{}) {
panic(fmt.Sprintf(format, a...))
} }
func (fd *sysFD) Bind(sa unix.Sockaddr) error { return unix.Bind(fd.fd, sa) }
func (fd *sysFD) Close() error { return unix.Close(fd.fd) }
func (fd *sysFD) Connect(sa unix.Sockaddr) error { return unix.Connect(fd.fd, sa) }
func (fd *sysFD) Getsockname() (unix.Sockaddr, error) { return unix.Getsockname(fd.fd) }
func (fd *sysFD) Listen(n int) error { return unix.Listen(fd.fd, n) }
func (fd *sysFD) NewFile(name string) *os.File { return os.NewFile(uintptr(fd.fd), name) }
func (fd *sysFD) SetNonblock(nonblocking bool) error { return unix.SetNonblock(fd.fd, nonblocking) }

View File

@@ -1,71 +0,0 @@
//+build go1.12,linux
package vsock
import (
"syscall"
"time"
"golang.org/x/sys/unix"
)
func (lfd *sysListenFD) accept4(flags int) (int, unix.Sockaddr, error) {
// In Go 1.12+, we make use of runtime network poller integration to allow
// net.Listener.Accept to be unblocked by a call to net.Listener.Close.
rc, err := lfd.f.SyscallConn()
if err != nil {
return 0, nil, err
}
var (
newFD int
sa unix.Sockaddr
)
doErr := rc.Read(func(fd uintptr) bool {
newFD, sa, err = unix.Accept4(int(fd), flags)
switch err {
case unix.EAGAIN, unix.ECONNABORTED:
// Return false to let the poller wait for readiness. See the
// source code for internal/poll.FD.RawRead for more details.
//
// When the socket is in non-blocking mode, we might see EAGAIN if
// the socket is not ready for reading.
//
// In addition, the network poller's accept implementation also
// deals with ECONNABORTED, in case a socket is closed before it is
// pulled from our listen queue.
return false
default:
// No error or some unrecognized error, treat this Read operation
// as completed.
return true
}
})
if doErr != nil {
return 0, nil, doErr
}
return newFD, sa, err
}
func (lfd *sysListenFD) setDeadline(t time.Time) error { return lfd.f.SetDeadline(t) }
func (cfd *sysConnFD) shutdown(how int) error {
rc, err := cfd.f.SyscallConn()
if err != nil {
return err
}
doErr := rc.Control(func(fd uintptr) {
err = unix.Shutdown(int(fd), how)
})
if doErr != nil {
return doErr
}
return err
}
func (cfd *sysConnFD) syscallConn() (syscall.RawConn, error) { return cfd.f.SyscallConn() }

View File

@@ -1,35 +0,0 @@
//+build !go1.12,linux
package vsock
import (
"fmt"
"runtime"
"syscall"
"time"
"golang.org/x/sys/unix"
)
func (lfd *sysListenFD) accept4(flags int) (int, unix.Sockaddr, error) {
// In Go 1.11, accept on the raw file descriptor directly, because lfd.f
// may be attached to the runtime network poller, forcing this call to block
// even if Close is called.
return unix.Accept4(lfd.fd, flags)
}
func (*sysListenFD) setDeadline(_ time.Time) error {
// Listener deadlines won't work as expected in this version of Go, so
// return an early error.
return fmt.Errorf("vsock: listener deadlines not supported on %s", runtime.Version())
}
func (*sysConnFD) shutdown(_ int) error {
// Shutdown functionality is not available in this version on Go.
return fmt.Errorf("vsock: close conn read/write not supported on %s", runtime.Version())
}
func (*sysConnFD) syscallConn() (syscall.RawConn, error) {
// SyscallConn functionality is not available in this version on Go.
return nil, fmt.Errorf("vsock: syscall conn not supported on %s", runtime.Version())
}

Some files were not shown because too many files have changed in this diff Show More