mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-01-17 18:29:30 +00:00
Merge pull request #123 from rootfs/master-to-1.0
Merge master to csi-v1.0 branch
This commit is contained in:
commit
661818bd79
@ -7,7 +7,7 @@ branches:
|
||||
- master
|
||||
- csi-v1.0
|
||||
|
||||
go: 1.9.x
|
||||
go: 1.10.x
|
||||
|
||||
before_script:
|
||||
- GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/)
|
||||
|
377
Gopkg.lock
generated
377
Gopkg.lock
generated
@ -9,6 +9,17 @@
|
||||
revision = "ed0bb0e1557548aa028307f48728767cfe8f6345"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:527e1e468c5586ef2645d143e9f5fbd50b4fe5abc8b1e25d9f1c416d22d24895"
|
||||
name = "github.com/gogo/protobuf"
|
||||
packages = [
|
||||
"proto",
|
||||
"sortkeys",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "4cbf7e384e768b4e01799441fdf2a706a5635ae7"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:107b233e45174dbab5b1324201d092ea9448e58243ab9f039e4c0f332e121e3a"
|
||||
@ -21,6 +32,7 @@
|
||||
digest = "1:3dd078fda7500c341bc26cfbc6c6a34614f295a2457149fc1045cab767cbcf18"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = [
|
||||
"descriptor",
|
||||
"proto",
|
||||
"protoc-gen-go/descriptor",
|
||||
"ptypes",
|
||||
@ -33,6 +45,22 @@
|
||||
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:1e5b1e14524ed08301977b7b8e10c719ed853cbf3f24ecb66fae783a46f207a6"
|
||||
name = "github.com/google/btree"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:754f77e9c839b24778a4b64422236d38515301d2baeb63113aa3edc42e6af692"
|
||||
name = "github.com/google/gofuzz"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a25a2c5ae694b01713fb6cd03c3b1ac1ccc1902b9f0a922680a88ec254f968e1"
|
||||
name = "github.com/google/uuid"
|
||||
@ -41,13 +69,76 @@
|
||||
revision = "9b3b1e0f5f99ae461456d768e7d301a7acdaa2d8"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:16b2837c8b3cf045fa2cdc82af0cf78b19582701394484ae76b2c3bc3c99ad73"
|
||||
name = "github.com/googleapis/gnostic"
|
||||
packages = [
|
||||
"OpenAPIv2",
|
||||
"compiler",
|
||||
"extensions",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "7c663266750e7d82587642f65e60bc4083f1f84e"
|
||||
version = "v0.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:01f6264649510cce626f907688df44f80c8ba788d064756701d85c51f21eb0d6"
|
||||
digest = "1:5e345eb75d8bfb2b91cfbfe02a82a79c0b2ea55cf06c5a4d180a9321f36973b4"
|
||||
name = "github.com/gregjones/httpcache"
|
||||
packages = [
|
||||
".",
|
||||
"diskcache",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "c63ab54fda8f77302f8d414e19933f2b6026a089"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:7ab38c15bd21e056e3115c8b526d201eaf74e0308da9370997c6b3c187115d36"
|
||||
name = "github.com/imdario/mergo"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4"
|
||||
version = "v0.3.6"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b79fc583e4dc7055ed86742e22164ac41bf8c0940722dbcb600f1a3ace1a8cb5"
|
||||
name = "github.com/json-iterator/go"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "1624edc4454b8682399def8740d46db5e4362ba4"
|
||||
version = "v1.1.5"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d1f1992c09d7b77bc5102cd8c369025d31d28dd5e6ca2a3a1a4ec9434724a4f5"
|
||||
name = "github.com/kubernetes-csi/csi-lib-utils"
|
||||
packages = ["protosanitizer"]
|
||||
pruneopts = ""
|
||||
revision = "5853414e1d4771302e0df10d1870c444c2135799"
|
||||
version = "v0.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:5031afaa62ff480905e90bed2d2fd74f07b12f4c0c30304bc4ab9472b55439d1"
|
||||
name = "github.com/kubernetes-csi/drivers"
|
||||
packages = ["pkg/csi-common"]
|
||||
pruneopts = ""
|
||||
revision = "8a7f2d3a4057ddcff31b7898bd4413dfdf3a3b67"
|
||||
revision = "05e1ea84df03b90296869812fa42f4244bd5ab53"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:0c0ff2a89c1bb0d01887e1dac043ad7efbf3ec77482ef058ac423d13497e16fd"
|
||||
name = "github.com/modern-go/concurrent"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94"
|
||||
version = "1.0.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:e32bdbdb7c377a07a9a46378290059822efdce5c8d96fe71940d87cb4f918855"
|
||||
name = "github.com/modern-go/reflect2"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
|
||||
version = "1.0.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a5484d4fa43127138ae6e7b2299a6a52ae006c7f803d98d717f60abf3e97192e"
|
||||
@ -58,19 +149,52 @@
|
||||
version = "v1.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:7365acd48986e205ccb8652cc746f09c8b7876030d53710ea6ef7d0bd0dcd7ca"
|
||||
branch = "master"
|
||||
digest = "1:c24598ffeadd2762552269271b3b1510df2d83ee6696c1e543a0ff653af494bc"
|
||||
name = "github.com/petar/GoLLRB"
|
||||
packages = ["llrb"]
|
||||
pruneopts = ""
|
||||
revision = "53be0d36a84c2a886ca057d34b6aa4468df9ccb4"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b46305723171710475f2dd37547edd57b67b9de9f2a6267cafdd98331fd6897f"
|
||||
name = "github.com/peterbourgon/diskv"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "5f041e8faa004a95c88a202771f4cc3e991971e6"
|
||||
version = "v2.0.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:1d7e1867c49a6dd9856598ef7c3123604ea3daabf5b83f303ff457bcbc410b1d"
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4"
|
||||
version = "v0.8.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:cbaf13cdbfef0e4734ed8a7504f57fe893d471d62a35b982bf6fb3f036449a66"
|
||||
name = "github.com/spf13/pflag"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "298182f68c66c05229eb03ac171abe6e309ee79a"
|
||||
version = "v1.0.3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:ea539c13b066dac72a940b62f37600a20ab8e88057397c78f3197c1a48475425"
|
||||
digest = "1:59b49c47c11a48f1054529207f65907c014ecf5f9a7c0d9c0f1616dec7b062ed"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = ["ssh/terminal"]
|
||||
pruneopts = ""
|
||||
revision = "ff983b9c42bc9fbf91556e191cc8efb585c16908"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:7ec13687f85b25087fe05f6ea8dd116013a8263f8eb7e057da7664bc7599d2d4"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"context",
|
||||
"context/ctxhttp",
|
||||
"http/httpguts",
|
||||
"http2",
|
||||
"http2/hpack",
|
||||
@ -79,15 +203,29 @@
|
||||
"trace",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "351d144fa1fc0bd934e2408202be0c29f25e35a0"
|
||||
revision = "915654e7eabcea33ae277abbecf52f0d8b7a9fdc"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:f358024b019f87eecaadcb098113a40852c94fe58ea670ef3c3e2d2c7bd93db1"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix"]
|
||||
digest = "1:790c83515921619a461cf47449bbdd5f58e35f689edc8164262cce7db4ae29ca"
|
||||
name = "golang.org/x/oauth2"
|
||||
packages = [
|
||||
".",
|
||||
"internal",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "4ed8d59d0b35e1e29334a206d1b3f38b1e5dfb31"
|
||||
revision = "36a7019397c4c86cf59eeab3bc0d188bac444277"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:69b7ecfaddca30f8e8d97798822ff2b8ddfa7634ed16661561b54f30c63c2a42"
|
||||
name = "golang.org/x/sys"
|
||||
packages = [
|
||||
"unix",
|
||||
"windows",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "a457fd036447854c0c02e89ea439481bdcf941a2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4"
|
||||
@ -114,31 +252,60 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:5fc6c317675b746d0c641b29aa0aab5fcb403c0d07afdbf0de86b0d447a0502a"
|
||||
digest = "1:14cb1d4240bcbbf1386ae763957e04e2765ec4e4ce7bb2769d05fa6faccd774e"
|
||||
name = "golang.org/x/time"
|
||||
packages = ["rate"]
|
||||
pruneopts = ""
|
||||
revision = "85acf8d2951cb2a3bde7632f9ff273ef0379bcbd"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:bc09e719c4e2a15d17163f5272d9a3131c45d77542b7fdc53ff518815bc19ab3"
|
||||
name = "google.golang.org/appengine"
|
||||
packages = [
|
||||
"internal",
|
||||
"internal/base",
|
||||
"internal/datastore",
|
||||
"internal/log",
|
||||
"internal/remote_api",
|
||||
"internal/urlfetch",
|
||||
"urlfetch",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "e9657d882bb81064595ca3b56cbe2546bbabf7b1"
|
||||
version = "v1.4.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:1aa609a0033ef2927e083f2e5e07203ca35fe21c4a24b563de9fea16ddaae9ba"
|
||||
name = "google.golang.org/genproto"
|
||||
packages = ["googleapis/rpc/status"]
|
||||
pruneopts = ""
|
||||
revision = "bd91e49a0898e27abb88c339b432fa53d7497ac0"
|
||||
revision = "db91494dd46c1fdcbbde05e5ff5eb56df8f7d79a"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:1293087271e314cfa2b3decededba2ecba0ff327e7b7809e00f73f616449191c"
|
||||
digest = "1:d141efe4aaad714e3059c340901aab3147b6253e58c85dafbcca3dd8b0e88ad6"
|
||||
name = "google.golang.org/grpc"
|
||||
packages = [
|
||||
".",
|
||||
"balancer",
|
||||
"balancer/base",
|
||||
"balancer/roundrobin",
|
||||
"binarylog/grpc_binarylog_v1",
|
||||
"codes",
|
||||
"connectivity",
|
||||
"credentials",
|
||||
"credentials/internal",
|
||||
"encoding",
|
||||
"encoding/proto",
|
||||
"grpclog",
|
||||
"internal",
|
||||
"internal/backoff",
|
||||
"internal/binarylog",
|
||||
"internal/channelz",
|
||||
"internal/envconfig",
|
||||
"internal/grpcrand",
|
||||
"internal/grpcsync",
|
||||
"internal/syscall",
|
||||
"internal/transport",
|
||||
"keepalive",
|
||||
"metadata",
|
||||
@ -152,21 +319,175 @@
|
||||
"tap",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "2e463a05d100327ca47ac218281906921038fd95"
|
||||
version = "v1.16.0"
|
||||
revision = "df014850f6dee74ba2fc94874043a9f3f75fbfd8"
|
||||
version = "v1.17.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:75fb3fcfc73a8c723efde7777b40e8e8ff9babf30d8c56160d01beffea8a95a6"
|
||||
name = "gopkg.in/inf.v0"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf"
|
||||
version = "v0.9.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:cedccf16b71e86db87a24f8d4c70b0a855872eb967cb906a66b95de56aefbd0d"
|
||||
name = "gopkg.in/yaml.v2"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "51d6538a90f86fe93ac480b35f37b2be17fef232"
|
||||
version = "v2.2.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:be67264067c68b1f601bfc4a6c102b1380ed0743147381de81ed11da88d2e246"
|
||||
name = "k8s.io/api"
|
||||
packages = [
|
||||
"admissionregistration/v1alpha1",
|
||||
"admissionregistration/v1beta1",
|
||||
"apps/v1",
|
||||
"apps/v1beta1",
|
||||
"apps/v1beta2",
|
||||
"auditregistration/v1alpha1",
|
||||
"authentication/v1",
|
||||
"authentication/v1beta1",
|
||||
"authorization/v1",
|
||||
"authorization/v1beta1",
|
||||
"autoscaling/v1",
|
||||
"autoscaling/v2beta1",
|
||||
"autoscaling/v2beta2",
|
||||
"batch/v1",
|
||||
"batch/v1beta1",
|
||||
"batch/v2alpha1",
|
||||
"certificates/v1beta1",
|
||||
"coordination/v1beta1",
|
||||
"core/v1",
|
||||
"events/v1beta1",
|
||||
"extensions/v1beta1",
|
||||
"networking/v1",
|
||||
"policy/v1beta1",
|
||||
"rbac/v1",
|
||||
"rbac/v1alpha1",
|
||||
"rbac/v1beta1",
|
||||
"scheduling/v1alpha1",
|
||||
"scheduling/v1beta1",
|
||||
"settings/v1alpha1",
|
||||
"storage/v1",
|
||||
"storage/v1alpha1",
|
||||
"storage/v1beta1",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "89a74a8d264df0e993299876a8cde88379b940ee"
|
||||
version = "kubernetes-1.13.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:66b0292f815d508d11ed5fe94fdeb0bcc5a988703a08e73bf3cb3a415de676cf"
|
||||
name = "k8s.io/apimachinery"
|
||||
packages = [
|
||||
"pkg/api/errors",
|
||||
"pkg/api/meta",
|
||||
"pkg/api/resource",
|
||||
"pkg/apis/meta/v1",
|
||||
"pkg/apis/meta/v1/unstructured",
|
||||
"pkg/apis/meta/v1beta1",
|
||||
"pkg/conversion",
|
||||
"pkg/conversion/queryparams",
|
||||
"pkg/fields",
|
||||
"pkg/labels",
|
||||
"pkg/runtime",
|
||||
"pkg/runtime/schema",
|
||||
"pkg/runtime/serializer",
|
||||
"pkg/runtime/serializer/json",
|
||||
"pkg/runtime/serializer/protobuf",
|
||||
"pkg/runtime/serializer/recognizer",
|
||||
"pkg/runtime/serializer/streaming",
|
||||
"pkg/runtime/serializer/versioning",
|
||||
"pkg/selection",
|
||||
"pkg/types",
|
||||
"pkg/util/clock",
|
||||
"pkg/util/errors",
|
||||
"pkg/util/framer",
|
||||
"pkg/util/intstr",
|
||||
"pkg/util/json",
|
||||
"pkg/util/naming",
|
||||
"pkg/util/net",
|
||||
"pkg/util/runtime",
|
||||
"pkg/util/sets",
|
||||
"pkg/util/validation",
|
||||
"pkg/util/validation/field",
|
||||
"pkg/util/wait",
|
||||
"pkg/util/yaml",
|
||||
"pkg/version",
|
||||
"pkg/watch",
|
||||
"third_party/forked/golang/reflect",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "2b1284ed4c93a43499e781493253e2ac5959c4fd"
|
||||
version = "kubernetes-1.13.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:96ab89894f66b77a0137bba12e607c6a9be992acadfb075b5602939e8519a157"
|
||||
name = "k8s.io/client-go"
|
||||
packages = [
|
||||
"discovery",
|
||||
"kubernetes",
|
||||
"kubernetes/scheme",
|
||||
"kubernetes/typed/admissionregistration/v1alpha1",
|
||||
"kubernetes/typed/admissionregistration/v1beta1",
|
||||
"kubernetes/typed/apps/v1",
|
||||
"kubernetes/typed/apps/v1beta1",
|
||||
"kubernetes/typed/apps/v1beta2",
|
||||
"kubernetes/typed/auditregistration/v1alpha1",
|
||||
"kubernetes/typed/authentication/v1",
|
||||
"kubernetes/typed/authentication/v1beta1",
|
||||
"kubernetes/typed/authorization/v1",
|
||||
"kubernetes/typed/authorization/v1beta1",
|
||||
"kubernetes/typed/autoscaling/v1",
|
||||
"kubernetes/typed/autoscaling/v2beta1",
|
||||
"kubernetes/typed/autoscaling/v2beta2",
|
||||
"kubernetes/typed/batch/v1",
|
||||
"kubernetes/typed/batch/v1beta1",
|
||||
"kubernetes/typed/batch/v2alpha1",
|
||||
"kubernetes/typed/certificates/v1beta1",
|
||||
"kubernetes/typed/coordination/v1beta1",
|
||||
"kubernetes/typed/core/v1",
|
||||
"kubernetes/typed/events/v1beta1",
|
||||
"kubernetes/typed/extensions/v1beta1",
|
||||
"kubernetes/typed/networking/v1",
|
||||
"kubernetes/typed/policy/v1beta1",
|
||||
"kubernetes/typed/rbac/v1",
|
||||
"kubernetes/typed/rbac/v1alpha1",
|
||||
"kubernetes/typed/rbac/v1beta1",
|
||||
"kubernetes/typed/scheduling/v1alpha1",
|
||||
"kubernetes/typed/scheduling/v1beta1",
|
||||
"kubernetes/typed/settings/v1alpha1",
|
||||
"kubernetes/typed/storage/v1",
|
||||
"kubernetes/typed/storage/v1alpha1",
|
||||
"kubernetes/typed/storage/v1beta1",
|
||||
"pkg/apis/clientauthentication",
|
||||
"pkg/apis/clientauthentication/v1alpha1",
|
||||
"pkg/apis/clientauthentication/v1beta1",
|
||||
"pkg/version",
|
||||
"plugin/pkg/client/auth/exec",
|
||||
"rest",
|
||||
"rest/watch",
|
||||
"tools/auth",
|
||||
"tools/clientcmd",
|
||||
"tools/clientcmd/api",
|
||||
"tools/clientcmd/api/latest",
|
||||
"tools/clientcmd/api/v1",
|
||||
"tools/metrics",
|
||||
"tools/reference",
|
||||
"transport",
|
||||
"util/cert",
|
||||
"util/connrotation",
|
||||
"util/flowcontrol",
|
||||
"util/homedir",
|
||||
"util/integer",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "e64494209f554a6723674bd494d69445fb76a1d4"
|
||||
version = "kubernetes-1.13.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:4f5eb833037cc0ba0bf8fe9cae6be9df62c19dd1c869415275c708daa8ccfda5"
|
||||
name = "k8s.io/klog"
|
||||
@ -176,7 +497,7 @@
|
||||
version = "v0.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a53c39a815a31aceb509f9987d7d8c65e74fcb1fcd5077eaf723a8defec1af90"
|
||||
digest = "1:9ac53939e57f04ea4886ed3c7b23612c65258de122c028a6c5ee8f9bdc0c51dd"
|
||||
name = "k8s.io/kubernetes"
|
||||
packages = [
|
||||
"pkg/util/file",
|
||||
@ -186,16 +507,24 @@
|
||||
"pkg/util/nsenter",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "ddf47ac13c1a9483ea035a79cd7c10005ff21a6d"
|
||||
version = "v1.13.0"
|
||||
revision = "cff46ab41ff0bb44d8584413b598ad8360ec1def"
|
||||
version = "v1.13.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:bea542e853f98bfcc80ecbe8fe0f32bc52c97664102aacdd7dca676354ef2faa"
|
||||
digest = "1:8b4b9c29be72c176988b04d5acc665c093b1efac228835f0a4716531c1f7563e"
|
||||
name = "k8s.io/utils"
|
||||
packages = ["exec"]
|
||||
pruneopts = ""
|
||||
revision = "0d26856f57b32ec3398579285e5c8a2bfe8c5243"
|
||||
revision = "8a16e7dd8fb6d97d1331b0c79a16722f934b00b1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:321081b4a44256715f2b68411d8eda9a17f17ebfe6f0cc61d2cc52d11c08acfa"
|
||||
name = "sigs.k8s.io/yaml"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "fd68e9863619f6ec2fdd8625fe1f02e7c877e480"
|
||||
version = "v1.1.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
@ -210,8 +539,14 @@
|
||||
"golang.org/x/net/context",
|
||||
"google.golang.org/grpc/codes",
|
||||
"google.golang.org/grpc/status",
|
||||
"k8s.io/api/core/v1",
|
||||
"k8s.io/apimachinery/pkg/api/errors",
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"k8s.io/apimachinery/pkg/util/sets",
|
||||
"k8s.io/apimachinery/pkg/util/wait",
|
||||
"k8s.io/client-go/kubernetes",
|
||||
"k8s.io/client-go/rest",
|
||||
"k8s.io/client-go/tools/clientcmd",
|
||||
"k8s.io/kubernetes/pkg/util/keymutex",
|
||||
"k8s.io/kubernetes/pkg/util/mount",
|
||||
"k8s.io/kubernetes/pkg/util/nsenter",
|
||||
|
@ -33,3 +33,7 @@
|
||||
[[override]]
|
||||
name = "github.com/golang/protobuf"
|
||||
version = "1.1.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "k8s.io/client-go"
|
||||
version = "kubernetes-1.13.0"
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/cephfs"
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
@ -34,6 +35,7 @@ var (
|
||||
driverName = flag.String("drivername", "csi-cephfsplugin", "name of the driver")
|
||||
nodeId = flag.String("nodeid", "", "node id")
|
||||
volumeMounter = flag.String("volumemounter", "", "default volume mounter (possible options are 'kernel', 'fuse')")
|
||||
metadataStorage = flag.String("metadatastorage", "", "metadata persistence method [node|k8s_configmap]")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -49,8 +51,14 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cp, err := util.NewCachePersister(*metadataStorage, *driverName)
|
||||
if err != nil {
|
||||
glog.Errorf("failed to define cache persistence method: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
driver := cephfs.NewCephFSDriver()
|
||||
driver.Run(*driverName, *nodeId, *endpoint, *volumeMounter)
|
||||
driver.Run(*driverName, *nodeId, *endpoint, *volumeMounter, cp)
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ spec:
|
||||
dnsPolicy: ClusterFirstWithHostNet
|
||||
containers:
|
||||
- name: driver-registrar
|
||||
image: quay.io/k8scsi/driver-registrar:v1.0.0
|
||||
image: quay.io/k8scsi/driver-registrar:canary
|
||||
args:
|
||||
- "--v=5"
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
@ -49,11 +49,16 @@ spec:
|
||||
- "--endpoint=$(CSI_ENDPOINT)"
|
||||
- "--v=5"
|
||||
- "--drivername=csi-cephfsplugin"
|
||||
- "--metadatastorage=k8s_configmap"
|
||||
env:
|
||||
- name: NODE_ID
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: CSI_ENDPOINT
|
||||
value: unix://var/lib/kubelet/plugins_registry/csi-cephfsplugin/csi.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
|
@ -21,6 +21,9 @@ rules:
|
||||
- apiGroups: ["storage.k8s.io"]
|
||||
resources: ["volumeattachments"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
verbs: ["get", "list", "create", "delete"]
|
||||
|
||||
---
|
||||
kind: ClusterRoleBinding
|
||||
|
21
deploy/rbd/helm/.helmignore
Normal file
21
deploy/rbd/helm/.helmignore
Normal file
@ -0,0 +1,21 @@
|
||||
# Patterns to ignore when building packages.
|
||||
# This supports shell glob matching, relative path matching, and
|
||||
# negation (prefixed with !). Only one pattern per line.
|
||||
.DS_Store
|
||||
# Common VCS dirs
|
||||
.git/
|
||||
.gitignore
|
||||
.bzr/
|
||||
.bzrignore
|
||||
.hg/
|
||||
.hgignore
|
||||
.svn/
|
||||
# Common backup files
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*~
|
||||
# Various IDEs
|
||||
.project
|
||||
.idea/
|
||||
*.tmproj
|
12
deploy/rbd/helm/Chart.yaml
Normal file
12
deploy/rbd/helm/Chart.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
appVersion: "0.3.0"
|
||||
description: Container Storage Interface (CSI) driver, provisioner, and attacher for Ceph RBD
|
||||
name: ceph-csi-rbd
|
||||
version: 0.1.0
|
||||
keywords:
|
||||
- ceph
|
||||
- rbd
|
||||
- ceph-csi
|
||||
home: https://github.com/ceph/ceph-csi
|
||||
sources:
|
||||
- https://github.com/ceph/ceph-csi/tree/master/deploy/rbd/kubernetes
|
1
deploy/rbd/helm/templates/NOTES.txt
Normal file
1
deploy/rbd/helm/templates/NOTES.txt
Normal file
@ -0,0 +1 @@
|
||||
The Ceph RBD Container Storage Interface has been deployed.
|
119
deploy/rbd/helm/templates/_helpers.tpl
Normal file
119
deploy/rbd/helm/templates/_helpers.tpl
Normal file
@ -0,0 +1,119 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.attacher.fullname" -}}
|
||||
{{- if .Values.attacher.fullnameOverride -}}
|
||||
{{- .Values.attacher.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- printf "%s-%s" .Release.Name .Values.attacher.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s-%s" .Release.Name $name .Values.attacher.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.nodeplugin.fullname" -}}
|
||||
{{- if .Values.nodeplugin.fullnameOverride -}}
|
||||
{{- .Values.nodeplugin.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- printf "%s-%s" .Release.Name .Values.nodeplugin.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s-%s" .Release.Name $name .Values.nodeplugin.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.provisioner.fullname" -}}
|
||||
{{- if .Values.provisioner.fullnameOverride -}}
|
||||
{{- .Values.provisioner.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- printf "%s-%s" .Release.Name .Values.provisioner.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s-%s" .Release.Name $name .Values.provisioner.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.serviceAccountName.attacher" -}}
|
||||
{{- if .Values.serviceAccounts.attacher.create -}}
|
||||
{{ default (include "ceph-csi-rbd.attacher.fullname" .) .Values.serviceAccounts.attacher.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccounts.attacher.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.serviceAccountName.nodeplugin" -}}
|
||||
{{- if .Values.serviceAccounts.nodeplugin.create -}}
|
||||
{{ default (include "ceph-csi-rbd.nodeplugin.fullname" .) .Values.serviceAccounts.nodeplugin.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccounts.nodeplugin.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "ceph-csi-rbd.serviceAccountName.provisioner" -}}
|
||||
{{- if .Values.serviceAccounts.provisioner.create -}}
|
||||
{{ default (include "ceph-csi-rbd.provisioner.fullname" .) .Values.serviceAccounts.provisioner.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccounts.provisioner.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
25
deploy/rbd/helm/templates/attacher-clusterrole.yaml
Normal file
25
deploy/rbd/helm/templates/attacher-clusterrole.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.attacher.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.attacher.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["events"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumes"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["nodes"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: ["storage.k8s.io"]
|
||||
resources: ["volumeattachments"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
{{- end -}}
|
20
deploy/rbd/helm/templates/attacher-clusterrolebinding.yaml
Normal file
20
deploy/rbd/helm/templates/attacher-clusterrolebinding.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.attacher.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.attacher.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "ceph-csi-rbd.serviceAccountName.attacher" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: {{ include "ceph-csi-rbd.attacher.fullname" . }}
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
{{- end -}}
|
18
deploy/rbd/helm/templates/attacher-service.yaml
Normal file
18
deploy/rbd/helm/templates/attacher-service.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.attacher.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.attacher.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
spec:
|
||||
selector:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
component: {{ .Values.attacher.name }}
|
||||
release: {{ .Release.Name }}
|
||||
ports:
|
||||
- name: dummy
|
||||
port: 12345
|
12
deploy/rbd/helm/templates/attacher-serviceaccount.yaml
Normal file
12
deploy/rbd/helm/templates/attacher-serviceaccount.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
{{- if .Values.serviceAccounts.attacher.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.serviceAccountName.attacher" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.attacher.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
{{- end -}}
|
55
deploy/rbd/helm/templates/attacher-statefulset.yaml
Normal file
55
deploy/rbd/helm/templates/attacher-statefulset.yaml
Normal file
@ -0,0 +1,55 @@
|
||||
kind: StatefulSet
|
||||
apiVersion: apps/v1beta1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.attacher.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.attacher.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
spec:
|
||||
serviceName: {{ include "ceph-csi-rbd.attacher.fullname" . }}
|
||||
replicas: {{ .Values.attacher.replicas }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.attacher.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "ceph-csi-rbd.serviceAccountName.attacher" . }}
|
||||
containers:
|
||||
- name: csi-rbdplugin-attacher
|
||||
image: "{{ .Values.attacher.image.repository }}:{{ .Values.attacher.image.tag }}"
|
||||
args:
|
||||
- "--v=5"
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: "{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||
imagePullPolicy: {{ .Values.attacher.image.pullPolicy }}
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: {{ .Values.socketDir }}
|
||||
resources:
|
||||
{{ toYaml .Values.attacher.resources | indent 12 }}
|
||||
volumes:
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: {{ .Values.socketDir }}
|
||||
type: DirectoryOrCreate
|
||||
{{- if .Values.attacher.affinity -}}
|
||||
affinity:
|
||||
{{ toYaml .Values.attacher.affinity . | indent 8 }}
|
||||
{{- end -}}
|
||||
{{- if .Values.attacher.nodeSelector -}}
|
||||
nodeSelector:
|
||||
{{ toYaml .Values.attacher.nodeSelector | indent 8 }}
|
||||
{{- end -}}
|
||||
{{- if .Values.attacher.tolerations -}}
|
||||
tolerations:
|
||||
{{ toYaml .Values.attacher.tolerations | indent 8 }}
|
||||
{{- end -}}
|
25
deploy/rbd/helm/templates/nodeplugin-clusterrole.yaml
Normal file
25
deploy/rbd/helm/templates/nodeplugin-clusterrole.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.nodeplugin.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.nodeplugin.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["nodes"]
|
||||
verbs: ["get", "list", "update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["namespaces"]
|
||||
verbs: ["get", "list"]
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumes"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: ["storage.k8s.io"]
|
||||
resources: ["volumeattachments"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
{{- end -}}
|
20
deploy/rbd/helm/templates/nodeplugin-clusterrolebinding.yaml
Normal file
20
deploy/rbd/helm/templates/nodeplugin-clusterrolebinding.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.nodeplugin.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.nodeplugin.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "ceph-csi-rbd.serviceAccountName.nodeplugin" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: {{ include "ceph-csi-rbd.nodeplugin.fullname" . }}
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
{{- end -}}
|
136
deploy/rbd/helm/templates/nodeplugin-daemonset.yaml
Normal file
136
deploy/rbd/helm/templates/nodeplugin-daemonset.yaml
Normal file
@ -0,0 +1,136 @@
|
||||
kind: DaemonSet
|
||||
apiVersion: apps/v1beta2
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.nodeplugin.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.nodeplugin.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
component: {{ .Values.nodeplugin.name }}
|
||||
release: {{ .Release.Name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.nodeplugin.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "ceph-csi-rbd.serviceAccountName.nodeplugin" . }}
|
||||
hostNetwork: true
|
||||
hostPID: true
|
||||
# to use e.g. Rook orchestrated cluster, and mons' FQDN is
|
||||
# resolved through k8s service, set dns policy to cluster first
|
||||
dnsPolicy: ClusterFirstWithHostNet
|
||||
containers:
|
||||
- name: driver-registrar
|
||||
image: "{{ .Values.nodeplugin.registrar.image.repository }}:{{ .Values.nodeplugin.registrar.image.tag }}"
|
||||
args:
|
||||
- "--v=5"
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: "{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||
- name: DRIVER_REG_SOCK_PATH
|
||||
value: "{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||
- name: KUBE_NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
imagePullPolicy: {{ .Values.nodeplugin.registrar.image.imagePullPolicy }}
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: {{ .Values.socketDir }}
|
||||
- name: registration-dir
|
||||
mountPath: /registration
|
||||
resources:
|
||||
{{ toYaml .Values.nodeplugin.registrar.resources | indent 12 }}
|
||||
- name: csi-rbdplugin
|
||||
securityContext:
|
||||
privileged: true
|
||||
capabilities:
|
||||
add: ["SYS_ADMIN"]
|
||||
allowPrivilegeEscalation: true
|
||||
image: "{{ .Values.nodeplugin.plugin.image.repository }}:{{ .Values.nodeplugin.plugin.image.tag }}"
|
||||
args :
|
||||
- "--nodeid=$(NODE_ID)"
|
||||
- "--endpoint=$(CSI_ENDPOINT)"
|
||||
- "--v=5"
|
||||
- "--drivername=csi-rbdplugin"
|
||||
- "--containerized=true"
|
||||
env:
|
||||
- name: HOST_ROOTFS
|
||||
value: "/rootfs"
|
||||
- name: NODE_ID
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: CSI_ENDPOINT
|
||||
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.imagePullPolicy }}
|
||||
volumeMounts:
|
||||
- name: plugin-dir
|
||||
mountPath: {{ .Values.socketDir }}
|
||||
- name: pods-mount-dir
|
||||
mountPath: /var/lib/kubelet/pods
|
||||
mountPropagation: "Bidirectional"
|
||||
- mountPath: /dev
|
||||
name: host-dev
|
||||
- mountPath: /rootfs
|
||||
name: host-rootfs
|
||||
- mountPath: /sys
|
||||
name: host-sys
|
||||
- mountPath: /lib/modules
|
||||
name: lib-modules
|
||||
readOnly: true
|
||||
resources:
|
||||
{{ toYaml .Values.nodeplugin.plugin.resources | indent 12 }}
|
||||
volumes:
|
||||
- name: plugin-dir
|
||||
hostPath:
|
||||
path: {{ .Values.socketDir }}
|
||||
type: DirectoryOrCreate
|
||||
- name: registration-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/
|
||||
type: Directory
|
||||
- name: pods-mount-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/pods
|
||||
type: Directory
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: {{ .Values.socketDir }}
|
||||
type: DirectoryOrCreate
|
||||
- name: host-dev
|
||||
hostPath:
|
||||
path: /dev
|
||||
- name: host-rootfs
|
||||
hostPath:
|
||||
path: /
|
||||
- name: host-sys
|
||||
hostPath:
|
||||
path: /sys
|
||||
- name: lib-modules
|
||||
hostPath:
|
||||
path: /lib/modules
|
||||
{{- if .Values.nodeplugin.affinity -}}
|
||||
affinity:
|
||||
{{ toYaml .Values.nodeplugin.affinity . | indent 8 }}
|
||||
{{- end -}}
|
||||
{{- if .Values.nodeplugin.nodeSelector -}}
|
||||
nodeSelector:
|
||||
{{ toYaml .Values.nodeplugin.nodeSelector | indent 8 }}
|
||||
{{- end -}}
|
||||
{{- if .Values.nodeplugin.tolerations -}}
|
||||
tolerations:
|
||||
{{ toYaml .Values.nodeplugin.tolerations | indent 8 }}
|
||||
{{- end -}}
|
12
deploy/rbd/helm/templates/nodeplugin-serviceaccount.yaml
Normal file
12
deploy/rbd/helm/templates/nodeplugin-serviceaccount.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
{{- if .Values.serviceAccounts.nodeplugin.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.serviceAccountName.nodeplugin" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.nodeplugin.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
{{- end -}}
|
28
deploy/rbd/helm/templates/provisioner-clusterrole.yaml
Normal file
28
deploy/rbd/helm/templates/provisioner-clusterrole.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.provisioner.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.provisioner.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["get", "list"]
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumes"]
|
||||
verbs: ["get", "list", "watch", "create", "delete"]
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumeclaims"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: ["storage.k8s.io"]
|
||||
resources: ["storageclasses"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["events"]
|
||||
verbs: ["list", "watch", "create", "update", "patch"]
|
||||
{{- end -}}
|
@ -0,0 +1,20 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.provisioner.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.provisioner.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "ceph-csi-rbd.serviceAccountName.provisioner" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: {{ include "ceph-csi-rbd.provisioner.fullname" . }}
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
{{- end -}}
|
18
deploy/rbd/helm/templates/provisioner-service.yaml
Normal file
18
deploy/rbd/helm/templates/provisioner-service.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.provisioner.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.provisioner.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
spec:
|
||||
selector:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
component: {{ .Values.provisioner.name }}
|
||||
release: {{ .Release.Name }}
|
||||
ports:
|
||||
- name: dummy
|
||||
port: 12345
|
12
deploy/rbd/helm/templates/provisioner-serviceaccount.yaml
Normal file
12
deploy/rbd/helm/templates/provisioner-serviceaccount.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
{{- if .Values.serviceAccounts.provisioner.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.serviceAccountName.provisioner" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.provisioner.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
{{- end -}}
|
56
deploy/rbd/helm/templates/provisioner-statefulset.yaml
Normal file
56
deploy/rbd/helm/templates/provisioner-statefulset.yaml
Normal file
@ -0,0 +1,56 @@
|
||||
kind: StatefulSet
|
||||
apiVersion: apps/v1beta1
|
||||
metadata:
|
||||
name: {{ include "ceph-csi-rbd.provisioner.fullname" . }}
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.provisioner.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
spec:
|
||||
serviceName: {{ include "ceph-csi-rbd.provisioner.fullname" . }}
|
||||
replicas: {{ .Values.provisioner.replicas }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ include "ceph-csi-rbd.name" . }}
|
||||
chart: {{ include "ceph-csi-rbd.chart" . }}
|
||||
component: {{ .Values.provisioner.name }}
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "ceph-csi-rbd.serviceAccountName.provisioner" . }}
|
||||
containers:
|
||||
- name: csi-provisioner
|
||||
image: "{{ .Values.provisioner.image.repository }}:{{ .Values.provisioner.image.tag }}"
|
||||
args:
|
||||
- "--provisioner=csi-rbdplugin"
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
- "--v=5"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: "{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||
imagePullPolicy: {{ .Values.provisioner.image.pullPolicy }}
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: {{ .Values.socketDir }}
|
||||
resources:
|
||||
{{ toYaml .Values.provisioner.resources | indent 12 }}
|
||||
volumes:
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: {{ .Values.socketDir }}
|
||||
type: DirectoryOrCreate
|
||||
{{- if .Values.provisioner.affinity -}}
|
||||
affinity:
|
||||
{{ toYaml .Values.provisioner.affinity . | indent 8 }}
|
||||
{{- end -}}
|
||||
{{- if .Values.provisioner.nodeSelector -}}
|
||||
nodeSelector:
|
||||
{{ toYaml .Values.provisioner.nodeSelector | indent 8 }}
|
||||
{{- end -}}
|
||||
{{- if .Values.provisioner.tolerations -}}
|
||||
tolerations:
|
||||
{{ toYaml .Values.provisioner.tolerations | indent 8 }}
|
||||
{{- end -}}
|
77
deploy/rbd/helm/values.yaml
Normal file
77
deploy/rbd/helm/values.yaml
Normal file
@ -0,0 +1,77 @@
|
||||
rbac:
|
||||
create: true
|
||||
|
||||
serviceAccounts:
|
||||
attacher:
|
||||
create: true
|
||||
name:
|
||||
nodeplugin:
|
||||
create: true
|
||||
name:
|
||||
provisioner:
|
||||
create: true
|
||||
name:
|
||||
|
||||
socketDir: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
socketFile: csi.sock
|
||||
|
||||
attacher:
|
||||
name: attacher
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: quay.io/k8scsi/csi-attacher
|
||||
tag: v0.3.0
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
resources: {}
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
nodeplugin:
|
||||
name: nodeplugin
|
||||
|
||||
registrar:
|
||||
image:
|
||||
repository: quay.io/k8scsi/driver-registrar
|
||||
tag: v0.3.0
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
resources: {}
|
||||
|
||||
plugin:
|
||||
image:
|
||||
repository: quay.io/cephcsi/rbdplugin
|
||||
tag: v0.3.0
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
resources: {}
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
provisioner:
|
||||
name: provisioner
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: quay.io/k8scsi/csi-provisioner
|
||||
tag: v0.3.0
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
resources: {}
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
@ -21,6 +21,9 @@ rules:
|
||||
- apiGroups: ["storage.k8s.io"]
|
||||
resources: ["volumeattachments"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
verbs: ["get", "list", "create", "delete"]
|
||||
|
||||
---
|
||||
kind: ClusterRoleBinding
|
||||
|
@ -19,7 +19,7 @@ spec:
|
||||
dnsPolicy: ClusterFirstWithHostNet
|
||||
containers:
|
||||
- name: driver-registrar
|
||||
image: quay.io/k8scsi/driver-registrar:v1.0.0
|
||||
image: quay.io/k8scsi/driver-registrar:canary
|
||||
args:
|
||||
- "--v=5"
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
@ -51,6 +51,7 @@ spec:
|
||||
- "--v=5"
|
||||
- "--drivername=csi-rbdplugin"
|
||||
- "--containerized=true"
|
||||
- "--metadatastorage=k8s_configmap"
|
||||
env:
|
||||
- name: HOST_ROOTFS
|
||||
value: "/rootfs"
|
||||
@ -58,6 +59,10 @@ spec:
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: CSI_ENDPOINT
|
||||
value: unix://var/lib/kubelet/plugins_registry/csi-rbdplugin/csi.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
|
@ -26,6 +26,12 @@ Option | Default value | Description
|
||||
`--drivername` | `csi-cephfsplugin` | name of the driver (Kubernetes: `provisioner` field in StorageClass must correspond to this value)
|
||||
`--nodeid` | _empty_ | This node's ID
|
||||
`--volumemounter` | _empty_ | default volume mounter. Available options are `kernel` and `fuse`. This is the mount method used if volume parameters don't specify otherwise. If left unspecified, the driver will first probe for `ceph-fuse` in system's path and will choose Ceph kernel client if probing failed.
|
||||
`--metadatastorage` | _empty_ | Whether should metadata be kept on node as file or in a k8s configmap (`node` or `k8s_configmap`)
|
||||
|
||||
**Available environmental variables:**
|
||||
`KUBERNETES_CONFIG_PATH`: if you use `k8s_configmap` as metadata store, specify the path of your k8s config file (if not specified, the plugin will assume you're running it inside a k8s cluster and find the config itself).
|
||||
|
||||
`POD_NAMESPACE`: if you use `k8s_configmap` as metadata store, `POD_NAMESPACE` is used to define in which namespace you want the configmaps to be stored
|
||||
|
||||
**Available volume parameters:**
|
||||
|
||||
|
@ -26,11 +26,15 @@ Option | Default value | Description
|
||||
`--drivername` | `csi-cephfsplugin` | name of the driver (Kubernetes: `provisioner` field in StorageClass must correspond to this value)
|
||||
`--nodeid` | _empty_ | This node's ID
|
||||
`--containerized` | true | Whether running in containerized mode
|
||||
|
||||
`--metadatastorage` | _empty_ | Whether should metadata be kept on node as file or in a k8s configmap (`node` or `k8s_configmap`)
|
||||
|
||||
**Available environmental variables:**
|
||||
`HOST_ROOTFS`: rbdplugin searches `/proc` directory under the directory set by `HOST_ROOTFS`.
|
||||
|
||||
`KUBERNETES_CONFIG_PATH`: if you use `k8s_configmap` as metadata store, specify the path of your k8s config file (if not specified, the plugin will assume you're running it inside a k8s cluster and find the config itself).
|
||||
|
||||
`POD_NAMESPACE`: if you use `k8s_configmap` as metadata store, `POD_NAMESPACE` is used to define in which namespace you want the configmaps to be stored
|
||||
|
||||
**Available volume parameters:**
|
||||
|
||||
Parameter | Required | Description
|
||||
@ -105,3 +109,19 @@ service/csi-rbdplugin-provisioner ClusterIP 10.104.2.130 <none> 123
|
||||
|
||||
You can try deploying a demo pod from `examples/rbd` to test the deployment further.
|
||||
|
||||
## Deployment with Helm
|
||||
|
||||
The same requirements from the Kubernetes section apply here, i.e. Kubernetes
|
||||
version, privileged flag and shared mounts.
|
||||
|
||||
The Helm chart is located in `deploy/rbd/helm`.
|
||||
|
||||
**Deploy Helm Chart:**
|
||||
|
||||
```bash
|
||||
$ helm install ./deploy/rbd/helm
|
||||
```
|
||||
|
||||
The Helm chart deploys all of the required resources to use the CSI RBD driver.
|
||||
After deploying the chart you can verify the deployment using the instructions
|
||||
above for verifying the deployment with Kubernetes
|
||||
|
@ -1,128 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes 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 cephfs
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
const (
|
||||
controllerCacheRoot = PluginFolder + "/controller/plugin-cache"
|
||||
)
|
||||
|
||||
type controllerCacheEntry struct {
|
||||
VolOptions volumeOptions
|
||||
VolumeID volumeID
|
||||
}
|
||||
|
||||
type controllerCacheMap map[volumeID]*controllerCacheEntry
|
||||
|
||||
var (
|
||||
ctrCache = make(controllerCacheMap)
|
||||
ctrCacheMtx sync.Mutex
|
||||
)
|
||||
|
||||
// Load all .json files from controllerCacheRoot into ctrCache
|
||||
// Called from driver.go's Run()
|
||||
func loadControllerCache() error {
|
||||
cacheDir, err := ioutil.ReadDir(controllerCacheRoot)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read controller cache from %s: %v", controllerCacheRoot, err)
|
||||
}
|
||||
|
||||
ctrCacheMtx.Lock()
|
||||
defer ctrCacheMtx.Unlock()
|
||||
|
||||
for _, fi := range cacheDir {
|
||||
if !strings.HasSuffix(fi.Name(), ".json") || !fi.Mode().IsRegular() {
|
||||
continue
|
||||
}
|
||||
|
||||
f, err := os.Open(path.Join(controllerCacheRoot, fi.Name()))
|
||||
if err != nil {
|
||||
glog.Errorf("cephfs: cloudn't read '%s' from controller cache: %v", fi.Name(), err)
|
||||
continue
|
||||
}
|
||||
|
||||
d := json.NewDecoder(f)
|
||||
ent := &controllerCacheEntry{}
|
||||
|
||||
if err = d.Decode(ent); err != nil {
|
||||
glog.Errorf("cephfs: failed to parse '%s': %v", fi.Name(), err)
|
||||
} else {
|
||||
ctrCache[ent.VolumeID] = ent
|
||||
}
|
||||
|
||||
f.Close()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getControllerCacheEntryPath(volId volumeID) string {
|
||||
return path.Join(controllerCacheRoot, string(volId)+".json")
|
||||
}
|
||||
|
||||
func (m controllerCacheMap) insert(ent *controllerCacheEntry) error {
|
||||
filePath := getControllerCacheEntryPath(ent.VolumeID)
|
||||
|
||||
ctrCacheMtx.Lock()
|
||||
defer ctrCacheMtx.Unlock()
|
||||
|
||||
f, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't create cache entry file '%s': %v", filePath, err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
enc := json.NewEncoder(f)
|
||||
if err = enc.Encode(ent); err != nil {
|
||||
return fmt.Errorf("failed to encode cache entry for volume %s: %v", ent.VolumeID, err)
|
||||
}
|
||||
|
||||
m[ent.VolumeID] = ent
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m controllerCacheMap) pop(volId volumeID) (*controllerCacheEntry, error) {
|
||||
ctrCacheMtx.Lock()
|
||||
defer ctrCacheMtx.Unlock()
|
||||
|
||||
ent, ok := m[volId]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cache entry for volume %s does not exist", volId)
|
||||
}
|
||||
|
||||
filePath := getControllerCacheEntryPath(volId)
|
||||
|
||||
if err := os.Remove(filePath); err != nil {
|
||||
return nil, fmt.Errorf("failed to remove cache entry file '%s': %v", filePath, err)
|
||||
}
|
||||
|
||||
delete(m, volId)
|
||||
|
||||
return ent, nil
|
||||
}
|
@ -24,10 +24,18 @@ import (
|
||||
|
||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
)
|
||||
|
||||
type controllerServer struct {
|
||||
*csicommon.DefaultControllerServer
|
||||
MetadataStore util.CachePersister
|
||||
}
|
||||
|
||||
type controllerCacheEntry struct {
|
||||
VolOptions volumeOptions
|
||||
VolumeID volumeID
|
||||
}
|
||||
|
||||
func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
|
||||
@ -35,7 +43,6 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
glog.Errorf("CreateVolumeRequest validation failed: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Configuration
|
||||
volOptions, err := newVolumeOptions(req.GetParameters())
|
||||
if err != nil {
|
||||
@ -55,7 +62,6 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
|
||||
if volOptions.ProvisionVolume {
|
||||
// Admin credentials are required
|
||||
|
||||
cr, err := getAdminCredentials(req.GetSecrets())
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||
@ -81,7 +87,8 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
glog.Infof("cephfs: volume %s is provisioned statically", volId)
|
||||
}
|
||||
|
||||
if err = ctrCache.insert(&controllerCacheEntry{VolOptions: *volOptions, VolumeID: volId}); err != nil {
|
||||
ce := &controllerCacheEntry{VolOptions: *volOptions, VolumeID: volId}
|
||||
if err := cs.MetadataStore.Create(string(volId), ce); err != nil {
|
||||
glog.Errorf("failed to store a cache entry for volume %s: %v", volId, err)
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
@ -106,30 +113,18 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
err error
|
||||
)
|
||||
|
||||
// Load volume info from cache
|
||||
|
||||
ent, err := ctrCache.pop(volId)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
ce := &controllerCacheEntry{}
|
||||
if err := cs.MetadataStore.Get(string(volId), ce); err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
if !ent.VolOptions.ProvisionVolume {
|
||||
if !ce.VolOptions.ProvisionVolume {
|
||||
// DeleteVolume() is forbidden for statically provisioned volumes!
|
||||
|
||||
glog.Warningf("volume %s is provisioned statically, aborting delete", volId)
|
||||
return &csi.DeleteVolumeResponse{}, nil
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
// Reinsert cache entry for retry
|
||||
if insErr := ctrCache.insert(ent); insErr != nil {
|
||||
glog.Errorf("failed to reinsert volume cache entry in rollback procedure for volume %s: %v", volId, err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Deleting a volume requires admin credentials
|
||||
|
||||
cr, err := getAdminCredentials(req.GetSecrets())
|
||||
@ -138,7 +133,7 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
if err = purgeVolume(volId, cr, &ent.VolOptions); err != nil {
|
||||
if err = purgeVolume(volId, cr, &ce.VolOptions); err != nil {
|
||||
glog.Errorf("failed to delete volume %s: %v", volId, err)
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
@ -148,6 +143,10 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
if err := cs.MetadataStore.Delete(string(volId)); err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
glog.Infof("cephfs: successfully deleted volume %s", volId)
|
||||
|
||||
return &csi.DeleteVolumeResponse{}, nil
|
||||
|
@ -17,12 +17,12 @@ limitations under the License.
|
||||
package cephfs
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -56,9 +56,10 @@ func NewIdentityServer(d *csicommon.CSIDriver) *identityServer {
|
||||
}
|
||||
}
|
||||
|
||||
func NewControllerServer(d *csicommon.CSIDriver) *controllerServer {
|
||||
func NewControllerServer(d *csicommon.CSIDriver, cachePersister util.CachePersister) *controllerServer {
|
||||
return &controllerServer{
|
||||
DefaultControllerServer: csicommon.NewDefaultControllerServer(d),
|
||||
MetadataStore: cachePersister,
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,20 +69,11 @@ func NewNodeServer(d *csicommon.CSIDriver) *nodeServer {
|
||||
}
|
||||
}
|
||||
|
||||
func (fs *cephfsDriver) Run(driverName, nodeId, endpoint, volumeMounter string) {
|
||||
func (fs *cephfsDriver) Run(driverName, nodeId, endpoint, volumeMounter string, cachePersister util.CachePersister) {
|
||||
glog.Infof("Driver: %v version: %v", driverName, Version)
|
||||
|
||||
// Configuration
|
||||
|
||||
if err := os.MkdirAll(controllerCacheRoot, 0755); err != nil {
|
||||
glog.Fatalf("cephfs: failed to create %s: %v", controllerCacheRoot, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := loadControllerCache(); err != nil {
|
||||
glog.Errorf("cephfs: failed to read volume cache: %v", err)
|
||||
}
|
||||
|
||||
if err := loadAvailableMounters(); err != nil {
|
||||
glog.Fatalf("cephfs: failed to load ceph mounters: %v", err)
|
||||
}
|
||||
@ -120,7 +112,8 @@ func (fs *cephfsDriver) Run(driverName, nodeId, endpoint, volumeMounter string)
|
||||
|
||||
fs.is = NewIdentityServer(fs.driver)
|
||||
fs.ns = NewNodeServer(fs.driver)
|
||||
fs.cs = NewControllerServer(fs.driver)
|
||||
|
||||
fs.cs = NewControllerServer(fs.driver, cachePersister)
|
||||
|
||||
server := csicommon.NewNonBlockingGRPCServer()
|
||||
server.Start(endpoint, fs.is, fs.cs, fs.ns)
|
||||
|
@ -20,10 +20,10 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/golang/glog"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
@ -41,6 +41,28 @@ const (
|
||||
|
||||
type controllerServer struct {
|
||||
*csicommon.DefaultControllerServer
|
||||
MetadataStore util.CachePersister
|
||||
}
|
||||
|
||||
var (
|
||||
rbdVolumes = map[string]*rbdVolume{}
|
||||
rbdSnapshots = map[string]*rbdSnapshot{}
|
||||
)
|
||||
|
||||
func (cs *controllerServer) LoadExDataFromMetadataStore() error {
|
||||
vol := &rbdVolume{}
|
||||
cs.MetadataStore.ForAll("csi-rbd-vol-", vol, func(identifier string) error {
|
||||
rbdVolumes[identifier] = vol
|
||||
return nil
|
||||
})
|
||||
|
||||
snap := &rbdSnapshot{}
|
||||
cs.MetadataStore.ForAll("csi-rbd-(.*)-snap-", snap, func(identifier string) error {
|
||||
rbdSnapshots[identifier] = snap
|
||||
return nil
|
||||
})
|
||||
glog.Infof("Loaded %d volumes and %d snapshots from metadata store", len(rbdVolumes), len(rbdSnapshots))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
|
||||
@ -55,6 +77,11 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
if req.VolumeCapabilities == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "Volume Capabilities cannot be empty")
|
||||
}
|
||||
for _, cap := range req.VolumeCapabilities {
|
||||
if cap.GetBlock() != nil {
|
||||
return nil, status.Error(codes.Unimplemented, "Block Volume not supported")
|
||||
}
|
||||
}
|
||||
|
||||
volumeNameMutex.LockKey(req.GetName())
|
||||
defer volumeNameMutex.UnlockKey(req.GetName())
|
||||
@ -93,7 +120,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
volName = rbdVol.Pool + "-dynamic-pvc-" + uniqueID
|
||||
}
|
||||
rbdVol.VolName = volName
|
||||
volumeID := "csi-rbd-" + uniqueID
|
||||
volumeID := "csi-rbd-vol-" + uniqueID
|
||||
rbdVol.VolID = volumeID
|
||||
// Volume Size - Default is 1 GiB
|
||||
volSizeBytes := int64(oneGB)
|
||||
@ -119,7 +146,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
}
|
||||
|
||||
rbdSnap := &rbdSnapshot{}
|
||||
if err := loadSnapInfo(snapshotID, path.Join(PluginFolder, "controller-snap"), rbdSnap); err != nil {
|
||||
if err := cs.MetadataStore.Get(snapshotID, rbdSnap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -138,11 +165,15 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
glog.V(4).Infof("create volume %s", volName)
|
||||
}
|
||||
}
|
||||
|
||||
// Storing volInfo into a persistent file.
|
||||
if err := persistVolInfo(volumeID, path.Join(PluginFolder, "controller"), rbdVol); err != nil {
|
||||
glog.Warningf("rbd: failed to store volInfo with error: %v", err)
|
||||
if err := cs.MetadataStore.Create(volumeID, rbdVol); err != nil {
|
||||
glog.Warningf("failed to store volume metadata with error: %v", err)
|
||||
if err := deleteRBDImage(rbdVol, rbdVol.AdminId, req.GetSecrets()); err != nil {
|
||||
glog.V(3).Infof("failed to delete rbd image: %s/%s with error: %v", rbdVol.Pool, rbdVol.VolName, err)
|
||||
return nil, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rbdVolumes[volumeID] = rbdVol
|
||||
return &csi.CreateVolumeResponse{
|
||||
Volume: &csi.Volume{
|
||||
@ -163,13 +194,13 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
volumeIDMutex.LockKey(volumeID)
|
||||
defer volumeIDMutex.UnlockKey(volumeID)
|
||||
rbdVol := &rbdVolume{}
|
||||
if err := loadVolInfo(volumeID, path.Join(PluginFolder, "controller"), rbdVol); err != nil {
|
||||
if err := cs.MetadataStore.Get(volumeID, rbdVol); err != nil {
|
||||
if os.IsNotExist(errors.Cause(err)) {
|
||||
// Must have been deleted already. This is not an error (idempotency!).
|
||||
return &csi.DeleteVolumeResponse{}, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
volName := rbdVol.VolName
|
||||
// Deleting rbd image
|
||||
glog.V(4).Infof("deleting volume %s", volName)
|
||||
@ -178,8 +209,8 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
glog.V(3).Infof("failed to delete rbd image: %s/%s with error: %v", rbdVol.Pool, volName, err)
|
||||
return nil, err
|
||||
}
|
||||
// Removing persistent storage file for the unmapped volume
|
||||
if err := deleteVolInfo(volumeID, path.Join(PluginFolder, "controller")); err != nil {
|
||||
|
||||
if err := cs.MetadataStore.Delete(volumeID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -301,24 +332,21 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
|
||||
|
||||
rbdSnap.CreatedAt = time.Now().UnixNano()
|
||||
|
||||
// Storing snapInfo into a persistent file.
|
||||
if err := persistSnapInfo(snapshotID, path.Join(PluginFolder, "controller-snap"), rbdSnap); err != nil {
|
||||
if err := cs.MetadataStore.Create(snapshotID, rbdSnap); err != nil {
|
||||
glog.Warningf("rbd: failed to store snapInfo with error: %v", err)
|
||||
|
||||
// Unprotect snapshot
|
||||
err := unprotectSnapshot(rbdSnap, rbdSnap.AdminId, req.GetSecrets())
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Unknown, fmt.Sprintf("This Snapshot should be removed but failed to unprotect snapshot: %s/%s with error: %v", rbdSnap.Pool, rbdSnap.SnapName, err))
|
||||
}
|
||||
|
||||
// Deleting snapshot
|
||||
glog.V(4).Infof("deleting Snaphot %s", rbdSnap.SnapName)
|
||||
if err := deleteSnapshot(rbdSnap, rbdSnap.AdminId, req.GetSecrets()); err != nil {
|
||||
return nil, status.Error(codes.Unknown, fmt.Sprintf("This Snapshot should be removed but failed to delete snapshot: %s/%s with error: %v", rbdSnap.Pool, rbdSnap.SnapName, err))
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rbdSnapshots[snapshotID] = rbdSnap
|
||||
return &csi.CreateSnapshotResponse{
|
||||
Snapshot: &csi.Snapshot{
|
||||
@ -347,7 +375,7 @@ func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
|
||||
defer snapshotIDMutex.UnlockKey(snapshotID)
|
||||
|
||||
rbdSnap := &rbdSnapshot{}
|
||||
if err := loadSnapInfo(snapshotID, path.Join(PluginFolder, "controller-snap"), rbdSnap); err != nil {
|
||||
if err := cs.MetadataStore.Get(snapshotID, rbdSnap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -363,8 +391,7 @@ func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
|
||||
return nil, status.Error(codes.FailedPrecondition, fmt.Sprintf("failed to delete snapshot: %s/%s with error: %v", rbdSnap.Pool, rbdSnap.SnapName, err))
|
||||
}
|
||||
|
||||
// Removing persistent storage file for the unmapped snapshot
|
||||
if err := deleteSnapInfo(snapshotID, path.Join(PluginFolder, "controller-snap")); err != nil {
|
||||
if err := cs.MetadataStore.Delete(snapshotID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
105
pkg/rbd/rbd.go
105
pkg/rbd/rbd.go
@ -17,14 +17,9 @@ limitations under the License.
|
||||
package rbd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
|
||||
@ -56,94 +51,6 @@ var (
|
||||
version = "1.0.0"
|
||||
)
|
||||
|
||||
var rbdVolumes map[string]*rbdVolume
|
||||
var rbdSnapshots map[string]*rbdSnapshot
|
||||
|
||||
// Init checks for the persistent volume file and loads all found volumes
|
||||
// into a memory structure
|
||||
func init() {
|
||||
rbdVolumes = map[string]*rbdVolume{}
|
||||
rbdSnapshots = map[string]*rbdSnapshot{}
|
||||
if _, err := os.Stat(path.Join(PluginFolder, "controller")); os.IsNotExist(err) {
|
||||
glog.Infof("rbd: folder %s not found. Creating... \n", path.Join(PluginFolder, "controller"))
|
||||
if err := os.Mkdir(path.Join(PluginFolder, "controller"), 0755); err != nil {
|
||||
glog.Fatalf("Failed to create a controller's volumes folder with error: %v\n", err)
|
||||
}
|
||||
} else {
|
||||
// Since "controller" folder exists, it means the rbdplugin has already been running, it means
|
||||
// there might be some volumes left, they must be re-inserted into rbdVolumes map
|
||||
loadExVolumes()
|
||||
}
|
||||
if _, err := os.Stat(path.Join(PluginFolder, "controller-snap")); os.IsNotExist(err) {
|
||||
glog.Infof("rbd: folder %s not found. Creating... \n", path.Join(PluginFolder, "controller-snap"))
|
||||
if err := os.Mkdir(path.Join(PluginFolder, "controller-snap"), 0755); err != nil {
|
||||
glog.Fatalf("Failed to create a controller's snapshots folder with error: %v\n", err)
|
||||
}
|
||||
} else {
|
||||
// Since "controller-snap" folder exists, it means the rbdplugin has already been running, it means
|
||||
// there might be some snapshots left, they must be re-inserted into rbdSnapshots map
|
||||
loadExSnapshots()
|
||||
}
|
||||
}
|
||||
|
||||
// loadExSnapshots check for any *.json files in the PluginFolder/controller-snap folder
|
||||
// and loads then into rbdSnapshots map
|
||||
func loadExSnapshots() {
|
||||
rbdSnap := rbdSnapshot{}
|
||||
files, err := ioutil.ReadDir(path.Join(PluginFolder, "controller-snap"))
|
||||
if err != nil {
|
||||
glog.Infof("rbd: failed to read controller's snapshots folder: %s error:%v", path.Join(PluginFolder, "controller-snap"), err)
|
||||
return
|
||||
}
|
||||
for _, f := range files {
|
||||
if !strings.HasSuffix(f.Name(), ".json") {
|
||||
continue
|
||||
}
|
||||
fp, err := os.Open(path.Join(PluginFolder, "controller-snap", f.Name()))
|
||||
if err != nil {
|
||||
glog.Infof("rbd: open file: %s err %v", f.Name(), err)
|
||||
continue
|
||||
}
|
||||
decoder := json.NewDecoder(fp)
|
||||
if err = decoder.Decode(&rbdSnap); err != nil {
|
||||
glog.Infof("rbd: decode file: %s err: %v", f.Name(), err)
|
||||
fp.Close()
|
||||
continue
|
||||
}
|
||||
rbdSnapshots[rbdSnap.SnapID] = &rbdSnap
|
||||
}
|
||||
glog.Infof("rbd: Loaded %d snapshots from %s", len(rbdSnapshots), path.Join(PluginFolder, "controller-snap"))
|
||||
}
|
||||
|
||||
// loadExVolumes check for any *.json files in the PluginFolder/controller folder
|
||||
// and loads then into rbdVolumes map
|
||||
func loadExVolumes() {
|
||||
rbdVol := rbdVolume{}
|
||||
files, err := ioutil.ReadDir(path.Join(PluginFolder, "controller"))
|
||||
if err != nil {
|
||||
glog.Infof("rbd: failed to read controller's volumes folder: %s error:%v", path.Join(PluginFolder, "controller"), err)
|
||||
return
|
||||
}
|
||||
for _, f := range files {
|
||||
if !strings.HasSuffix(f.Name(), ".json") {
|
||||
continue
|
||||
}
|
||||
fp, err := os.Open(path.Join(PluginFolder, "controller", f.Name()))
|
||||
if err != nil {
|
||||
glog.Infof("rbd: open file: %s err %v", f.Name(), err)
|
||||
continue
|
||||
}
|
||||
decoder := json.NewDecoder(fp)
|
||||
if err = decoder.Decode(&rbdVol); err != nil {
|
||||
glog.Infof("rbd: decode file: %s err: %v", f.Name(), err)
|
||||
fp.Close()
|
||||
continue
|
||||
}
|
||||
rbdVolumes[rbdVol.VolID] = &rbdVol
|
||||
}
|
||||
glog.Infof("rbd: Loaded %d volumes from %s", len(rbdVolumes), path.Join(PluginFolder, "controller"))
|
||||
}
|
||||
|
||||
func GetRBDDriver() *rbd {
|
||||
return &rbd{}
|
||||
}
|
||||
@ -154,9 +61,10 @@ func NewIdentityServer(d *csicommon.CSIDriver) *identityServer {
|
||||
}
|
||||
}
|
||||
|
||||
func NewControllerServer(d *csicommon.CSIDriver) *controllerServer {
|
||||
func NewControllerServer(d *csicommon.CSIDriver, cachePersister util.CachePersister) *controllerServer {
|
||||
return &controllerServer{
|
||||
DefaultControllerServer: csicommon.NewDefaultControllerServer(d),
|
||||
MetadataStore: cachePersister,
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +83,7 @@ func NewNodeServer(d *csicommon.CSIDriver, containerized bool) (*nodeServer, err
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (rbd *rbd) Run(driverName, nodeID, endpoint string, containerized bool) {
|
||||
func (rbd *rbd) Run(driverName, nodeID, endpoint string, containerized bool, cachePersister util.CachePersister) {
|
||||
var err error
|
||||
glog.Infof("Driver: %v version: %v", driverName, version)
|
||||
|
||||
@ -198,7 +106,10 @@ func (rbd *rbd) Run(driverName, nodeID, endpoint string, containerized bool) {
|
||||
if err != nil {
|
||||
glog.Fatalf("failed to start node server, err %v\n", err)
|
||||
}
|
||||
rbd.cs = NewControllerServer(rbd.driver)
|
||||
|
||||
rbd.cs = NewControllerServer(rbd.driver, cachePersister)
|
||||
rbd.cs.LoadExDataFromMetadataStore()
|
||||
|
||||
s := csicommon.NewNonBlockingGRPCServer()
|
||||
s.Start(endpoint, rbd.ids, rbd.cs, rbd.ns)
|
||||
s.Wait()
|
||||
|
@ -17,11 +17,8 @@ limitations under the License.
|
||||
package rbd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -316,95 +313,6 @@ func hasSnapshotFeature(imageFeatures string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func persistVolInfo(image string, persistentStoragePath string, volInfo *rbdVolume) error {
|
||||
file := path.Join(persistentStoragePath, image+".json")
|
||||
fp, err := os.Create(file)
|
||||
if err != nil {
|
||||
glog.Errorf("rbd: failed to create persistent storage file %s with error: %v\n", file, err)
|
||||
return errors.Wrapf(err, "rbd: create error for %s", file)
|
||||
}
|
||||
defer fp.Close()
|
||||
encoder := json.NewEncoder(fp)
|
||||
if err = encoder.Encode(volInfo); err != nil {
|
||||
glog.Errorf("rbd: failed to encode volInfo: %+v for file: %s with error: %v\n", volInfo, file, err)
|
||||
return errors.Wrap(err, "rbd: encode error")
|
||||
}
|
||||
glog.Infof("rbd: successfully saved volInfo: %+v into file: %s\n", volInfo, file)
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadVolInfo(image string, persistentStoragePath string, volInfo *rbdVolume) error {
|
||||
file := path.Join(persistentStoragePath, image+".json")
|
||||
fp, err := os.Open(file)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "rbd: open error for %s", file)
|
||||
}
|
||||
defer fp.Close()
|
||||
|
||||
decoder := json.NewDecoder(fp)
|
||||
if err = decoder.Decode(volInfo); err != nil {
|
||||
return errors.Wrap(err, "rbd: decode error")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteVolInfo(image string, persistentStoragePath string) error {
|
||||
file := path.Join(persistentStoragePath, image+".json")
|
||||
glog.Infof("rbd: Deleting file for Volume: %s at: %s resulting path: %+v\n", image, persistentStoragePath, file)
|
||||
err := os.Remove(file)
|
||||
if err != nil {
|
||||
if err != os.ErrNotExist {
|
||||
return errors.Wrapf(err, "rbd: error removing file %s", file)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func persistSnapInfo(snapshot string, persistentStoragePath string, snapInfo *rbdSnapshot) error {
|
||||
file := path.Join(persistentStoragePath, snapshot+".json")
|
||||
fp, err := os.Create(file)
|
||||
if err != nil {
|
||||
glog.Errorf("rbd: failed to create persistent storage file %s with error: %v\n", file, err)
|
||||
return errors.Wrapf(err, "rbd: create error for %s", file)
|
||||
}
|
||||
defer fp.Close()
|
||||
encoder := json.NewEncoder(fp)
|
||||
if err = encoder.Encode(snapInfo); err != nil {
|
||||
glog.Errorf("rbd: failed to encode snapInfo: %+v for file: %s with error: %v\n", snapInfo, file, err)
|
||||
return errors.Wrap(err, "rbd: encode error")
|
||||
}
|
||||
glog.Infof("rbd: successfully saved snapInfo: %+v into file: %s\n", snapInfo, file)
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadSnapInfo(snapshot string, persistentStoragePath string, snapInfo *rbdSnapshot) error {
|
||||
file := path.Join(persistentStoragePath, snapshot+".json")
|
||||
fp, err := os.Open(file)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "rbd: open error for %s", file)
|
||||
}
|
||||
defer fp.Close()
|
||||
|
||||
decoder := json.NewDecoder(fp)
|
||||
if err = decoder.Decode(snapInfo); err != nil {
|
||||
return errors.Wrap(err, "rbd: decode error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteSnapInfo(snapshot string, persistentStoragePath string) error {
|
||||
file := path.Join(persistentStoragePath, snapshot+".json")
|
||||
glog.Infof("rbd: Deleting file for Snapshot: %s at: %s resulting path: %+v\n", snapshot, persistentStoragePath, file)
|
||||
err := os.Remove(file)
|
||||
if err != nil {
|
||||
if err != os.ErrNotExist {
|
||||
return errors.Wrapf(err, "rbd: error removing file %s", file)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getRBDVolumeByID(volumeID string) (*rbdVolume, error) {
|
||||
if rbdVol, ok := rbdVolumes[volumeID]; ok {
|
||||
return rbdVol, nil
|
||||
|
52
pkg/util/cachepersister.go
Normal file
52
pkg/util/cachepersister.go
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes 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 util
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
const (
|
||||
PluginFolder = "/var/lib/kubelet/plugins"
|
||||
)
|
||||
|
||||
type ForAllFunc func(identifier string) error
|
||||
|
||||
type CachePersister interface {
|
||||
Create(identifier string, data interface{}) error
|
||||
Get(identifier string, data interface{}) error
|
||||
ForAll(pattern string, destObj interface{}, f ForAllFunc) error
|
||||
Delete(identifier string) error
|
||||
}
|
||||
|
||||
func NewCachePersister(metadataStore string, driverName string) (CachePersister, error) {
|
||||
if metadataStore == "k8s_configmap" {
|
||||
glog.Infof("cache-perister: using kubernetes configmap as metadata cache persister")
|
||||
k8scm := &K8sCMCache{}
|
||||
k8scm.Client = NewK8sClient()
|
||||
k8scm.Namespace = GetK8sNamespace()
|
||||
return k8scm, nil
|
||||
} else if metadataStore == "node" {
|
||||
glog.Infof("cache-persister: using node as metadata cache persister")
|
||||
nc := &NodeCache{}
|
||||
nc.BasePath = PluginFolder + "/" + driverName
|
||||
return nc, nil
|
||||
}
|
||||
return nil, errors.New("cache-persister: couldn't parse metadatastorage flag")
|
||||
}
|
172
pkg/util/k8scmcache.go
Normal file
172
pkg/util/k8scmcache.go
Normal file
@ -0,0 +1,172 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes 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 util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
apierrs "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
k8s "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
type K8sCMCache struct {
|
||||
Client *k8s.Clientset
|
||||
Namespace string
|
||||
}
|
||||
|
||||
const (
|
||||
defaultNamespace = "default"
|
||||
|
||||
cmLabel = "csi-metadata"
|
||||
cmDataKey = "content"
|
||||
|
||||
csiMetadataLabelAttr = "com.ceph.ceph-csi/metadata"
|
||||
)
|
||||
|
||||
func GetK8sNamespace() string {
|
||||
namespace := os.Getenv("POD_NAMESPACE")
|
||||
if namespace == "" {
|
||||
return defaultNamespace
|
||||
}
|
||||
return namespace
|
||||
}
|
||||
|
||||
func NewK8sClient() *k8s.Clientset {
|
||||
var cfg *rest.Config
|
||||
var err error
|
||||
cPath := os.Getenv("KUBERNETES_CONFIG_PATH")
|
||||
if cPath != "" {
|
||||
cfg, err = clientcmd.BuildConfigFromFlags("", cPath)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to get cluster config with error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
cfg, err = rest.InClusterConfig()
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to get cluster config with error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
client, err := k8s.NewForConfig(cfg)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to create client with error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
func (k8scm *K8sCMCache) getMetadataCM(resourceID string) (*v1.ConfigMap, error) {
|
||||
cm, err := k8scm.Client.CoreV1().ConfigMaps(k8scm.Namespace).Get(resourceID, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cm, nil
|
||||
}
|
||||
|
||||
func (k8scm *K8sCMCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) error {
|
||||
listOpts := metav1.ListOptions{LabelSelector: fmt.Sprintf("%s=%s", csiMetadataLabelAttr, cmLabel)}
|
||||
cms, err := k8scm.Client.CoreV1().ConfigMaps(k8scm.Namespace).List(listOpts)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "k8s-cm-cache: failed to list metadata configmaps")
|
||||
}
|
||||
|
||||
for _, cm := range cms.Items {
|
||||
data := cm.Data[cmDataKey]
|
||||
match, err := regexp.MatchString(pattern, cm.ObjectMeta.Name)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if !match {
|
||||
continue
|
||||
}
|
||||
if err := json.Unmarshal([]byte(data), destObj); err != nil {
|
||||
return errors.Wrap(err, "k8s-cm-cache: unmarshal error")
|
||||
}
|
||||
if err = f(cm.ObjectMeta.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k8scm *K8sCMCache) Create(identifier string, data interface{}) error {
|
||||
cm, err := k8scm.getMetadataCM(identifier)
|
||||
if cm != nil && err == nil {
|
||||
glog.V(4).Infof("k8s-cm-cache: configmap already exists, skipping configmap creation")
|
||||
return nil
|
||||
} else {
|
||||
dataJson, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "k8s-cm-cache: marshal error")
|
||||
}
|
||||
cm := &v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: identifier,
|
||||
Namespace: k8scm.Namespace,
|
||||
Labels: map[string]string{
|
||||
csiMetadataLabelAttr: cmLabel,
|
||||
},
|
||||
},
|
||||
Data: map[string]string{},
|
||||
}
|
||||
cm.Data[cmDataKey] = string(dataJson)
|
||||
|
||||
_, err = k8scm.Client.CoreV1().ConfigMaps(k8scm.Namespace).Create(cm)
|
||||
if err != nil {
|
||||
if apierrs.IsAlreadyExists(err) {
|
||||
glog.V(4).Infof("k8s-cm-cache: configmap already exists")
|
||||
return nil
|
||||
}
|
||||
return errors.Wrapf(err, "k8s-cm-cache: couldn't persist %s metadata as configmap", identifier)
|
||||
}
|
||||
|
||||
}
|
||||
glog.V(4).Infof("k8s-cm-cache: configmap %s successfully created\n", identifier)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k8scm *K8sCMCache) Get(identifier string, data interface{}) error {
|
||||
cm, err := k8scm.getMetadataCM(identifier)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = json.Unmarshal([]byte(cm.Data[cmDataKey]), data)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "k8s-cm-cache: unmarshal error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k8scm *K8sCMCache) Delete(identifier string) error {
|
||||
err := k8scm.Client.CoreV1().ConfigMaps(k8scm.Namespace).Delete(identifier, nil)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "k8s-cm-cache: couldn't delete metadata configmap %s", identifier)
|
||||
}
|
||||
glog.V(4).Infof("k8s-cm-cache: successfully deleted metadata configmap %s", identifier)
|
||||
return nil
|
||||
}
|
124
pkg/util/nodecache.go
Normal file
124
pkg/util/nodecache.go
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes 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 util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type NodeCache struct {
|
||||
BasePath string
|
||||
}
|
||||
|
||||
var cacheDir = "controller"
|
||||
|
||||
func (nc *NodeCache) EnsureCacheDirectory(cacheDir string) error {
|
||||
fullPath := path.Join(nc.BasePath, cacheDir)
|
||||
if _, err := os.Stat(fullPath); os.IsNotExist(err) {
|
||||
if err := os.Mkdir(fullPath, 0755); err != nil {
|
||||
return errors.Wrapf(err, "node-cache: failed to create %s folder with error: %v", fullPath, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nc *NodeCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) error {
|
||||
err := nc.EnsureCacheDirectory(cacheDir)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "node-cache: couldn't ensure cache directory exists")
|
||||
}
|
||||
files, err := ioutil.ReadDir(path.Join(nc.BasePath, cacheDir))
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "node-cache: failed to read %s folder", nc.BasePath)
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
match, err := regexp.MatchString(pattern, file.Name())
|
||||
if err != nil || !match {
|
||||
continue
|
||||
}
|
||||
if !strings.HasSuffix(file.Name(), ".json") {
|
||||
continue
|
||||
}
|
||||
fp, err := os.Open(path.Join(nc.BasePath, cacheDir, file.Name()))
|
||||
if err != nil {
|
||||
glog.Infof("node-cache: open file: %s err %%v", file.Name(), err)
|
||||
continue
|
||||
}
|
||||
decoder := json.NewDecoder(fp)
|
||||
if err = decoder.Decode(destObj); err != nil {
|
||||
fp.Close()
|
||||
return errors.Wrapf(err, "node-cache: couldn't decode file %s", file.Name())
|
||||
}
|
||||
if err := f(strings.TrimSuffix(file.Name(), filepath.Ext(file.Name()))); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nc *NodeCache) Create(identifier string, data interface{}) error {
|
||||
file := path.Join(nc.BasePath, cacheDir, identifier+".json")
|
||||
fp, err := os.Create(file)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "node-cache: failed to create metadata storage file %s\n", file)
|
||||
}
|
||||
defer fp.Close()
|
||||
encoder := json.NewEncoder(fp)
|
||||
if err = encoder.Encode(data); err != nil {
|
||||
return errors.Wrapf(err, "node-cache: failed to encode metadata for file: %s\n", file)
|
||||
}
|
||||
glog.V(4).Infof("node-cache: successfully saved metadata into file: %s\n", file)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nc *NodeCache) Get(identifier string, data interface{}) error {
|
||||
file := path.Join(nc.BasePath, cacheDir, identifier+".json")
|
||||
fp, err := os.Open(file)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "node-cache: open error for %s", file)
|
||||
}
|
||||
defer fp.Close()
|
||||
|
||||
decoder := json.NewDecoder(fp)
|
||||
if err = decoder.Decode(data); err != nil {
|
||||
return errors.Wrap(err, "rbd: decode error")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nc *NodeCache) Delete(identifier string) error {
|
||||
file := path.Join(nc.BasePath, cacheDir, identifier+".json")
|
||||
err := os.Remove(file)
|
||||
if err != nil {
|
||||
if err != os.ErrNotExist {
|
||||
return errors.Wrapf(err, "node-cache: error removing file %s", file)
|
||||
}
|
||||
}
|
||||
glog.V(4).Infof("node-cache: successfully deleted metadata storage file at: %+v\n", file)
|
||||
return nil
|
||||
}
|
15
rbd/main.go
15
rbd/main.go
@ -22,6 +22,7 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/rbd"
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
@ -34,6 +35,7 @@ var (
|
||||
driverName = flag.String("drivername", "csi-rbdplugin", "name of the driver")
|
||||
nodeID = flag.String("nodeid", "", "node id")
|
||||
containerized = flag.Bool("containerized", true, "whether run as containerized")
|
||||
metadataStorage = flag.String("metadatastorage", "", "metadata persistence method [node|k8s_configmap]")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -48,13 +50,16 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
handle()
|
||||
os.Exit(0)
|
||||
}
|
||||
cp, err := util.NewCachePersister(*metadataStorage, *driverName)
|
||||
if err != nil {
|
||||
glog.Errorf("failed to define cache persistence method: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func handle() {
|
||||
driver := rbd.GetRBDDriver()
|
||||
driver.Run(*driverName, *nodeID, *endpoint, *containerized)
|
||||
driver.Run(*driverName, *nodeID, *endpoint, *containerized, cp)
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func createPersistentStorage(persistentStoragePath string) error {
|
||||
|
6
vendor/github.com/gogo/protobuf/.gitignore
generated
vendored
Normal file
6
vendor/github.com/gogo/protobuf/.gitignore
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
._*
|
||||
*.js
|
||||
*.js.map
|
||||
|
||||
# Conformance test output and transient files.
|
||||
conformance/failing_tests.txt
|
8
vendor/github.com/gogo/protobuf/.mailmap
generated
vendored
Normal file
8
vendor/github.com/gogo/protobuf/.mailmap
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
Walter Schulze <awalterschulze@gmail.com> Walter Schulze <walter@vastech.co.za>
|
||||
Walter Schulze <awalterschulze@gmail.com> <walter@vastech.co.za>
|
||||
Walter Schulze <awalterschulze@gmail.com> awalterschulze <awalterschulze@gmail.com>
|
||||
Walter Schulze <awalterschulze@gmail.com> awalterschulze@gmail.com <awalterschulze@gmail.com>
|
||||
John Tuley <john@tuley.org> <jtuley@pivotal.io>
|
||||
Anton Povarov <anton.povarov@gmail.com> <antoxa@corp.badoo.com>
|
||||
Denis Smirnov <denis.smirnov.91@gmail.com> dennwc
|
||||
DongYun Kang <ceram1000@gmail.com> <ceram1000@gmail.com>
|
22
vendor/github.com/gogo/protobuf/.travis.yml
generated
vendored
Normal file
22
vendor/github.com/gogo/protobuf/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
apt:
|
||||
update: true
|
||||
|
||||
env:
|
||||
- PROTOBUF_VERSION=2.6.1
|
||||
- PROTOBUF_VERSION=3.0.2
|
||||
- PROTOBUF_VERSION=3.5.1
|
||||
|
||||
before_install:
|
||||
- ./install-protobuf.sh
|
||||
- PATH=/home/travis/bin:$PATH protoc --version
|
||||
|
||||
script:
|
||||
- PATH=/home/travis/bin:$PATH make buildserverall
|
||||
- echo $TRAVIS_GO_VERSION
|
||||
- if [[ "$PROTOBUF_VERSION" == "3.5.1" ]] && [[ "$TRAVIS_GO_VERSION" == "1.11.x" ]]; then ! git status --porcelain | read || (git status; git diff; exit 1); fi
|
||||
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.10.x
|
||||
- 1.11.x
|
15
vendor/github.com/gogo/protobuf/AUTHORS
generated
vendored
Normal file
15
vendor/github.com/gogo/protobuf/AUTHORS
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# This is the official list of GoGo authors for copyright purposes.
|
||||
# This file is distinct from the CONTRIBUTORS file, which
|
||||
# lists people. For example, employees are listed in CONTRIBUTORS,
|
||||
# but not in AUTHORS, because the employer holds the copyright.
|
||||
|
||||
# Names should be added to this file as one of
|
||||
# Organization's name
|
||||
# Individual's name <submission email address>
|
||||
# Individual's name <submission email address> <email2> <emailN>
|
||||
|
||||
# Please keep the list sorted.
|
||||
|
||||
Sendgrid, Inc
|
||||
Vastech SA (PTY) LTD
|
||||
Walter Schulze <awalterschulze@gmail.com>
|
23
vendor/github.com/gogo/protobuf/CONTRIBUTORS
generated
vendored
Normal file
23
vendor/github.com/gogo/protobuf/CONTRIBUTORS
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
Anton Povarov <anton.povarov@gmail.com>
|
||||
Brian Goff <cpuguy83@gmail.com>
|
||||
Clayton Coleman <ccoleman@redhat.com>
|
||||
Denis Smirnov <denis.smirnov.91@gmail.com>
|
||||
DongYun Kang <ceram1000@gmail.com>
|
||||
Dwayne Schultz <dschultz@pivotal.io>
|
||||
Georg Apitz <gapitz@pivotal.io>
|
||||
Gustav Paul <gustav.paul@gmail.com>
|
||||
Johan Brandhorst <johan.brandhorst@gmail.com>
|
||||
John Shahid <jvshahid@gmail.com>
|
||||
John Tuley <john@tuley.org>
|
||||
Laurent <laurent@adyoulike.com>
|
||||
Patrick Lee <patrick@dropbox.com>
|
||||
Peter Edge <peter.edge@gmail.com>
|
||||
Roger Johansson <rogeralsing@gmail.com>
|
||||
Sam Nguyen <sam.nguyen@sendgrid.com>
|
||||
Sergio Arbeo <serabe@gmail.com>
|
||||
Stephen J Day <stephen.day@docker.com>
|
||||
Tamir Duberstein <tamird@gmail.com>
|
||||
Todd Eisenberger <teisenberger@dropbox.com>
|
||||
Tormod Erevik Lea <tormodlea@gmail.com>
|
||||
Vyacheslav Kim <kane@sendgrid.com>
|
||||
Walter Schulze <awalterschulze@gmail.com>
|
5
vendor/github.com/gogo/protobuf/GOLANG_CONTRIBUTORS
generated
vendored
Normal file
5
vendor/github.com/gogo/protobuf/GOLANG_CONTRIBUTORS
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
The contributors to the Go protobuf repository:
|
||||
|
||||
# This source code was written by the Go contributors.
|
||||
# The master list of contributors is in the main Go distribution,
|
||||
# visible at http://tip.golang.org/CONTRIBUTORS.
|
35
vendor/github.com/gogo/protobuf/LICENSE
generated
vendored
Normal file
35
vendor/github.com/gogo/protobuf/LICENSE
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
||||
|
||||
Protocol Buffers for Go with Gadgets
|
||||
|
||||
Go support for Protocol Buffers - Google's data interchange format
|
||||
|
||||
Copyright 2010 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.
|
||||
|
182
vendor/github.com/gogo/protobuf/Makefile
generated
vendored
Normal file
182
vendor/github.com/gogo/protobuf/Makefile
generated
vendored
Normal file
@ -0,0 +1,182 @@
|
||||
# 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.
|
||||
|
||||
GO_VERSION:=$(shell go version)
|
||||
|
||||
# Skip known issues from purego tests
|
||||
# https://github.com/gogo/protobuf/issues/447
|
||||
# https://github.com/gogo/protobuf/issues/448
|
||||
SKIPISSUE:="/jsonpb|/test/casttype/|/test/oneof/combos/"
|
||||
|
||||
.PHONY: nuke regenerate tests clean install gofmt vet contributors
|
||||
|
||||
all: clean install regenerate install tests errcheck vet
|
||||
|
||||
buildserverall: clean install regenerate install tests vet js purego
|
||||
|
||||
install:
|
||||
go install ./proto
|
||||
go install ./gogoproto
|
||||
go install ./jsonpb
|
||||
go install ./protoc-gen-gogo
|
||||
go install ./protoc-gen-gofast
|
||||
go install ./protoc-gen-gogofast
|
||||
go install ./protoc-gen-gogofaster
|
||||
go install ./protoc-gen-gogoslick
|
||||
go install ./protoc-gen-gostring
|
||||
go install ./protoc-min-version
|
||||
go install ./protoc-gen-combo
|
||||
go install ./gogoreplace
|
||||
|
||||
clean:
|
||||
go clean ./...
|
||||
|
||||
nuke:
|
||||
go clean -i -cache ./...
|
||||
|
||||
gofmt:
|
||||
gofmt -l -s -w .
|
||||
|
||||
regenerate:
|
||||
make -C protoc-gen-gogo regenerate
|
||||
make -C gogoproto regenerate
|
||||
make -C proto/test_proto regenerate
|
||||
make -C proto/proto3_proto regenerate
|
||||
make -C jsonpb/jsonpb_test_proto regenerate
|
||||
make -C conformance regenerate
|
||||
make -C protobuf regenerate
|
||||
make -C test regenerate
|
||||
make -C test/example regenerate
|
||||
make -C test/unrecognized regenerate
|
||||
make -C test/group regenerate
|
||||
make -C test/unrecognizedgroup regenerate
|
||||
make -C test/enumstringer regenerate
|
||||
make -C test/unmarshalmerge regenerate
|
||||
make -C test/moredefaults regenerate
|
||||
make -C test/issue8 regenerate
|
||||
make -C test/enumprefix regenerate
|
||||
make -C test/enumcustomname regenerate
|
||||
make -C test/packed regenerate
|
||||
make -C test/protosize regenerate
|
||||
make -C test/tags regenerate
|
||||
make -C test/oneof regenerate
|
||||
make -C test/oneof3 regenerate
|
||||
make -C test/theproto3 regenerate
|
||||
make -C test/mapdefaults regenerate
|
||||
make -C test/mapsproto2 regenerate
|
||||
make -C test/issue42order regenerate
|
||||
make -C proto generate-test-pbs
|
||||
make -C test/importdedup regenerate
|
||||
make -C test/importduplicate regenerate
|
||||
make -C test/custombytesnonstruct regenerate
|
||||
make -C test/required regenerate
|
||||
make -C test/casttype regenerate
|
||||
make -C test/castvalue regenerate
|
||||
make -C vanity/test regenerate
|
||||
make -C test/sizeunderscore regenerate
|
||||
make -C test/issue34 regenerate
|
||||
make -C test/empty-issue70 regenerate
|
||||
make -C test/indeximport-issue72 regenerate
|
||||
make -C test/fuzztests regenerate
|
||||
make -C test/oneofembed regenerate
|
||||
make -C test/asymetric-issue125 regenerate
|
||||
make -C test/filedotname regenerate
|
||||
make -C test/nopackage regenerate
|
||||
make -C test/types regenerate
|
||||
make -C test/proto3extension regenerate
|
||||
make -C test/stdtypes regenerate
|
||||
make -C test/data regenerate
|
||||
make -C test/typedecl regenerate
|
||||
make -C test/issue260 regenerate
|
||||
make -C test/issue261 regenerate
|
||||
make -C test/issue262 regenerate
|
||||
make -C test/issue312 regenerate
|
||||
make -C test/enumdecl regenerate
|
||||
make -C test/typedecl_all regenerate
|
||||
make -C test/enumdecl_all regenerate
|
||||
make -C test/int64support regenerate
|
||||
make -C test/issue322 regenerate
|
||||
make -C test/issue330 regenerate
|
||||
make -C test/importcustom-issue389 regenerate
|
||||
make -C test/merge regenerate
|
||||
make -C test/cachedsize regenerate
|
||||
make -C test/deterministic regenerate
|
||||
make -C test/issue438 regenerate
|
||||
make -C test/issue444 regenerate
|
||||
make -C test/issue449 regenerate
|
||||
make -C test/xxxfields regenerate
|
||||
make -C test/issue435 regenerate
|
||||
make -C test/issue411 regenerate
|
||||
|
||||
make gofmt
|
||||
|
||||
tests:
|
||||
go build ./test/enumprefix
|
||||
go test ./...
|
||||
(cd test/stdtypes && make test)
|
||||
|
||||
vet:
|
||||
go vet ./...
|
||||
go tool vet --shadow .
|
||||
|
||||
errcheck:
|
||||
go get github.com/kisielk/errcheck
|
||||
errcheck ./test/...
|
||||
|
||||
drone:
|
||||
sudo apt-get install protobuf-compiler
|
||||
(cd $(GOPATH)/src/github.com/gogo/protobuf && make buildserverall)
|
||||
|
||||
testall:
|
||||
go get -u github.com/golang/protobuf/proto
|
||||
make -C protoc-gen-gogo test
|
||||
make -C vanity/test test
|
||||
make -C test/registration test
|
||||
make -C conformance test
|
||||
make -C test/issue427 test
|
||||
make tests
|
||||
|
||||
bench:
|
||||
go get golang.org/x/tools/cmd/benchcmp
|
||||
(cd test/mixbench && go build .)
|
||||
./test/mixbench/mixbench
|
||||
|
||||
contributors:
|
||||
git log --format='%aN <%aE>' | sort -fu > CONTRIBUTORS
|
||||
|
||||
js:
|
||||
ifeq (go1.11, $(findstring go1.11, $(GO_VERSION)))
|
||||
go get -u github.com/gopherjs/gopherjs
|
||||
gopherjs build github.com/gogo/protobuf/protoc-gen-gogo
|
||||
endif
|
||||
|
||||
purego:
|
||||
go test -tags purego $$(go list ./... | grep -Ev $(SKIPISSUE))
|
||||
|
||||
update:
|
||||
(cd protobuf && make update)
|
298
vendor/github.com/gogo/protobuf/README
generated
vendored
Normal file
298
vendor/github.com/gogo/protobuf/README
generated
vendored
Normal file
@ -0,0 +1,298 @@
|
||||
Protocol Buffers for Go with Gadgets
|
||||
|
||||
GoGoProtobuf http://github.com/gogo/protobuf extends
|
||||
GoProtobuf http://github.com/golang/protobuf
|
||||
|
||||
Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
||||
|
||||
|
||||
# Go support for Protocol Buffers
|
||||
|
||||
Google's data interchange format.
|
||||
Copyright 2010 The Go Authors.
|
||||
https://github.com/golang/protobuf
|
||||
|
||||
This package and the code it generates requires at least Go 1.6.
|
||||
|
||||
This software implements Go bindings for protocol buffers. For
|
||||
information about protocol buffers themselves, see
|
||||
https://developers.google.com/protocol-buffers/
|
||||
|
||||
## Installation ##
|
||||
|
||||
To use this software, you must:
|
||||
- Install the standard C++ implementation of protocol buffers from
|
||||
https://developers.google.com/protocol-buffers/
|
||||
- Of course, install the Go compiler and tools from
|
||||
https://golang.org/
|
||||
See
|
||||
https://golang.org/doc/install
|
||||
for details or, if you are using gccgo, follow the instructions at
|
||||
https://golang.org/doc/install/gccgo
|
||||
- Grab the code from the repository and install the proto package.
|
||||
The simplest way is to run `go get -u github.com/golang/protobuf/protoc-gen-go`.
|
||||
The compiler plugin, protoc-gen-go, will be installed in $GOBIN,
|
||||
defaulting to $GOPATH/bin. It must be in your $PATH for the protocol
|
||||
compiler, protoc, to find it.
|
||||
|
||||
This software has two parts: a 'protocol compiler plugin' that
|
||||
generates Go source files that, once compiled, can access and manage
|
||||
protocol buffers; and a library that implements run-time support for
|
||||
encoding (marshaling), decoding (unmarshaling), and accessing protocol
|
||||
buffers.
|
||||
|
||||
There is support for gRPC in Go using protocol buffers.
|
||||
See the note at the bottom of this file for details.
|
||||
|
||||
There are no insertion points in the plugin.
|
||||
|
||||
GoGoProtobuf provides extensions for protocol buffers and GoProtobuf
|
||||
see http://github.com/gogo/protobuf/gogoproto/doc.go
|
||||
|
||||
## Using protocol buffers with Go ##
|
||||
|
||||
Once the software is installed, there are two steps to using it.
|
||||
First you must compile the protocol buffer definitions and then import
|
||||
them, with the support library, into your program.
|
||||
|
||||
To compile the protocol buffer definition, run protoc with the --gogo_out
|
||||
parameter set to the directory you want to output the Go code to.
|
||||
|
||||
protoc --gogo_out=. *.proto
|
||||
|
||||
The generated files will be suffixed .pb.go. See the Test code below
|
||||
for an example using such a file.
|
||||
|
||||
## Packages and input paths ##
|
||||
|
||||
The protocol buffer language has a concept of "packages" which does not
|
||||
correspond well to the Go notion of packages. In generated Go code,
|
||||
each source `.proto` file is associated with a single Go package. The
|
||||
name and import path for this package is specified with the `go_package`
|
||||
proto option:
|
||||
|
||||
option go_package = "github.com/gogo/protobuf/types";
|
||||
|
||||
The protocol buffer compiler will attempt to derive a package name and
|
||||
import path if a `go_package` option is not present, but it is
|
||||
best to always specify one explicitly.
|
||||
|
||||
There is a one-to-one relationship between source `.proto` files and
|
||||
generated `.pb.go` files, but any number of `.pb.go` files may be
|
||||
contained in the same Go package.
|
||||
|
||||
The output name of a generated file is produced by replacing the
|
||||
`.proto` suffix with `.pb.go` (e.g., `foo.proto` produces `foo.pb.go`).
|
||||
However, the output directory is selected in one of two ways. Let
|
||||
us say we have `inputs/x.proto` with a `go_package` option of
|
||||
`github.com/golang/protobuf/p`. The corresponding output file may
|
||||
be:
|
||||
|
||||
- Relative to the import path:
|
||||
|
||||
protoc --gogo_out=. inputs/x.proto
|
||||
# writes ./github.com/gogo/protobuf/p/x.pb.go
|
||||
|
||||
(This can work well with `--gogo_out=$GOPATH`.)
|
||||
|
||||
- Relative to the input file:
|
||||
|
||||
protoc --gogo_out=paths=source_relative:. inputs/x.proto
|
||||
# generate ./inputs/x.pb.go
|
||||
|
||||
## Generated code ##
|
||||
|
||||
The package comment for the proto library contains text describing
|
||||
the interface provided in Go for protocol buffers. Here is an edited
|
||||
version.
|
||||
|
||||
If you are using any gogo.proto extensions you will need to specify the
|
||||
proto_path to include the descriptor.proto and gogo.proto.
|
||||
gogo.proto is located in github.com/gogo/protobuf/gogoproto
|
||||
This should be fine, since your import is the same.
|
||||
descriptor.proto is located in either github.com/gogo/protobuf/protobuf
|
||||
or code.google.com/p/protobuf/trunk/src/
|
||||
Its import is google/protobuf/descriptor.proto so it might need some help.
|
||||
|
||||
protoc --gogo_out=. -I=.:github.com/gogo/protobuf/protobuf *.proto
|
||||
|
||||
==========
|
||||
|
||||
The proto package converts data structures to and from the
|
||||
wire format of protocol buffers. It works in concert with the
|
||||
Go source code generated for .proto files by the protocol compiler.
|
||||
|
||||
A summary of the properties of the protocol buffer interface
|
||||
for a protocol buffer variable v:
|
||||
|
||||
- Names are turned from camel_case to CamelCase for export.
|
||||
- There are no methods on v to set fields; just treat
|
||||
them as structure fields.
|
||||
- There are getters that return a field's value if set,
|
||||
and return the field's default value if unset.
|
||||
The getters work even if the receiver is a nil message.
|
||||
- The zero value for a struct is its correct initialization state.
|
||||
All desired fields must be set before marshaling.
|
||||
- A Reset() method will restore a protobuf struct to its zero state.
|
||||
- Non-repeated fields are pointers to the values; nil means unset.
|
||||
That is, optional or required field int32 f becomes F *int32.
|
||||
- Repeated fields are slices.
|
||||
- Helper functions are available to aid the setting of fields.
|
||||
Helpers for getting values are superseded by the
|
||||
GetFoo methods and their use is deprecated.
|
||||
msg.Foo = proto.String("hello") // set field
|
||||
- Constants are defined to hold the default values of all fields that
|
||||
have them. They have the form Default_StructName_FieldName.
|
||||
Because the getter methods handle defaulted values,
|
||||
direct use of these constants should be rare.
|
||||
- Enums are given type names and maps from names to values.
|
||||
Enum values are prefixed with the enum's type name. Enum types have
|
||||
a String method, and a Enum method to assist in message construction.
|
||||
- Nested groups and enums have type names prefixed with the name of
|
||||
the surrounding message type.
|
||||
- Extensions are given descriptor names that start with E_,
|
||||
followed by an underscore-delimited list of the nested messages
|
||||
that contain it (if any) followed by the CamelCased name of the
|
||||
extension field itself. HasExtension, ClearExtension, GetExtension
|
||||
and SetExtension are functions for manipulating extensions.
|
||||
- Oneof field sets are given a single field in their message,
|
||||
with distinguished wrapper types for each possible field value.
|
||||
- Marshal and Unmarshal are functions to encode and decode the wire format.
|
||||
|
||||
When the .proto file specifies `syntax="proto3"`, there are some differences:
|
||||
|
||||
- Non-repeated fields of non-message type are values instead of pointers.
|
||||
- Enum types do not get an Enum method.
|
||||
|
||||
Consider file test.proto, containing
|
||||
|
||||
```proto
|
||||
syntax = "proto2";
|
||||
package example;
|
||||
|
||||
enum FOO { X = 17; };
|
||||
|
||||
message Test {
|
||||
required string label = 1;
|
||||
optional int32 type = 2 [default=77];
|
||||
repeated int64 reps = 3;
|
||||
}
|
||||
```
|
||||
|
||||
To create and play with a Test object from the example package,
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"path/to/example"
|
||||
)
|
||||
|
||||
func main() {
|
||||
test := &example.Test{
|
||||
Label: proto.String("hello"),
|
||||
Type: proto.Int32(17),
|
||||
Reps: []int64{1, 2, 3},
|
||||
}
|
||||
data, err := proto.Marshal(test)
|
||||
if err != nil {
|
||||
log.Fatal("marshaling error: ", err)
|
||||
}
|
||||
newTest := &example.Test{}
|
||||
err = proto.Unmarshal(data, newTest)
|
||||
if err != nil {
|
||||
log.Fatal("unmarshaling error: ", err)
|
||||
}
|
||||
// Now test and newTest contain the same data.
|
||||
if test.GetLabel() != newTest.GetLabel() {
|
||||
log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel())
|
||||
}
|
||||
// etc.
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Parameters ##
|
||||
|
||||
To pass extra parameters to the plugin, use a comma-separated
|
||||
parameter list separated from the output directory by a colon:
|
||||
|
||||
|
||||
protoc --gogo_out=plugins=grpc,import_path=mypackage:. *.proto
|
||||
|
||||
- `paths=(import | source_relative)` - specifies how the paths of
|
||||
generated files are structured. See the "Packages and imports paths"
|
||||
section above. The default is `import`.
|
||||
- `plugins=plugin1+plugin2` - specifies the list of sub-plugins to
|
||||
load. The only plugin in this repo is `grpc`.
|
||||
- `Mfoo/bar.proto=quux/shme` - declares that foo/bar.proto is
|
||||
associated with Go package quux/shme. This is subject to the
|
||||
import_prefix parameter.
|
||||
|
||||
The following parameters are deprecated and should not be used:
|
||||
|
||||
- `import_prefix=xxx` - a prefix that is added onto the beginning of
|
||||
all imports.
|
||||
- `import_path=foo/bar` - used as the package if no input files
|
||||
declare `go_package`. If it contains slashes, everything up to the
|
||||
rightmost slash is ignored.
|
||||
|
||||
## gRPC Support ##
|
||||
|
||||
If a proto file specifies RPC services, protoc-gen-go can be instructed to
|
||||
generate code compatible with gRPC (http://www.grpc.io/). To do this, pass
|
||||
the `plugins` parameter to protoc-gen-go; the usual way is to insert it into
|
||||
the --go_out argument to protoc:
|
||||
|
||||
protoc --gogo_out=plugins=grpc:. *.proto
|
||||
|
||||
## Compatibility ##
|
||||
|
||||
The library and the generated code are expected to be stable over time.
|
||||
However, we reserve the right to make breaking changes without notice for the
|
||||
following reasons:
|
||||
|
||||
- Security. A security issue in the specification or implementation may come to
|
||||
light whose resolution requires breaking compatibility. We reserve the right
|
||||
to address such security issues.
|
||||
- Unspecified behavior. There are some aspects of the Protocol Buffers
|
||||
specification that are undefined. Programs that depend on such unspecified
|
||||
behavior may break in future releases.
|
||||
- Specification errors or changes. If it becomes necessary to address an
|
||||
inconsistency, incompleteness, or change in the Protocol Buffers
|
||||
specification, resolving the issue could affect the meaning or legality of
|
||||
existing programs. We reserve the right to address such issues, including
|
||||
updating the implementations.
|
||||
- Bugs. If the library has a bug that violates the specification, a program
|
||||
that depends on the buggy behavior may break if the bug is fixed. We reserve
|
||||
the right to fix such bugs.
|
||||
- Adding methods or fields to generated structs. These may conflict with field
|
||||
names that already exist in a schema, causing applications to break. When the
|
||||
code generator encounters a field in the schema that would collide with a
|
||||
generated field or method name, the code generator will append an underscore
|
||||
to the generated field or method name.
|
||||
- Adding, removing, or changing methods or fields in generated structs that
|
||||
start with `XXX`. These parts of the generated code are exported out of
|
||||
necessity, but should not be considered part of the public API.
|
||||
- Adding, removing, or changing unexported symbols in generated code.
|
||||
|
||||
Any breaking changes outside of these will be announced 6 months in advance to
|
||||
protobuf@googlegroups.com.
|
||||
|
||||
You should, whenever possible, use generated code created by the `protoc-gen-go`
|
||||
tool built at the same commit as the `proto` package. The `proto` package
|
||||
declares package-level constants in the form `ProtoPackageIsVersionX`.
|
||||
Application code and generated code may depend on one of these constants to
|
||||
ensure that compilation will fail if the available version of the proto library
|
||||
is too old. Whenever we make a change to the generated code that requires newer
|
||||
library support, in the same commit we will increment the version number of the
|
||||
generated code and declare a new package-level constant whose name incorporates
|
||||
the latest version number. Removing a compatibility constant is considered a
|
||||
breaking change and would be subject to the announcement policy stated above.
|
||||
|
||||
The `protoc-gen-go/generator` package exposes a plugin interface,
|
||||
which is used by the gRPC code generation. This interface is not
|
||||
supported and is subject to incompatible changes without notice.
|
159
vendor/github.com/gogo/protobuf/Readme.md
generated
vendored
Normal file
159
vendor/github.com/gogo/protobuf/Readme.md
generated
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
# Protocol Buffers for Go with Gadgets
|
||||
|
||||
[![Build Status](https://travis-ci.org/gogo/protobuf.svg?branch=master)](https://travis-ci.org/gogo/protobuf)
|
||||
[![GoDoc](https://godoc.org/github.com/gogo/protobuf?status.svg)](http://godoc.org/github.com/gogo/protobuf)
|
||||
|
||||
gogoprotobuf is a fork of <a href="https://github.com/golang/protobuf">golang/protobuf</a> with extra code generation features.
|
||||
|
||||
This code generation is used to achieve:
|
||||
|
||||
- fast marshalling and unmarshalling
|
||||
- more canonical Go structures
|
||||
- goprotobuf compatibility
|
||||
- less typing by optionally generating extra helper code
|
||||
- peace of mind by optionally generating test and benchmark code
|
||||
- other serialization formats
|
||||
|
||||
Keeping track of how up to date gogoprotobuf is relative to golang/protobuf is done in this
|
||||
<a href="https://github.com/gogo/protobuf/issues/191">issue</a>
|
||||
|
||||
## Users
|
||||
|
||||
These projects use gogoprotobuf:
|
||||
|
||||
- <a href="http://godoc.org/github.com/coreos/etcd">etcd</a> - <a href="https://blog.gopheracademy.com/advent-2015/etcd-distributed-key-value-store-with-grpc-http2/">blog</a> - <a href="https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/etcdserver.proto">sample proto file</a>
|
||||
- <a href="https://www.spacemonkey.com/">spacemonkey</a> - <a href="https://www.spacemonkey.com/blog/posts/go-space-monkey">blog</a>
|
||||
- <a href="http://badoo.com">badoo</a> - <a href="https://github.com/badoo/lsd/blob/32061f501c5eca9c76c596d790b450501ba27b2f/proto/lsd.proto">sample proto file</a>
|
||||
- <a href="https://github.com/mesos/mesos-go">mesos-go</a> - <a href="https://github.com/mesos/mesos-go/blob/f9e5fb7c2f50ab5f23299f26b6b07c5d6afdd252/api/v0/mesosproto/authentication.proto">sample proto file</a>
|
||||
- <a href="https://github.com/mozilla-services/heka">heka</a> - <a href="https://github.com/mozilla-services/heka/commit/eb72fbf7d2d28249fbaf8d8dc6607f4eb6f03351">the switch from golang/protobuf to gogo/protobuf when it was still on code.google.com</a>
|
||||
- <a href="https://github.com/cockroachdb/cockroach">cockroachdb</a> - <a href="https://github.com/cockroachdb/cockroach/blob/651d54d393e391a30154e9117ab4b18d9ee6d845/roachpb/metadata.proto">sample proto file</a>
|
||||
- <a href="https://github.com/jbenet/go-ipfs">go-ipfs</a> - <a href="https://github.com/ipfs/go-ipfs/blob/2b6da0c024f28abeb16947fb452787196a6b56a2/merkledag/pb/merkledag.proto">sample proto file</a>
|
||||
- <a href="https://github.com/philhofer/rkive">rkive-go</a> - <a href="https://github.com/philhofer/rkive/blob/e5dd884d3ea07b341321073882ae28aa16dd11be/rpbc/riak_dt.proto">sample proto file</a>
|
||||
- <a href="https://www.dropbox.com">dropbox</a>
|
||||
- <a href="https://srclib.org/">srclib</a> - <a href="https://github.com/sourcegraph/srclib/blob/6538858f0c410cac5c63440317b8d009e889d3fb/graph/def.proto">sample proto file</a>
|
||||
- <a href="http://www.adyoulike.com/">adyoulike</a>
|
||||
- <a href="http://www.cloudfoundry.org/">cloudfoundry</a> - <a href="https://github.com/cloudfoundry/bbs/blob/d673710b8c4211037805129944ee4c5373d6588a/models/events.proto">sample proto file</a>
|
||||
- <a href="http://kubernetes.io/">kubernetes</a> - <a href="https://github.com/kubernetes/kubernetes/tree/88d8628137f94ee816aaa6606ae8cd045dee0bff/cmd/libs/go2idl">go2idl built on top of gogoprotobuf</a>
|
||||
- <a href="https://dgraph.io/">dgraph</a> - <a href="https://github.com/dgraph-io/dgraph/releases/tag/v0.4.3">release notes</a> - <a href="https://discuss.dgraph.io/t/gogoprotobuf-is-extremely-fast/639">benchmarks</a></a>
|
||||
- <a href="https://github.com/centrifugal/centrifugo">centrifugo</a> - <a href="https://forum.golangbridge.org/t/centrifugo-real-time-messaging-websocket-or-sockjs-server-v1-5-0-released/2861">release notes</a> - <a href="https://medium.com/@fzambia/centrifugo-protobuf-inside-json-outside-21d39bdabd68#.o3icmgjqd">blog</a>
|
||||
- <a href="https://github.com/docker/swarmkit">docker swarmkit</a> - <a href="https://github.com/docker/swarmkit/blob/63600e01af3b8da2a0ed1c9fa6e1ae4299d75edb/api/objects.proto">sample proto file</a>
|
||||
- <a href="https://nats.io/">nats.io</a> - <a href="https://github.com/nats-io/go-nats-streaming/blob/master/pb/protocol.proto">go-nats-streaming</a>
|
||||
- <a href="https://github.com/pingcap/tidb">tidb</a> - Communication between <a href="https://github.com/pingcap/tipb/blob/master/generate-go.sh#L4">tidb</a> and <a href="https://github.com/pingcap/kvproto/blob/master/generate_go.sh#L3">tikv</a>
|
||||
- <a href="https://github.com/AsynkronIT/protoactor-go">protoactor-go</a> - <a href="https://github.com/AsynkronIT/protoactor-go/blob/master/protobuf/protoc-gen-protoactor/main.go">vanity command</a> that also generates actors from service definitions
|
||||
- <a href="https://containerd.io/">containerd</a> - <a href="https://github.com/containerd/containerd/tree/master/cmd/protoc-gen-gogoctrd">vanity command with custom field names</a> that conforms to the golang convention.
|
||||
- <a href="https://github.com/heroiclabs/nakama">nakama</a>
|
||||
- <a href="https://github.com/src-d/proteus">proteus</a>
|
||||
- <a href="https://github.com/go-graphite">carbonzipper stack</a>
|
||||
- <a href="https://sendgrid.com/">sendgrid</a>
|
||||
- <a href="https://github.com/zero-os/0-stor">zero-os/0-stor</a>
|
||||
- <a href="https://github.com/spacemeshos/go-spacemesh">go-spacemesh</a>
|
||||
- <a href="https://github.com/weaveworks/cortex">cortex</a> - <a href="https://github.com/weaveworks/cortex/blob/fee02a59729d3771ef888f7bf0fd050e1197c56e/pkg/ingester/client/cortex.proto">sample proto file</a>
|
||||
- <a href="http://skywalking.apache.org/">Apache SkyWalking APM</a> - Istio telemetry receiver based on Mixer bypass protocol
|
||||
|
||||
Please let us know if you are using gogoprotobuf by posting on our <a href="https://groups.google.com/forum/#!topic/gogoprotobuf/Brw76BxmFpQ">GoogleGroup</a>.
|
||||
|
||||
### Mentioned
|
||||
|
||||
- <a href="http://www.slideshare.net/albertstrasheim/serialization-in-go">Cloudflare - go serialization talk - Albert Strasheim</a>
|
||||
- <a href="https://youtu.be/4xB46Xl9O9Q?t=557">GopherCon 2014 Writing High Performance Databases in Go by Ben Johnson</a>
|
||||
- <a href="https://github.com/alecthomas/go_serialization_benchmarks">alecthomas' go serialization benchmarks</a>
|
||||
- <a href="http://agniva.me/go/2017/11/18/gogoproto.html">Go faster with gogoproto - Agniva De Sarker</a>
|
||||
- <a href="https://www.youtube.com/watch?v=CY9T020HLP8">Evolution of protobuf (Gource Visualization) - Landon Wilkins</a>
|
||||
- <a href="https://fosdem.org/2018/schedule/event/gopherjs/">Creating GopherJS Apps with gRPC-Web - Johan Brandhorst</a>
|
||||
- <a href="https://jbrandhorst.com/post/gogoproto/">So you want to use GoGo Protobuf - Johan Brandhorst</a>
|
||||
- <a href="https://jbrandhorst.com/post/grpc-errors/">Advanced gRPC Error Usage - Johan Brandhorst</a>
|
||||
- <a href="https://www.udemy.com/grpc-golang/?couponCode=GITHUB10">gRPC Golang Course on Udemy - Stephane Maarek</a>
|
||||
|
||||
## Getting Started
|
||||
|
||||
There are several ways to use gogoprotobuf, but for all you need to install go and protoc.
|
||||
After that you can choose:
|
||||
|
||||
- Speed
|
||||
- More Speed and more generated code
|
||||
- Most Speed and most customization
|
||||
|
||||
### Installation
|
||||
|
||||
To install it, you must first have Go (at least version 1.6.3 or 1.9 if you are using gRPC) installed (see [http://golang.org/doc/install](http://golang.org/doc/install)).
|
||||
Latest patch versions of 1.9 and 1.10 are continuously tested.
|
||||
|
||||
Next, install the standard protocol buffer implementation from [https://github.com/google/protobuf](https://github.com/google/protobuf).
|
||||
Most versions from 2.3.1 should not give any problems, but 2.6.1, 3.0.2 and 3.5.1 are continuously tested.
|
||||
|
||||
### Speed
|
||||
|
||||
Install the protoc-gen-gofast binary
|
||||
|
||||
go get github.com/gogo/protobuf/protoc-gen-gofast
|
||||
|
||||
Use it to generate faster marshaling and unmarshaling go code for your protocol buffers.
|
||||
|
||||
protoc --gofast_out=. myproto.proto
|
||||
|
||||
This does not allow you to use any of the other gogoprotobuf [extensions](https://github.com/gogo/protobuf/blob/master/extensions.md).
|
||||
|
||||
### More Speed and more generated code
|
||||
|
||||
Fields without pointers cause less time in the garbage collector.
|
||||
More code generation results in more convenient methods.
|
||||
|
||||
Other binaries are also included:
|
||||
|
||||
protoc-gen-gogofast (same as gofast, but imports gogoprotobuf)
|
||||
protoc-gen-gogofaster (same as gogofast, without XXX_unrecognized, less pointer fields)
|
||||
protoc-gen-gogoslick (same as gogofaster, but with generated string, gostring and equal methods)
|
||||
|
||||
Installing any of these binaries is easy. Simply run:
|
||||
|
||||
go get github.com/gogo/protobuf/proto
|
||||
go get github.com/gogo/protobuf/{binary}
|
||||
go get github.com/gogo/protobuf/gogoproto
|
||||
|
||||
These binaries allow you to use gogoprotobuf [extensions](https://github.com/gogo/protobuf/blob/master/extensions.md). You can also use your own binary.
|
||||
|
||||
To generate the code, you also need to set the include path properly.
|
||||
|
||||
protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --{binary}_out=. myproto.proto
|
||||
|
||||
To use proto files from "google/protobuf" you need to add additional args to protoc.
|
||||
|
||||
protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --{binary}_out=\
|
||||
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types:. \
|
||||
myproto.proto
|
||||
|
||||
Note that in the protoc command, {binary} does not contain the initial prefix of "protoc-gen".
|
||||
|
||||
### Most Speed and most customization
|
||||
|
||||
Customizing the fields of the messages to be the fields that you actually want to use removes the need to copy between the structs you use and structs you use to serialize.
|
||||
gogoprotobuf also offers more serialization formats and generation of tests and even more methods.
|
||||
|
||||
Please visit the [extensions](https://github.com/gogo/protobuf/blob/master/extensions.md) page for more documentation.
|
||||
|
||||
Install protoc-gen-gogo:
|
||||
|
||||
go get github.com/gogo/protobuf/proto
|
||||
go get github.com/gogo/protobuf/jsonpb
|
||||
go get github.com/gogo/protobuf/protoc-gen-gogo
|
||||
go get github.com/gogo/protobuf/gogoproto
|
||||
|
||||
## GRPC
|
||||
|
||||
It works the same as golang/protobuf, simply specify the plugin.
|
||||
Here is an example using gofast:
|
||||
|
||||
protoc --gofast_out=plugins=grpc:. my.proto
|
||||
|
||||
See [https://github.com/gogo/grpc-example](https://github.com/gogo/grpc-example) for an example of using gRPC with gogoprotobuf and the wider grpc-ecosystem.
|
||||
|
||||
|
||||
## License
|
||||
This software is licensed under the 3-Clause BSD License
|
||||
("BSD License 2.0", "Revised BSD License", "New BSD License", or "Modified BSD License").
|
||||
|
||||
|
190
vendor/github.com/gogo/protobuf/bench.md
generated
vendored
Normal file
190
vendor/github.com/gogo/protobuf/bench.md
generated
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
# Benchmarks
|
||||
|
||||
## How to reproduce
|
||||
|
||||
For a comparison run:
|
||||
|
||||
make bench
|
||||
|
||||
followed by [benchcmp](http://code.google.com/p/go/source/browse/misc/benchcmp benchcmp) on the resulting files:
|
||||
|
||||
$GOROOT/misc/benchcmp $GOPATH/src/github.com/gogo/protobuf/test/mixbench/marshal.txt $GOPATH/src/github.com/gogo/protobuf/test/mixbench/marshaler.txt
|
||||
$GOROOT/misc/benchcmp $GOPATH/src/github.com/gogo/protobuf/test/mixbench/unmarshal.txt $GOPATH/src/github.com/gogo/protobuf/test/mixbench/unmarshaler.txt
|
||||
|
||||
Benchmarks ran on Revision: 11c56be39364
|
||||
|
||||
June 2013
|
||||
|
||||
Processor 2,66 GHz Intel Core i7
|
||||
|
||||
Memory 8 GB 1067 MHz DDR3
|
||||
|
||||
## Marshaler
|
||||
|
||||
<table>
|
||||
<tr><td>benchmark</td><td>old ns/op</td><td>new ns/op</td><td>delta</td></tr>
|
||||
<tr><td>BenchmarkNidOptNativeProtoMarshal</td><td>2656</td><td>889</td><td>-66.53%</td></tr>
|
||||
<tr><td>BenchmarkNinOptNativeProtoMarshal</td><td>2651</td><td>1015</td><td>-61.71%</td></tr>
|
||||
<tr><td>BenchmarkNidRepNativeProtoMarshal</td><td>42661</td><td>12519</td><td>-70.65%</td></tr>
|
||||
<tr><td>BenchmarkNinRepNativeProtoMarshal</td><td>42306</td><td>12354</td><td>-70.80%</td></tr>
|
||||
<tr><td>BenchmarkNidRepPackedNativeProtoMarshal</td><td>34148</td><td>11902</td><td>-65.15%</td></tr>
|
||||
<tr><td>BenchmarkNinRepPackedNativeProtoMarshal</td><td>33375</td><td>11969</td><td>-64.14%</td></tr>
|
||||
<tr><td>BenchmarkNidOptStructProtoMarshal</td><td>7148</td><td>3727</td><td>-47.86%</td></tr>
|
||||
<tr><td>BenchmarkNinOptStructProtoMarshal</td><td>6956</td><td>3481</td><td>-49.96%</td></tr>
|
||||
<tr><td>BenchmarkNidRepStructProtoMarshal</td><td>46551</td><td>19492</td><td>-58.13%</td></tr>
|
||||
<tr><td>BenchmarkNinRepStructProtoMarshal</td><td>46715</td><td>19043</td><td>-59.24%</td></tr>
|
||||
<tr><td>BenchmarkNidEmbeddedStructProtoMarshal</td><td>5231</td><td>2050</td><td>-60.81%</td></tr>
|
||||
<tr><td>BenchmarkNinEmbeddedStructProtoMarshal</td><td>4665</td><td>2000</td><td>-57.13%</td></tr>
|
||||
<tr><td>BenchmarkNidNestedStructProtoMarshal</td><td>181106</td><td>103604</td><td>-42.79%</td></tr>
|
||||
<tr><td>BenchmarkNinNestedStructProtoMarshal</td><td>182053</td><td>102069</td><td>-43.93%</td></tr>
|
||||
<tr><td>BenchmarkNidOptCustomProtoMarshal</td><td>1209</td><td>310</td><td>-74.36%</td></tr>
|
||||
<tr><td>BenchmarkNinOptCustomProtoMarshal</td><td>1435</td><td>277</td><td>-80.70%</td></tr>
|
||||
<tr><td>BenchmarkNidRepCustomProtoMarshal</td><td>4126</td><td>763</td><td>-81.51%</td></tr>
|
||||
<tr><td>BenchmarkNinRepCustomProtoMarshal</td><td>3972</td><td>769</td><td>-80.64%</td></tr>
|
||||
<tr><td>BenchmarkNinOptNativeUnionProtoMarshal</td><td>973</td><td>303</td><td>-68.86%</td></tr>
|
||||
<tr><td>BenchmarkNinOptStructUnionProtoMarshal</td><td>1536</td><td>521</td><td>-66.08%</td></tr>
|
||||
<tr><td>BenchmarkNinEmbeddedStructUnionProtoMarshal</td><td>2327</td><td>884</td><td>-62.01%</td></tr>
|
||||
<tr><td>BenchmarkNinNestedStructUnionProtoMarshal</td><td>2070</td><td>743</td><td>-64.11%</td></tr>
|
||||
<tr><td>BenchmarkTreeProtoMarshal</td><td>1554</td><td>838</td><td>-46.07%</td></tr>
|
||||
<tr><td>BenchmarkOrBranchProtoMarshal</td><td>3156</td><td>2012</td><td>-36.25%</td></tr>
|
||||
<tr><td>BenchmarkAndBranchProtoMarshal</td><td>3183</td><td>1996</td><td>-37.29%</td></tr>
|
||||
<tr><td>BenchmarkLeafProtoMarshal</td><td>965</td><td>606</td><td>-37.20%</td></tr>
|
||||
<tr><td>BenchmarkDeepTreeProtoMarshal</td><td>2316</td><td>1283</td><td>-44.60%</td></tr>
|
||||
<tr><td>BenchmarkADeepBranchProtoMarshal</td><td>2719</td><td>1492</td><td>-45.13%</td></tr>
|
||||
<tr><td>BenchmarkAndDeepBranchProtoMarshal</td><td>4663</td><td>2922</td><td>-37.34%</td></tr>
|
||||
<tr><td>BenchmarkDeepLeafProtoMarshal</td><td>1849</td><td>1016</td><td>-45.05%</td></tr>
|
||||
<tr><td>BenchmarkNilProtoMarshal</td><td>439</td><td>76</td><td>-82.53%</td></tr>
|
||||
<tr><td>BenchmarkNidOptEnumProtoMarshal</td><td>514</td><td>152</td><td>-70.43%</td></tr>
|
||||
<tr><td>BenchmarkNinOptEnumProtoMarshal</td><td>550</td><td>158</td><td>-71.27%</td></tr>
|
||||
<tr><td>BenchmarkNidRepEnumProtoMarshal</td><td>647</td><td>207</td><td>-68.01%</td></tr>
|
||||
<tr><td>BenchmarkNinRepEnumProtoMarshal</td><td>662</td><td>213</td><td>-67.82%</td></tr>
|
||||
<tr><td>BenchmarkTimerProtoMarshal</td><td>934</td><td>271</td><td>-70.99%</td></tr>
|
||||
<tr><td>BenchmarkMyExtendableProtoMarshal</td><td>608</td><td>185</td><td>-69.57%</td></tr>
|
||||
<tr><td>BenchmarkOtherExtenableProtoMarshal</td><td>1112</td><td>332</td><td>-70.14%</td></tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr><td>benchmark</td><td>old MB/s</td><td>new MB/s</td><td>speedup</td></tr>
|
||||
<tr><td>BenchmarkNidOptNativeProtoMarshal</td><td>126.86</td><td>378.86</td><td>2.99x</td></tr>
|
||||
<tr><td>BenchmarkNinOptNativeProtoMarshal</td><td>114.27</td><td>298.42</td><td>2.61x</td></tr>
|
||||
<tr><td>BenchmarkNidRepNativeProtoMarshal</td><td>164.25</td><td>561.20</td><td>3.42x</td></tr>
|
||||
<tr><td>BenchmarkNinRepNativeProtoMarshal</td><td>166.10</td><td>568.23</td><td>3.42x</td></tr>
|
||||
<tr><td>BenchmarkNidRepPackedNativeProtoMarshal</td><td>99.10</td><td>283.97</td><td>2.87x</td></tr>
|
||||
<tr><td>BenchmarkNinRepPackedNativeProtoMarshal</td><td>101.30</td><td>282.31</td><td>2.79x</td></tr>
|
||||
<tr><td>BenchmarkNidOptStructProtoMarshal</td><td>176.83</td><td>339.07</td><td>1.92x</td></tr>
|
||||
<tr><td>BenchmarkNinOptStructProtoMarshal</td><td>163.59</td><td>326.57</td><td>2.00x</td></tr>
|
||||
<tr><td>BenchmarkNidRepStructProtoMarshal</td><td>178.84</td><td>427.49</td><td>2.39x</td></tr>
|
||||
<tr><td>BenchmarkNinRepStructProtoMarshal</td><td>178.70</td><td>437.69</td><td>2.45x</td></tr>
|
||||
<tr><td>BenchmarkNidEmbeddedStructProtoMarshal</td><td>124.24</td><td>317.56</td><td>2.56x</td></tr>
|
||||
<tr><td>BenchmarkNinEmbeddedStructProtoMarshal</td><td>132.03</td><td>307.99</td><td>2.33x</td></tr>
|
||||
<tr><td>BenchmarkNidNestedStructProtoMarshal</td><td>192.91</td><td>337.86</td><td>1.75x</td></tr>
|
||||
<tr><td>BenchmarkNinNestedStructProtoMarshal</td><td>192.44</td><td>344.45</td><td>1.79x</td></tr>
|
||||
<tr><td>BenchmarkNidOptCustomProtoMarshal</td><td>29.77</td><td>116.03</td><td>3.90x</td></tr>
|
||||
<tr><td>BenchmarkNinOptCustomProtoMarshal</td><td>22.29</td><td>115.38</td><td>5.18x</td></tr>
|
||||
<tr><td>BenchmarkNidRepCustomProtoMarshal</td><td>35.14</td><td>189.80</td><td>5.40x</td></tr>
|
||||
<tr><td>BenchmarkNinRepCustomProtoMarshal</td><td>36.50</td><td>188.40</td><td>5.16x</td></tr>
|
||||
<tr><td>BenchmarkNinOptNativeUnionProtoMarshal</td><td>32.87</td><td>105.39</td><td>3.21x</td></tr>
|
||||
<tr><td>BenchmarkNinOptStructUnionProtoMarshal</td><td>66.40</td><td>195.76</td><td>2.95x</td></tr>
|
||||
<tr><td>BenchmarkNinEmbeddedStructUnionProtoMarshal</td><td>93.24</td><td>245.26</td><td>2.63x</td></tr>
|
||||
<tr><td>BenchmarkNinNestedStructUnionProtoMarshal</td><td>57.49</td><td>160.06</td><td>2.78x</td></tr>
|
||||
<tr><td>BenchmarkTreeProtoMarshal</td><td>137.64</td><td>255.12</td><td>1.85x</td></tr>
|
||||
<tr><td>BenchmarkOrBranchProtoMarshal</td><td>137.80</td><td>216.10</td><td>1.57x</td></tr>
|
||||
<tr><td>BenchmarkAndBranchProtoMarshal</td><td>136.64</td><td>217.89</td><td>1.59x</td></tr>
|
||||
<tr><td>BenchmarkLeafProtoMarshal</td><td>214.48</td><td>341.53</td><td>1.59x</td></tr>
|
||||
<tr><td>BenchmarkDeepTreeProtoMarshal</td><td>95.85</td><td>173.03</td><td>1.81x</td></tr>
|
||||
<tr><td>BenchmarkADeepBranchProtoMarshal</td><td>82.73</td><td>150.78</td><td>1.82x</td></tr>
|
||||
<tr><td>BenchmarkAndDeepBranchProtoMarshal</td><td>96.72</td><td>153.98</td><td>1.59x</td></tr>
|
||||
<tr><td>BenchmarkDeepLeafProtoMarshal</td><td>117.34</td><td>213.41</td><td>1.82x</td></tr>
|
||||
<tr><td>BenchmarkNidOptEnumProtoMarshal</td><td>3.89</td><td>13.16</td><td>3.38x</td></tr>
|
||||
<tr><td>BenchmarkNinOptEnumProtoMarshal</td><td>1.82</td><td>6.30</td><td>3.46x</td></tr>
|
||||
<tr><td>BenchmarkNidRepEnumProtoMarshal</td><td>12.36</td><td>38.50</td><td>3.11x</td></tr>
|
||||
<tr><td>BenchmarkNinRepEnumProtoMarshal</td><td>12.08</td><td>37.53</td><td>3.11x</td></tr>
|
||||
<tr><td>BenchmarkTimerProtoMarshal</td><td>73.81</td><td>253.87</td><td>3.44x</td></tr>
|
||||
<tr><td>BenchmarkMyExtendableProtoMarshal</td><td>13.15</td><td>43.08</td><td>3.28x</td></tr>
|
||||
<tr><td>BenchmarkOtherExtenableProtoMarshal</td><td>24.28</td><td>81.09</td><td>3.34x</td></tr>
|
||||
</table>
|
||||
|
||||
## Unmarshaler
|
||||
|
||||
<table>
|
||||
<tr><td>benchmark</td><td>old ns/op</td><td>new ns/op</td><td>delta</td></tr>
|
||||
<tr><td>BenchmarkNidOptNativeProtoUnmarshal</td><td>2521</td><td>1006</td><td>-60.10%</td></tr>
|
||||
<tr><td>BenchmarkNinOptNativeProtoUnmarshal</td><td>2529</td><td>1750</td><td>-30.80%</td></tr>
|
||||
<tr><td>BenchmarkNidRepNativeProtoUnmarshal</td><td>49067</td><td>35299</td><td>-28.06%</td></tr>
|
||||
<tr><td>BenchmarkNinRepNativeProtoUnmarshal</td><td>47990</td><td>35456</td><td>-26.12%</td></tr>
|
||||
<tr><td>BenchmarkNidRepPackedNativeProtoUnmarshal</td><td>26456</td><td>23950</td><td>-9.47%</td></tr>
|
||||
<tr><td>BenchmarkNinRepPackedNativeProtoUnmarshal</td><td>26499</td><td>24037</td><td>-9.29%</td></tr>
|
||||
<tr><td>BenchmarkNidOptStructProtoUnmarshal</td><td>6803</td><td>3873</td><td>-43.07%</td></tr>
|
||||
<tr><td>BenchmarkNinOptStructProtoUnmarshal</td><td>6786</td><td>4154</td><td>-38.79%</td></tr>
|
||||
<tr><td>BenchmarkNidRepStructProtoUnmarshal</td><td>56276</td><td>31970</td><td>-43.19%</td></tr>
|
||||
<tr><td>BenchmarkNinRepStructProtoUnmarshal</td><td>48750</td><td>31832</td><td>-34.70%</td></tr>
|
||||
<tr><td>BenchmarkNidEmbeddedStructProtoUnmarshal</td><td>4556</td><td>1973</td><td>-56.69%</td></tr>
|
||||
<tr><td>BenchmarkNinEmbeddedStructProtoUnmarshal</td><td>4485</td><td>1975</td><td>-55.96%</td></tr>
|
||||
<tr><td>BenchmarkNidNestedStructProtoUnmarshal</td><td>223395</td><td>135844</td><td>-39.19%</td></tr>
|
||||
<tr><td>BenchmarkNinNestedStructProtoUnmarshal</td><td>226446</td><td>134022</td><td>-40.82%</td></tr>
|
||||
<tr><td>BenchmarkNidOptCustomProtoUnmarshal</td><td>1859</td><td>300</td><td>-83.86%</td></tr>
|
||||
<tr><td>BenchmarkNinOptCustomProtoUnmarshal</td><td>1486</td><td>402</td><td>-72.95%</td></tr>
|
||||
<tr><td>BenchmarkNidRepCustomProtoUnmarshal</td><td>8229</td><td>1669</td><td>-79.72%</td></tr>
|
||||
<tr><td>BenchmarkNinRepCustomProtoUnmarshal</td><td>8253</td><td>1649</td><td>-80.02%</td></tr>
|
||||
<tr><td>BenchmarkNinOptNativeUnionProtoUnmarshal</td><td>840</td><td>307</td><td>-63.45%</td></tr>
|
||||
<tr><td>BenchmarkNinOptStructUnionProtoUnmarshal</td><td>1395</td><td>639</td><td>-54.19%</td></tr>
|
||||
<tr><td>BenchmarkNinEmbeddedStructUnionProtoUnmarshal</td><td>2297</td><td>1167</td><td>-49.19%</td></tr>
|
||||
<tr><td>BenchmarkNinNestedStructUnionProtoUnmarshal</td><td>1820</td><td>889</td><td>-51.15%</td></tr>
|
||||
<tr><td>BenchmarkTreeProtoUnmarshal</td><td>1521</td><td>720</td><td>-52.66%</td></tr>
|
||||
<tr><td>BenchmarkOrBranchProtoUnmarshal</td><td>2669</td><td>1385</td><td>-48.11%</td></tr>
|
||||
<tr><td>BenchmarkAndBranchProtoUnmarshal</td><td>2667</td><td>1420</td><td>-46.76%</td></tr>
|
||||
<tr><td>BenchmarkLeafProtoUnmarshal</td><td>1171</td><td>584</td><td>-50.13%</td></tr>
|
||||
<tr><td>BenchmarkDeepTreeProtoUnmarshal</td><td>2065</td><td>1081</td><td>-47.65%</td></tr>
|
||||
<tr><td>BenchmarkADeepBranchProtoUnmarshal</td><td>2695</td><td>1178</td><td>-56.29%</td></tr>
|
||||
<tr><td>BenchmarkAndDeepBranchProtoUnmarshal</td><td>4055</td><td>1918</td><td>-52.70%</td></tr>
|
||||
<tr><td>BenchmarkDeepLeafProtoUnmarshal</td><td>1758</td><td>865</td><td>-50.80%</td></tr>
|
||||
<tr><td>BenchmarkNilProtoUnmarshal</td><td>564</td><td>63</td><td>-88.79%</td></tr>
|
||||
<tr><td>BenchmarkNidOptEnumProtoUnmarshal</td><td>762</td><td>73</td><td>-90.34%</td></tr>
|
||||
<tr><td>BenchmarkNinOptEnumProtoUnmarshal</td><td>764</td><td>163</td><td>-78.66%</td></tr>
|
||||
<tr><td>BenchmarkNidRepEnumProtoUnmarshal</td><td>1078</td><td>447</td><td>-58.53%</td></tr>
|
||||
<tr><td>BenchmarkNinRepEnumProtoUnmarshal</td><td>1071</td><td>479</td><td>-55.28%</td></tr>
|
||||
<tr><td>BenchmarkTimerProtoUnmarshal</td><td>1128</td><td>362</td><td>-67.91%</td></tr>
|
||||
<tr><td>BenchmarkMyExtendableProtoUnmarshal</td><td>808</td><td>217</td><td>-73.14%</td></tr>
|
||||
<tr><td>BenchmarkOtherExtenableProtoUnmarshal</td><td>1233</td><td>517</td><td>-58.07%</td></tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr><td>benchmark</td><td>old MB/s</td><td>new MB/s</td><td>speedup</td></tr>
|
||||
<tr><td>BenchmarkNidOptNativeProtoUnmarshal</td><td>133.67</td><td>334.98</td><td>2.51x</td></tr>
|
||||
<tr><td>BenchmarkNinOptNativeProtoUnmarshal</td><td>119.77</td><td>173.08</td><td>1.45x</td></tr>
|
||||
<tr><td>BenchmarkNidRepNativeProtoUnmarshal</td><td>143.23</td><td>199.12</td><td>1.39x</td></tr>
|
||||
<tr><td>BenchmarkNinRepNativeProtoUnmarshal</td><td>146.07</td><td>198.16</td><td>1.36x</td></tr>
|
||||
<tr><td>BenchmarkNidRepPackedNativeProtoUnmarshal</td><td>127.80</td><td>141.04</td><td>1.10x</td></tr>
|
||||
<tr><td>BenchmarkNinRepPackedNativeProtoUnmarshal</td><td>127.55</td><td>140.78</td><td>1.10x</td></tr>
|
||||
<tr><td>BenchmarkNidOptStructProtoUnmarshal</td><td>185.79</td><td>326.31</td><td>1.76x</td></tr>
|
||||
<tr><td>BenchmarkNinOptStructProtoUnmarshal</td><td>167.68</td><td>273.66</td><td>1.63x</td></tr>
|
||||
<tr><td>BenchmarkNidRepStructProtoUnmarshal</td><td>147.88</td><td>260.39</td><td>1.76x</td></tr>
|
||||
<tr><td>BenchmarkNinRepStructProtoUnmarshal</td><td>171.20</td><td>261.97</td><td>1.53x</td></tr>
|
||||
<tr><td>BenchmarkNidEmbeddedStructProtoUnmarshal</td><td>142.86</td><td>329.42</td><td>2.31x</td></tr>
|
||||
<tr><td>BenchmarkNinEmbeddedStructProtoUnmarshal</td><td>137.33</td><td>311.83</td><td>2.27x</td></tr>
|
||||
<tr><td>BenchmarkNidNestedStructProtoUnmarshal</td><td>154.97</td><td>259.47</td><td>1.67x</td></tr>
|
||||
<tr><td>BenchmarkNinNestedStructProtoUnmarshal</td><td>154.32</td><td>258.42</td><td>1.67x</td></tr>
|
||||
<tr><td>BenchmarkNidOptCustomProtoUnmarshal</td><td>19.36</td><td>119.66</td><td>6.18x</td></tr>
|
||||
<tr><td>BenchmarkNinOptCustomProtoUnmarshal</td><td>21.52</td><td>79.50</td><td>3.69x</td></tr>
|
||||
<tr><td>BenchmarkNidRepCustomProtoUnmarshal</td><td>17.62</td><td>86.86</td><td>4.93x</td></tr>
|
||||
<tr><td>BenchmarkNinRepCustomProtoUnmarshal</td><td>17.57</td><td>87.92</td><td>5.00x</td></tr>
|
||||
<tr><td>BenchmarkNinOptNativeUnionProtoUnmarshal</td><td>38.07</td><td>104.12</td><td>2.73x</td></tr>
|
||||
<tr><td>BenchmarkNinOptStructUnionProtoUnmarshal</td><td>73.08</td><td>159.54</td><td>2.18x</td></tr>
|
||||
<tr><td>BenchmarkNinEmbeddedStructUnionProtoUnmarshal</td><td>94.00</td><td>185.92</td><td>1.98x</td></tr>
|
||||
<tr><td>BenchmarkNinNestedStructUnionProtoUnmarshal</td><td>65.35</td><td>133.75</td><td>2.05x</td></tr>
|
||||
<tr><td>BenchmarkTreeProtoUnmarshal</td><td>141.28</td><td>297.13</td><td>2.10x</td></tr>
|
||||
<tr><td>BenchmarkOrBranchProtoUnmarshal</td><td>162.56</td><td>313.96</td><td>1.93x</td></tr>
|
||||
<tr><td>BenchmarkAndBranchProtoUnmarshal</td><td>163.06</td><td>306.15</td><td>1.88x</td></tr>
|
||||
<tr><td>BenchmarkLeafProtoUnmarshal</td><td>176.72</td><td>354.19</td><td>2.00x</td></tr>
|
||||
<tr><td>BenchmarkDeepTreeProtoUnmarshal</td><td>107.50</td><td>205.30</td><td>1.91x</td></tr>
|
||||
<tr><td>BenchmarkADeepBranchProtoUnmarshal</td><td>83.48</td><td>190.88</td><td>2.29x</td></tr>
|
||||
<tr><td>BenchmarkAndDeepBranchProtoUnmarshal</td><td>110.97</td><td>234.60</td><td>2.11x</td></tr>
|
||||
<tr><td>BenchmarkDeepLeafProtoUnmarshal</td><td>123.40</td><td>250.73</td><td>2.03x</td></tr>
|
||||
<tr><td>BenchmarkNidOptEnumProtoUnmarshal</td><td>2.62</td><td>27.16</td><td>10.37x</td></tr>
|
||||
<tr><td>BenchmarkNinOptEnumProtoUnmarshal</td><td>1.31</td><td>6.11</td><td>4.66x</td></tr>
|
||||
<tr><td>BenchmarkNidRepEnumProtoUnmarshal</td><td>7.42</td><td>17.88</td><td>2.41x</td></tr>
|
||||
<tr><td>BenchmarkNinRepEnumProtoUnmarshal</td><td>7.47</td><td>16.69</td><td>2.23x</td></tr>
|
||||
<tr><td>BenchmarkTimerProtoUnmarshal</td><td>61.12</td><td>190.34</td><td>3.11x</td></tr>
|
||||
<tr><td>BenchmarkMyExtendableProtoUnmarshal</td><td>9.90</td><td>36.71</td><td>3.71x</td></tr>
|
||||
<tr><td>BenchmarkOtherExtenableProtoUnmarshal</td><td>21.90</td><td>52.13</td><td>2.38x</td></tr>
|
||||
</table>
|
91
vendor/github.com/gogo/protobuf/codec/codec.go
generated
vendored
Normal file
91
vendor/github.com/gogo/protobuf/codec/codec.go
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
// Protocol Buffers for Go with Gadgets
|
||||
//
|
||||
// Copyright (c) 2015, 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 codec
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
type Codec interface {
|
||||
Marshal(v interface{}) ([]byte, error)
|
||||
Unmarshal(data []byte, v interface{}) error
|
||||
String() string
|
||||
}
|
||||
|
||||
type marshaler interface {
|
||||
MarshalTo(data []byte) (n int, err error)
|
||||
}
|
||||
|
||||
func getSize(v interface{}) (int, bool) {
|
||||
if sz, ok := v.(interface {
|
||||
Size() (n int)
|
||||
}); ok {
|
||||
return sz.Size(), true
|
||||
} else if sz, ok := v.(interface {
|
||||
ProtoSize() (n int)
|
||||
}); ok {
|
||||
return sz.ProtoSize(), true
|
||||
} else {
|
||||
return 0, false
|
||||
}
|
||||
}
|
||||
|
||||
type codec struct {
|
||||
buf []byte
|
||||
}
|
||||
|
||||
func (this *codec) String() string {
|
||||
return "proto"
|
||||
}
|
||||
|
||||
func New(size int) Codec {
|
||||
return &codec{make([]byte, size)}
|
||||
}
|
||||
|
||||
func (this *codec) Marshal(v interface{}) ([]byte, error) {
|
||||
if m, ok := v.(marshaler); ok {
|
||||
n, ok := getSize(v)
|
||||
if !ok {
|
||||
return proto.Marshal(v.(proto.Message))
|
||||
}
|
||||
if n > len(this.buf) {
|
||||
this.buf = make([]byte, n)
|
||||
}
|
||||
_, err := m.MarshalTo(this.buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return this.buf[:n], nil
|
||||
}
|
||||
return proto.Marshal(v.(proto.Message))
|
||||
}
|
||||
|
||||
func (this *codec) Unmarshal(data []byte, v interface{}) error {
|
||||
return proto.Unmarshal(data, v.(proto.Message))
|
||||
}
|
54
vendor/github.com/gogo/protobuf/codec/codec_test.go
generated
vendored
Normal file
54
vendor/github.com/gogo/protobuf/codec/codec_test.go
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
// Protocol Buffers for Go with Gadgets
|
||||
//
|
||||
// Copyright (c) 2015, 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 codec
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/test"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCodec(t *testing.T) {
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
in := test.NewPopulatedNinOptStruct(r, true)
|
||||
c := New(r.Intn(1024))
|
||||
data, err := c.Marshal(in)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out := &test.NinOptStruct{}
|
||||
err = c.Unmarshal(data, out)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := in.VerboseEqual(out); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
59
vendor/github.com/gogo/protobuf/conformance/Makefile
generated
vendored
Normal file
59
vendor/github.com/gogo/protobuf/conformance/Makefile
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
# 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.
|
||||
|
||||
PROTOBUF_ROOT=$(HOME)/src/protobuf
|
||||
|
||||
all:
|
||||
@echo To run the tests in this directory, acquire the main protobuf
|
||||
@echo distribution from:
|
||||
@echo
|
||||
@echo ' https://github.com/google/protobuf'
|
||||
@echo
|
||||
@echo Build the test runner with:
|
||||
@echo
|
||||
@echo ' cd conformance && make conformance-test-runner'
|
||||
@echo
|
||||
@echo And run the tests in this directory with:
|
||||
@echo
|
||||
@echo ' make test PROTOBUF_ROOT=<protobuf distribution>'
|
||||
|
||||
test:
|
||||
./test.sh $(PROTOBUF_ROOT)
|
||||
|
||||
regenerate:
|
||||
protoc-min-version --version="3.0.0" --proto_path=$(GOPATH)/src:$(GOPATH)/src/github.com/gogo/protobuf/protobuf:. --gogo_out=\
|
||||
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,\
|
||||
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types\
|
||||
:. ./internal/conformance_proto/conformance.proto
|
154
vendor/github.com/gogo/protobuf/conformance/conformance.go
generated
vendored
Normal file
154
vendor/github.com/gogo/protobuf/conformance/conformance.go
generated
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
// 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.
|
||||
|
||||
// conformance implements the conformance test subprocess protocol as
|
||||
// documented in conformance.proto.
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
pb "github.com/gogo/protobuf/conformance/internal/conformance_proto"
|
||||
"github.com/gogo/protobuf/jsonpb"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var sizeBuf [4]byte
|
||||
inbuf := make([]byte, 0, 4096)
|
||||
outbuf := proto.NewBuffer(nil)
|
||||
for {
|
||||
if _, err := io.ReadFull(os.Stdin, sizeBuf[:]); err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "go conformance: read request:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
size := binary.LittleEndian.Uint32(sizeBuf[:])
|
||||
if int(size) > cap(inbuf) {
|
||||
inbuf = make([]byte, size)
|
||||
}
|
||||
inbuf = inbuf[:size]
|
||||
if _, err := io.ReadFull(os.Stdin, inbuf); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "go conformance: read request:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
req := new(pb.ConformanceRequest)
|
||||
if err := proto.Unmarshal(inbuf, req); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "go conformance: parse request:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
res := handle(req)
|
||||
|
||||
if err := outbuf.Marshal(res); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "go conformance: marshal response:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
binary.LittleEndian.PutUint32(sizeBuf[:], uint32(len(outbuf.Bytes())))
|
||||
if _, err := os.Stdout.Write(sizeBuf[:]); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "go conformance: write response:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if _, err := os.Stdout.Write(outbuf.Bytes()); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "go conformance: write response:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
outbuf.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
var jsonMarshaler = jsonpb.Marshaler{
|
||||
OrigName: true,
|
||||
}
|
||||
|
||||
func handle(req *pb.ConformanceRequest) *pb.ConformanceResponse {
|
||||
var err error
|
||||
var msg pb.TestAllTypes
|
||||
switch p := req.Payload.(type) {
|
||||
case *pb.ConformanceRequest_ProtobufPayload:
|
||||
err = proto.Unmarshal(p.ProtobufPayload, &msg)
|
||||
case *pb.ConformanceRequest_JsonPayload:
|
||||
err = jsonpb.UnmarshalString(p.JsonPayload, &msg)
|
||||
default:
|
||||
return &pb.ConformanceResponse{
|
||||
Result: &pb.ConformanceResponse_RuntimeError{
|
||||
RuntimeError: "unknown request payload type",
|
||||
},
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return &pb.ConformanceResponse{
|
||||
Result: &pb.ConformanceResponse_ParseError{
|
||||
ParseError: err.Error(),
|
||||
},
|
||||
}
|
||||
}
|
||||
switch req.RequestedOutputFormat {
|
||||
case pb.WireFormat_PROTOBUF:
|
||||
p, err := proto.Marshal(&msg)
|
||||
if err != nil {
|
||||
return &pb.ConformanceResponse{
|
||||
Result: &pb.ConformanceResponse_SerializeError{
|
||||
SerializeError: err.Error(),
|
||||
},
|
||||
}
|
||||
}
|
||||
return &pb.ConformanceResponse{
|
||||
Result: &pb.ConformanceResponse_ProtobufPayload{
|
||||
ProtobufPayload: p,
|
||||
},
|
||||
}
|
||||
case pb.WireFormat_JSON:
|
||||
p, err := jsonMarshaler.MarshalToString(&msg)
|
||||
if err != nil {
|
||||
return &pb.ConformanceResponse{
|
||||
Result: &pb.ConformanceResponse_SerializeError{
|
||||
SerializeError: err.Error(),
|
||||
},
|
||||
}
|
||||
}
|
||||
return &pb.ConformanceResponse{
|
||||
Result: &pb.ConformanceResponse_JsonPayload{
|
||||
JsonPayload: p,
|
||||
},
|
||||
}
|
||||
default:
|
||||
return &pb.ConformanceResponse{
|
||||
Result: &pb.ConformanceResponse_RuntimeError{
|
||||
RuntimeError: "unknown output format",
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
4
vendor/github.com/gogo/protobuf/conformance/conformance.sh
generated
vendored
Normal file
4
vendor/github.com/gogo/protobuf/conformance/conformance.sh
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd $(dirname $0)
|
||||
exec go run conformance.go $*
|
1814
vendor/github.com/gogo/protobuf/conformance/internal/conformance_proto/conformance.pb.go
generated
vendored
Normal file
1814
vendor/github.com/gogo/protobuf/conformance/internal/conformance_proto/conformance.pb.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
273
vendor/github.com/gogo/protobuf/conformance/internal/conformance_proto/conformance.proto
generated
vendored
Normal file
273
vendor/github.com/gogo/protobuf/conformance/internal/conformance_proto/conformance.proto
generated
vendored
Normal file
@ -0,0 +1,273 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// 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.
|
||||
|
||||
syntax = "proto3";
|
||||
package conformance;
|
||||
option java_package = "com.google.protobuf.conformance";
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
// This defines the conformance testing protocol. This protocol exists between
|
||||
// the conformance test suite itself and the code being tested. For each test,
|
||||
// the suite will send a ConformanceRequest message and expect a
|
||||
// ConformanceResponse message.
|
||||
//
|
||||
// You can either run the tests in two different ways:
|
||||
//
|
||||
// 1. in-process (using the interface in conformance_test.h).
|
||||
//
|
||||
// 2. as a sub-process communicating over a pipe. Information about how to
|
||||
// do this is in conformance_test_runner.cc.
|
||||
//
|
||||
// Pros/cons of the two approaches:
|
||||
//
|
||||
// - running as a sub-process is much simpler for languages other than C/C++.
|
||||
//
|
||||
// - running as a sub-process may be more tricky in unusual environments like
|
||||
// iOS apps, where fork/stdin/stdout are not available.
|
||||
|
||||
enum WireFormat {
|
||||
UNSPECIFIED = 0;
|
||||
PROTOBUF = 1;
|
||||
JSON = 2;
|
||||
}
|
||||
|
||||
// Represents a single test case's input. The testee should:
|
||||
//
|
||||
// 1. parse this proto (which should always succeed)
|
||||
// 2. parse the protobuf or JSON payload in "payload" (which may fail)
|
||||
// 3. if the parse succeeded, serialize the message in the requested format.
|
||||
message ConformanceRequest {
|
||||
// The payload (whether protobuf of JSON) is always for a TestAllTypes proto
|
||||
// (see below).
|
||||
oneof payload {
|
||||
bytes protobuf_payload = 1;
|
||||
string json_payload = 2;
|
||||
}
|
||||
|
||||
// Which format should the testee serialize its message to?
|
||||
WireFormat requested_output_format = 3;
|
||||
}
|
||||
|
||||
// Represents a single test case's output.
|
||||
message ConformanceResponse {
|
||||
oneof result {
|
||||
// This string should be set to indicate parsing failed. The string can
|
||||
// provide more information about the parse error if it is available.
|
||||
//
|
||||
// Setting this string does not necessarily mean the testee failed the
|
||||
// test. Some of the test cases are intentionally invalid input.
|
||||
string parse_error = 1;
|
||||
|
||||
// If the input was successfully parsed but errors occurred when
|
||||
// serializing it to the requested output format, set the error message in
|
||||
// this field.
|
||||
string serialize_error = 6;
|
||||
|
||||
// This should be set if some other error occurred. This will always
|
||||
// indicate that the test failed. The string can provide more information
|
||||
// about the failure.
|
||||
string runtime_error = 2;
|
||||
|
||||
// If the input was successfully parsed and the requested output was
|
||||
// protobuf, serialize it to protobuf and set it in this field.
|
||||
bytes protobuf_payload = 3;
|
||||
|
||||
// If the input was successfully parsed and the requested output was JSON,
|
||||
// serialize to JSON and set it in this field.
|
||||
string json_payload = 4;
|
||||
|
||||
// For when the testee skipped the test, likely because a certain feature
|
||||
// wasn't supported, like JSON input/output.
|
||||
string skipped = 5;
|
||||
}
|
||||
}
|
||||
|
||||
// This proto includes every type of field in both singular and repeated
|
||||
// forms.
|
||||
message TestAllTypes {
|
||||
message NestedMessage {
|
||||
int32 a = 1;
|
||||
TestAllTypes corecursive = 2;
|
||||
}
|
||||
|
||||
enum NestedEnum {
|
||||
FOO = 0;
|
||||
BAR = 1;
|
||||
BAZ = 2;
|
||||
NEG = -1; // Intentionally negative.
|
||||
}
|
||||
|
||||
// Singular
|
||||
int32 optional_int32 = 1;
|
||||
int64 optional_int64 = 2;
|
||||
uint32 optional_uint32 = 3;
|
||||
uint64 optional_uint64 = 4;
|
||||
sint32 optional_sint32 = 5;
|
||||
sint64 optional_sint64 = 6;
|
||||
fixed32 optional_fixed32 = 7;
|
||||
fixed64 optional_fixed64 = 8;
|
||||
sfixed32 optional_sfixed32 = 9;
|
||||
sfixed64 optional_sfixed64 = 10;
|
||||
float optional_float = 11;
|
||||
double optional_double = 12;
|
||||
bool optional_bool = 13;
|
||||
string optional_string = 14;
|
||||
bytes optional_bytes = 15;
|
||||
|
||||
NestedMessage optional_nested_message = 18;
|
||||
ForeignMessage optional_foreign_message = 19;
|
||||
|
||||
NestedEnum optional_nested_enum = 21;
|
||||
ForeignEnum optional_foreign_enum = 22;
|
||||
|
||||
string optional_string_piece = 24 [ctype=STRING_PIECE];
|
||||
string optional_cord = 25 [ctype=CORD];
|
||||
|
||||
TestAllTypes recursive_message = 27;
|
||||
|
||||
// Repeated
|
||||
repeated int32 repeated_int32 = 31;
|
||||
repeated int64 repeated_int64 = 32;
|
||||
repeated uint32 repeated_uint32 = 33;
|
||||
repeated uint64 repeated_uint64 = 34;
|
||||
repeated sint32 repeated_sint32 = 35;
|
||||
repeated sint64 repeated_sint64 = 36;
|
||||
repeated fixed32 repeated_fixed32 = 37;
|
||||
repeated fixed64 repeated_fixed64 = 38;
|
||||
repeated sfixed32 repeated_sfixed32 = 39;
|
||||
repeated sfixed64 repeated_sfixed64 = 40;
|
||||
repeated float repeated_float = 41;
|
||||
repeated double repeated_double = 42;
|
||||
repeated bool repeated_bool = 43;
|
||||
repeated string repeated_string = 44;
|
||||
repeated bytes repeated_bytes = 45;
|
||||
|
||||
repeated NestedMessage repeated_nested_message = 48;
|
||||
repeated ForeignMessage repeated_foreign_message = 49;
|
||||
|
||||
repeated NestedEnum repeated_nested_enum = 51;
|
||||
repeated ForeignEnum repeated_foreign_enum = 52;
|
||||
|
||||
repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
|
||||
repeated string repeated_cord = 55 [ctype=CORD];
|
||||
|
||||
// Map
|
||||
map < int32, int32> map_int32_int32 = 56;
|
||||
map < int64, int64> map_int64_int64 = 57;
|
||||
map < uint32, uint32> map_uint32_uint32 = 58;
|
||||
map < uint64, uint64> map_uint64_uint64 = 59;
|
||||
map < sint32, sint32> map_sint32_sint32 = 60;
|
||||
map < sint64, sint64> map_sint64_sint64 = 61;
|
||||
map < fixed32, fixed32> map_fixed32_fixed32 = 62;
|
||||
map < fixed64, fixed64> map_fixed64_fixed64 = 63;
|
||||
map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
|
||||
map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
|
||||
map < int32, float> map_int32_float = 66;
|
||||
map < int32, double> map_int32_double = 67;
|
||||
map < bool, bool> map_bool_bool = 68;
|
||||
map < string, string> map_string_string = 69;
|
||||
map < string, bytes> map_string_bytes = 70;
|
||||
map < string, NestedMessage> map_string_nested_message = 71;
|
||||
map < string, ForeignMessage> map_string_foreign_message = 72;
|
||||
map < string, NestedEnum> map_string_nested_enum = 73;
|
||||
map < string, ForeignEnum> map_string_foreign_enum = 74;
|
||||
|
||||
oneof oneof_field {
|
||||
uint32 oneof_uint32 = 111;
|
||||
NestedMessage oneof_nested_message = 112;
|
||||
string oneof_string = 113;
|
||||
bytes oneof_bytes = 114;
|
||||
}
|
||||
|
||||
// Well-known types
|
||||
google.protobuf.BoolValue optional_bool_wrapper = 201;
|
||||
google.protobuf.Int32Value optional_int32_wrapper = 202;
|
||||
google.protobuf.Int64Value optional_int64_wrapper = 203;
|
||||
google.protobuf.UInt32Value optional_uint32_wrapper = 204;
|
||||
google.protobuf.UInt64Value optional_uint64_wrapper = 205;
|
||||
google.protobuf.FloatValue optional_float_wrapper = 206;
|
||||
google.protobuf.DoubleValue optional_double_wrapper = 207;
|
||||
google.protobuf.StringValue optional_string_wrapper = 208;
|
||||
google.protobuf.BytesValue optional_bytes_wrapper = 209;
|
||||
|
||||
repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
|
||||
repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
|
||||
repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
|
||||
repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
|
||||
repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
|
||||
repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
|
||||
repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
|
||||
repeated google.protobuf.StringValue repeated_string_wrapper = 218;
|
||||
repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
|
||||
|
||||
google.protobuf.Duration optional_duration = 301;
|
||||
google.protobuf.Timestamp optional_timestamp = 302;
|
||||
google.protobuf.FieldMask optional_field_mask = 303;
|
||||
google.protobuf.Struct optional_struct = 304;
|
||||
google.protobuf.Any optional_any = 305;
|
||||
google.protobuf.Value optional_value = 306;
|
||||
|
||||
repeated google.protobuf.Duration repeated_duration = 311;
|
||||
repeated google.protobuf.Timestamp repeated_timestamp = 312;
|
||||
repeated google.protobuf.FieldMask repeated_fieldmask = 313;
|
||||
repeated google.protobuf.Struct repeated_struct = 324;
|
||||
repeated google.protobuf.Any repeated_any = 315;
|
||||
repeated google.protobuf.Value repeated_value = 316;
|
||||
|
||||
// Test field-name-to-JSON-name convention.
|
||||
int32 fieldname1 = 401;
|
||||
int32 field_name2 = 402;
|
||||
int32 _field_name3 = 403;
|
||||
int32 field__name4_ = 404;
|
||||
int32 field0name5 = 405;
|
||||
int32 field_0_name6 = 406;
|
||||
int32 fieldName7 = 407;
|
||||
int32 FieldName8 = 408;
|
||||
int32 field_Name9 = 409;
|
||||
int32 Field_Name10 = 410;
|
||||
int32 FIELD_NAME11 = 411;
|
||||
int32 FIELD_name12 = 412;
|
||||
}
|
||||
|
||||
message ForeignMessage {
|
||||
int32 c = 1;
|
||||
}
|
||||
|
||||
enum ForeignEnum {
|
||||
FOREIGN_FOO = 0;
|
||||
FOREIGN_BAR = 1;
|
||||
FOREIGN_BAZ = 2;
|
||||
}
|
26
vendor/github.com/gogo/protobuf/conformance/test.sh
generated
vendored
Executable file
26
vendor/github.com/gogo/protobuf/conformance/test.sh
generated
vendored
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROTOBUF_ROOT=$1
|
||||
CONFORMANCE_ROOT=$1/conformance
|
||||
CONFORMANCE_TEST_RUNNER=$CONFORMANCE_ROOT/conformance-test-runner
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
if [[ $PROTOBUF_ROOT == "" ]]; then
|
||||
echo "usage: test.sh <protobuf-root>" >/dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -x $CONFORMANCE_TEST_RUNNER ]]; then
|
||||
echo "SKIP: conformance test runner not installed" >/dev/stderr
|
||||
exit 0
|
||||
fi
|
||||
|
||||
a=$CONFORMANCE_ROOT/conformance.proto
|
||||
b=internal/conformance_proto/conformance.proto
|
||||
if [[ $(diff $a $b) != "" ]]; then
|
||||
cp $a $b
|
||||
echo "WARNING: conformance.proto is out of date" >/dev/stderr
|
||||
fi
|
||||
|
||||
$CONFORMANCE_TEST_RUNNER --failure_list failure_list_go.txt ./conformance.sh
|
71
vendor/github.com/gogo/protobuf/custom_types.md
generated
vendored
Normal file
71
vendor/github.com/gogo/protobuf/custom_types.md
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
# Custom types
|
||||
|
||||
Custom types is a gogo protobuf extensions that allows for using a custom
|
||||
struct type to decorate the underlying structure of the protocol message.
|
||||
|
||||
# How to use
|
||||
|
||||
## Defining the protobuf message
|
||||
|
||||
```proto
|
||||
message CustomType {
|
||||
optional ProtoType Field = 1 [(gogoproto.customtype) = "T"];
|
||||
}
|
||||
|
||||
message ProtoType {
|
||||
optional string Field = 1;
|
||||
}
|
||||
```
|
||||
|
||||
or alternatively you can declare the field type in the protocol message to be
|
||||
`bytes`:
|
||||
|
||||
```proto
|
||||
message BytesCustomType {
|
||||
optional bytes Field = 1 [(gogoproto.customtype) = "T"];
|
||||
}
|
||||
```
|
||||
|
||||
The downside of using `bytes` is that it makes it harder to generate protobuf
|
||||
code in other languages. In either case, it is the user responsibility to
|
||||
ensure that the custom type marshals and unmarshals to the expected wire
|
||||
format. That is, in the first example, gogo protobuf will not attempt to ensure
|
||||
that the wire format of `ProtoType` and `T` are wire compatible.
|
||||
|
||||
## Custom type method signatures
|
||||
|
||||
The custom type must define the following methods with the given
|
||||
signatures. Assuming the custom type is called `T`:
|
||||
|
||||
```go
|
||||
func (t T) Marshal() ([]byte, error) {}
|
||||
func (t *T) MarshalTo(data []byte) (n int, err error) {}
|
||||
func (t *T) Unmarshal(data []byte) error {}
|
||||
func (t *T) Size() int {}
|
||||
|
||||
func (t T) MarshalJSON() ([]byte, error) {}
|
||||
func (t *T) UnmarshalJSON(data []byte) error {}
|
||||
|
||||
// only required if the compare option is set
|
||||
func (t T) Compare(other T) int {}
|
||||
// only required if the equal option is set
|
||||
func (t T) Equal(other T) bool {}
|
||||
// only required if populate option is set
|
||||
func NewPopulatedT(r randyThetest) *T {}
|
||||
```
|
||||
|
||||
Check [t.go](test/t.go) for a full example
|
||||
|
||||
# Warnings and issues
|
||||
|
||||
`Warning about customtype: It is your responsibility to test all cases of your marshaling, unmarshaling and size methods implemented for your custom type.`
|
||||
|
||||
Issues with customtype include:
|
||||
* <a href="https://github.com/gogo/protobuf/issues/199">A Bytes method is not allowed.<a/>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/132">Defining a customtype as a fake proto message is broken.</a>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/147">proto.Clone is broken.</a>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/125">Using a proto message as a customtype is not allowed.</a>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/200">cusomtype of type map can not UnmarshalText</a>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/201">customtype of type struct cannot jsonpb unmarshal</a>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/477">Customtype field does not get a generated 'getter' method</a>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/478">Repeated customtype fields generate slices without pointer to the custom type </a>
|
168
vendor/github.com/gogo/protobuf/extensions.md
generated
vendored
Normal file
168
vendor/github.com/gogo/protobuf/extensions.md
generated
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
# gogoprotobuf Extensions
|
||||
|
||||
Here is an [example.proto](https://github.com/gogo/protobuf/blob/master/test/example/example.proto) which uses most of the gogoprotobuf code generation plugins.
|
||||
|
||||
Please also look at the example [Makefile](https://github.com/gogo/protobuf/blob/master/test/example/Makefile) which shows how to specify the `descriptor.proto` and `gogo.proto` in your proto_path
|
||||
|
||||
The documentation at [http://godoc.org/github.com/gogo/protobuf/gogoproto](http://godoc.org/github.com/gogo/protobuf/gogoproto) describes the extensions made to goprotobuf in more detail.
|
||||
|
||||
Also see [http://godoc.org/github.com/gogo/protobuf/plugin/](http://godoc.org/github.com/gogo/protobuf/plugin/) for documentation of each of the extensions which have their own plugins.
|
||||
|
||||
# Fast Marshalling and Unmarshalling
|
||||
|
||||
Generating a `Marshal`, `MarshalTo`, `Size` (or `ProtoSize`) and `Unmarshal` method for a struct results in faster marshalling and unmarshalling than when using reflect.
|
||||
|
||||
See [BenchComparison](https://github.com/gogo/protobuf/blob/master/bench.md) for a comparison between reflect and generated code used for marshalling and unmarshalling.
|
||||
|
||||
<table>
|
||||
<tr><td><b>Name</b></td><td><b>Option</b></td><td><b>Type</b></td><td><b>Description</b></td><td><b>Default</b></td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/marshalto">marshaler</a></td><td>Message</td><td>bool</td><td>if true, a Marshal and MarshalTo method is generated for the specific message</td><td>false</td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/size">sizer</a></td><td>Message</td><td>bool</td><td>if true, a Size method is generated for the specific message</td><td>false</td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/unmarshal">unmarshaler</a></td><td> Message </td><td> bool </td><td> if true, an Unmarshal method is generated for the specific message </td><td> false</td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/size">protosizer</a></td><td>Message</td><td>bool</td><td>if true, a ProtoSize method is generated for the specific message</td><td>false</td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/marshalto"> unsafe_marshaler</a> (deprecated) </td><td> Message </td><td> bool </td><td> if true, a Marshal and MarshalTo method is generated. </td><td> false</td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/unmarshal">unsafe_unmarshaler</a> (deprecated) </td><td> Message </td><td> bool </td><td> if true, an Unmarshal method is generated. </td><td> false</td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/marshalto">stable_marshaler</a></td><td> Message </td><td> bool </td><td> if true, a Marshal and MarshalTo method is generated for the specific message, but unlike marshaler the output is guaranteed to be deterministic, at the sacrifice of some speed</td><td> false </td></tr>
|
||||
<tr><td>typedecl (beta)</td><td> Message </td><td> bool </td><td> if false, type declaration of the message is excluded from the generated output. Requires the marshaler and unmarshaler to be generated.</td><td> true </td></tr>
|
||||
</table>
|
||||
|
||||
# More Canonical Go Structures
|
||||
|
||||
Lots of times working with a goprotobuf struct will lead you to a place where you create another struct that is easier to work with and then have a function to copy the values between the two structs.
|
||||
|
||||
You might also find that basic structs that started their life as part of an API need to be sent over the wire. With gob, you could just send it. With goprotobuf, you need to make a new struct.
|
||||
|
||||
`gogoprotobuf` tries to fix these problems with the nullable, embed, customtype, customname, casttype, castkey and castvalue field extensions.
|
||||
|
||||
<table>
|
||||
<tr><td><b>Name</b></td><td><b>Option</b></td><td><b>Type</b></td><td><b>Description</b></td><td><b>Default</b></td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/gogoproto">nullable</a></td><td> Field </td><td> bool </td><td> if false, a field is generated without a pointer (see warning below). </td><td> true </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/gogoproto">embed</a></td><td> Field </td><td> bool </td><td> if true, the field is generated as an embedded field. </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/gogoproto">customtype</a> </td><td> Field </td><td> string </td><td> It works with the Marshal and Unmarshal methods, to allow you to have your own types in your struct, but marshal to bytes. For example, custom.Uuid or custom.Fixed128. For more information please refer to the <a href="custom_types.md">CustomTypes</a> document </td><td> goprotobuf type </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/gogoproto"> customname</a> (beta) </td><td> Field </td><td> string </td><td> Changes the generated fieldname. This is especially useful when generated methods conflict with fieldnames. </td><td> goprotobuf field name </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/gogoproto"> casttype</a> (beta) </td><td> Field </td><td> string </td><td> Changes the generated field type. It assumes that this type is castable to the original goprotobuf field type. It currently does not support maps, structs or enums. </td><td> goprotobuf field type </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/gogoproto"> castkey </a> (beta) </td><td> Field </td><td> string </td><td> Changes the generated fieldtype for a map key. All generated code assumes that this type is castable to the protocol buffer field type. Only supported on maps. </td><td> goprotobuf field type </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/gogoproto"> castvalue </a> (beta) </td><td> Field </td><td> string </td><td> Changes the generated fieldtype for a map value. All generated code assumes that this type is castable to the protocol buffer field type. Only supported on maps. </td><td> goprotobuf field type </td></tr>
|
||||
<tr><td>enum_customname (beta)</td><td> Enum </td><td> string </td><td>Sets the type name of an enum. If goproto_enum_prefix is enabled, this value will be used as a prefix when generating enum values.</td><td>goprotobuf enum type name. Helps with golint issues.</td></tr>
|
||||
<tr><td>enumdecl (beta)</td><td> Enum </td><td> bool </td><td> if false, type declaration of the enum is excluded from the generated output. Requires the marshaler and unmarshaler to be generated. </td><td> true </td></tr>
|
||||
<tr><td>enumvalue_customname (beta) </td><td> Enum Value </td><td> string </td><td>Changes the generated enum name. Helps with golint issues.</td><td>goprotobuf enum value name</td></tr>
|
||||
<tr><td><a href="https://github.com/gogo/protobuf/blob/master/test/types/types.proto">stdtime</a></td><td> Timestamp Field </td><td> bool </td><td>Changes the Well Known Timestamp Type to time.Time</td><td>Timestamp</td></tr>
|
||||
<tr><td><a href="https://github.com/gogo/protobuf/blob/master/test/types/types.proto">stdduration</a></td><td> Duration Field </td><td> bool </td><td>Changes the Well Known Duration Type to time.Duration</td><td>Duration</td></tr>
|
||||
</table>
|
||||
|
||||
`Warning about nullable: according to the Protocol Buffer specification, you should be able to tell whether a field is set or unset. With the option nullable=false this feature is lost, since your non-nullable fields will always be set.`
|
||||
|
||||
# Goprotobuf Compatibility
|
||||
|
||||
Gogoprotobuf is compatible with Goprotobuf, because it is compatible with protocol buffers (see the section on tests below).
|
||||
|
||||
Gogoprotobuf generates the same code as goprotobuf if no extensions are used.
|
||||
|
||||
The enumprefix, getters and stringer extensions can be used to remove some of the unnecessary code generated by goprotobuf.
|
||||
|
||||
<table>
|
||||
<tr><td><b>Name</b></td><td><b>Option</b></td><td><b>Type</b></td><td><b>Description</b></td><td><b>Default</b></td></tr>
|
||||
<tr><td> gogoproto_import </td><td> File </td><td> bool </td><td> if false, the generated code imports github.com/golang/protobuf/proto instead of github.com/gogo/protobuf/proto. </td><td> true </td></tr>
|
||||
<tr><td> goproto_enum_prefix </td><td> Enum </td><td> bool </td><td> if false, generates the enum constant names without the messagetype prefix </td><td> true </td></tr>
|
||||
<tr><td> goproto_getters </td><td> Message </td><td> bool </td><td> if false, the message is generated without get methods, this is useful when you would rather want to use face </td><td> true </td></tr>
|
||||
<tr><td> goproto_stringer </td><td> Message </td><td> bool </td><td> if false, the message is generated without the default string method, this is useful for rather using stringer </td><td> true </td></tr>
|
||||
<tr><td> goproto_enum_stringer (experimental) </td><td> Enum </td><td> bool </td><td> if false, the enum is generated without the default string method, this is useful for rather using enum_stringer </td><td> true </td></tr>
|
||||
<tr><td> goproto_extensions_map (beta) </td><td> Message </td><td> bool </td><td> if false, the extensions field is generated as type []byte instead of type map[int32]proto.Extension </td><td> true </td></tr>
|
||||
<tr><td> goproto_unrecognized (beta) </td><td> Message </td><td> bool </td><td>if false, XXX_unrecognized field is not generated. This is useful to reduce GC pressure at the cost of losing information about unrecognized fields. </td><td> true </td></tr>
|
||||
<tr><td> goproto_unkeyed (alpha) </td><td> Message </td><td> bool </td><td>if false, XXX_unkeyed field is not generated. </td><td> true </td></tr>
|
||||
<tr><td> goproto_sizecache (alpha) </td><td> Message </td><td> bool </td><td>if false, XXX_sizecache field is not generated. </td><td> true </td></tr>
|
||||
<tr><td> goproto_registration (beta) </td><td> File </td><td> bool </td><td>if true, the generated files will register all messages and types against both gogo/protobuf and golang/protobuf. This is necessary when using third-party packages which read registrations from golang/protobuf (such as the grpc-gateway). </td><td> false </td></tr>
|
||||
<tr><td> message_name </td><td> Message </td><td> bool </td><td>if true, a `XXX_MessageName()` method is generated that returns the message's name. This is useful for grpc-gateway compatibility.</td><td> false </td></tr>
|
||||
</table>
|
||||
|
||||
# Less Typing
|
||||
|
||||
The Protocol Buffer language is very parseable and extra code can be easily generated for structures.
|
||||
|
||||
Helper methods, functions and interfaces can be generated by triggering certain extensions like gostring.
|
||||
|
||||
<table>
|
||||
<tr><td><b>Name</b></td><td><b>Option</b></td><td><b>Type</b></td><td><b>Description</b></td><td><b>Default</b></td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/gostring">gostring</a></td><td> Message </td><td> bool </td><td> if true, a `GoString` method is generated. This returns a string representing valid go code to reproduce the current state of the struct. </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/union"> onlyone</a> </td><td> Message </td><td> bool </td><td> if true, all fields must be nullable and only one of the fields may be set, like a union. Two methods are generated: `GetValue() interface{}` and `SetValue(v interface{}) (set bool)`. These provide easier interaction with a union. </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/equal"> equal</a></td><td> Message </td><td> bool </td><td> if true, an Equal method is generated </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/compare"> compare</a></td><td> Message </td><td> bool </td><td> if true, a Compare method is generated. This is very useful for quickly implementing sort on a list of protobuf structs </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/equal"> verbose_equal</a> </td><td> Message </td><td> bool </td><td> if true, a verbose equal method is generated for the message. This returns an error which describes the exact element which is not equal to the exact element in the other struct. </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/stringer"> stringer</a> </td><td> Message </td><td> bool </td><td> if true, a String method is generated for the message. </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/face">face</a> </td><td> Message </td><td> bool </td><td> if true, a function will be generated which can convert a structure which satisfies an interface (face) to the specified structure. This interface contains getters for each of the fields in the struct. The specified struct is also generated with the getters. This allows it to satisfy its own face. </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/description"> description</a> (beta) </td><td> Message </td><td> bool </td><td> if true, a Description method is generated for the message. </td><td> false </td></tr>
|
||||
<tr><td> <a href="http://godoc.org/github.com/gogo/protobuf/plugin/populate"> populate</a> </td><td> Message </td><td> bool </td><td> if true, a `NewPopulated<MessageName>` function is generated. This is necessary for generated tests. </td><td> false </td></tr>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/enumstringer"> enum_stringer</a> (experimental) </td><td> Enum </td><td> bool </td><td> if true, a String method is generated for an Enum </td><td> false </td></tr>
|
||||
</table>
|
||||
|
||||
Issues with Compare include:
|
||||
* <a href="https://github.com/gogo/protobuf/issues/221">Oneof is not supported yet</a>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/230">Not all Well Known Types are supported yet</a>
|
||||
* <a href="https://github.com/gogo/protobuf/issues/231">Maps are not supported</a>
|
||||
|
||||
#Peace of Mind
|
||||
|
||||
Test and Benchmark generation is done with the following extensions:
|
||||
|
||||
<table>
|
||||
<tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/testgen">testgen</a> </td><td> Message </td><td> bool </td><td> if true, tests are generated for proto, json and prototext marshalling as well as for some of the other enabled plugins </td><td> false </td></tr>
|
||||
<tr><td> benchgen </td><td> Message </td><td> bool </td><td> if true, benchmarks are generated for proto, json and prototext marshalling as well as for some of the other enabled plugins </td><td> false </td></tr>
|
||||
</table>
|
||||
|
||||
# More Serialization Formats
|
||||
|
||||
Other serialization formats like xml and json typically use reflect to marshal and unmarshal structured data. Manipulating these structs into something other than the default Go requires editing tags. The following extensions provide ways of editing these tags for the generated protobuf structs.
|
||||
|
||||
<table>
|
||||
<tr><td><a href="https://github.com/gogo/protobuf/blob/master/test/tags/tags.proto">jsontag</a> (beta) </td><td> Field </td><td> string </td><td> if set, the json tag value between the double quotes is replaced with this string </td><td> fieldname </td></tr>
|
||||
<tr><td><a href="https://github.com/gogo/protobuf/blob/master/test/tags/tags.proto">moretags</a> (beta) </td><td> Field </td><td> string </td><td> if set, this string is appended to the tag string </td><td> empty </td></tr>
|
||||
</table>
|
||||
|
||||
<a href="https://groups.google.com/forum/#!topic/gogoprotobuf/xmFnqAS6MIc">Here is a longer explanation of jsontag and moretags</a>
|
||||
|
||||
# File Options
|
||||
|
||||
Each of the boolean message and enum extensions also have a file extension:
|
||||
|
||||
* `marshaler_all`
|
||||
* `sizer_all`
|
||||
* `protosizer_all`
|
||||
* `unmarshaler_all`
|
||||
* `unsafe_marshaler_all`
|
||||
* `unsafe_unmarshaler_all`
|
||||
* `stable_marshaler_all`
|
||||
* `goproto_enum_prefix_all`
|
||||
* `goproto_getters_all`
|
||||
* `goproto_stringer_all`
|
||||
* `goproto_enum_stringer_all`
|
||||
* `goproto_extensions_map_all`
|
||||
* `goproto_unrecognized_all`
|
||||
* `goproto_unkeyed_all`
|
||||
* `goproto_sizecache_all`
|
||||
* `gostring_all`
|
||||
* `onlyone_all`
|
||||
* `equal_all`
|
||||
* `compare_all`
|
||||
* `verbose_equal_all`
|
||||
* `stringer_all`
|
||||
* `enum_stringer_all`
|
||||
* `face_all`
|
||||
* `description_all`
|
||||
* `populate_all`
|
||||
* `testgen_all`
|
||||
* `benchgen_all`
|
||||
* `enumdecl_all`
|
||||
* `typedecl_all`
|
||||
* `messagename_all`
|
||||
|
||||
Each of these are the same as their Message Option counterparts, except they apply to all messages in the file. Their Message option counterparts can also be used to overwrite their effect.
|
||||
|
||||
# Tests
|
||||
|
||||
* The normal barrage of tests are run with: `make tests`
|
||||
* A few weird tests: `make testall`
|
||||
* Tests for compatibility with [golang/protobuf](https://github.com/golang/protobuf) are handled by a different project [harmonytests](https://github.com/gogo/harmonytests), since it requires goprotobuf.
|
||||
* Cross version tests are made with [Travis CI](https://travis-ci.org/gogo/protobuf).
|
||||
* GRPC Tests are also handled by a different project [grpctests](https://github.com/gogo/grpctests), since it depends on a lot of grpc libraries.
|
||||
* Thanks to [go-fuzz](https://github.com/dvyukov/go-fuzz/) we have proper [fuzztests](https://github.com/gogo/fuzztests).
|
||||
|
37
vendor/github.com/gogo/protobuf/gogoproto/Makefile
generated
vendored
Normal file
37
vendor/github.com/gogo/protobuf/gogoproto/Makefile
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
# 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.
|
||||
|
||||
regenerate:
|
||||
go install github.com/gogo/protobuf/protoc-gen-gogo
|
||||
protoc --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:../../../../ --proto_path=../../../../:../protobuf/:. *.proto
|
||||
|
||||
restore:
|
||||
cp gogo.pb.golden gogo.pb.go
|
||||
|
||||
preserve:
|
||||
cp gogo.pb.go gogo.pb.golden
|
169
vendor/github.com/gogo/protobuf/gogoproto/doc.go
generated
vendored
Normal file
169
vendor/github.com/gogo/protobuf/gogoproto/doc.go
generated
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
// 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 gogoproto provides extensions for protocol buffers to achieve:
|
||||
|
||||
- fast marshalling and unmarshalling.
|
||||
- peace of mind by optionally generating test and benchmark code.
|
||||
- more canonical Go structures.
|
||||
- less typing by optionally generating extra helper code.
|
||||
- goprotobuf compatibility
|
||||
|
||||
More Canonical Go Structures
|
||||
|
||||
A lot of time working with a goprotobuf struct will lead you to a place where you create another struct that is easier to work with and then have a function to copy the values between the two structs.
|
||||
You might also find that basic structs that started their life as part of an API need to be sent over the wire. With gob, you could just send it. With goprotobuf, you need to make a parallel struct.
|
||||
Gogoprotobuf tries to fix these problems with the nullable, embed, customtype and customname field extensions.
|
||||
|
||||
- nullable, if false, a field is generated without a pointer (see warning below).
|
||||
- embed, if true, the field is generated as an embedded field.
|
||||
- customtype, It works with the Marshal and Unmarshal methods, to allow you to have your own types in your struct, but marshal to bytes. For example, custom.Uuid or custom.Fixed128
|
||||
- customname (beta), Changes the generated fieldname. This is especially useful when generated methods conflict with fieldnames.
|
||||
- casttype (beta), Changes the generated fieldtype. All generated code assumes that this type is castable to the protocol buffer field type. It does not work for structs or enums.
|
||||
- castkey (beta), Changes the generated fieldtype for a map key. All generated code assumes that this type is castable to the protocol buffer field type. Only supported on maps.
|
||||
- castvalue (beta), Changes the generated fieldtype for a map value. All generated code assumes that this type is castable to the protocol buffer field type. Only supported on maps.
|
||||
|
||||
Warning about nullable: According to the Protocol Buffer specification, you should be able to tell whether a field is set or unset. With the option nullable=false this feature is lost, since your non-nullable fields will always be set. It can be seen as a layer on top of Protocol Buffers, where before and after marshalling all non-nullable fields are set and they cannot be unset.
|
||||
|
||||
Let us look at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/example.proto
|
||||
|
||||
for a quicker overview.
|
||||
|
||||
The following message:
|
||||
|
||||
package test;
|
||||
|
||||
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
||||
|
||||
message A {
|
||||
optional string Description = 1 [(gogoproto.nullable) = false];
|
||||
optional int64 Number = 2 [(gogoproto.nullable) = false];
|
||||
optional bytes Id = 3 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uuid", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
Will generate a go struct which looks a lot like this:
|
||||
|
||||
type A struct {
|
||||
Description string
|
||||
Number int64
|
||||
Id github_com_gogo_protobuf_test_custom.Uuid
|
||||
}
|
||||
|
||||
You will see there are no pointers, since all fields are non-nullable.
|
||||
You will also see a custom type which marshals to a string.
|
||||
Be warned it is your responsibility to test your custom types thoroughly.
|
||||
You should think of every possible empty and nil case for your marshaling, unmarshaling and size methods.
|
||||
|
||||
Next we will embed the message A in message B.
|
||||
|
||||
message B {
|
||||
optional A A = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
repeated bytes G = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
See below that A is embedded in B.
|
||||
|
||||
type B struct {
|
||||
A
|
||||
G []github_com_gogo_protobuf_test_custom.Uint128
|
||||
}
|
||||
|
||||
Also see the repeated custom type.
|
||||
|
||||
type Uint128 [2]uint64
|
||||
|
||||
Next we will create a custom name for one of our fields.
|
||||
|
||||
message C {
|
||||
optional int64 size = 1 [(gogoproto.customname) = "MySize"];
|
||||
}
|
||||
|
||||
See below that the field's name is MySize and not Size.
|
||||
|
||||
type C struct {
|
||||
MySize *int64
|
||||
}
|
||||
|
||||
The is useful when having a protocol buffer message with a field name which conflicts with a generated method.
|
||||
As an example, having a field name size and using the sizer plugin to generate a Size method will cause a go compiler error.
|
||||
Using customname you can fix this error without changing the field name.
|
||||
This is typically useful when working with a protocol buffer that was designed before these methods and/or the go language were avialable.
|
||||
|
||||
Gogoprotobuf also has some more subtle changes, these could be changed back:
|
||||
|
||||
- the generated package name for imports do not have the extra /filename.pb,
|
||||
but are actually the imports specified in the .proto file.
|
||||
|
||||
Gogoprotobuf also has lost some features which should be brought back with time:
|
||||
|
||||
- Marshalling and unmarshalling with reflect and without the unsafe package,
|
||||
this requires work in pointer_reflect.go
|
||||
|
||||
Why does nullable break protocol buffer specifications:
|
||||
|
||||
The protocol buffer specification states, somewhere, that you should be able to tell whether a
|
||||
field is set or unset. With the option nullable=false this feature is lost,
|
||||
since your non-nullable fields will always be set. It can be seen as a layer on top of
|
||||
protocol buffers, where before and after marshalling all non-nullable fields are set
|
||||
and they cannot be unset.
|
||||
|
||||
Goprotobuf Compatibility:
|
||||
|
||||
Gogoprotobuf is compatible with Goprotobuf, because it is compatible with protocol buffers.
|
||||
Gogoprotobuf generates the same code as goprotobuf if no extensions are used.
|
||||
The enumprefix, getters and stringer extensions can be used to remove some of the unnecessary code generated by goprotobuf:
|
||||
|
||||
- gogoproto_import, if false, the generated code imports github.com/golang/protobuf/proto instead of github.com/gogo/protobuf/proto.
|
||||
- goproto_enum_prefix, if false, generates the enum constant names without the messagetype prefix
|
||||
- goproto_enum_stringer (experimental), if false, the enum is generated without the default string method, this is useful for rather using enum_stringer, or allowing you to write your own string method.
|
||||
- goproto_getters, if false, the message is generated without get methods, this is useful when you would rather want to use face
|
||||
- goproto_stringer, if false, the message is generated without the default string method, this is useful for rather using stringer, or allowing you to write your own string method.
|
||||
- goproto_extensions_map (beta), if false, the extensions field is generated as type []byte instead of type map[int32]proto.Extension
|
||||
- goproto_unrecognized (beta), if false, XXX_unrecognized field is not generated. This is useful in conjunction with gogoproto.nullable=false, to generate structures completely devoid of pointers and reduce GC pressure at the cost of losing information about unrecognized fields.
|
||||
- goproto_registration (beta), if true, the generated files will register all messages and types against both gogo/protobuf and golang/protobuf. This is necessary when using third-party packages which read registrations from golang/protobuf (such as the grpc-gateway).
|
||||
|
||||
Less Typing and Peace of Mind is explained in their specific plugin folders godoc:
|
||||
|
||||
- github.com/gogo/protobuf/plugin/<extension_name>
|
||||
|
||||
If you do not use any of these extension the code that is generated
|
||||
will be the same as if goprotobuf has generated it.
|
||||
|
||||
The most complete way to see examples is to look at
|
||||
|
||||
github.com/gogo/protobuf/test/thetest.proto
|
||||
|
||||
Gogoprototest is a seperate project,
|
||||
because we want to keep gogoprotobuf independent of goprotobuf,
|
||||
but we still want to test it thoroughly.
|
||||
|
||||
*/
|
||||
package gogoproto
|
872
vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go
generated
vendored
Normal file
872
vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go
generated
vendored
Normal file
@ -0,0 +1,872 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: gogo.proto
|
||||
|
||||
package gogoproto // import "github.com/gogo/protobuf/gogoproto"
|
||||
|
||||
import proto "github.com/gogo/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
|
||||
// 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
|
||||
|
||||
var E_GoprotoEnumPrefix = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 62001,
|
||||
Name: "gogoproto.goproto_enum_prefix",
|
||||
Tag: "varint,62001,opt,name=goproto_enum_prefix,json=goprotoEnumPrefix",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoEnumStringer = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 62021,
|
||||
Name: "gogoproto.goproto_enum_stringer",
|
||||
Tag: "varint,62021,opt,name=goproto_enum_stringer,json=goprotoEnumStringer",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_EnumStringer = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 62022,
|
||||
Name: "gogoproto.enum_stringer",
|
||||
Tag: "varint,62022,opt,name=enum_stringer,json=enumStringer",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_EnumCustomname = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 62023,
|
||||
Name: "gogoproto.enum_customname",
|
||||
Tag: "bytes,62023,opt,name=enum_customname,json=enumCustomname",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Enumdecl = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.EnumOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 62024,
|
||||
Name: "gogoproto.enumdecl",
|
||||
Tag: "varint,62024,opt,name=enumdecl",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_EnumvalueCustomname = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 66001,
|
||||
Name: "gogoproto.enumvalue_customname",
|
||||
Tag: "bytes,66001,opt,name=enumvalue_customname,json=enumvalueCustomname",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoGettersAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63001,
|
||||
Name: "gogoproto.goproto_getters_all",
|
||||
Tag: "varint,63001,opt,name=goproto_getters_all,json=goprotoGettersAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63002,
|
||||
Name: "gogoproto.goproto_enum_prefix_all",
|
||||
Tag: "varint,63002,opt,name=goproto_enum_prefix_all,json=goprotoEnumPrefixAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoStringerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63003,
|
||||
Name: "gogoproto.goproto_stringer_all",
|
||||
Tag: "varint,63003,opt,name=goproto_stringer_all,json=goprotoStringerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_VerboseEqualAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63004,
|
||||
Name: "gogoproto.verbose_equal_all",
|
||||
Tag: "varint,63004,opt,name=verbose_equal_all,json=verboseEqualAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_FaceAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63005,
|
||||
Name: "gogoproto.face_all",
|
||||
Tag: "varint,63005,opt,name=face_all,json=faceAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GostringAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63006,
|
||||
Name: "gogoproto.gostring_all",
|
||||
Tag: "varint,63006,opt,name=gostring_all,json=gostringAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_PopulateAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63007,
|
||||
Name: "gogoproto.populate_all",
|
||||
Tag: "varint,63007,opt,name=populate_all,json=populateAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_StringerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63008,
|
||||
Name: "gogoproto.stringer_all",
|
||||
Tag: "varint,63008,opt,name=stringer_all,json=stringerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_OnlyoneAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63009,
|
||||
Name: "gogoproto.onlyone_all",
|
||||
Tag: "varint,63009,opt,name=onlyone_all,json=onlyoneAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_EqualAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63013,
|
||||
Name: "gogoproto.equal_all",
|
||||
Tag: "varint,63013,opt,name=equal_all,json=equalAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_DescriptionAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63014,
|
||||
Name: "gogoproto.description_all",
|
||||
Tag: "varint,63014,opt,name=description_all,json=descriptionAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_TestgenAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63015,
|
||||
Name: "gogoproto.testgen_all",
|
||||
Tag: "varint,63015,opt,name=testgen_all,json=testgenAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_BenchgenAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63016,
|
||||
Name: "gogoproto.benchgen_all",
|
||||
Tag: "varint,63016,opt,name=benchgen_all,json=benchgenAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_MarshalerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63017,
|
||||
Name: "gogoproto.marshaler_all",
|
||||
Tag: "varint,63017,opt,name=marshaler_all,json=marshalerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_UnmarshalerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63018,
|
||||
Name: "gogoproto.unmarshaler_all",
|
||||
Tag: "varint,63018,opt,name=unmarshaler_all,json=unmarshalerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_StableMarshalerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63019,
|
||||
Name: "gogoproto.stable_marshaler_all",
|
||||
Tag: "varint,63019,opt,name=stable_marshaler_all,json=stableMarshalerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_SizerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63020,
|
||||
Name: "gogoproto.sizer_all",
|
||||
Tag: "varint,63020,opt,name=sizer_all,json=sizerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63021,
|
||||
Name: "gogoproto.goproto_enum_stringer_all",
|
||||
Tag: "varint,63021,opt,name=goproto_enum_stringer_all,json=goprotoEnumStringerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_EnumStringerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63022,
|
||||
Name: "gogoproto.enum_stringer_all",
|
||||
Tag: "varint,63022,opt,name=enum_stringer_all,json=enumStringerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_UnsafeMarshalerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63023,
|
||||
Name: "gogoproto.unsafe_marshaler_all",
|
||||
Tag: "varint,63023,opt,name=unsafe_marshaler_all,json=unsafeMarshalerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63024,
|
||||
Name: "gogoproto.unsafe_unmarshaler_all",
|
||||
Tag: "varint,63024,opt,name=unsafe_unmarshaler_all,json=unsafeUnmarshalerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63025,
|
||||
Name: "gogoproto.goproto_extensions_map_all",
|
||||
Tag: "varint,63025,opt,name=goproto_extensions_map_all,json=goprotoExtensionsMapAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63026,
|
||||
Name: "gogoproto.goproto_unrecognized_all",
|
||||
Tag: "varint,63026,opt,name=goproto_unrecognized_all,json=goprotoUnrecognizedAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GogoprotoImport = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63027,
|
||||
Name: "gogoproto.gogoproto_import",
|
||||
Tag: "varint,63027,opt,name=gogoproto_import,json=gogoprotoImport",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_ProtosizerAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63028,
|
||||
Name: "gogoproto.protosizer_all",
|
||||
Tag: "varint,63028,opt,name=protosizer_all,json=protosizerAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_CompareAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63029,
|
||||
Name: "gogoproto.compare_all",
|
||||
Tag: "varint,63029,opt,name=compare_all,json=compareAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_TypedeclAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63030,
|
||||
Name: "gogoproto.typedecl_all",
|
||||
Tag: "varint,63030,opt,name=typedecl_all,json=typedeclAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_EnumdeclAll = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63031,
|
||||
Name: "gogoproto.enumdecl_all",
|
||||
Tag: "varint,63031,opt,name=enumdecl_all,json=enumdeclAll",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoRegistration = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FileOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 63032,
|
||||
Name: "gogoproto.goproto_registration",
|
||||
Tag: "varint,63032,opt,name=goproto_registration,json=goprotoRegistration",
|
||||
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{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64001,
|
||||
Name: "gogoproto.goproto_getters",
|
||||
Tag: "varint,64001,opt,name=goproto_getters,json=goprotoGetters",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoStringer = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64003,
|
||||
Name: "gogoproto.goproto_stringer",
|
||||
Tag: "varint,64003,opt,name=goproto_stringer,json=goprotoStringer",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_VerboseEqual = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64004,
|
||||
Name: "gogoproto.verbose_equal",
|
||||
Tag: "varint,64004,opt,name=verbose_equal,json=verboseEqual",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Face = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64005,
|
||||
Name: "gogoproto.face",
|
||||
Tag: "varint,64005,opt,name=face",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Gostring = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64006,
|
||||
Name: "gogoproto.gostring",
|
||||
Tag: "varint,64006,opt,name=gostring",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Populate = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64007,
|
||||
Name: "gogoproto.populate",
|
||||
Tag: "varint,64007,opt,name=populate",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Stringer = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 67008,
|
||||
Name: "gogoproto.stringer",
|
||||
Tag: "varint,67008,opt,name=stringer",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Onlyone = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64009,
|
||||
Name: "gogoproto.onlyone",
|
||||
Tag: "varint,64009,opt,name=onlyone",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Equal = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64013,
|
||||
Name: "gogoproto.equal",
|
||||
Tag: "varint,64013,opt,name=equal",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Description = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64014,
|
||||
Name: "gogoproto.description",
|
||||
Tag: "varint,64014,opt,name=description",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Testgen = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64015,
|
||||
Name: "gogoproto.testgen",
|
||||
Tag: "varint,64015,opt,name=testgen",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Benchgen = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64016,
|
||||
Name: "gogoproto.benchgen",
|
||||
Tag: "varint,64016,opt,name=benchgen",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Marshaler = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64017,
|
||||
Name: "gogoproto.marshaler",
|
||||
Tag: "varint,64017,opt,name=marshaler",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Unmarshaler = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64018,
|
||||
Name: "gogoproto.unmarshaler",
|
||||
Tag: "varint,64018,opt,name=unmarshaler",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_StableMarshaler = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64019,
|
||||
Name: "gogoproto.stable_marshaler",
|
||||
Tag: "varint,64019,opt,name=stable_marshaler,json=stableMarshaler",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Sizer = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64020,
|
||||
Name: "gogoproto.sizer",
|
||||
Tag: "varint,64020,opt,name=sizer",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_UnsafeMarshaler = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64023,
|
||||
Name: "gogoproto.unsafe_marshaler",
|
||||
Tag: "varint,64023,opt,name=unsafe_marshaler,json=unsafeMarshaler",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_UnsafeUnmarshaler = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64024,
|
||||
Name: "gogoproto.unsafe_unmarshaler",
|
||||
Tag: "varint,64024,opt,name=unsafe_unmarshaler,json=unsafeUnmarshaler",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoExtensionsMap = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64025,
|
||||
Name: "gogoproto.goproto_extensions_map",
|
||||
Tag: "varint,64025,opt,name=goproto_extensions_map,json=goprotoExtensionsMap",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_GoprotoUnrecognized = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64026,
|
||||
Name: "gogoproto.goproto_unrecognized",
|
||||
Tag: "varint,64026,opt,name=goproto_unrecognized,json=goprotoUnrecognized",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Protosizer = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64028,
|
||||
Name: "gogoproto.protosizer",
|
||||
Tag: "varint,64028,opt,name=protosizer",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Compare = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64029,
|
||||
Name: "gogoproto.compare",
|
||||
Tag: "varint,64029,opt,name=compare",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Typedecl = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.MessageOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 64030,
|
||||
Name: "gogoproto.typedecl",
|
||||
Tag: "varint,64030,opt,name=typedecl",
|
||||
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{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 65001,
|
||||
Name: "gogoproto.nullable",
|
||||
Tag: "varint,65001,opt,name=nullable",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Embed = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 65002,
|
||||
Name: "gogoproto.embed",
|
||||
Tag: "varint,65002,opt,name=embed",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Customtype = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 65003,
|
||||
Name: "gogoproto.customtype",
|
||||
Tag: "bytes,65003,opt,name=customtype",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Customname = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 65004,
|
||||
Name: "gogoproto.customname",
|
||||
Tag: "bytes,65004,opt,name=customname",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Jsontag = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 65005,
|
||||
Name: "gogoproto.jsontag",
|
||||
Tag: "bytes,65005,opt,name=jsontag",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Moretags = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 65006,
|
||||
Name: "gogoproto.moretags",
|
||||
Tag: "bytes,65006,opt,name=moretags",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Casttype = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 65007,
|
||||
Name: "gogoproto.casttype",
|
||||
Tag: "bytes,65007,opt,name=casttype",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Castkey = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 65008,
|
||||
Name: "gogoproto.castkey",
|
||||
Tag: "bytes,65008,opt,name=castkey",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Castvalue = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 65009,
|
||||
Name: "gogoproto.castvalue",
|
||||
Tag: "bytes,65009,opt,name=castvalue",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Stdtime = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 65010,
|
||||
Name: "gogoproto.stdtime",
|
||||
Tag: "varint,65010,opt,name=stdtime",
|
||||
Filename: "gogo.proto",
|
||||
}
|
||||
|
||||
var E_Stdduration = &proto.ExtensionDesc{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 65011,
|
||||
Name: "gogoproto.stdduration",
|
||||
Tag: "varint,65011,opt,name=stdduration",
|
||||
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() {
|
||||
proto.RegisterExtension(E_GoprotoEnumPrefix)
|
||||
proto.RegisterExtension(E_GoprotoEnumStringer)
|
||||
proto.RegisterExtension(E_EnumStringer)
|
||||
proto.RegisterExtension(E_EnumCustomname)
|
||||
proto.RegisterExtension(E_Enumdecl)
|
||||
proto.RegisterExtension(E_EnumvalueCustomname)
|
||||
proto.RegisterExtension(E_GoprotoGettersAll)
|
||||
proto.RegisterExtension(E_GoprotoEnumPrefixAll)
|
||||
proto.RegisterExtension(E_GoprotoStringerAll)
|
||||
proto.RegisterExtension(E_VerboseEqualAll)
|
||||
proto.RegisterExtension(E_FaceAll)
|
||||
proto.RegisterExtension(E_GostringAll)
|
||||
proto.RegisterExtension(E_PopulateAll)
|
||||
proto.RegisterExtension(E_StringerAll)
|
||||
proto.RegisterExtension(E_OnlyoneAll)
|
||||
proto.RegisterExtension(E_EqualAll)
|
||||
proto.RegisterExtension(E_DescriptionAll)
|
||||
proto.RegisterExtension(E_TestgenAll)
|
||||
proto.RegisterExtension(E_BenchgenAll)
|
||||
proto.RegisterExtension(E_MarshalerAll)
|
||||
proto.RegisterExtension(E_UnmarshalerAll)
|
||||
proto.RegisterExtension(E_StableMarshalerAll)
|
||||
proto.RegisterExtension(E_SizerAll)
|
||||
proto.RegisterExtension(E_GoprotoEnumStringerAll)
|
||||
proto.RegisterExtension(E_EnumStringerAll)
|
||||
proto.RegisterExtension(E_UnsafeMarshalerAll)
|
||||
proto.RegisterExtension(E_UnsafeUnmarshalerAll)
|
||||
proto.RegisterExtension(E_GoprotoExtensionsMapAll)
|
||||
proto.RegisterExtension(E_GoprotoUnrecognizedAll)
|
||||
proto.RegisterExtension(E_GogoprotoImport)
|
||||
proto.RegisterExtension(E_ProtosizerAll)
|
||||
proto.RegisterExtension(E_CompareAll)
|
||||
proto.RegisterExtension(E_TypedeclAll)
|
||||
proto.RegisterExtension(E_EnumdeclAll)
|
||||
proto.RegisterExtension(E_GoprotoRegistration)
|
||||
proto.RegisterExtension(E_MessagenameAll)
|
||||
proto.RegisterExtension(E_GoprotoSizecacheAll)
|
||||
proto.RegisterExtension(E_GoprotoUnkeyedAll)
|
||||
proto.RegisterExtension(E_GoprotoGetters)
|
||||
proto.RegisterExtension(E_GoprotoStringer)
|
||||
proto.RegisterExtension(E_VerboseEqual)
|
||||
proto.RegisterExtension(E_Face)
|
||||
proto.RegisterExtension(E_Gostring)
|
||||
proto.RegisterExtension(E_Populate)
|
||||
proto.RegisterExtension(E_Stringer)
|
||||
proto.RegisterExtension(E_Onlyone)
|
||||
proto.RegisterExtension(E_Equal)
|
||||
proto.RegisterExtension(E_Description)
|
||||
proto.RegisterExtension(E_Testgen)
|
||||
proto.RegisterExtension(E_Benchgen)
|
||||
proto.RegisterExtension(E_Marshaler)
|
||||
proto.RegisterExtension(E_Unmarshaler)
|
||||
proto.RegisterExtension(E_StableMarshaler)
|
||||
proto.RegisterExtension(E_Sizer)
|
||||
proto.RegisterExtension(E_UnsafeMarshaler)
|
||||
proto.RegisterExtension(E_UnsafeUnmarshaler)
|
||||
proto.RegisterExtension(E_GoprotoExtensionsMap)
|
||||
proto.RegisterExtension(E_GoprotoUnrecognized)
|
||||
proto.RegisterExtension(E_Protosizer)
|
||||
proto.RegisterExtension(E_Compare)
|
||||
proto.RegisterExtension(E_Typedecl)
|
||||
proto.RegisterExtension(E_Messagename)
|
||||
proto.RegisterExtension(E_GoprotoSizecache)
|
||||
proto.RegisterExtension(E_GoprotoUnkeyed)
|
||||
proto.RegisterExtension(E_Nullable)
|
||||
proto.RegisterExtension(E_Embed)
|
||||
proto.RegisterExtension(E_Customtype)
|
||||
proto.RegisterExtension(E_Customname)
|
||||
proto.RegisterExtension(E_Jsontag)
|
||||
proto.RegisterExtension(E_Moretags)
|
||||
proto.RegisterExtension(E_Casttype)
|
||||
proto.RegisterExtension(E_Castkey)
|
||||
proto.RegisterExtension(E_Castvalue)
|
||||
proto.RegisterExtension(E_Stdtime)
|
||||
proto.RegisterExtension(E_Stdduration)
|
||||
proto.RegisterExtension(E_Wktpointer)
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("gogo.proto", fileDescriptor_gogo_b95f77e237336c7c) }
|
||||
|
||||
var fileDescriptor_gogo_b95f77e237336c7c = []byte{
|
||||
// 1328 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0x49, 0x6f, 0x1c, 0x45,
|
||||
0x14, 0x80, 0x85, 0x48, 0x64, 0x4f, 0x79, 0x8b, 0xc7, 0xc6, 0x84, 0x08, 0x44, 0xe0, 0xc4, 0xc9,
|
||||
0x3e, 0x45, 0x28, 0x65, 0x45, 0x96, 0x63, 0x39, 0x56, 0x10, 0x0e, 0xc6, 0x89, 0xc3, 0x76, 0x18,
|
||||
0xf5, 0xf4, 0x94, 0xdb, 0x8d, 0xbb, 0xbb, 0x9a, 0xee, 0xea, 0x10, 0xe7, 0x86, 0xc2, 0x22, 0x84,
|
||||
0xd8, 0x91, 0x20, 0x21, 0x09, 0x04, 0xc4, 0xbe, 0x86, 0x7d, 0xb9, 0x70, 0x61, 0xb9, 0xf2, 0x1f,
|
||||
0xb8, 0x00, 0x66, 0xf7, 0xcd, 0x17, 0xf4, 0xba, 0xdf, 0xeb, 0xa9, 0x69, 0x8f, 0x54, 0x35, 0xb7,
|
||||
0xf6, 0xb8, 0xbe, 0x6f, 0xaa, 0xdf, 0xeb, 0x7a, 0xef, 0x4d, 0x33, 0xe6, 0x49, 0x4f, 0x4e, 0xc6,
|
||||
0x89, 0x54, 0xb2, 0x5e, 0x83, 0xeb, 0xfc, 0x72, 0xdf, 0x7e, 0x4f, 0x4a, 0x2f, 0x10, 0x53, 0xf9,
|
||||
0x5f, 0xcd, 0x6c, 0x75, 0xaa, 0x25, 0x52, 0x37, 0xf1, 0x63, 0x25, 0x93, 0x62, 0x31, 0x3f, 0xc6,
|
||||
0xc6, 0x70, 0x71, 0x43, 0x44, 0x59, 0xd8, 0x88, 0x13, 0xb1, 0xea, 0x9f, 0xae, 0x5f, 0x3f, 0x59,
|
||||
0x90, 0x93, 0x44, 0x4e, 0xce, 0x47, 0x59, 0x78, 0x47, 0xac, 0x7c, 0x19, 0xa5, 0x7b, 0xaf, 0xfc,
|
||||
0x72, 0xf5, 0xfe, 0xab, 0x6e, 0xe9, 0x5f, 0x1e, 0x45, 0x14, 0xfe, 0xb7, 0x94, 0x83, 0x7c, 0x99,
|
||||
0x5d, 0xd3, 0xe1, 0x4b, 0x55, 0xe2, 0x47, 0x9e, 0x48, 0x0c, 0xc6, 0xef, 0xd1, 0x38, 0xa6, 0x19,
|
||||
0x8f, 0x23, 0xca, 0xe7, 0xd8, 0x50, 0x2f, 0xae, 0x1f, 0xd0, 0x35, 0x28, 0x74, 0xc9, 0x02, 0x1b,
|
||||
0xc9, 0x25, 0x6e, 0x96, 0x2a, 0x19, 0x46, 0x4e, 0x28, 0x0c, 0x9a, 0x1f, 0x73, 0x4d, 0x6d, 0x79,
|
||||
0x18, 0xb0, 0xb9, 0x92, 0xe2, 0x9c, 0xf5, 0xc3, 0x27, 0x2d, 0xe1, 0x06, 0x06, 0xc3, 0x4f, 0xb8,
|
||||
0x91, 0x72, 0x3d, 0x3f, 0xc9, 0xc6, 0xe1, 0xfa, 0x94, 0x13, 0x64, 0x42, 0xdf, 0xc9, 0x4d, 0x5d,
|
||||
0x3d, 0x27, 0x61, 0x19, 0xc9, 0x7e, 0x3e, 0xbb, 0x2b, 0xdf, 0xce, 0x58, 0x29, 0xd0, 0xf6, 0xa4,
|
||||
0x65, 0xd1, 0x13, 0x4a, 0x89, 0x24, 0x6d, 0x38, 0x41, 0xb7, 0xed, 0x1d, 0xf1, 0x83, 0xd2, 0x78,
|
||||
0x6e, 0xb3, 0x33, 0x8b, 0x0b, 0x05, 0x39, 0x1b, 0x04, 0x7c, 0x85, 0x5d, 0xdb, 0xe5, 0xa9, 0xb0,
|
||||
0x70, 0x9e, 0x47, 0xe7, 0xf8, 0x8e, 0x27, 0x03, 0xb4, 0x4b, 0x8c, 0x3e, 0x2f, 0x73, 0x69, 0xe1,
|
||||
0x7c, 0x19, 0x9d, 0x75, 0x64, 0x29, 0xa5, 0x60, 0xbc, 0x8d, 0x8d, 0x9e, 0x12, 0x49, 0x53, 0xa6,
|
||||
0xa2, 0x21, 0x1e, 0xc8, 0x9c, 0xc0, 0x42, 0x77, 0x01, 0x75, 0x23, 0x08, 0xce, 0x03, 0x07, 0xae,
|
||||
0x83, 0xac, 0x7f, 0xd5, 0x71, 0x85, 0x85, 0xe2, 0x22, 0x2a, 0xfa, 0x60, 0x3d, 0xa0, 0xb3, 0x6c,
|
||||
0xd0, 0x93, 0xc5, 0x2d, 0x59, 0xe0, 0x97, 0x10, 0x1f, 0x20, 0x06, 0x15, 0xb1, 0x8c, 0xb3, 0xc0,
|
||||
0x51, 0x36, 0x3b, 0x78, 0x85, 0x14, 0xc4, 0xa0, 0xa2, 0x87, 0xb0, 0xbe, 0x4a, 0x8a, 0x54, 0x8b,
|
||||
0xe7, 0x0c, 0x1b, 0x90, 0x51, 0xb0, 0x21, 0x23, 0x9b, 0x4d, 0x5c, 0x46, 0x03, 0x43, 0x04, 0x04,
|
||||
0xd3, 0xac, 0x66, 0x9b, 0x88, 0x37, 0x36, 0xe9, 0x78, 0x50, 0x06, 0x16, 0xd8, 0x08, 0x15, 0x28,
|
||||
0x5f, 0x46, 0x16, 0x8a, 0x37, 0x51, 0x31, 0xac, 0x61, 0x78, 0x1b, 0x4a, 0xa4, 0xca, 0x13, 0x36,
|
||||
0x92, 0xb7, 0xe8, 0x36, 0x10, 0xc1, 0x50, 0x36, 0x45, 0xe4, 0xae, 0xd9, 0x19, 0xde, 0xa6, 0x50,
|
||||
0x12, 0x03, 0x8a, 0x39, 0x36, 0x14, 0x3a, 0x49, 0xba, 0xe6, 0x04, 0x56, 0xe9, 0x78, 0x07, 0x1d,
|
||||
0x83, 0x25, 0x84, 0x11, 0xc9, 0xa2, 0x5e, 0x34, 0xef, 0x52, 0x44, 0x34, 0x0c, 0x8f, 0x5e, 0xaa,
|
||||
0x9c, 0x66, 0x20, 0x1a, 0xbd, 0xd8, 0xde, 0xa3, 0xa3, 0x57, 0xb0, 0x8b, 0xba, 0x71, 0x9a, 0xd5,
|
||||
0x52, 0xff, 0x8c, 0x95, 0xe6, 0x7d, 0xca, 0x74, 0x0e, 0x00, 0x7c, 0x0f, 0xbb, 0xae, 0x6b, 0x9b,
|
||||
0xb0, 0x90, 0x7d, 0x80, 0xb2, 0x89, 0x2e, 0xad, 0x02, 0x4b, 0x42, 0xaf, 0xca, 0x0f, 0xa9, 0x24,
|
||||
0x88, 0x8a, 0x6b, 0x89, 0x8d, 0x67, 0x51, 0xea, 0xac, 0xf6, 0x16, 0xb5, 0x8f, 0x28, 0x6a, 0x05,
|
||||
0xdb, 0x11, 0xb5, 0x13, 0x6c, 0x02, 0x8d, 0xbd, 0xe5, 0xf5, 0x63, 0x2a, 0xac, 0x05, 0xbd, 0xd2,
|
||||
0x99, 0xdd, 0xfb, 0xd8, 0xbe, 0x32, 0x9c, 0xa7, 0x95, 0x88, 0x52, 0x60, 0x1a, 0xa1, 0x13, 0x5b,
|
||||
0x98, 0xaf, 0xa0, 0x99, 0x2a, 0xfe, 0x7c, 0x29, 0x58, 0x74, 0x62, 0x90, 0xdf, 0xcd, 0xf6, 0x92,
|
||||
0x3c, 0x8b, 0x12, 0xe1, 0x4a, 0x2f, 0xf2, 0xcf, 0x88, 0x96, 0x85, 0xfa, 0x93, 0x4a, 0xaa, 0x56,
|
||||
0x34, 0x1c, 0xcc, 0x47, 0xd9, 0x9e, 0x72, 0x56, 0x69, 0xf8, 0x61, 0x2c, 0x13, 0x65, 0x30, 0x7e,
|
||||
0x4a, 0x99, 0x2a, 0xb9, 0xa3, 0x39, 0xc6, 0xe7, 0xd9, 0x70, 0xfe, 0xa7, 0xed, 0x23, 0xf9, 0x19,
|
||||
0x8a, 0x86, 0xda, 0x14, 0x16, 0x0e, 0x57, 0x86, 0xb1, 0x93, 0xd8, 0xd4, 0xbf, 0xcf, 0xa9, 0x70,
|
||||
0x20, 0x82, 0x85, 0x43, 0x6d, 0xc4, 0x02, 0xba, 0xbd, 0x85, 0xe1, 0x0b, 0x2a, 0x1c, 0xc4, 0xa0,
|
||||
0x82, 0x06, 0x06, 0x0b, 0xc5, 0x97, 0xa4, 0x20, 0x06, 0x14, 0x77, 0xb6, 0x1b, 0x6d, 0x22, 0x3c,
|
||||
0x3f, 0x55, 0x89, 0x03, 0xab, 0x0d, 0xaa, 0xaf, 0x36, 0x3b, 0x87, 0xb0, 0x65, 0x0d, 0x85, 0x4a,
|
||||
0x14, 0x8a, 0x34, 0x75, 0x3c, 0x01, 0x13, 0x87, 0xc5, 0xc6, 0xbe, 0xa6, 0x4a, 0xa4, 0x61, 0xb0,
|
||||
0x37, 0x6d, 0x42, 0x84, 0xb0, 0xbb, 0x8e, 0xbb, 0x66, 0xa3, 0xfb, 0xa6, 0xb2, 0xb9, 0xe3, 0xc4,
|
||||
0x82, 0x53, 0x9b, 0x7f, 0xb2, 0x68, 0x5d, 0x6c, 0x58, 0x3d, 0x9d, 0xdf, 0x56, 0xe6, 0x9f, 0x95,
|
||||
0x82, 0x2c, 0x6a, 0xc8, 0x48, 0x65, 0x9e, 0xaa, 0xdf, 0xb8, 0xc3, 0xb5, 0x58, 0xdc, 0x17, 0xe9,
|
||||
0x1e, 0xda, 0xc2, 0xfb, 0xed, 0x1c, 0xa7, 0xf8, 0xed, 0xf0, 0x90, 0x77, 0x0e, 0x3d, 0x66, 0xd9,
|
||||
0xd9, 0xad, 0xf2, 0x39, 0xef, 0x98, 0x79, 0xf8, 0x11, 0x36, 0xd4, 0x31, 0xf0, 0x98, 0x55, 0x0f,
|
||||
0xa3, 0x6a, 0x50, 0x9f, 0x77, 0xf8, 0x01, 0xb6, 0x0b, 0x86, 0x17, 0x33, 0xfe, 0x08, 0xe2, 0xf9,
|
||||
0x72, 0x7e, 0x88, 0xf5, 0xd3, 0xd0, 0x62, 0x46, 0x1f, 0x45, 0xb4, 0x44, 0x00, 0xa7, 0x81, 0xc5,
|
||||
0x8c, 0x3f, 0x46, 0x38, 0x21, 0x80, 0xdb, 0x87, 0xf0, 0xbb, 0x27, 0x76, 0x61, 0xd3, 0xa1, 0xd8,
|
||||
0x4d, 0xb3, 0x3e, 0x9c, 0x54, 0xcc, 0xf4, 0xe3, 0xf8, 0xe5, 0x44, 0xf0, 0x5b, 0xd9, 0x6e, 0xcb,
|
||||
0x80, 0x3f, 0x89, 0x68, 0xb1, 0x9e, 0xcf, 0xb1, 0x01, 0x6d, 0x3a, 0x31, 0xe3, 0x4f, 0x21, 0xae,
|
||||
0x53, 0xb0, 0x75, 0x9c, 0x4e, 0xcc, 0x82, 0xa7, 0x69, 0xeb, 0x48, 0x40, 0xd8, 0x68, 0x30, 0x31,
|
||||
0xd3, 0xcf, 0x50, 0xd4, 0x09, 0xe1, 0x33, 0xac, 0x56, 0x36, 0x1b, 0x33, 0xff, 0x2c, 0xf2, 0x6d,
|
||||
0x06, 0x22, 0xa0, 0x35, 0x3b, 0xb3, 0xe2, 0x39, 0x8a, 0x80, 0x46, 0xc1, 0x31, 0xaa, 0x0e, 0x30,
|
||||
0x66, 0xd3, 0xf3, 0x74, 0x8c, 0x2a, 0xf3, 0x0b, 0x64, 0x33, 0xaf, 0xf9, 0x66, 0xc5, 0x0b, 0x94,
|
||||
0xcd, 0x7c, 0x3d, 0x6c, 0xa3, 0x3a, 0x11, 0x98, 0x1d, 0x2f, 0xd2, 0x36, 0x2a, 0x03, 0x01, 0x5f,
|
||||
0x62, 0xf5, 0x9d, 0xd3, 0x80, 0xd9, 0xf7, 0x12, 0xfa, 0x46, 0x77, 0x0c, 0x03, 0xfc, 0x2e, 0x36,
|
||||
0xd1, 0x7d, 0x12, 0x30, 0x5b, 0xcf, 0x6d, 0x55, 0x7e, 0xbb, 0xe9, 0x83, 0x00, 0x3f, 0xd1, 0x6e,
|
||||
0x29, 0xfa, 0x14, 0x60, 0xd6, 0x9e, 0xdf, 0xea, 0x2c, 0xdc, 0xfa, 0x10, 0xc0, 0x67, 0x19, 0x6b,
|
||||
0x37, 0x60, 0xb3, 0xeb, 0x02, 0xba, 0x34, 0x08, 0x8e, 0x06, 0xf6, 0x5f, 0x33, 0x7f, 0x91, 0x8e,
|
||||
0x06, 0x12, 0x70, 0x34, 0xa8, 0xf5, 0x9a, 0xe9, 0x4b, 0x74, 0x34, 0x08, 0x81, 0x27, 0x5b, 0xeb,
|
||||
0x6e, 0x66, 0xc3, 0x65, 0x7a, 0xb2, 0x35, 0x8a, 0x1f, 0x63, 0xa3, 0x3b, 0x1a, 0xa2, 0x59, 0xf5,
|
||||
0x1a, 0xaa, 0xf6, 0x54, 0xfb, 0xa1, 0xde, 0xbc, 0xb0, 0x19, 0x9a, 0x6d, 0xaf, 0x57, 0x9a, 0x17,
|
||||
0xf6, 0x42, 0x3e, 0xcd, 0xfa, 0xa3, 0x2c, 0x08, 0xe0, 0xf0, 0xd4, 0x6f, 0xe8, 0xd2, 0x4d, 0x45,
|
||||
0xd0, 0x22, 0xc5, 0xaf, 0xdb, 0x18, 0x1d, 0x02, 0xf8, 0x01, 0xb6, 0x5b, 0x84, 0x4d, 0xd1, 0x32,
|
||||
0x91, 0xbf, 0x6d, 0x53, 0xc1, 0x84, 0xd5, 0x7c, 0x86, 0xb1, 0xe2, 0xd5, 0x08, 0x84, 0xd9, 0xc4,
|
||||
0xfe, 0xbe, 0x5d, 0xbc, 0xa5, 0xd1, 0x90, 0xb6, 0x20, 0x4f, 0x8a, 0x41, 0xb0, 0xd9, 0x29, 0xc8,
|
||||
0x33, 0x72, 0x90, 0xf5, 0xdd, 0x9f, 0xca, 0x48, 0x39, 0x9e, 0x89, 0xfe, 0x03, 0x69, 0x5a, 0x0f,
|
||||
0x01, 0x0b, 0x65, 0x22, 0x94, 0xe3, 0xa5, 0x26, 0xf6, 0x4f, 0x64, 0x4b, 0x00, 0x60, 0xd7, 0x49,
|
||||
0x95, 0xcd, 0x7d, 0xff, 0x45, 0x30, 0x01, 0xb0, 0x69, 0xb8, 0x5e, 0x17, 0x1b, 0x26, 0xf6, 0x6f,
|
||||
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,
|
||||
}
|
45
vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.golden
generated
vendored
Normal file
45
vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.golden
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: gogo.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
package gogoproto
|
||||
|
||||
import proto "github.com/gogo/protobuf/proto"
|
||||
import json "encoding/json"
|
||||
import math "math"
|
||||
import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
|
||||
// Reference proto, json, and math imports to suppress error if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = &json.SyntaxError{}
|
||||
var _ = math.Inf
|
||||
|
||||
var E_Nullable = &proto.ExtensionDesc{
|
||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 51235,
|
||||
Name: "gogoproto.nullable",
|
||||
Tag: "varint,51235,opt,name=nullable",
|
||||
}
|
||||
|
||||
var E_Embed = &proto.ExtensionDesc{
|
||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
||||
ExtensionType: (*bool)(nil),
|
||||
Field: 51236,
|
||||
Name: "gogoproto.embed",
|
||||
Tag: "varint,51236,opt,name=embed",
|
||||
}
|
||||
|
||||
var E_Customtype = &proto.ExtensionDesc{
|
||||
ExtendedType: (*google_protobuf.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 51237,
|
||||
Name: "gogoproto.customtype",
|
||||
Tag: "bytes,51237,opt,name=customtype",
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterExtension(E_Nullable)
|
||||
proto.RegisterExtension(E_Embed)
|
||||
proto.RegisterExtension(E_Customtype)
|
||||
}
|
144
vendor/github.com/gogo/protobuf/gogoproto/gogo.proto
generated
vendored
Normal file
144
vendor/github.com/gogo/protobuf/gogoproto/gogo.proto
generated
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
// 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.
|
||||
|
||||
syntax = "proto2";
|
||||
package gogoproto;
|
||||
|
||||
import "google/protobuf/descriptor.proto";
|
||||
|
||||
option java_package = "com.google.protobuf";
|
||||
option java_outer_classname = "GoGoProtos";
|
||||
option go_package = "github.com/gogo/protobuf/gogoproto";
|
||||
|
||||
extend google.protobuf.EnumOptions {
|
||||
optional bool goproto_enum_prefix = 62001;
|
||||
optional bool goproto_enum_stringer = 62021;
|
||||
optional bool enum_stringer = 62022;
|
||||
optional string enum_customname = 62023;
|
||||
optional bool enumdecl = 62024;
|
||||
}
|
||||
|
||||
extend google.protobuf.EnumValueOptions {
|
||||
optional string enumvalue_customname = 66001;
|
||||
}
|
||||
|
||||
extend google.protobuf.FileOptions {
|
||||
optional bool goproto_getters_all = 63001;
|
||||
optional bool goproto_enum_prefix_all = 63002;
|
||||
optional bool goproto_stringer_all = 63003;
|
||||
optional bool verbose_equal_all = 63004;
|
||||
optional bool face_all = 63005;
|
||||
optional bool gostring_all = 63006;
|
||||
optional bool populate_all = 63007;
|
||||
optional bool stringer_all = 63008;
|
||||
optional bool onlyone_all = 63009;
|
||||
|
||||
optional bool equal_all = 63013;
|
||||
optional bool description_all = 63014;
|
||||
optional bool testgen_all = 63015;
|
||||
optional bool benchgen_all = 63016;
|
||||
optional bool marshaler_all = 63017;
|
||||
optional bool unmarshaler_all = 63018;
|
||||
optional bool stable_marshaler_all = 63019;
|
||||
|
||||
optional bool sizer_all = 63020;
|
||||
|
||||
optional bool goproto_enum_stringer_all = 63021;
|
||||
optional bool enum_stringer_all = 63022;
|
||||
|
||||
optional bool unsafe_marshaler_all = 63023;
|
||||
optional bool unsafe_unmarshaler_all = 63024;
|
||||
|
||||
optional bool goproto_extensions_map_all = 63025;
|
||||
optional bool goproto_unrecognized_all = 63026;
|
||||
optional bool gogoproto_import = 63027;
|
||||
optional bool protosizer_all = 63028;
|
||||
optional bool compare_all = 63029;
|
||||
optional bool typedecl_all = 63030;
|
||||
optional bool enumdecl_all = 63031;
|
||||
|
||||
optional bool goproto_registration = 63032;
|
||||
optional bool messagename_all = 63033;
|
||||
|
||||
optional bool goproto_sizecache_all = 63034;
|
||||
optional bool goproto_unkeyed_all = 63035;
|
||||
}
|
||||
|
||||
extend google.protobuf.MessageOptions {
|
||||
optional bool goproto_getters = 64001;
|
||||
optional bool goproto_stringer = 64003;
|
||||
optional bool verbose_equal = 64004;
|
||||
optional bool face = 64005;
|
||||
optional bool gostring = 64006;
|
||||
optional bool populate = 64007;
|
||||
optional bool stringer = 67008;
|
||||
optional bool onlyone = 64009;
|
||||
|
||||
optional bool equal = 64013;
|
||||
optional bool description = 64014;
|
||||
optional bool testgen = 64015;
|
||||
optional bool benchgen = 64016;
|
||||
optional bool marshaler = 64017;
|
||||
optional bool unmarshaler = 64018;
|
||||
optional bool stable_marshaler = 64019;
|
||||
|
||||
optional bool sizer = 64020;
|
||||
|
||||
optional bool unsafe_marshaler = 64023;
|
||||
optional bool unsafe_unmarshaler = 64024;
|
||||
|
||||
optional bool goproto_extensions_map = 64025;
|
||||
optional bool goproto_unrecognized = 64026;
|
||||
|
||||
optional bool protosizer = 64028;
|
||||
optional bool compare = 64029;
|
||||
|
||||
optional bool typedecl = 64030;
|
||||
|
||||
optional bool messagename = 64033;
|
||||
|
||||
optional bool goproto_sizecache = 64034;
|
||||
optional bool goproto_unkeyed = 64035;
|
||||
}
|
||||
|
||||
extend google.protobuf.FieldOptions {
|
||||
optional bool nullable = 65001;
|
||||
optional bool embed = 65002;
|
||||
optional string customtype = 65003;
|
||||
optional string customname = 65004;
|
||||
optional string jsontag = 65005;
|
||||
optional string moretags = 65006;
|
||||
optional string casttype = 65007;
|
||||
optional string castkey = 65008;
|
||||
optional string castvalue = 65009;
|
||||
|
||||
optional bool stdtime = 65010;
|
||||
optional bool stdduration = 65011;
|
||||
optional bool wktpointer = 65012;
|
||||
|
||||
}
|
415
vendor/github.com/gogo/protobuf/gogoproto/helper.go
generated
vendored
Normal file
415
vendor/github.com/gogo/protobuf/gogoproto/helper.go
generated
vendored
Normal file
@ -0,0 +1,415 @@
|
||||
// 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 gogoproto
|
||||
|
||||
import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
import proto "github.com/gogo/protobuf/proto"
|
||||
|
||||
func IsEmbed(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
return proto.GetBoolExtension(field.Options, E_Embed, false)
|
||||
}
|
||||
|
||||
func IsNullable(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
return proto.GetBoolExtension(field.Options, E_Nullable, true)
|
||||
}
|
||||
|
||||
func IsStdTime(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
return proto.GetBoolExtension(field.Options, E_Stdtime, false)
|
||||
}
|
||||
|
||||
func IsStdDuration(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
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 {
|
||||
nullable := IsNullable(field)
|
||||
if field.IsMessage() || IsCustomType(field) {
|
||||
return nullable
|
||||
}
|
||||
if proto3 {
|
||||
return false
|
||||
}
|
||||
return nullable || *field.Type == google_protobuf.FieldDescriptorProto_TYPE_BYTES
|
||||
}
|
||||
|
||||
func IsCustomType(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
typ := GetCustomType(field)
|
||||
if len(typ) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsCastType(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
typ := GetCastType(field)
|
||||
if len(typ) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsCastKey(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
typ := GetCastKey(field)
|
||||
if len(typ) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsCastValue(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
typ := GetCastValue(field)
|
||||
if len(typ) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func HasEnumDecl(file *google_protobuf.FileDescriptorProto, enum *google_protobuf.EnumDescriptorProto) bool {
|
||||
return proto.GetBoolExtension(enum.Options, E_Enumdecl, proto.GetBoolExtension(file.Options, E_EnumdeclAll, true))
|
||||
}
|
||||
|
||||
func HasTypeDecl(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Typedecl, proto.GetBoolExtension(file.Options, E_TypedeclAll, true))
|
||||
}
|
||||
|
||||
func GetCustomType(field *google_protobuf.FieldDescriptorProto) string {
|
||||
if field == nil {
|
||||
return ""
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_Customtype)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return *(v.(*string))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetCastType(field *google_protobuf.FieldDescriptorProto) string {
|
||||
if field == nil {
|
||||
return ""
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_Casttype)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return *(v.(*string))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetCastKey(field *google_protobuf.FieldDescriptorProto) string {
|
||||
if field == nil {
|
||||
return ""
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_Castkey)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return *(v.(*string))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetCastValue(field *google_protobuf.FieldDescriptorProto) string {
|
||||
if field == nil {
|
||||
return ""
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_Castvalue)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return *(v.(*string))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func IsCustomName(field *google_protobuf.FieldDescriptorProto) bool {
|
||||
name := GetCustomName(field)
|
||||
if len(name) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsEnumCustomName(field *google_protobuf.EnumDescriptorProto) bool {
|
||||
name := GetEnumCustomName(field)
|
||||
if len(name) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsEnumValueCustomName(field *google_protobuf.EnumValueDescriptorProto) bool {
|
||||
name := GetEnumValueCustomName(field)
|
||||
if len(name) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func GetCustomName(field *google_protobuf.FieldDescriptorProto) string {
|
||||
if field == nil {
|
||||
return ""
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_Customname)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return *(v.(*string))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetEnumCustomName(field *google_protobuf.EnumDescriptorProto) string {
|
||||
if field == nil {
|
||||
return ""
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_EnumCustomname)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return *(v.(*string))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetEnumValueCustomName(field *google_protobuf.EnumValueDescriptorProto) string {
|
||||
if field == nil {
|
||||
return ""
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_EnumvalueCustomname)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return *(v.(*string))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetJsonTag(field *google_protobuf.FieldDescriptorProto) *string {
|
||||
if field == nil {
|
||||
return nil
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_Jsontag)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return (v.(*string))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetMoreTags(field *google_protobuf.FieldDescriptorProto) *string {
|
||||
if field == nil {
|
||||
return nil
|
||||
}
|
||||
if field.Options != nil {
|
||||
v, err := proto.GetExtension(field.Options, E_Moretags)
|
||||
if err == nil && v.(*string) != nil {
|
||||
return (v.(*string))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type EnableFunc func(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool
|
||||
|
||||
func EnabledGoEnumPrefix(file *google_protobuf.FileDescriptorProto, enum *google_protobuf.EnumDescriptorProto) bool {
|
||||
return proto.GetBoolExtension(enum.Options, E_GoprotoEnumPrefix, proto.GetBoolExtension(file.Options, E_GoprotoEnumPrefixAll, true))
|
||||
}
|
||||
|
||||
func EnabledGoStringer(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_GoprotoStringer, proto.GetBoolExtension(file.Options, E_GoprotoStringerAll, true))
|
||||
}
|
||||
|
||||
func HasGoGetters(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_GoprotoGetters, proto.GetBoolExtension(file.Options, E_GoprotoGettersAll, true))
|
||||
}
|
||||
|
||||
func IsUnion(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Onlyone, proto.GetBoolExtension(file.Options, E_OnlyoneAll, false))
|
||||
}
|
||||
|
||||
func HasGoString(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Gostring, proto.GetBoolExtension(file.Options, E_GostringAll, false))
|
||||
}
|
||||
|
||||
func HasEqual(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Equal, proto.GetBoolExtension(file.Options, E_EqualAll, false))
|
||||
}
|
||||
|
||||
func HasVerboseEqual(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_VerboseEqual, proto.GetBoolExtension(file.Options, E_VerboseEqualAll, false))
|
||||
}
|
||||
|
||||
func IsStringer(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Stringer, proto.GetBoolExtension(file.Options, E_StringerAll, false))
|
||||
}
|
||||
|
||||
func IsFace(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Face, proto.GetBoolExtension(file.Options, E_FaceAll, false))
|
||||
}
|
||||
|
||||
func HasDescription(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Description, proto.GetBoolExtension(file.Options, E_DescriptionAll, false))
|
||||
}
|
||||
|
||||
func HasPopulate(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Populate, proto.GetBoolExtension(file.Options, E_PopulateAll, false))
|
||||
}
|
||||
|
||||
func HasTestGen(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Testgen, proto.GetBoolExtension(file.Options, E_TestgenAll, false))
|
||||
}
|
||||
|
||||
func HasBenchGen(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Benchgen, proto.GetBoolExtension(file.Options, E_BenchgenAll, false))
|
||||
}
|
||||
|
||||
func IsMarshaler(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Marshaler, proto.GetBoolExtension(file.Options, E_MarshalerAll, false))
|
||||
}
|
||||
|
||||
func IsUnmarshaler(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Unmarshaler, proto.GetBoolExtension(file.Options, E_UnmarshalerAll, false))
|
||||
}
|
||||
|
||||
func IsStableMarshaler(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_StableMarshaler, proto.GetBoolExtension(file.Options, E_StableMarshalerAll, false))
|
||||
}
|
||||
|
||||
func IsSizer(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Sizer, proto.GetBoolExtension(file.Options, E_SizerAll, false))
|
||||
}
|
||||
|
||||
func IsProtoSizer(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Protosizer, proto.GetBoolExtension(file.Options, E_ProtosizerAll, false))
|
||||
}
|
||||
|
||||
func IsGoEnumStringer(file *google_protobuf.FileDescriptorProto, enum *google_protobuf.EnumDescriptorProto) bool {
|
||||
return proto.GetBoolExtension(enum.Options, E_GoprotoEnumStringer, proto.GetBoolExtension(file.Options, E_GoprotoEnumStringerAll, true))
|
||||
}
|
||||
|
||||
func IsEnumStringer(file *google_protobuf.FileDescriptorProto, enum *google_protobuf.EnumDescriptorProto) bool {
|
||||
return proto.GetBoolExtension(enum.Options, E_EnumStringer, proto.GetBoolExtension(file.Options, E_EnumStringerAll, false))
|
||||
}
|
||||
|
||||
func IsUnsafeMarshaler(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_UnsafeMarshaler, proto.GetBoolExtension(file.Options, E_UnsafeMarshalerAll, false))
|
||||
}
|
||||
|
||||
func IsUnsafeUnmarshaler(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_UnsafeUnmarshaler, proto.GetBoolExtension(file.Options, E_UnsafeUnmarshalerAll, false))
|
||||
}
|
||||
|
||||
func HasExtensionsMap(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_GoprotoExtensionsMap, proto.GetBoolExtension(file.Options, E_GoprotoExtensionsMapAll, true))
|
||||
}
|
||||
|
||||
func HasUnrecognized(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_GoprotoUnrecognized, proto.GetBoolExtension(file.Options, E_GoprotoUnrecognizedAll, true))
|
||||
}
|
||||
|
||||
func IsProto3(file *google_protobuf.FileDescriptorProto) bool {
|
||||
return file.GetSyntax() == "proto3"
|
||||
}
|
||||
|
||||
func ImportsGoGoProto(file *google_protobuf.FileDescriptorProto) bool {
|
||||
return proto.GetBoolExtension(file.Options, E_GogoprotoImport, true)
|
||||
}
|
||||
|
||||
func HasCompare(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool {
|
||||
return proto.GetBoolExtension(message.Options, E_Compare, proto.GetBoolExtension(file.Options, E_CompareAll, false))
|
||||
}
|
||||
|
||||
func RegistersGolangProto(file *google_protobuf.FileDescriptorProto) bool {
|
||||
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))
|
||||
}
|
25
vendor/github.com/gogo/protobuf/gogoreplace/main.go
generated
vendored
Normal file
25
vendor/github.com/gogo/protobuf/gogoreplace/main.go
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
args := os.Args
|
||||
if len(args) != 4 {
|
||||
fmt.Println("gogoreplace wants three arguments")
|
||||
fmt.Println(" gogoreplace oldsubstring newsubstring filename")
|
||||
os.Exit(1)
|
||||
}
|
||||
data, err := ioutil.ReadFile(args[3])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
data = bytes.Replace(data, []byte(args[1]), []byte(args[2]), -1)
|
||||
if err := ioutil.WriteFile(args[3], data, 0666); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
28
vendor/github.com/gogo/protobuf/install-protobuf.sh
generated
vendored
Executable file
28
vendor/github.com/gogo/protobuf/install-protobuf.sh
generated
vendored
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
die() {
|
||||
echo "$@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cd /home/travis
|
||||
|
||||
case "$PROTOBUF_VERSION" in
|
||||
2*)
|
||||
basename=protobuf-$PROTOBUF_VERSION
|
||||
wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename.tar.gz
|
||||
tar xzf $basename.tar.gz
|
||||
cd protobuf-$PROTOBUF_VERSION
|
||||
./configure --prefix=/home/travis && make -j2 && make install
|
||||
;;
|
||||
3*)
|
||||
basename=protoc-$PROTOBUF_VERSION-linux-x86_64
|
||||
wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename.zip
|
||||
unzip $basename.zip
|
||||
;;
|
||||
*)
|
||||
die "unknown protobuf version: $PROTOBUF_VERSION"
|
||||
;;
|
||||
esac
|
102
vendor/github.com/gogo/protobuf/io/full.go
generated
vendored
Normal file
102
vendor/github.com/gogo/protobuf/io/full.go
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
// 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 io
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"io"
|
||||
)
|
||||
|
||||
func NewFullWriter(w io.Writer) WriteCloser {
|
||||
return &fullWriter{w, nil}
|
||||
}
|
||||
|
||||
type fullWriter struct {
|
||||
w io.Writer
|
||||
buffer []byte
|
||||
}
|
||||
|
||||
func (this *fullWriter) WriteMsg(msg proto.Message) (err error) {
|
||||
var data []byte
|
||||
if m, ok := msg.(marshaler); ok {
|
||||
n, ok := getSize(m)
|
||||
if !ok {
|
||||
data, err = proto.Marshal(msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if n >= len(this.buffer) {
|
||||
this.buffer = make([]byte, n)
|
||||
}
|
||||
_, err = m.MarshalTo(this.buffer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data = this.buffer[:n]
|
||||
} else {
|
||||
data, err = proto.Marshal(msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err = this.w.Write(data)
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *fullWriter) Close() error {
|
||||
if closer, ok := this.w.(io.Closer); ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type fullReader struct {
|
||||
r io.Reader
|
||||
buf []byte
|
||||
}
|
||||
|
||||
func NewFullReader(r io.Reader, maxSize int) ReadCloser {
|
||||
return &fullReader{r, make([]byte, maxSize)}
|
||||
}
|
||||
|
||||
func (this *fullReader) ReadMsg(msg proto.Message) error {
|
||||
length, err := this.r.Read(this.buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return proto.Unmarshal(this.buf[:length], msg)
|
||||
}
|
||||
|
||||
func (this *fullReader) Close() error {
|
||||
if closer, ok := this.r.(io.Closer); ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
70
vendor/github.com/gogo/protobuf/io/io.go
generated
vendored
Normal file
70
vendor/github.com/gogo/protobuf/io/io.go
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
// 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 io
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"io"
|
||||
)
|
||||
|
||||
type Writer interface {
|
||||
WriteMsg(proto.Message) error
|
||||
}
|
||||
|
||||
type WriteCloser interface {
|
||||
Writer
|
||||
io.Closer
|
||||
}
|
||||
|
||||
type Reader interface {
|
||||
ReadMsg(msg proto.Message) error
|
||||
}
|
||||
|
||||
type ReadCloser interface {
|
||||
Reader
|
||||
io.Closer
|
||||
}
|
||||
|
||||
type marshaler interface {
|
||||
MarshalTo(data []byte) (n int, err error)
|
||||
}
|
||||
|
||||
func getSize(v interface{}) (int, bool) {
|
||||
if sz, ok := v.(interface {
|
||||
Size() (n int)
|
||||
}); ok {
|
||||
return sz.Size(), true
|
||||
} else if sz, ok := v.(interface {
|
||||
ProtoSize() (n int)
|
||||
}); ok {
|
||||
return sz.ProtoSize(), true
|
||||
} else {
|
||||
return 0, false
|
||||
}
|
||||
}
|
221
vendor/github.com/gogo/protobuf/io/io_test.go
generated
vendored
Normal file
221
vendor/github.com/gogo/protobuf/io/io_test.go
generated
vendored
Normal file
@ -0,0 +1,221 @@
|
||||
// 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 io_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"github.com/gogo/protobuf/io"
|
||||
"github.com/gogo/protobuf/test"
|
||||
goio "io"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func iotest(writer io.WriteCloser, reader io.ReadCloser) error {
|
||||
size := 1000
|
||||
msgs := make([]*test.NinOptNative, size)
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
for i := range msgs {
|
||||
msgs[i] = test.NewPopulatedNinOptNative(r, true)
|
||||
//issue 31
|
||||
if i == 5 {
|
||||
msgs[i] = &test.NinOptNative{}
|
||||
}
|
||||
//issue 31
|
||||
if i == 999 {
|
||||
msgs[i] = &test.NinOptNative{}
|
||||
}
|
||||
err := writer.WriteMsg(msgs[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := writer.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
i := 0
|
||||
for {
|
||||
msg := &test.NinOptNative{}
|
||||
if err := reader.ReadMsg(msg); err != nil {
|
||||
if err == goio.EOF {
|
||||
break
|
||||
}
|
||||
return err
|
||||
}
|
||||
if err := msg.VerboseEqual(msgs[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
i++
|
||||
}
|
||||
if i != size {
|
||||
panic("not enough messages read")
|
||||
}
|
||||
if err := reader.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type buffer struct {
|
||||
*bytes.Buffer
|
||||
closed bool
|
||||
}
|
||||
|
||||
func (this *buffer) Close() error {
|
||||
this.closed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func newBuffer() *buffer {
|
||||
return &buffer{bytes.NewBuffer(nil), false}
|
||||
}
|
||||
|
||||
func TestBigUint32Normal(t *testing.T) {
|
||||
buf := newBuffer()
|
||||
writer := io.NewUint32DelimitedWriter(buf, binary.BigEndian)
|
||||
reader := io.NewUint32DelimitedReader(buf, binary.BigEndian, 1024*1024)
|
||||
if err := iotest(writer, reader); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !buf.closed {
|
||||
t.Fatalf("did not close buffer")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBigUint32MaxSize(t *testing.T) {
|
||||
buf := newBuffer()
|
||||
writer := io.NewUint32DelimitedWriter(buf, binary.BigEndian)
|
||||
reader := io.NewUint32DelimitedReader(buf, binary.BigEndian, 20)
|
||||
if err := iotest(writer, reader); err != goio.ErrShortBuffer {
|
||||
t.Error(err)
|
||||
} else {
|
||||
t.Logf("%s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLittleUint32Normal(t *testing.T) {
|
||||
buf := newBuffer()
|
||||
writer := io.NewUint32DelimitedWriter(buf, binary.LittleEndian)
|
||||
reader := io.NewUint32DelimitedReader(buf, binary.LittleEndian, 1024*1024)
|
||||
if err := iotest(writer, reader); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !buf.closed {
|
||||
t.Fatalf("did not close buffer")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLittleUint32MaxSize(t *testing.T) {
|
||||
buf := newBuffer()
|
||||
writer := io.NewUint32DelimitedWriter(buf, binary.LittleEndian)
|
||||
reader := io.NewUint32DelimitedReader(buf, binary.LittleEndian, 20)
|
||||
if err := iotest(writer, reader); err != goio.ErrShortBuffer {
|
||||
t.Error(err)
|
||||
} else {
|
||||
t.Logf("%s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVarintNormal(t *testing.T) {
|
||||
buf := newBuffer()
|
||||
writer := io.NewDelimitedWriter(buf)
|
||||
reader := io.NewDelimitedReader(buf, 1024*1024)
|
||||
if err := iotest(writer, reader); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !buf.closed {
|
||||
t.Fatalf("did not close buffer")
|
||||
}
|
||||
}
|
||||
|
||||
func TestVarintNoClose(t *testing.T) {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
writer := io.NewDelimitedWriter(buf)
|
||||
reader := io.NewDelimitedReader(buf, 1024*1024)
|
||||
if err := iotest(writer, reader); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
//issue 32
|
||||
func TestVarintMaxSize(t *testing.T) {
|
||||
buf := newBuffer()
|
||||
writer := io.NewDelimitedWriter(buf)
|
||||
reader := io.NewDelimitedReader(buf, 20)
|
||||
if err := iotest(writer, reader); err != goio.ErrShortBuffer {
|
||||
t.Error(err)
|
||||
} else {
|
||||
t.Logf("%s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVarintError(t *testing.T) {
|
||||
buf := newBuffer()
|
||||
buf.Write([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f})
|
||||
reader := io.NewDelimitedReader(buf, 1024*1024)
|
||||
msg := &test.NinOptNative{}
|
||||
err := reader.ReadMsg(msg)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFull(t *testing.T) {
|
||||
buf := newBuffer()
|
||||
writer := io.NewFullWriter(buf)
|
||||
reader := io.NewFullReader(buf, 1024*1024)
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
msgIn := test.NewPopulatedNinOptNative(r, true)
|
||||
if err := writer.WriteMsg(msgIn); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := writer.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
msgOut := &test.NinOptNative{}
|
||||
if err := reader.ReadMsg(msgOut); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := msgIn.VerboseEqual(msgOut); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := reader.ReadMsg(msgOut); err != nil {
|
||||
if err != goio.EOF {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if err := reader.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if !buf.closed {
|
||||
t.Fatalf("did not close buffer")
|
||||
}
|
||||
}
|
138
vendor/github.com/gogo/protobuf/io/uint32.go
generated
vendored
Normal file
138
vendor/github.com/gogo/protobuf/io/uint32.go
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
// 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 io
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
const uint32BinaryLen = 4
|
||||
|
||||
func NewUint32DelimitedWriter(w io.Writer, byteOrder binary.ByteOrder) WriteCloser {
|
||||
return &uint32Writer{w, byteOrder, nil, make([]byte, uint32BinaryLen)}
|
||||
}
|
||||
|
||||
func NewSizeUint32DelimitedWriter(w io.Writer, byteOrder binary.ByteOrder, size int) WriteCloser {
|
||||
return &uint32Writer{w, byteOrder, make([]byte, size), make([]byte, uint32BinaryLen)}
|
||||
}
|
||||
|
||||
type uint32Writer struct {
|
||||
w io.Writer
|
||||
byteOrder binary.ByteOrder
|
||||
buffer []byte
|
||||
lenBuf []byte
|
||||
}
|
||||
|
||||
func (this *uint32Writer) writeFallback(msg proto.Message) error {
|
||||
data, err := proto.Marshal(msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
length := uint32(len(data))
|
||||
this.byteOrder.PutUint32(this.lenBuf, length)
|
||||
if _, err = this.w.Write(this.lenBuf); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = this.w.Write(data)
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *uint32Writer) WriteMsg(msg proto.Message) error {
|
||||
m, ok := msg.(marshaler)
|
||||
if !ok {
|
||||
return this.writeFallback(msg)
|
||||
}
|
||||
|
||||
n, ok := getSize(m)
|
||||
if !ok {
|
||||
return this.writeFallback(msg)
|
||||
}
|
||||
|
||||
size := n + uint32BinaryLen
|
||||
if size > len(this.buffer) {
|
||||
this.buffer = make([]byte, size)
|
||||
}
|
||||
|
||||
this.byteOrder.PutUint32(this.buffer, uint32(n))
|
||||
if _, err := m.MarshalTo(this.buffer[uint32BinaryLen:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := this.w.Write(this.buffer[:size])
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *uint32Writer) Close() error {
|
||||
if closer, ok := this.w.(io.Closer); ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type uint32Reader struct {
|
||||
r io.Reader
|
||||
byteOrder binary.ByteOrder
|
||||
lenBuf []byte
|
||||
buf []byte
|
||||
maxSize int
|
||||
}
|
||||
|
||||
func NewUint32DelimitedReader(r io.Reader, byteOrder binary.ByteOrder, maxSize int) ReadCloser {
|
||||
return &uint32Reader{r, byteOrder, make([]byte, 4), nil, maxSize}
|
||||
}
|
||||
|
||||
func (this *uint32Reader) ReadMsg(msg proto.Message) error {
|
||||
if _, err := io.ReadFull(this.r, this.lenBuf); err != nil {
|
||||
return err
|
||||
}
|
||||
length32 := this.byteOrder.Uint32(this.lenBuf)
|
||||
length := int(length32)
|
||||
if length < 0 || length > this.maxSize {
|
||||
return io.ErrShortBuffer
|
||||
}
|
||||
if length >= len(this.buf) {
|
||||
this.buf = make([]byte, length)
|
||||
}
|
||||
_, err := io.ReadFull(this.r, this.buf[:length])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return proto.Unmarshal(this.buf[:length], msg)
|
||||
}
|
||||
|
||||
func (this *uint32Reader) Close() error {
|
||||
if closer, ok := this.r.(io.Closer); ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
38
vendor/github.com/gogo/protobuf/io/uint32_test.go
generated
vendored
Normal file
38
vendor/github.com/gogo/protobuf/io/uint32_test.go
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
package io_test
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/test"
|
||||
example "github.com/gogo/protobuf/test/example"
|
||||
|
||||
"github.com/gogo/protobuf/io"
|
||||
)
|
||||
|
||||
func BenchmarkUint32DelimWriterMarshaller(b *testing.B) {
|
||||
w := io.NewUint32DelimitedWriter(ioutil.Discard, binary.BigEndian)
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
msg := example.NewPopulatedA(r, true)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err := w.WriteMsg(msg); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkUint32DelimWriterFallback(b *testing.B) {
|
||||
w := io.NewUint32DelimitedWriter(ioutil.Discard, binary.BigEndian)
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
msg := test.NewPopulatedNinOptNative(r, true)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
if err := w.WriteMsg(msg); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
133
vendor/github.com/gogo/protobuf/io/varint.go
generated
vendored
Normal file
133
vendor/github.com/gogo/protobuf/io/varint.go
generated
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
// 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 io
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"io"
|
||||
)
|
||||
|
||||
var (
|
||||
errSmallBuffer = errors.New("Buffer Too Small")
|
||||
errLargeValue = errors.New("Value is Larger than 64 bits")
|
||||
)
|
||||
|
||||
func NewDelimitedWriter(w io.Writer) WriteCloser {
|
||||
return &varintWriter{w, make([]byte, binary.MaxVarintLen64), nil}
|
||||
}
|
||||
|
||||
type varintWriter struct {
|
||||
w io.Writer
|
||||
lenBuf []byte
|
||||
buffer []byte
|
||||
}
|
||||
|
||||
func (this *varintWriter) WriteMsg(msg proto.Message) (err error) {
|
||||
var data []byte
|
||||
if m, ok := msg.(marshaler); ok {
|
||||
n, ok := getSize(m)
|
||||
if ok {
|
||||
if n+binary.MaxVarintLen64 >= len(this.buffer) {
|
||||
this.buffer = make([]byte, n+binary.MaxVarintLen64)
|
||||
}
|
||||
lenOff := binary.PutUvarint(this.buffer, uint64(n))
|
||||
_, err = m.MarshalTo(this.buffer[lenOff:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = this.w.Write(this.buffer[:lenOff+n])
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// fallback
|
||||
data, err = proto.Marshal(msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
length := uint64(len(data))
|
||||
n := binary.PutUvarint(this.lenBuf, length)
|
||||
_, err = this.w.Write(this.lenBuf[:n])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = this.w.Write(data)
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *varintWriter) Close() error {
|
||||
if closer, ok := this.w.(io.Closer); ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDelimitedReader(r io.Reader, maxSize int) ReadCloser {
|
||||
var closer io.Closer
|
||||
if c, ok := r.(io.Closer); ok {
|
||||
closer = c
|
||||
}
|
||||
return &varintReader{bufio.NewReader(r), nil, maxSize, closer}
|
||||
}
|
||||
|
||||
type varintReader struct {
|
||||
r *bufio.Reader
|
||||
buf []byte
|
||||
maxSize int
|
||||
closer io.Closer
|
||||
}
|
||||
|
||||
func (this *varintReader) ReadMsg(msg proto.Message) error {
|
||||
length64, err := binary.ReadUvarint(this.r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
length := int(length64)
|
||||
if length < 0 || length > this.maxSize {
|
||||
return io.ErrShortBuffer
|
||||
}
|
||||
if len(this.buf) < length {
|
||||
this.buf = make([]byte, length)
|
||||
}
|
||||
buf := this.buf[:length]
|
||||
if _, err := io.ReadFull(this.r, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
return proto.Unmarshal(buf, msg)
|
||||
}
|
||||
|
||||
func (this *varintReader) Close() error {
|
||||
if this.closer != nil {
|
||||
return this.closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
1416
vendor/github.com/gogo/protobuf/jsonpb/jsonpb.go
generated
vendored
Normal file
1416
vendor/github.com/gogo/protobuf/jsonpb/jsonpb.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1225
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test.go
generated
vendored
Normal file
1225
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
33
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/Makefile
generated
vendored
Normal file
33
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/Makefile
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
# Go support for Protocol Buffers - Google's data interchange format
|
||||
#
|
||||
# Copyright 2015 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.
|
||||
|
||||
regenerate:
|
||||
protoc-min-version --version="3.0.0" --gogo_out=Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types:. *.proto -I . -I ../../ -I ../../protobuf/
|
7
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/bytes.go
generated
vendored
Normal file
7
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/bytes.go
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package jsonpb
|
||||
|
||||
// Byte is used to test that []byte type aliases are serialized to base64.
|
||||
type Byte byte
|
||||
|
||||
// Bytes is used to test that []byte type aliases are serialized to base64.
|
||||
type Bytes []Byte
|
368
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go
generated
vendored
Normal file
368
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go
generated
vendored
Normal file
@ -0,0 +1,368 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: more_test_objects.proto
|
||||
|
||||
package jsonpb
|
||||
|
||||
import proto "github.com/gogo/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// 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
|
||||
|
||||
type Numeral int32
|
||||
|
||||
const (
|
||||
Numeral_UNKNOWN Numeral = 0
|
||||
Numeral_ARABIC Numeral = 1
|
||||
Numeral_ROMAN Numeral = 2
|
||||
)
|
||||
|
||||
var Numeral_name = map[int32]string{
|
||||
0: "UNKNOWN",
|
||||
1: "ARABIC",
|
||||
2: "ROMAN",
|
||||
}
|
||||
var Numeral_value = map[string]int32{
|
||||
"UNKNOWN": 0,
|
||||
"ARABIC": 1,
|
||||
"ROMAN": 2,
|
||||
}
|
||||
|
||||
func (x Numeral) String() string {
|
||||
return proto.EnumName(Numeral_name, int32(x))
|
||||
}
|
||||
func (Numeral) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{0}
|
||||
}
|
||||
|
||||
type Simple3 struct {
|
||||
Dub float64 `protobuf:"fixed64,1,opt,name=dub,proto3" json:"dub,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Simple3) Reset() { *m = Simple3{} }
|
||||
func (m *Simple3) String() string { return proto.CompactTextString(m) }
|
||||
func (*Simple3) ProtoMessage() {}
|
||||
func (*Simple3) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{0}
|
||||
}
|
||||
func (m *Simple3) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Simple3.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Simple3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Simple3.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *Simple3) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Simple3.Merge(dst, src)
|
||||
}
|
||||
func (m *Simple3) XXX_Size() int {
|
||||
return xxx_messageInfo_Simple3.Size(m)
|
||||
}
|
||||
func (m *Simple3) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Simple3.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Simple3 proto.InternalMessageInfo
|
||||
|
||||
func (m *Simple3) GetDub() float64 {
|
||||
if m != nil {
|
||||
return m.Dub
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type SimpleSlice3 struct {
|
||||
Slices []string `protobuf:"bytes,1,rep,name=slices,proto3" json:"slices,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SimpleSlice3) Reset() { *m = SimpleSlice3{} }
|
||||
func (m *SimpleSlice3) String() string { return proto.CompactTextString(m) }
|
||||
func (*SimpleSlice3) ProtoMessage() {}
|
||||
func (*SimpleSlice3) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{1}
|
||||
}
|
||||
func (m *SimpleSlice3) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SimpleSlice3.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SimpleSlice3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SimpleSlice3.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *SimpleSlice3) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SimpleSlice3.Merge(dst, src)
|
||||
}
|
||||
func (m *SimpleSlice3) XXX_Size() int {
|
||||
return xxx_messageInfo_SimpleSlice3.Size(m)
|
||||
}
|
||||
func (m *SimpleSlice3) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SimpleSlice3.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SimpleSlice3 proto.InternalMessageInfo
|
||||
|
||||
func (m *SimpleSlice3) GetSlices() []string {
|
||||
if m != nil {
|
||||
return m.Slices
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SimpleMap3 struct {
|
||||
Stringy map[string]string `protobuf:"bytes,1,rep,name=stringy,proto3" json:"stringy,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 *SimpleMap3) Reset() { *m = SimpleMap3{} }
|
||||
func (m *SimpleMap3) String() string { return proto.CompactTextString(m) }
|
||||
func (*SimpleMap3) ProtoMessage() {}
|
||||
func (*SimpleMap3) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{2}
|
||||
}
|
||||
func (m *SimpleMap3) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SimpleMap3.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SimpleMap3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SimpleMap3.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *SimpleMap3) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SimpleMap3.Merge(dst, src)
|
||||
}
|
||||
func (m *SimpleMap3) XXX_Size() int {
|
||||
return xxx_messageInfo_SimpleMap3.Size(m)
|
||||
}
|
||||
func (m *SimpleMap3) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SimpleMap3.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SimpleMap3 proto.InternalMessageInfo
|
||||
|
||||
func (m *SimpleMap3) GetStringy() map[string]string {
|
||||
if m != nil {
|
||||
return m.Stringy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SimpleNull3 struct {
|
||||
Simple *Simple3 `protobuf:"bytes,1,opt,name=simple,proto3" json:"simple,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SimpleNull3) Reset() { *m = SimpleNull3{} }
|
||||
func (m *SimpleNull3) String() string { return proto.CompactTextString(m) }
|
||||
func (*SimpleNull3) ProtoMessage() {}
|
||||
func (*SimpleNull3) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{3}
|
||||
}
|
||||
func (m *SimpleNull3) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SimpleNull3.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SimpleNull3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SimpleNull3.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *SimpleNull3) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SimpleNull3.Merge(dst, src)
|
||||
}
|
||||
func (m *SimpleNull3) XXX_Size() int {
|
||||
return xxx_messageInfo_SimpleNull3.Size(m)
|
||||
}
|
||||
func (m *SimpleNull3) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SimpleNull3.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SimpleNull3 proto.InternalMessageInfo
|
||||
|
||||
func (m *SimpleNull3) GetSimple() *Simple3 {
|
||||
if m != nil {
|
||||
return m.Simple
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Mappy struct {
|
||||
Nummy map[int64]int32 `protobuf:"bytes,1,rep,name=nummy,proto3" json:"nummy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
Strry map[string]string `protobuf:"bytes,2,rep,name=strry,proto3" json:"strry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Objjy map[int32]*Simple3 `protobuf:"bytes,3,rep,name=objjy,proto3" json:"objjy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Buggy map[int64]string `protobuf:"bytes,4,rep,name=buggy,proto3" json:"buggy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Booly map[bool]bool `protobuf:"bytes,5,rep,name=booly,proto3" json:"booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
Enumy map[string]Numeral `protobuf:"bytes,6,rep,name=enumy,proto3" json:"enumy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=jsonpb.Numeral"`
|
||||
S32Booly map[int32]bool `protobuf:"bytes,7,rep,name=s32booly,proto3" json:"s32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
S64Booly map[int64]bool `protobuf:"bytes,8,rep,name=s64booly,proto3" json:"s64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
U32Booly map[uint32]bool `protobuf:"bytes,9,rep,name=u32booly,proto3" json:"u32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
U64Booly map[uint64]bool `protobuf:"bytes,10,rep,name=u64booly,proto3" json:"u64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Mappy) Reset() { *m = Mappy{} }
|
||||
func (m *Mappy) String() string { return proto.CompactTextString(m) }
|
||||
func (*Mappy) ProtoMessage() {}
|
||||
func (*Mappy) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_more_test_objects_bef0d79b901f4c4a, []int{4}
|
||||
}
|
||||
func (m *Mappy) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Mappy.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Mappy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Mappy.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *Mappy) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Mappy.Merge(dst, src)
|
||||
}
|
||||
func (m *Mappy) XXX_Size() int {
|
||||
return xxx_messageInfo_Mappy.Size(m)
|
||||
}
|
||||
func (m *Mappy) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Mappy.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Mappy proto.InternalMessageInfo
|
||||
|
||||
func (m *Mappy) GetNummy() map[int64]int32 {
|
||||
if m != nil {
|
||||
return m.Nummy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetStrry() map[string]string {
|
||||
if m != nil {
|
||||
return m.Strry
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetObjjy() map[int32]*Simple3 {
|
||||
if m != nil {
|
||||
return m.Objjy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetBuggy() map[int64]string {
|
||||
if m != nil {
|
||||
return m.Buggy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetBooly() map[bool]bool {
|
||||
if m != nil {
|
||||
return m.Booly
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetEnumy() map[string]Numeral {
|
||||
if m != nil {
|
||||
return m.Enumy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetS32Booly() map[int32]bool {
|
||||
if m != nil {
|
||||
return m.S32Booly
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetS64Booly() map[int64]bool {
|
||||
if m != nil {
|
||||
return m.S64Booly
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetU32Booly() map[uint32]bool {
|
||||
if m != nil {
|
||||
return m.U32Booly
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mappy) GetU64Booly() map[uint64]bool {
|
||||
if m != nil {
|
||||
return m.U64Booly
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Simple3)(nil), "jsonpb.Simple3")
|
||||
proto.RegisterType((*SimpleSlice3)(nil), "jsonpb.SimpleSlice3")
|
||||
proto.RegisterType((*SimpleMap3)(nil), "jsonpb.SimpleMap3")
|
||||
proto.RegisterMapType((map[string]string)(nil), "jsonpb.SimpleMap3.StringyEntry")
|
||||
proto.RegisterType((*SimpleNull3)(nil), "jsonpb.SimpleNull3")
|
||||
proto.RegisterType((*Mappy)(nil), "jsonpb.Mappy")
|
||||
proto.RegisterMapType((map[bool]bool)(nil), "jsonpb.Mappy.BoolyEntry")
|
||||
proto.RegisterMapType((map[int64]string)(nil), "jsonpb.Mappy.BuggyEntry")
|
||||
proto.RegisterMapType((map[string]Numeral)(nil), "jsonpb.Mappy.EnumyEntry")
|
||||
proto.RegisterMapType((map[int64]int32)(nil), "jsonpb.Mappy.NummyEntry")
|
||||
proto.RegisterMapType((map[int32]*Simple3)(nil), "jsonpb.Mappy.ObjjyEntry")
|
||||
proto.RegisterMapType((map[int32]bool)(nil), "jsonpb.Mappy.S32boolyEntry")
|
||||
proto.RegisterMapType((map[int64]bool)(nil), "jsonpb.Mappy.S64boolyEntry")
|
||||
proto.RegisterMapType((map[string]string)(nil), "jsonpb.Mappy.StrryEntry")
|
||||
proto.RegisterMapType((map[uint32]bool)(nil), "jsonpb.Mappy.U32boolyEntry")
|
||||
proto.RegisterMapType((map[uint64]bool)(nil), "jsonpb.Mappy.U64boolyEntry")
|
||||
proto.RegisterEnum("jsonpb.Numeral", Numeral_name, Numeral_value)
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("more_test_objects.proto", fileDescriptor_more_test_objects_bef0d79b901f4c4a)
|
||||
}
|
||||
|
||||
var fileDescriptor_more_test_objects_bef0d79b901f4c4a = []byte{
|
||||
// 526 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xdd, 0x6b, 0xdb, 0x3c,
|
||||
0x14, 0x87, 0x5f, 0x27, 0xf5, 0xd7, 0x49, 0xfb, 0x2e, 0x88, 0xb1, 0x99, 0xf4, 0x62, 0xc5, 0xb0,
|
||||
0xad, 0x0c, 0xe6, 0x8b, 0x78, 0x74, 0x5d, 0x77, 0x95, 0x8e, 0x5e, 0x94, 0x11, 0x07, 0x1c, 0xc2,
|
||||
0x2e, 0x4b, 0xdc, 0x99, 0x90, 0xcc, 0x5f, 0xd8, 0xd6, 0xc0, 0xd7, 0xfb, 0xbb, 0x07, 0xe3, 0x48,
|
||||
0x72, 0x2d, 0x07, 0x85, 0x6c, 0x77, 0x52, 0x7e, 0xcf, 0xe3, 0x73, 0x24, 0x1d, 0x02, 0x2f, 0xd3,
|
||||
0xbc, 0x8c, 0x1f, 0xea, 0xb8, 0xaa, 0x1f, 0xf2, 0x68, 0x17, 0x3f, 0xd6, 0x95, 0x57, 0x94, 0x79,
|
||||
0x9d, 0x13, 0x63, 0x57, 0xe5, 0x59, 0x11, 0xb9, 0xe7, 0x60, 0x2e, 0xb7, 0x69, 0x91, 0xc4, 0x3e,
|
||||
0x19, 0xc3, 0xf0, 0x3b, 0x8d, 0x1c, 0xed, 0x42, 0xbb, 0xd4, 0x42, 0x5c, 0xba, 0x6f, 0xe0, 0x94,
|
||||
0x87, 0xcb, 0x64, 0xfb, 0x18, 0xfb, 0xe4, 0x05, 0x18, 0x15, 0xae, 0x2a, 0x47, 0xbb, 0x18, 0x5e,
|
||||
0xda, 0xa1, 0xd8, 0xb9, 0xbf, 0x34, 0x00, 0x0e, 0xce, 0xd7, 0x85, 0x4f, 0x3e, 0x81, 0x59, 0xd5,
|
||||
0xe5, 0x36, 0xdb, 0x34, 0x8c, 0x1b, 0x4d, 0x5f, 0x79, 0xbc, 0x9a, 0xd7, 0x41, 0xde, 0x92, 0x13,
|
||||
0x77, 0x59, 0x5d, 0x36, 0x61, 0xcb, 0x4f, 0x6e, 0xe0, 0x54, 0x0e, 0xb0, 0xa7, 0x1f, 0x71, 0xc3,
|
||||
0x7a, 0xb2, 0x43, 0x5c, 0x92, 0xe7, 0xa0, 0xff, 0x5c, 0x27, 0x34, 0x76, 0x06, 0xec, 0x37, 0xbe,
|
||||
0xb9, 0x19, 0x5c, 0x6b, 0xee, 0x15, 0x8c, 0xf8, 0xf7, 0x03, 0x9a, 0x24, 0x3e, 0x79, 0x0b, 0x46,
|
||||
0xc5, 0xb6, 0xcc, 0x1e, 0x4d, 0x9f, 0xf5, 0x9b, 0xf0, 0x43, 0x11, 0xbb, 0xbf, 0x2d, 0xd0, 0xe7,
|
||||
0xeb, 0xa2, 0x68, 0x88, 0x07, 0x7a, 0x46, 0xd3, 0xb4, 0x6d, 0xdb, 0x69, 0x0d, 0x96, 0x7a, 0x01,
|
||||
0x46, 0xbc, 0x5f, 0x8e, 0x21, 0x5f, 0xd5, 0x65, 0xd9, 0x38, 0x03, 0x15, 0xbf, 0xc4, 0x48, 0xf0,
|
||||
0x0c, 0x43, 0x3e, 0x8f, 0x76, 0xbb, 0xc6, 0x19, 0xaa, 0xf8, 0x05, 0x46, 0x82, 0x67, 0x18, 0xf2,
|
||||
0x11, 0xdd, 0x6c, 0x1a, 0xe7, 0x44, 0xc5, 0xdf, 0x62, 0x24, 0x78, 0x86, 0x31, 0x3e, 0xcf, 0x93,
|
||||
0xc6, 0xd1, 0x95, 0x3c, 0x46, 0x2d, 0x8f, 0x6b, 0xe4, 0xe3, 0x8c, 0xa6, 0x8d, 0x63, 0xa8, 0xf8,
|
||||
0x3b, 0x8c, 0x04, 0xcf, 0x30, 0xf2, 0x11, 0xac, 0xca, 0x9f, 0xf2, 0x12, 0x26, 0x53, 0xce, 0xf7,
|
||||
0x8e, 0x2c, 0x52, 0x6e, 0x3d, 0xc1, 0x4c, 0xbc, 0xfa, 0xc0, 0x45, 0x4b, 0x29, 0x8a, 0xb4, 0x15,
|
||||
0xc5, 0x16, 0x45, 0xda, 0x56, 0xb4, 0x55, 0xe2, 0xaa, 0x5f, 0x91, 0x4a, 0x15, 0x69, 0x5b, 0x11,
|
||||
0x94, 0x62, 0xbf, 0x62, 0x0b, 0x4f, 0xae, 0x01, 0xba, 0x87, 0x96, 0xe7, 0x6f, 0xa8, 0x98, 0x3f,
|
||||
0x5d, 0x9a, 0x3f, 0x34, 0xbb, 0x27, 0xff, 0x97, 0xc9, 0x9d, 0xdc, 0x03, 0x74, 0x8f, 0x2f, 0x9b,
|
||||
0x3a, 0x37, 0x5f, 0xcb, 0xa6, 0x62, 0x92, 0xfb, 0x4d, 0x74, 0x73, 0x71, 0xac, 0x7d, 0x7b, 0xdf,
|
||||
0x7c, 0xba, 0x10, 0xd9, 0xb4, 0x14, 0xa6, 0xb5, 0xd7, 0x7e, 0x37, 0x2b, 0x8a, 0x83, 0xf7, 0xda,
|
||||
0xff, 0xbf, 0x6b, 0x3f, 0xa0, 0x69, 0x5c, 0xae, 0x13, 0xf9, 0x53, 0x9f, 0xe1, 0xac, 0x37, 0x43,
|
||||
0x8a, 0xcb, 0x38, 0xdc, 0x07, 0xca, 0xf2, 0xab, 0x1e, 0x3b, 0xfe, 0xbe, 0xbc, 0x3a, 0x54, 0xf9,
|
||||
0xec, 0x6f, 0xe4, 0x43, 0x95, 0x4f, 0x8e, 0xc8, 0xef, 0xde, 0x83, 0x29, 0x6e, 0x82, 0x8c, 0xc0,
|
||||
0x5c, 0x05, 0x5f, 0x83, 0xc5, 0xb7, 0x60, 0xfc, 0x1f, 0x01, 0x30, 0x66, 0xe1, 0xec, 0xf6, 0xfe,
|
||||
0xcb, 0x58, 0x23, 0x36, 0xe8, 0xe1, 0x62, 0x3e, 0x0b, 0xc6, 0x83, 0xc8, 0x60, 0x7f, 0xe0, 0xfe,
|
||||
0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x84, 0x34, 0xaf, 0xdb, 0x05, 0x00, 0x00,
|
||||
}
|
69
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto
generated
vendored
Normal file
69
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
// Go support for Protocol Buffers - Google's data interchange format
|
||||
//
|
||||
// Copyright 2015 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.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package jsonpb;
|
||||
|
||||
message Simple3 {
|
||||
double dub = 1;
|
||||
}
|
||||
|
||||
message SimpleSlice3 {
|
||||
repeated string slices = 1;
|
||||
}
|
||||
|
||||
message SimpleMap3 {
|
||||
map<string,string> stringy = 1;
|
||||
}
|
||||
|
||||
message SimpleNull3 {
|
||||
Simple3 simple = 1;
|
||||
}
|
||||
|
||||
enum Numeral {
|
||||
UNKNOWN = 0;
|
||||
ARABIC = 1;
|
||||
ROMAN = 2;
|
||||
}
|
||||
|
||||
message Mappy {
|
||||
map<int64, int32> nummy = 1;
|
||||
map<string, string> strry = 2;
|
||||
map<int32, Simple3> objjy = 3;
|
||||
map<int64, string> buggy = 4;
|
||||
map<bool, bool> booly = 5;
|
||||
map<string, Numeral> enumy = 6;
|
||||
map<int32, bool> s32booly = 7;
|
||||
map<int64, bool> s64booly = 8;
|
||||
map<uint32, bool> u32booly = 9;
|
||||
map<uint64, bool> u64booly = 10;
|
||||
}
|
1357
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go
generated
vendored
Normal file
1357
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
183
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto
generated
vendored
Normal file
183
vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto
generated
vendored
Normal file
@ -0,0 +1,183 @@
|
||||
// Go support for Protocol Buffers - Google's data interchange format
|
||||
//
|
||||
// Copyright 2015 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.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
package jsonpb;
|
||||
|
||||
import weak "gogoproto/gogo.proto";
|
||||
|
||||
// Test message for holding primitive types.
|
||||
message Simple {
|
||||
optional bool o_bool = 1;
|
||||
optional int32 o_int32 = 2;
|
||||
optional int32 o_int32_str = 3;
|
||||
optional int64 o_int64 = 4;
|
||||
optional int64 o_int64_str = 5;
|
||||
optional uint32 o_uint32 = 6;
|
||||
optional uint32 o_uint32_str = 7;
|
||||
optional uint64 o_uint64 = 8;
|
||||
optional uint64 o_uint64_str = 9;
|
||||
optional sint32 o_sint32 = 10;
|
||||
optional sint32 o_sint32_str = 11;
|
||||
optional sint64 o_sint64 = 12;
|
||||
optional sint64 o_sint64_str = 13;
|
||||
optional float o_float = 14;
|
||||
optional float o_float_str = 15;
|
||||
optional double o_double = 16;
|
||||
optional double o_double_str = 17;
|
||||
optional string o_string = 18;
|
||||
optional bytes o_bytes = 19;
|
||||
optional bytes o_cast_bytes = 20 [(gogoproto.casttype) = "Bytes"];
|
||||
}
|
||||
|
||||
// Test message for holding special non-finites primitives.
|
||||
message NonFinites {
|
||||
optional float f_nan = 1;
|
||||
optional float f_pinf = 2;
|
||||
optional float f_ninf = 3;
|
||||
optional double d_nan = 4;
|
||||
optional double d_pinf = 5;
|
||||
optional double d_ninf = 6;
|
||||
}
|
||||
|
||||
|
||||
// Test message for holding repeated primitives.
|
||||
message Repeats {
|
||||
repeated bool r_bool = 1;
|
||||
repeated int32 r_int32 = 2;
|
||||
repeated int64 r_int64 = 3;
|
||||
repeated uint32 r_uint32 = 4;
|
||||
repeated uint64 r_uint64 = 5;
|
||||
repeated sint32 r_sint32 = 6;
|
||||
repeated sint64 r_sint64 = 7;
|
||||
repeated float r_float = 8;
|
||||
repeated double r_double = 9;
|
||||
repeated string r_string = 10;
|
||||
repeated bytes r_bytes = 11;
|
||||
}
|
||||
|
||||
// Test message for holding enums and nested messages.
|
||||
message Widget {
|
||||
enum Color {
|
||||
RED = 0;
|
||||
GREEN = 1;
|
||||
BLUE = 2;
|
||||
};
|
||||
optional Color color = 1;
|
||||
repeated Color r_color = 2;
|
||||
|
||||
optional Simple simple = 10;
|
||||
repeated Simple r_simple = 11;
|
||||
|
||||
optional Repeats repeats = 20;
|
||||
repeated Repeats r_repeats = 21;
|
||||
}
|
||||
|
||||
message Maps {
|
||||
map<int64, string> m_int64_str = 1;
|
||||
map<bool, Simple> m_bool_simple = 2;
|
||||
}
|
||||
|
||||
message MsgWithOneof {
|
||||
oneof union {
|
||||
string title = 1;
|
||||
int64 salary = 2;
|
||||
string Country = 3;
|
||||
string home_address = 4;
|
||||
MsgWithRequired msg_with_required = 5;
|
||||
}
|
||||
}
|
||||
|
||||
message Real {
|
||||
optional double value = 1;
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
||||
extend Real {
|
||||
optional string name = 124;
|
||||
}
|
||||
|
||||
message Complex {
|
||||
extend Real {
|
||||
optional Complex real_extension = 123;
|
||||
}
|
||||
optional double imaginary = 1;
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
||||
message KnownTypes {
|
||||
optional google.protobuf.Any an = 14;
|
||||
optional google.protobuf.Duration dur = 1;
|
||||
optional google.protobuf.Struct st = 12;
|
||||
optional google.protobuf.Timestamp ts = 2;
|
||||
optional google.protobuf.ListValue lv = 15;
|
||||
optional google.protobuf.Value val = 16;
|
||||
|
||||
optional google.protobuf.DoubleValue dbl = 3;
|
||||
optional google.protobuf.FloatValue flt = 4;
|
||||
optional google.protobuf.Int64Value i64 = 5;
|
||||
optional google.protobuf.UInt64Value u64 = 6;
|
||||
optional google.protobuf.Int32Value i32 = 7;
|
||||
optional google.protobuf.UInt32Value u32 = 8;
|
||||
optional google.protobuf.BoolValue bool = 9;
|
||||
optional google.protobuf.StringValue str = 10;
|
||||
optional google.protobuf.BytesValue bytes = 11;
|
||||
}
|
||||
|
||||
// Test messages for marshaling/unmarshaling required fields.
|
||||
message MsgWithRequired {
|
||||
required string str = 1;
|
||||
}
|
||||
|
||||
message MsgWithIndirectRequired {
|
||||
optional MsgWithRequired subm = 1;
|
||||
map<string, MsgWithRequired> map_field = 2;
|
||||
repeated MsgWithRequired slice_field = 3;
|
||||
}
|
||||
|
||||
message MsgWithRequiredBytes {
|
||||
required bytes byts = 1;
|
||||
}
|
||||
|
||||
message MsgWithRequiredWKT {
|
||||
required google.protobuf.StringValue str = 1;
|
||||
}
|
||||
|
||||
extend Real {
|
||||
optional MsgWithRequired extm = 125;
|
||||
}
|
526
vendor/github.com/gogo/protobuf/plugin/compare/compare.go
generated
vendored
Normal file
526
vendor/github.com/gogo/protobuf/plugin/compare/compare.go
generated
vendored
Normal file
@ -0,0 +1,526 @@
|
||||
// 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 compare
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
"github.com/gogo/protobuf/vanity"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
*generator.Generator
|
||||
generator.PluginImports
|
||||
fmtPkg generator.Single
|
||||
bytesPkg generator.Single
|
||||
sortkeysPkg generator.Single
|
||||
protoPkg generator.Single
|
||||
}
|
||||
|
||||
func NewPlugin() *plugin {
|
||||
return &plugin{}
|
||||
}
|
||||
|
||||
func (p *plugin) Name() string {
|
||||
return "compare"
|
||||
}
|
||||
|
||||
func (p *plugin) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func (p *plugin) Generate(file *generator.FileDescriptor) {
|
||||
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||
p.fmtPkg = p.NewImport("fmt")
|
||||
p.bytesPkg = p.NewImport("bytes")
|
||||
p.sortkeysPkg = p.NewImport("github.com/gogo/protobuf/sortkeys")
|
||||
p.protoPkg = p.NewImport("github.com/gogo/protobuf/proto")
|
||||
|
||||
for _, msg := range file.Messages() {
|
||||
if msg.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
if gogoproto.HasCompare(file.FileDescriptorProto, msg.DescriptorProto) {
|
||||
p.generateMessage(file, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) generateNullableField(fieldname string) {
|
||||
p.P(`if this.`, fieldname, ` != nil && that1.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`if *this.`, fieldname, ` != *that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
p.P(`if *this.`, fieldname, ` < *that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`} else if that1.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
func (p *plugin) generateMsgNullAndTypeCheck(ccTypeName string) {
|
||||
p.P(`if that == nil {`)
|
||||
p.In()
|
||||
p.P(`if this == nil {`)
|
||||
p.In()
|
||||
p.P(`return 0`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(``)
|
||||
p.P(`that1, ok := that.(*`, ccTypeName, `)`)
|
||||
p.P(`if !ok {`)
|
||||
p.In()
|
||||
p.P(`that2, ok := that.(`, ccTypeName, `)`)
|
||||
p.P(`if ok {`)
|
||||
p.In()
|
||||
p.P(`that1 = &that2`)
|
||||
p.Out()
|
||||
p.P(`} else {`)
|
||||
p.In()
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`if that1 == nil {`)
|
||||
p.In()
|
||||
p.P(`if this == nil {`)
|
||||
p.In()
|
||||
p.P(`return 0`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`} else if this == nil {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
func (p *plugin) generateField(file *generator.FileDescriptor, message *generator.Descriptor, field *descriptor.FieldDescriptorProto) {
|
||||
proto3 := gogoproto.IsProto3(file.FileDescriptorProto)
|
||||
fieldname := p.GetOneOfFieldName(message, field)
|
||||
repeated := field.IsRepeated()
|
||||
ctype := gogoproto.IsCustomType(field)
|
||||
nullable := gogoproto.IsNullable(field)
|
||||
// oneof := field.OneofIndex != nil
|
||||
if !repeated {
|
||||
if ctype {
|
||||
if nullable {
|
||||
p.P(`if that1.`, fieldname, ` == nil {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if this.`, fieldname, ` == nil {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`} else if c := this.`, fieldname, `.Compare(*that1.`, fieldname, `); c != 0 {`)
|
||||
} else {
|
||||
p.P(`if c := this.`, fieldname, `.Compare(that1.`, fieldname, `); c != 0 {`)
|
||||
}
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
if field.IsMessage() || p.IsGroup(field) {
|
||||
if nullable {
|
||||
p.P(`if c := this.`, fieldname, `.Compare(that1.`, fieldname, `); c != 0 {`)
|
||||
} else {
|
||||
p.P(`if c := this.`, fieldname, `.Compare(&that1.`, fieldname, `); c != 0 {`)
|
||||
}
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if field.IsBytes() {
|
||||
p.P(`if c := `, p.bytesPkg.Use(), `.Compare(this.`, fieldname, `, that1.`, fieldname, `); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if field.IsString() {
|
||||
if nullable && !proto3 {
|
||||
p.generateNullableField(fieldname)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, ` != that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, ` < that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else if field.IsBool() {
|
||||
if nullable && !proto3 {
|
||||
p.P(`if this.`, fieldname, ` != nil && that1.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`if *this.`, fieldname, ` != *that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
p.P(`if !*this.`, fieldname, ` {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`} else if that1.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, ` != that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
p.P(`if !this.`, fieldname, ` {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else {
|
||||
if nullable && !proto3 {
|
||||
p.generateNullableField(fieldname)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, ` != that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, ` < that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.P(`if len(this.`, fieldname, `) != len(that1.`, fieldname, `) {`)
|
||||
p.In()
|
||||
p.P(`if len(this.`, fieldname, `) < len(that1.`, fieldname, `) {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`for i := range this.`, fieldname, ` {`)
|
||||
p.In()
|
||||
if ctype {
|
||||
p.P(`if c := this.`, fieldname, `[i].Compare(that1.`, fieldname, `[i]); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
if p.IsMap(field) {
|
||||
m := p.GoMapType(nil, field)
|
||||
valuegoTyp, _ := p.GoType(nil, m.ValueField)
|
||||
valuegoAliasTyp, _ := p.GoType(nil, m.ValueAliasField)
|
||||
nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp)
|
||||
|
||||
mapValue := m.ValueAliasField
|
||||
if mapValue.IsMessage() || p.IsGroup(mapValue) {
|
||||
if nullable && valuegoTyp == valuegoAliasTyp {
|
||||
p.P(`if c := this.`, fieldname, `[i].Compare(that1.`, fieldname, `[i]); c != 0 {`)
|
||||
} else {
|
||||
// Compare() has a pointer receiver, but map value is a value type
|
||||
a := `this.` + fieldname + `[i]`
|
||||
b := `that1.` + fieldname + `[i]`
|
||||
if valuegoTyp != valuegoAliasTyp {
|
||||
// cast back to the type that has the generated methods on it
|
||||
a = `(` + valuegoTyp + `)(` + a + `)`
|
||||
b = `(` + valuegoTyp + `)(` + b + `)`
|
||||
}
|
||||
p.P(`a := `, a)
|
||||
p.P(`b := `, b)
|
||||
if nullable {
|
||||
p.P(`if c := a.Compare(b); c != 0 {`)
|
||||
} else {
|
||||
p.P(`if c := (&a).Compare(&b); c != 0 {`)
|
||||
}
|
||||
}
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if mapValue.IsBytes() {
|
||||
p.P(`if c := `, p.bytesPkg.Use(), `.Compare(this.`, fieldname, `[i], that1.`, fieldname, `[i]); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if mapValue.IsString() {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, `[i] < that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, `[i] < that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else if field.IsMessage() || p.IsGroup(field) {
|
||||
if nullable {
|
||||
p.P(`if c := this.`, fieldname, `[i].Compare(that1.`, fieldname, `[i]); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.P(`if c := this.`, fieldname, `[i].Compare(&that1.`, fieldname, `[i]); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else if field.IsBytes() {
|
||||
p.P(`if c := `, p.bytesPkg.Use(), `.Compare(this.`, fieldname, `[i], that1.`, fieldname, `[i]); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if field.IsString() {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, `[i] < that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if field.IsBool() {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`if !this.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, `[i] < that1.`, fieldname, `[i] {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) generateMessage(file *generator.FileDescriptor, message *generator.Descriptor) {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
p.P(`func (this *`, ccTypeName, `) Compare(that interface{}) int {`)
|
||||
p.In()
|
||||
p.generateMsgNullAndTypeCheck(ccTypeName)
|
||||
oneofs := make(map[string]struct{})
|
||||
|
||||
for _, field := range message.Field {
|
||||
oneof := field.OneofIndex != nil
|
||||
if oneof {
|
||||
fieldname := p.GetFieldName(message, field)
|
||||
if _, ok := oneofs[fieldname]; ok {
|
||||
continue
|
||||
} else {
|
||||
oneofs[fieldname] = struct{}{}
|
||||
}
|
||||
p.P(`if that1.`, fieldname, ` == nil {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if this.`, fieldname, ` == nil {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`} else if c := this.`, fieldname, `.Compare(that1.`, fieldname, `); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.generateField(file, message, field)
|
||||
}
|
||||
}
|
||||
if message.DescriptorProto.HasExtension() {
|
||||
if gogoproto.HasExtensionsMap(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
p.P(`thismap := `, p.protoPkg.Use(), `.GetUnsafeExtensionsMap(this)`)
|
||||
p.P(`thatmap := `, p.protoPkg.Use(), `.GetUnsafeExtensionsMap(that1)`)
|
||||
p.P(`extkeys := make([]int32, 0, len(thismap)+len(thatmap))`)
|
||||
p.P(`for k, _ := range thismap {`)
|
||||
p.In()
|
||||
p.P(`extkeys = append(extkeys, k)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`for k, _ := range thatmap {`)
|
||||
p.In()
|
||||
p.P(`if _, ok := thismap[k]; !ok {`)
|
||||
p.In()
|
||||
p.P(`extkeys = append(extkeys, k)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(p.sortkeysPkg.Use(), `.Int32s(extkeys)`)
|
||||
p.P(`for _, k := range extkeys {`)
|
||||
p.In()
|
||||
p.P(`if v, ok := thismap[k]; ok {`)
|
||||
p.In()
|
||||
p.P(`if v2, ok := thatmap[k]; ok {`)
|
||||
p.In()
|
||||
p.P(`if c := v.Compare(&v2); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else {`)
|
||||
p.In()
|
||||
p.P(`return 1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else {`)
|
||||
p.In()
|
||||
p.P(`return -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
fieldname := "XXX_extensions"
|
||||
p.P(`if c := `, p.bytesPkg.Use(), `.Compare(this.`, fieldname, `, that1.`, fieldname, `); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
if gogoproto.HasUnrecognized(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
fieldname := "XXX_unrecognized"
|
||||
p.P(`if c := `, p.bytesPkg.Use(), `.Compare(this.`, fieldname, `, that1.`, fieldname, `); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`return c`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
p.P(`return 0`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
//Generate Compare methods for oneof fields
|
||||
m := proto.Clone(message.DescriptorProto).(*descriptor.DescriptorProto)
|
||||
for _, field := range m.Field {
|
||||
oneof := field.OneofIndex != nil
|
||||
if !oneof {
|
||||
continue
|
||||
}
|
||||
ccTypeName := p.OneOfTypeName(message, field)
|
||||
p.P(`func (this *`, ccTypeName, `) Compare(that interface{}) int {`)
|
||||
p.In()
|
||||
|
||||
p.generateMsgNullAndTypeCheck(ccTypeName)
|
||||
vanity.TurnOffNullableForNativeTypes(field)
|
||||
p.generateField(file, message, field)
|
||||
|
||||
p.P(`return 0`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewPlugin())
|
||||
}
|
118
vendor/github.com/gogo/protobuf/plugin/compare/comparetest.go
generated
vendored
Normal file
118
vendor/github.com/gogo/protobuf/plugin/compare/comparetest.go
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
// 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 compare
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/plugin/testgen"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type test struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewTest(g *generator.Generator) testgen.TestPlugin {
|
||||
return &test{g}
|
||||
}
|
||||
|
||||
func (p *test) Generate(imports generator.PluginImports, file *generator.FileDescriptor) bool {
|
||||
used := false
|
||||
randPkg := imports.NewImport("math/rand")
|
||||
timePkg := imports.NewImport("time")
|
||||
testingPkg := imports.NewImport("testing")
|
||||
protoPkg := imports.NewImport("github.com/gogo/protobuf/proto")
|
||||
unsafePkg := imports.NewImport("unsafe")
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
protoPkg = imports.NewImport("github.com/golang/protobuf/proto")
|
||||
}
|
||||
for _, message := range file.Messages() {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
if !gogoproto.HasCompare(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
|
||||
if gogoproto.HasTestGen(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
used = true
|
||||
hasUnsafe := gogoproto.IsUnsafeMarshaler(file.FileDescriptorProto, message.DescriptorProto) ||
|
||||
gogoproto.IsUnsafeUnmarshaler(file.FileDescriptorProto, message.DescriptorProto)
|
||||
p.P(`func Test`, ccTypeName, `Compare(t *`, testingPkg.Use(), `.T) {`)
|
||||
p.In()
|
||||
if hasUnsafe {
|
||||
p.P(`var bigendian uint32 = 0x01020304`)
|
||||
p.P(`if *(*byte)(`, unsafePkg.Use(), `.Pointer(&bigendian)) == 1 {`)
|
||||
p.In()
|
||||
p.P(`t.Skip("unsafe does not work on big endian architectures")`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
p.P(`popr := `, randPkg.Use(), `.New(`, randPkg.Use(), `.NewSource(`, timePkg.Use(), `.Now().UnixNano()))`)
|
||||
p.P(`p := NewPopulated`, ccTypeName, `(popr, false)`)
|
||||
p.P(`dAtA, err := `, protoPkg.Use(), `.Marshal(p)`)
|
||||
p.P(`if err != nil {`)
|
||||
p.In()
|
||||
p.P(`panic(err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`msg := &`, ccTypeName, `{}`)
|
||||
p.P(`if err := `, protoPkg.Use(), `.Unmarshal(dAtA, msg); err != nil {`)
|
||||
p.In()
|
||||
p.P(`panic(err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`if c := p.Compare(msg); c != 0 {`)
|
||||
p.In()
|
||||
p.P(`t.Fatalf("%#v !Compare %#v, since %d", msg, p, c)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`p2 := NewPopulated`, ccTypeName, `(popr, false)`)
|
||||
p.P(`c := p.Compare(p2)`)
|
||||
p.P(`c2 := p2.Compare(p)`)
|
||||
p.P(`if c != (-1 * c2) {`)
|
||||
p.In()
|
||||
p.P(`t.Errorf("p.Compare(p2) = %d", c)`)
|
||||
p.P(`t.Errorf("p2.Compare(p) = %d", c2)`)
|
||||
p.P(`t.Errorf("p = %#v", p)`)
|
||||
p.P(`t.Errorf("p2 = %#v", p2)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
}
|
||||
return used
|
||||
}
|
||||
|
||||
func init() {
|
||||
testgen.RegisterTestPlugin(NewTest)
|
||||
}
|
133
vendor/github.com/gogo/protobuf/plugin/defaultcheck/defaultcheck.go
generated
vendored
Normal file
133
vendor/github.com/gogo/protobuf/plugin/defaultcheck/defaultcheck.go
generated
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The defaultcheck plugin is used to check whether nullable is not used incorrectly.
|
||||
For instance:
|
||||
An error is caused if a nullable field:
|
||||
- has a default value,
|
||||
- is an enum which does not start at zero,
|
||||
- is used for an extension,
|
||||
- is used for a native proto3 type,
|
||||
- is used for a repeated native type.
|
||||
|
||||
An error is also caused if a field with a default value is used in a message:
|
||||
- which is a face.
|
||||
- without getters.
|
||||
|
||||
It is enabled by the following extensions:
|
||||
|
||||
- nullable
|
||||
|
||||
For incorrect usage of nullable with tests see:
|
||||
|
||||
github.com/gogo/protobuf/test/nullableconflict
|
||||
|
||||
*/
|
||||
package defaultcheck
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
"os"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewPlugin() *plugin {
|
||||
return &plugin{}
|
||||
}
|
||||
|
||||
func (p *plugin) Name() string {
|
||||
return "defaultcheck"
|
||||
}
|
||||
|
||||
func (p *plugin) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func (p *plugin) Generate(file *generator.FileDescriptor) {
|
||||
proto3 := gogoproto.IsProto3(file.FileDescriptorProto)
|
||||
for _, msg := range file.Messages() {
|
||||
getters := gogoproto.HasGoGetters(file.FileDescriptorProto, msg.DescriptorProto)
|
||||
face := gogoproto.IsFace(file.FileDescriptorProto, msg.DescriptorProto)
|
||||
for _, field := range msg.GetField() {
|
||||
if len(field.GetDefaultValue()) > 0 {
|
||||
if !getters {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v cannot have a default value and not have a getter method", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
if face {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v cannot have a default value be in a face", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if gogoproto.IsNullable(field) {
|
||||
continue
|
||||
}
|
||||
if len(field.GetDefaultValue()) > 0 {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v cannot be non-nullable and have a default value", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
if !field.IsMessage() && !gogoproto.IsCustomType(field) {
|
||||
if field.IsRepeated() {
|
||||
fmt.Fprintf(os.Stderr, "WARNING: field %v.%v is a repeated non-nullable native type, nullable=false has no effect\n", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
} else if proto3 {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v is a native type and in proto3 syntax with nullable=false there exists conflicting implementations when encoding zero values", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
if field.IsBytes() {
|
||||
fmt.Fprintf(os.Stderr, "WARNING: field %v.%v is a non-nullable bytes type, nullable=false has no effect\n", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
}
|
||||
}
|
||||
if !field.IsEnum() {
|
||||
continue
|
||||
}
|
||||
enum := p.ObjectNamed(field.GetTypeName()).(*generator.EnumDescriptor)
|
||||
if len(enum.Value) == 0 || enum.Value[0].GetNumber() != 0 {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v cannot be non-nullable and be an enum type %v which does not start with zero", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name), enum.GetName())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, e := range file.GetExtension() {
|
||||
if !gogoproto.IsNullable(e) {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: extended field %v cannot be nullable %v", generator.CamelCase(e.GetName()), generator.CamelCase(*e.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) GenerateImports(*generator.FileDescriptor) {}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewPlugin())
|
||||
}
|
201
vendor/github.com/gogo/protobuf/plugin/description/description.go
generated
vendored
Normal file
201
vendor/github.com/gogo/protobuf/plugin/description/description.go
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The description (experimental) plugin generates a Description method for each message.
|
||||
The Description method returns a populated google_protobuf.FileDescriptorSet struct.
|
||||
This contains the description of the files used to generate this message.
|
||||
|
||||
It is enabled by the following extensions:
|
||||
|
||||
- description
|
||||
- description_all
|
||||
|
||||
The description plugin also generates a test given it is enabled using one of the following extensions:
|
||||
|
||||
- testgen
|
||||
- testgen_all
|
||||
|
||||
Let us look at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/example.proto
|
||||
|
||||
Btw all the output can be seen at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/*
|
||||
|
||||
The following message:
|
||||
|
||||
message B {
|
||||
option (gogoproto.description) = true;
|
||||
optional A A = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
repeated bytes G = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
given to the description plugin, will generate the following code:
|
||||
|
||||
func (this *B) Description() (desc *google_protobuf.FileDescriptorSet) {
|
||||
return ExampleDescription()
|
||||
}
|
||||
|
||||
and the following test code:
|
||||
|
||||
func TestDescription(t *testing9.T) {
|
||||
ExampleDescription()
|
||||
}
|
||||
|
||||
The hope is to use this struct in some way instead of reflect.
|
||||
This package is subject to change, since a use has not been figured out yet.
|
||||
|
||||
*/
|
||||
package description
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
*generator.Generator
|
||||
generator.PluginImports
|
||||
}
|
||||
|
||||
func NewPlugin() *plugin {
|
||||
return &plugin{}
|
||||
}
|
||||
|
||||
func (p *plugin) Name() string {
|
||||
return "description"
|
||||
}
|
||||
|
||||
func (p *plugin) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func (p *plugin) Generate(file *generator.FileDescriptor) {
|
||||
used := false
|
||||
localName := generator.FileName(file)
|
||||
|
||||
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||
descriptorPkg := p.NewImport("github.com/gogo/protobuf/protoc-gen-gogo/descriptor")
|
||||
protoPkg := p.NewImport("github.com/gogo/protobuf/proto")
|
||||
gzipPkg := p.NewImport("compress/gzip")
|
||||
bytesPkg := p.NewImport("bytes")
|
||||
ioutilPkg := p.NewImport("io/ioutil")
|
||||
|
||||
for _, message := range file.Messages() {
|
||||
if !gogoproto.HasDescription(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
used = true
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
p.P(`func (this *`, ccTypeName, `) Description() (desc *`, descriptorPkg.Use(), `.FileDescriptorSet) {`)
|
||||
p.In()
|
||||
p.P(`return `, localName, `Description()`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
if used {
|
||||
|
||||
p.P(`func `, localName, `Description() (desc *`, descriptorPkg.Use(), `.FileDescriptorSet) {`)
|
||||
p.In()
|
||||
//Don't generate SourceCodeInfo, since it will create too much code.
|
||||
|
||||
ss := make([]*descriptor.SourceCodeInfo, 0)
|
||||
for _, f := range p.Generator.AllFiles().GetFile() {
|
||||
ss = append(ss, f.SourceCodeInfo)
|
||||
f.SourceCodeInfo = nil
|
||||
}
|
||||
b, err := proto.Marshal(p.Generator.AllFiles())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for i, f := range p.Generator.AllFiles().GetFile() {
|
||||
f.SourceCodeInfo = ss[i]
|
||||
}
|
||||
p.P(`d := &`, descriptorPkg.Use(), `.FileDescriptorSet{}`)
|
||||
var buf bytes.Buffer
|
||||
w, _ := gzip.NewWriterLevel(&buf, gzip.BestCompression)
|
||||
w.Write(b)
|
||||
w.Close()
|
||||
b = buf.Bytes()
|
||||
p.P("var gzipped = []byte{")
|
||||
p.In()
|
||||
p.P("// ", len(b), " bytes of a gzipped FileDescriptorSet")
|
||||
for len(b) > 0 {
|
||||
n := 16
|
||||
if n > len(b) {
|
||||
n = len(b)
|
||||
}
|
||||
|
||||
s := ""
|
||||
for _, c := range b[:n] {
|
||||
s += fmt.Sprintf("0x%02x,", c)
|
||||
}
|
||||
p.P(s)
|
||||
|
||||
b = b[n:]
|
||||
}
|
||||
p.Out()
|
||||
p.P("}")
|
||||
p.P(`r := `, bytesPkg.Use(), `.NewReader(gzipped)`)
|
||||
p.P(`gzipr, err := `, gzipPkg.Use(), `.NewReader(r)`)
|
||||
p.P(`if err != nil {`)
|
||||
p.In()
|
||||
p.P(`panic(err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`ungzipped, err := `, ioutilPkg.Use(), `.ReadAll(gzipr)`)
|
||||
p.P(`if err != nil {`)
|
||||
p.In()
|
||||
p.P(`panic(err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`if err := `, protoPkg.Use(), `.Unmarshal(ungzipped, d); err != nil {`)
|
||||
p.In()
|
||||
p.P(`panic(err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return d`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewPlugin())
|
||||
}
|
73
vendor/github.com/gogo/protobuf/plugin/description/descriptiontest.go
generated
vendored
Normal file
73
vendor/github.com/gogo/protobuf/plugin/description/descriptiontest.go
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
// 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 description
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/plugin/testgen"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type test struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewTest(g *generator.Generator) testgen.TestPlugin {
|
||||
return &test{g}
|
||||
}
|
||||
|
||||
func (p *test) Generate(imports generator.PluginImports, file *generator.FileDescriptor) bool {
|
||||
used := false
|
||||
testingPkg := imports.NewImport("testing")
|
||||
for _, message := range file.Messages() {
|
||||
if !gogoproto.HasDescription(file.FileDescriptorProto, message.DescriptorProto) ||
|
||||
!gogoproto.HasTestGen(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
used = true
|
||||
}
|
||||
|
||||
if used {
|
||||
localName := generator.FileName(file)
|
||||
p.P(`func Test`, localName, `Description(t *`, testingPkg.Use(), `.T) {`)
|
||||
p.In()
|
||||
p.P(localName, `Description()`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
}
|
||||
return used
|
||||
}
|
||||
|
||||
func init() {
|
||||
testgen.RegisterTestPlugin(NewTest)
|
||||
}
|
200
vendor/github.com/gogo/protobuf/plugin/embedcheck/embedcheck.go
generated
vendored
Normal file
200
vendor/github.com/gogo/protobuf/plugin/embedcheck/embedcheck.go
generated
vendored
Normal file
@ -0,0 +1,200 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The embedcheck plugin is used to check whether embed is not used incorrectly.
|
||||
For instance:
|
||||
An embedded message has a generated string method, but the is a member of a message which does not.
|
||||
This causes a warning.
|
||||
An error is caused by a namespace conflict.
|
||||
|
||||
It is enabled by the following extensions:
|
||||
|
||||
- embed
|
||||
- embed_all
|
||||
|
||||
For incorrect usage of embed with tests see:
|
||||
|
||||
github.com/gogo/protobuf/test/embedconflict
|
||||
|
||||
*/
|
||||
package embedcheck
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewPlugin() *plugin {
|
||||
return &plugin{}
|
||||
}
|
||||
|
||||
func (p *plugin) Name() string {
|
||||
return "embedcheck"
|
||||
}
|
||||
|
||||
func (p *plugin) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
var overwriters []map[string]gogoproto.EnableFunc = []map[string]gogoproto.EnableFunc{
|
||||
{
|
||||
"stringer": gogoproto.IsStringer,
|
||||
},
|
||||
{
|
||||
"gostring": gogoproto.HasGoString,
|
||||
},
|
||||
{
|
||||
"equal": gogoproto.HasEqual,
|
||||
},
|
||||
{
|
||||
"verboseequal": gogoproto.HasVerboseEqual,
|
||||
},
|
||||
{
|
||||
"size": gogoproto.IsSizer,
|
||||
"protosizer": gogoproto.IsProtoSizer,
|
||||
},
|
||||
{
|
||||
"unmarshaler": gogoproto.IsUnmarshaler,
|
||||
"unsafe_unmarshaler": gogoproto.IsUnsafeUnmarshaler,
|
||||
},
|
||||
{
|
||||
"marshaler": gogoproto.IsMarshaler,
|
||||
"unsafe_marshaler": gogoproto.IsUnsafeMarshaler,
|
||||
},
|
||||
}
|
||||
|
||||
func (p *plugin) Generate(file *generator.FileDescriptor) {
|
||||
for _, msg := range file.Messages() {
|
||||
for _, os := range overwriters {
|
||||
possible := true
|
||||
for _, overwriter := range os {
|
||||
if overwriter(file.FileDescriptorProto, msg.DescriptorProto) {
|
||||
possible = false
|
||||
}
|
||||
}
|
||||
if possible {
|
||||
p.checkOverwrite(msg, os)
|
||||
}
|
||||
}
|
||||
p.checkNameSpace(msg)
|
||||
for _, field := range msg.GetField() {
|
||||
if gogoproto.IsEmbed(field) && gogoproto.IsCustomName(field) {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v with custom name %v cannot be embedded", *field.Name, gogoproto.GetCustomName(field))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
p.checkRepeated(msg)
|
||||
}
|
||||
for _, e := range file.GetExtension() {
|
||||
if gogoproto.IsEmbed(e) {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: extended field %v cannot be embedded", generator.CamelCase(*e.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) checkNameSpace(message *generator.Descriptor) map[string]bool {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
names := make(map[string]bool)
|
||||
for _, field := range message.Field {
|
||||
fieldname := generator.CamelCase(*field.Name)
|
||||
if field.IsMessage() && gogoproto.IsEmbed(field) {
|
||||
desc := p.ObjectNamed(field.GetTypeName())
|
||||
moreNames := p.checkNameSpace(desc.(*generator.Descriptor))
|
||||
for another := range moreNames {
|
||||
if names[another] {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: duplicate embedded fieldname %v in type %v\n", fieldname, ccTypeName)
|
||||
os.Exit(1)
|
||||
}
|
||||
names[another] = true
|
||||
}
|
||||
} else {
|
||||
if names[fieldname] {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: duplicate embedded fieldname %v in type %v\n", fieldname, ccTypeName)
|
||||
os.Exit(1)
|
||||
}
|
||||
names[fieldname] = true
|
||||
}
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
func (p *plugin) checkOverwrite(message *generator.Descriptor, enablers map[string]gogoproto.EnableFunc) {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
names := []string{}
|
||||
for name := range enablers {
|
||||
names = append(names, name)
|
||||
}
|
||||
for _, field := range message.Field {
|
||||
if field.IsMessage() && gogoproto.IsEmbed(field) {
|
||||
fieldname := generator.CamelCase(*field.Name)
|
||||
desc := p.ObjectNamed(field.GetTypeName())
|
||||
msg := desc.(*generator.Descriptor)
|
||||
for errStr, enabled := range enablers {
|
||||
if enabled(msg.File().FileDescriptorProto, msg.DescriptorProto) {
|
||||
fmt.Fprintf(os.Stderr, "WARNING: found non-%v %v with embedded %v %v\n", names, ccTypeName, errStr, fieldname)
|
||||
}
|
||||
}
|
||||
p.checkOverwrite(msg, enablers)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) checkRepeated(message *generator.Descriptor) {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
for _, field := range message.Field {
|
||||
if !gogoproto.IsEmbed(field) {
|
||||
continue
|
||||
}
|
||||
if field.IsBytes() {
|
||||
fieldname := generator.CamelCase(*field.Name)
|
||||
fmt.Fprintf(os.Stderr, "ERROR: found embedded bytes field %s in message %s\n", fieldname, ccTypeName)
|
||||
os.Exit(1)
|
||||
}
|
||||
if !field.IsRepeated() {
|
||||
continue
|
||||
}
|
||||
fieldname := generator.CamelCase(*field.Name)
|
||||
fmt.Fprintf(os.Stderr, "ERROR: found repeated embedded field %s in message %s\n", fieldname, ccTypeName)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) GenerateImports(*generator.FileDescriptor) {}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewPlugin())
|
||||
}
|
104
vendor/github.com/gogo/protobuf/plugin/enumstringer/enumstringer.go
generated
vendored
Normal file
104
vendor/github.com/gogo/protobuf/plugin/enumstringer/enumstringer.go
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The enumstringer (experimental) plugin generates a String method for each enum.
|
||||
|
||||
It is enabled by the following extensions:
|
||||
|
||||
- enum_stringer
|
||||
- enum_stringer_all
|
||||
|
||||
This package is subject to change.
|
||||
|
||||
*/
|
||||
package enumstringer
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type enumstringer struct {
|
||||
*generator.Generator
|
||||
generator.PluginImports
|
||||
atleastOne bool
|
||||
localName string
|
||||
}
|
||||
|
||||
func NewEnumStringer() *enumstringer {
|
||||
return &enumstringer{}
|
||||
}
|
||||
|
||||
func (p *enumstringer) Name() string {
|
||||
return "enumstringer"
|
||||
}
|
||||
|
||||
func (p *enumstringer) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func (p *enumstringer) Generate(file *generator.FileDescriptor) {
|
||||
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||
p.atleastOne = false
|
||||
|
||||
p.localName = generator.FileName(file)
|
||||
|
||||
strconvPkg := p.NewImport("strconv")
|
||||
|
||||
for _, enum := range file.Enums() {
|
||||
if !gogoproto.IsEnumStringer(file.FileDescriptorProto, enum.EnumDescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if gogoproto.IsGoEnumStringer(file.FileDescriptorProto, enum.EnumDescriptorProto) {
|
||||
panic("Go enum stringer conflicts with new enumstringer plugin: please use gogoproto.goproto_enum_stringer or gogoproto.goproto_enum_string_all and set it to false")
|
||||
}
|
||||
p.atleastOne = true
|
||||
ccTypeName := generator.CamelCaseSlice(enum.TypeName())
|
||||
p.P("func (x ", ccTypeName, ") String() string {")
|
||||
p.In()
|
||||
p.P(`s, ok := `, ccTypeName, `_name[int32(x)]`)
|
||||
p.P(`if ok {`)
|
||||
p.In()
|
||||
p.P(`return s`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return `, strconvPkg.Use(), `.Itoa(int(x))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
if !p.atleastOne {
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewEnumStringer())
|
||||
}
|
694
vendor/github.com/gogo/protobuf/plugin/equal/equal.go
generated
vendored
Normal file
694
vendor/github.com/gogo/protobuf/plugin/equal/equal.go
generated
vendored
Normal file
@ -0,0 +1,694 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The equal plugin generates an Equal and a VerboseEqual method for each message.
|
||||
These equal methods are quite obvious.
|
||||
The only difference is that VerboseEqual returns a non nil error if it is not equal.
|
||||
This error contains more detail on exactly which part of the message was not equal to the other message.
|
||||
The idea is that this is useful for debugging.
|
||||
|
||||
Equal is enabled using the following extensions:
|
||||
|
||||
- equal
|
||||
- equal_all
|
||||
|
||||
While VerboseEqual is enable dusing the following extensions:
|
||||
|
||||
- verbose_equal
|
||||
- verbose_equal_all
|
||||
|
||||
The equal plugin also generates a test given it is enabled using one of the following extensions:
|
||||
|
||||
- testgen
|
||||
- testgen_all
|
||||
|
||||
Let us look at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/example.proto
|
||||
|
||||
Btw all the output can be seen at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/*
|
||||
|
||||
The following message:
|
||||
|
||||
option (gogoproto.equal_all) = true;
|
||||
option (gogoproto.verbose_equal_all) = true;
|
||||
|
||||
message B {
|
||||
optional A A = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
repeated bytes G = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
given to the equal plugin, will generate the following code:
|
||||
|
||||
func (this *B) VerboseEqual(that interface{}) error {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt2.Errorf("that == nil && this != nil")
|
||||
}
|
||||
|
||||
that1, ok := that.(*B)
|
||||
if !ok {
|
||||
return fmt2.Errorf("that is not of type *B")
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt2.Errorf("that is type *B but is nil && this != nil")
|
||||
} else if this == nil {
|
||||
return fmt2.Errorf("that is type *B but is not nil && this == nil")
|
||||
}
|
||||
if !this.A.Equal(&that1.A) {
|
||||
return fmt2.Errorf("A this(%v) Not Equal that(%v)", this.A, that1.A)
|
||||
}
|
||||
if len(this.G) != len(that1.G) {
|
||||
return fmt2.Errorf("G this(%v) Not Equal that(%v)", len(this.G), len(that1.G))
|
||||
}
|
||||
for i := range this.G {
|
||||
if !this.G[i].Equal(that1.G[i]) {
|
||||
return fmt2.Errorf("G this[%v](%v) Not Equal that[%v](%v)", i, this.G[i], i, that1.G[i])
|
||||
}
|
||||
}
|
||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||
return fmt2.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *B) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*B)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !this.A.Equal(&that1.A) {
|
||||
return false
|
||||
}
|
||||
if len(this.G) != len(that1.G) {
|
||||
return false
|
||||
}
|
||||
for i := range this.G {
|
||||
if !this.G[i].Equal(that1.G[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
and the following test code:
|
||||
|
||||
func TestBVerboseEqual(t *testing8.T) {
|
||||
popr := math_rand8.New(math_rand8.NewSource(time8.Now().UnixNano()))
|
||||
p := NewPopulatedB(popr, false)
|
||||
dAtA, err := github_com_gogo_protobuf_proto2.Marshal(p)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
msg := &B{}
|
||||
if err := github_com_gogo_protobuf_proto2.Unmarshal(dAtA, msg); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := p.VerboseEqual(msg); err != nil {
|
||||
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
||||
}
|
||||
|
||||
*/
|
||||
package equal
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
"github.com/gogo/protobuf/vanity"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
*generator.Generator
|
||||
generator.PluginImports
|
||||
fmtPkg generator.Single
|
||||
bytesPkg generator.Single
|
||||
protoPkg generator.Single
|
||||
}
|
||||
|
||||
func NewPlugin() *plugin {
|
||||
return &plugin{}
|
||||
}
|
||||
|
||||
func (p *plugin) Name() string {
|
||||
return "equal"
|
||||
}
|
||||
|
||||
func (p *plugin) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func (p *plugin) Generate(file *generator.FileDescriptor) {
|
||||
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||
p.fmtPkg = p.NewImport("fmt")
|
||||
p.bytesPkg = p.NewImport("bytes")
|
||||
p.protoPkg = p.NewImport("github.com/gogo/protobuf/proto")
|
||||
|
||||
for _, msg := range file.Messages() {
|
||||
if msg.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
if gogoproto.HasVerboseEqual(file.FileDescriptorProto, msg.DescriptorProto) {
|
||||
p.generateMessage(file, msg, true)
|
||||
}
|
||||
if gogoproto.HasEqual(file.FileDescriptorProto, msg.DescriptorProto) {
|
||||
p.generateMessage(file, msg, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) generateNullableField(fieldname string, verbose bool) {
|
||||
p.P(`if this.`, fieldname, ` != nil && that1.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`if *this.`, fieldname, ` != *that1.`, fieldname, `{`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", *this.`, fieldname, `, *that1.`, fieldname, `)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("this.`, fieldname, ` == nil && that.`, fieldname, ` != nil")`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`} else if that1.`, fieldname, ` != nil {`)
|
||||
}
|
||||
|
||||
func (p *plugin) generateMsgNullAndTypeCheck(ccTypeName string, verbose bool) {
|
||||
p.P(`if that == nil {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`if this == nil {`)
|
||||
p.In()
|
||||
p.P(`return nil`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("that == nil && this != nil")`)
|
||||
} else {
|
||||
p.P(`return this == nil`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(``)
|
||||
p.P(`that1, ok := that.(*`, ccTypeName, `)`)
|
||||
p.P(`if !ok {`)
|
||||
p.In()
|
||||
p.P(`that2, ok := that.(`, ccTypeName, `)`)
|
||||
p.P(`if ok {`)
|
||||
p.In()
|
||||
p.P(`that1 = &that2`)
|
||||
p.Out()
|
||||
p.P(`} else {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("that is not of type *`, ccTypeName, `")`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`if that1 == nil {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`if this == nil {`)
|
||||
p.In()
|
||||
p.P(`return nil`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("that is type *`, ccTypeName, ` but is nil && this != nil")`)
|
||||
} else {
|
||||
p.P(`return this == nil`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`} else if this == nil {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("that is type *`, ccTypeName, ` but is not nil && this == nil")`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
func (p *plugin) generateField(file *generator.FileDescriptor, message *generator.Descriptor, field *descriptor.FieldDescriptorProto, verbose bool) {
|
||||
proto3 := gogoproto.IsProto3(file.FileDescriptorProto)
|
||||
fieldname := p.GetOneOfFieldName(message, field)
|
||||
repeated := field.IsRepeated()
|
||||
ctype := gogoproto.IsCustomType(field)
|
||||
nullable := gogoproto.IsNullable(field)
|
||||
isNormal := (gogoproto.IsStdDuration(field) ||
|
||||
gogoproto.IsStdDouble(field) ||
|
||||
gogoproto.IsStdFloat(field) ||
|
||||
gogoproto.IsStdInt64(field) ||
|
||||
gogoproto.IsStdUInt64(field) ||
|
||||
gogoproto.IsStdInt32(field) ||
|
||||
gogoproto.IsStdUInt32(field) ||
|
||||
gogoproto.IsStdBool(field) ||
|
||||
gogoproto.IsStdString(field))
|
||||
isBytes := gogoproto.IsStdBytes(field)
|
||||
isTimestamp := gogoproto.IsStdTime(field)
|
||||
// oneof := field.OneofIndex != nil
|
||||
if !repeated {
|
||||
if ctype || isTimestamp {
|
||||
if nullable {
|
||||
p.P(`if that1.`, fieldname, ` == nil {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("this.`, fieldname, ` != nil && that1.`, fieldname, ` == nil")`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if !this.`, fieldname, `.Equal(*that1.`, fieldname, `) {`)
|
||||
} else {
|
||||
p.P(`if !this.`, fieldname, `.Equal(that1.`, fieldname, `) {`)
|
||||
}
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if isNormal {
|
||||
if nullable {
|
||||
p.generateNullableField(fieldname, verbose)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, ` != that1.`, fieldname, `{`)
|
||||
}
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if isBytes {
|
||||
if nullable {
|
||||
p.P(`if that1.`, fieldname, ` == nil {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("this.`, fieldname, ` != nil && that1.`, fieldname, ` == nil")`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if !`, p.bytesPkg.Use(), `.Equal(*this.`, fieldname, `, *that1.`, fieldname, `) {`)
|
||||
} else {
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `, that1.`, fieldname, `) {`)
|
||||
}
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
if field.IsMessage() || p.IsGroup(field) {
|
||||
if nullable {
|
||||
p.P(`if !this.`, fieldname, `.Equal(that1.`, fieldname, `) {`)
|
||||
} else {
|
||||
p.P(`if !this.`, fieldname, `.Equal(&that1.`, fieldname, `) {`)
|
||||
}
|
||||
} else if field.IsBytes() {
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `, that1.`, fieldname, `) {`)
|
||||
} else if field.IsString() {
|
||||
if nullable && !proto3 {
|
||||
p.generateNullableField(fieldname, verbose)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, ` != that1.`, fieldname, `{`)
|
||||
}
|
||||
} else {
|
||||
if nullable && !proto3 {
|
||||
p.generateNullableField(fieldname, verbose)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, ` != that1.`, fieldname, `{`)
|
||||
}
|
||||
}
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else {
|
||||
p.P(`if len(this.`, fieldname, `) != len(that1.`, fieldname, `) {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", len(this.`, fieldname, `), len(that1.`, fieldname, `))`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`for i := range this.`, fieldname, ` {`)
|
||||
p.In()
|
||||
if ctype && !p.IsMap(field) {
|
||||
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`)
|
||||
} else if isTimestamp {
|
||||
if nullable {
|
||||
p.P(`if !this.`, fieldname, `[i].Equal(*that1.`, fieldname, `[i]) {`)
|
||||
} else {
|
||||
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`)
|
||||
}
|
||||
} else if isNormal {
|
||||
if nullable {
|
||||
p.P(`if dthis, dthat := this.`, fieldname, `[i], that1.`, fieldname, `[i]; (dthis != nil && dthat != nil && *dthis != *dthat) || (dthis != nil && dthat == nil) || (dthis == nil && dthat != nil) {`)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
}
|
||||
} else if isBytes {
|
||||
if nullable {
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(*this.`, fieldname, `[i], *that1.`, fieldname, `[i]) {`)
|
||||
} else {
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `[i], that1.`, fieldname, `[i]) {`)
|
||||
}
|
||||
} else {
|
||||
if p.IsMap(field) {
|
||||
m := p.GoMapType(nil, field)
|
||||
valuegoTyp, _ := p.GoType(nil, m.ValueField)
|
||||
valuegoAliasTyp, _ := p.GoType(nil, m.ValueAliasField)
|
||||
nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp)
|
||||
|
||||
mapValue := m.ValueAliasField
|
||||
mapValueNormal := (gogoproto.IsStdDuration(mapValue) ||
|
||||
gogoproto.IsStdDouble(mapValue) ||
|
||||
gogoproto.IsStdFloat(mapValue) ||
|
||||
gogoproto.IsStdInt64(mapValue) ||
|
||||
gogoproto.IsStdUInt64(mapValue) ||
|
||||
gogoproto.IsStdInt32(mapValue) ||
|
||||
gogoproto.IsStdUInt32(mapValue) ||
|
||||
gogoproto.IsStdBool(mapValue) ||
|
||||
gogoproto.IsStdString(mapValue))
|
||||
mapValueBytes := gogoproto.IsStdBytes(mapValue)
|
||||
if mapValue.IsMessage() || p.IsGroup(mapValue) {
|
||||
if nullable && valuegoTyp == valuegoAliasTyp {
|
||||
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`)
|
||||
} else {
|
||||
// Equal() has a pointer receiver, but map value is a value type
|
||||
a := `this.` + fieldname + `[i]`
|
||||
b := `that1.` + fieldname + `[i]`
|
||||
if !mapValueNormal && !mapValueBytes && valuegoTyp != valuegoAliasTyp {
|
||||
// cast back to the type that has the generated methods on it
|
||||
a = `(` + valuegoTyp + `)(` + a + `)`
|
||||
b = `(` + valuegoTyp + `)(` + b + `)`
|
||||
}
|
||||
p.P(`a := `, a)
|
||||
p.P(`b := `, b)
|
||||
if mapValueNormal {
|
||||
if nullable {
|
||||
p.P(`if *a != *b {`)
|
||||
} else {
|
||||
p.P(`if a != b {`)
|
||||
}
|
||||
} else if mapValueBytes {
|
||||
if nullable {
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(*a, *b) {`)
|
||||
} else {
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(a, b) {`)
|
||||
}
|
||||
} else if nullable {
|
||||
p.P(`if !a.Equal(b) {`)
|
||||
} else {
|
||||
p.P(`if !(&a).Equal(&b) {`)
|
||||
}
|
||||
}
|
||||
} else if mapValue.IsBytes() {
|
||||
if ctype {
|
||||
if nullable {
|
||||
p.P(`if !this.`, fieldname, `[i].Equal(*that1.`, fieldname, `[i]) { //nullable`)
|
||||
} else {
|
||||
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) { //not nullable`)
|
||||
}
|
||||
} else {
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `[i], that1.`, fieldname, `[i]) {`)
|
||||
}
|
||||
} else if mapValue.IsString() {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
}
|
||||
} else if field.IsMessage() || p.IsGroup(field) {
|
||||
if nullable {
|
||||
p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`)
|
||||
} else {
|
||||
p.P(`if !this.`, fieldname, `[i].Equal(&that1.`, fieldname, `[i]) {`)
|
||||
}
|
||||
} else if field.IsBytes() {
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `[i], that1.`, fieldname, `[i]) {`)
|
||||
} else if field.IsString() {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
} else {
|
||||
p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`)
|
||||
}
|
||||
}
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this[%v](%v) Not Equal that[%v](%v)", i, this.`, fieldname, `[i], i, that1.`, fieldname, `[i])`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) generateMessage(file *generator.FileDescriptor, message *generator.Descriptor, verbose bool) {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
if verbose {
|
||||
p.P(`func (this *`, ccTypeName, `) VerboseEqual(that interface{}) error {`)
|
||||
} else {
|
||||
p.P(`func (this *`, ccTypeName, `) Equal(that interface{}) bool {`)
|
||||
}
|
||||
p.In()
|
||||
p.generateMsgNullAndTypeCheck(ccTypeName, verbose)
|
||||
oneofs := make(map[string]struct{})
|
||||
|
||||
for _, field := range message.Field {
|
||||
oneof := field.OneofIndex != nil
|
||||
if oneof {
|
||||
fieldname := p.GetFieldName(message, field)
|
||||
if _, ok := oneofs[fieldname]; ok {
|
||||
continue
|
||||
} else {
|
||||
oneofs[fieldname] = struct{}{}
|
||||
}
|
||||
p.P(`if that1.`, fieldname, ` == nil {`)
|
||||
p.In()
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("this.`, fieldname, ` != nil && that1.`, fieldname, ` == nil")`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if this.`, fieldname, ` == nil {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("this.`, fieldname, ` == nil && that1.`, fieldname, ` != nil")`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
if verbose {
|
||||
p.P(`} else if err := this.`, fieldname, `.VerboseEqual(that1.`, fieldname, `); err != nil {`)
|
||||
} else {
|
||||
p.P(`} else if !this.`, fieldname, `.Equal(that1.`, fieldname, `) {`)
|
||||
}
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return err`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.generateField(file, message, field, verbose)
|
||||
}
|
||||
}
|
||||
if message.DescriptorProto.HasExtension() {
|
||||
if gogoproto.HasExtensionsMap(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
fieldname := "XXX_InternalExtensions"
|
||||
p.P(`thismap := `, p.protoPkg.Use(), `.GetUnsafeExtensionsMap(this)`)
|
||||
p.P(`thatmap := `, p.protoPkg.Use(), `.GetUnsafeExtensionsMap(that1)`)
|
||||
p.P(`for k, v := range thismap {`)
|
||||
p.In()
|
||||
p.P(`if v2, ok := thatmap[k]; ok {`)
|
||||
p.In()
|
||||
p.P(`if !v.Equal(&v2) {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this[%v](%v) Not Equal that[%v](%v)", k, thismap[k], k, thatmap[k])`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, `[%v] Not In that", k)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
p.P(`for k, _ := range thatmap {`)
|
||||
p.In()
|
||||
p.P(`if _, ok := thismap[k]; !ok {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, `[%v] Not In this", k)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
fieldname := "XXX_extensions"
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `, that1.`, fieldname, `) {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
if gogoproto.HasUnrecognized(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
fieldname := "XXX_unrecognized"
|
||||
p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `, that1.`, fieldname, `) {`)
|
||||
p.In()
|
||||
if verbose {
|
||||
p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`)
|
||||
} else {
|
||||
p.P(`return false`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
if verbose {
|
||||
p.P(`return nil`)
|
||||
} else {
|
||||
p.P(`return true`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
//Generate Equal methods for oneof fields
|
||||
m := proto.Clone(message.DescriptorProto).(*descriptor.DescriptorProto)
|
||||
for _, field := range m.Field {
|
||||
oneof := field.OneofIndex != nil
|
||||
if !oneof {
|
||||
continue
|
||||
}
|
||||
ccTypeName := p.OneOfTypeName(message, field)
|
||||
if verbose {
|
||||
p.P(`func (this *`, ccTypeName, `) VerboseEqual(that interface{}) error {`)
|
||||
} else {
|
||||
p.P(`func (this *`, ccTypeName, `) Equal(that interface{}) bool {`)
|
||||
}
|
||||
p.In()
|
||||
|
||||
p.generateMsgNullAndTypeCheck(ccTypeName, verbose)
|
||||
vanity.TurnOffNullableForNativeTypes(field)
|
||||
p.generateField(file, message, field, verbose)
|
||||
|
||||
if verbose {
|
||||
p.P(`return nil`)
|
||||
} else {
|
||||
p.P(`return true`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewPlugin())
|
||||
}
|
109
vendor/github.com/gogo/protobuf/plugin/equal/equaltest.go
generated
vendored
Normal file
109
vendor/github.com/gogo/protobuf/plugin/equal/equaltest.go
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
// 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 equal
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/plugin/testgen"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type test struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewTest(g *generator.Generator) testgen.TestPlugin {
|
||||
return &test{g}
|
||||
}
|
||||
|
||||
func (p *test) Generate(imports generator.PluginImports, file *generator.FileDescriptor) bool {
|
||||
used := false
|
||||
randPkg := imports.NewImport("math/rand")
|
||||
timePkg := imports.NewImport("time")
|
||||
testingPkg := imports.NewImport("testing")
|
||||
protoPkg := imports.NewImport("github.com/gogo/protobuf/proto")
|
||||
unsafePkg := imports.NewImport("unsafe")
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
protoPkg = imports.NewImport("github.com/golang/protobuf/proto")
|
||||
}
|
||||
for _, message := range file.Messages() {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
if !gogoproto.HasVerboseEqual(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
|
||||
if gogoproto.HasTestGen(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
used = true
|
||||
hasUnsafe := gogoproto.IsUnsafeMarshaler(file.FileDescriptorProto, message.DescriptorProto) ||
|
||||
gogoproto.IsUnsafeUnmarshaler(file.FileDescriptorProto, message.DescriptorProto)
|
||||
p.P(`func Test`, ccTypeName, `VerboseEqual(t *`, testingPkg.Use(), `.T) {`)
|
||||
p.In()
|
||||
if hasUnsafe {
|
||||
if hasUnsafe {
|
||||
p.P(`var bigendian uint32 = 0x01020304`)
|
||||
p.P(`if *(*byte)(`, unsafePkg.Use(), `.Pointer(&bigendian)) == 1 {`)
|
||||
p.In()
|
||||
p.P(`t.Skip("unsafe does not work on big endian architectures")`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
p.P(`popr := `, randPkg.Use(), `.New(`, randPkg.Use(), `.NewSource(`, timePkg.Use(), `.Now().UnixNano()))`)
|
||||
p.P(`p := NewPopulated`, ccTypeName, `(popr, false)`)
|
||||
p.P(`dAtA, err := `, protoPkg.Use(), `.Marshal(p)`)
|
||||
p.P(`if err != nil {`)
|
||||
p.In()
|
||||
p.P(`panic(err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`msg := &`, ccTypeName, `{}`)
|
||||
p.P(`if err := `, protoPkg.Use(), `.Unmarshal(dAtA, msg); err != nil {`)
|
||||
p.In()
|
||||
p.P(`panic(err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`if err := p.VerboseEqual(msg); err != nil {`)
|
||||
p.In()
|
||||
p.P(`t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
}
|
||||
return used
|
||||
}
|
||||
|
||||
func init() {
|
||||
testgen.RegisterTestPlugin(NewTest)
|
||||
}
|
233
vendor/github.com/gogo/protobuf/plugin/face/face.go
generated
vendored
Normal file
233
vendor/github.com/gogo/protobuf/plugin/face/face.go
generated
vendored
Normal file
@ -0,0 +1,233 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The face plugin generates a function will be generated which can convert a structure which satisfies an interface (face) to the specified structure.
|
||||
This interface contains getters for each of the fields in the struct.
|
||||
The specified struct is also generated with the getters.
|
||||
This means that getters should be turned off so as not to conflict with face getters.
|
||||
This allows it to satisfy its own face.
|
||||
|
||||
It is enabled by the following extensions:
|
||||
|
||||
- face
|
||||
- face_all
|
||||
|
||||
Turn off getters by using the following extensions:
|
||||
|
||||
- getters
|
||||
- getters_all
|
||||
|
||||
The face plugin also generates a test given it is enabled using one of the following extensions:
|
||||
|
||||
- testgen
|
||||
- testgen_all
|
||||
|
||||
Let us look at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/example.proto
|
||||
|
||||
Btw all the output can be seen at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/*
|
||||
|
||||
The following message:
|
||||
|
||||
message A {
|
||||
option (gogoproto.face) = true;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
optional string Description = 1 [(gogoproto.nullable) = false];
|
||||
optional int64 Number = 2 [(gogoproto.nullable) = false];
|
||||
optional bytes Id = 3 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uuid", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
given to the face plugin, will generate the following code:
|
||||
|
||||
type AFace interface {
|
||||
Proto() github_com_gogo_protobuf_proto.Message
|
||||
GetDescription() string
|
||||
GetNumber() int64
|
||||
GetId() github_com_gogo_protobuf_test_custom.Uuid
|
||||
}
|
||||
|
||||
func (this *A) Proto() github_com_gogo_protobuf_proto.Message {
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *A) TestProto() github_com_gogo_protobuf_proto.Message {
|
||||
return NewAFromFace(this)
|
||||
}
|
||||
|
||||
func (this *A) GetDescription() string {
|
||||
return this.Description
|
||||
}
|
||||
|
||||
func (this *A) GetNumber() int64 {
|
||||
return this.Number
|
||||
}
|
||||
|
||||
func (this *A) GetId() github_com_gogo_protobuf_test_custom.Uuid {
|
||||
return this.Id
|
||||
}
|
||||
|
||||
func NewAFromFace(that AFace) *A {
|
||||
this := &A{}
|
||||
this.Description = that.GetDescription()
|
||||
this.Number = that.GetNumber()
|
||||
this.Id = that.GetId()
|
||||
return this
|
||||
}
|
||||
|
||||
and the following test code:
|
||||
|
||||
func TestAFace(t *testing7.T) {
|
||||
popr := math_rand7.New(math_rand7.NewSource(time7.Now().UnixNano()))
|
||||
p := NewPopulatedA(popr, true)
|
||||
msg := p.TestProto()
|
||||
if !p.Equal(msg) {
|
||||
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
||||
}
|
||||
}
|
||||
|
||||
The struct A, representing the message, will also be generated just like always.
|
||||
As you can see A satisfies its own Face, AFace.
|
||||
|
||||
Creating another struct which satisfies AFace is very easy.
|
||||
Simply create all these methods specified in AFace.
|
||||
Implementing The Proto method is done with the helper function NewAFromFace:
|
||||
|
||||
func (this *MyStruct) Proto() proto.Message {
|
||||
return NewAFromFace(this)
|
||||
}
|
||||
|
||||
just the like TestProto method which is used to test the NewAFromFace function.
|
||||
|
||||
*/
|
||||
package face
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
*generator.Generator
|
||||
generator.PluginImports
|
||||
}
|
||||
|
||||
func NewPlugin() *plugin {
|
||||
return &plugin{}
|
||||
}
|
||||
|
||||
func (p *plugin) Name() string {
|
||||
return "face"
|
||||
}
|
||||
|
||||
func (p *plugin) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func (p *plugin) Generate(file *generator.FileDescriptor) {
|
||||
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||
protoPkg := p.NewImport("github.com/gogo/protobuf/proto")
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
protoPkg = p.NewImport("github.com/golang/protobuf/proto")
|
||||
}
|
||||
for _, message := range file.Messages() {
|
||||
if !gogoproto.IsFace(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.HasExtension() {
|
||||
panic("face does not support message with extensions")
|
||||
}
|
||||
if gogoproto.HasGoGetters(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
panic("face requires getters to be disabled please use gogoproto.getters or gogoproto.getters_all and set it to false")
|
||||
}
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
p.P(`type `, ccTypeName, `Face interface{`)
|
||||
p.In()
|
||||
p.P(`Proto() `, protoPkg.Use(), `.Message`)
|
||||
for _, field := range message.Field {
|
||||
fieldname := p.GetFieldName(message, field)
|
||||
goTyp, _ := p.GoType(message, field)
|
||||
if p.IsMap(field) {
|
||||
m := p.GoMapType(nil, field)
|
||||
goTyp = m.GoType
|
||||
}
|
||||
p.P(`Get`, fieldname, `() `, goTyp)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(``)
|
||||
p.P(`func (this *`, ccTypeName, `) Proto() `, protoPkg.Use(), `.Message {`)
|
||||
p.In()
|
||||
p.P(`return this`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(``)
|
||||
p.P(`func (this *`, ccTypeName, `) TestProto() `, protoPkg.Use(), `.Message {`)
|
||||
p.In()
|
||||
p.P(`return New`, ccTypeName, `FromFace(this)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(``)
|
||||
for _, field := range message.Field {
|
||||
fieldname := p.GetFieldName(message, field)
|
||||
goTyp, _ := p.GoType(message, field)
|
||||
if p.IsMap(field) {
|
||||
m := p.GoMapType(nil, field)
|
||||
goTyp = m.GoType
|
||||
}
|
||||
p.P(`func (this *`, ccTypeName, `) Get`, fieldname, `() `, goTyp, `{`)
|
||||
p.In()
|
||||
p.P(` return this.`, fieldname)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(``)
|
||||
}
|
||||
p.P(``)
|
||||
p.P(`func New`, ccTypeName, `FromFace(that `, ccTypeName, `Face) *`, ccTypeName, ` {`)
|
||||
p.In()
|
||||
p.P(`this := &`, ccTypeName, `{}`)
|
||||
for _, field := range message.Field {
|
||||
fieldname := p.GetFieldName(message, field)
|
||||
p.P(`this.`, fieldname, ` = that.Get`, fieldname, `()`)
|
||||
}
|
||||
p.P(`return this`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(``)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewPlugin())
|
||||
}
|
82
vendor/github.com/gogo/protobuf/plugin/face/facetest.go
generated
vendored
Normal file
82
vendor/github.com/gogo/protobuf/plugin/face/facetest.go
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
// 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 face
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/plugin/testgen"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type test struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewTest(g *generator.Generator) testgen.TestPlugin {
|
||||
return &test{g}
|
||||
}
|
||||
|
||||
func (p *test) Generate(imports generator.PluginImports, file *generator.FileDescriptor) bool {
|
||||
used := false
|
||||
randPkg := imports.NewImport("math/rand")
|
||||
timePkg := imports.NewImport("time")
|
||||
testingPkg := imports.NewImport("testing")
|
||||
for _, message := range file.Messages() {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
if !gogoproto.IsFace(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
|
||||
if gogoproto.HasTestGen(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
used = true
|
||||
|
||||
p.P(`func Test`, ccTypeName, `Face(t *`, testingPkg.Use(), `.T) {`)
|
||||
p.In()
|
||||
p.P(`popr := `, randPkg.Use(), `.New(`, randPkg.Use(), `.NewSource(`, timePkg.Use(), `.Now().UnixNano()))`)
|
||||
p.P(`p := NewPopulated`, ccTypeName, `(popr, true)`)
|
||||
p.P(`msg := p.TestProto()`)
|
||||
p.P(`if !p.Equal(msg) {`)
|
||||
p.In()
|
||||
p.P(`t.Fatalf("%#v !Face Equal %#v", msg, p)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
}
|
||||
return used
|
||||
}
|
||||
|
||||
func init() {
|
||||
testgen.RegisterTestPlugin(NewTest)
|
||||
}
|
386
vendor/github.com/gogo/protobuf/plugin/gostring/gostring.go
generated
vendored
Normal file
386
vendor/github.com/gogo/protobuf/plugin/gostring/gostring.go
generated
vendored
Normal file
@ -0,0 +1,386 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The gostring plugin generates a GoString method for each message.
|
||||
The GoString method is called whenever you use a fmt.Printf as such:
|
||||
|
||||
fmt.Printf("%#v", mymessage)
|
||||
|
||||
or whenever you actually call GoString()
|
||||
The output produced by the GoString method can be copied from the output into code and used to set a variable.
|
||||
It is totally valid Go Code and is populated exactly as the struct that was printed out.
|
||||
|
||||
It is enabled by the following extensions:
|
||||
|
||||
- gostring
|
||||
- gostring_all
|
||||
|
||||
The gostring plugin also generates a test given it is enabled using one of the following extensions:
|
||||
|
||||
- testgen
|
||||
- testgen_all
|
||||
|
||||
Let us look at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/example.proto
|
||||
|
||||
Btw all the output can be seen at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/*
|
||||
|
||||
The following message:
|
||||
|
||||
option (gogoproto.gostring_all) = true;
|
||||
|
||||
message A {
|
||||
optional string Description = 1 [(gogoproto.nullable) = false];
|
||||
optional int64 Number = 2 [(gogoproto.nullable) = false];
|
||||
optional bytes Id = 3 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uuid", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
given to the gostring plugin, will generate the following code:
|
||||
|
||||
func (this *A) GoString() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
}
|
||||
s := strings1.Join([]string{`&test.A{` + `Description:` + fmt1.Sprintf("%#v", this.Description), `Number:` + fmt1.Sprintf("%#v", this.Number), `Id:` + fmt1.Sprintf("%#v", this.Id), `XXX_unrecognized:` + fmt1.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
|
||||
return s
|
||||
}
|
||||
|
||||
and the following test code:
|
||||
|
||||
func TestAGoString(t *testing6.T) {
|
||||
popr := math_rand6.New(math_rand6.NewSource(time6.Now().UnixNano()))
|
||||
p := NewPopulatedA(popr, false)
|
||||
s1 := p.GoString()
|
||||
s2 := fmt2.Sprintf("%#v", p)
|
||||
if s1 != s2 {
|
||||
t.Fatalf("GoString want %v got %v", s1, s2)
|
||||
}
|
||||
_, err := go_parser.ParseExpr(s1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Typically fmt.Printf("%#v") will stop to print when it reaches a pointer and
|
||||
not print their values, while the generated GoString method will always print all values, recursively.
|
||||
|
||||
*/
|
||||
package gostring
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type gostring struct {
|
||||
*generator.Generator
|
||||
generator.PluginImports
|
||||
atleastOne bool
|
||||
localName string
|
||||
overwrite bool
|
||||
}
|
||||
|
||||
func NewGoString() *gostring {
|
||||
return &gostring{}
|
||||
}
|
||||
|
||||
func (p *gostring) Name() string {
|
||||
return "gostring"
|
||||
}
|
||||
|
||||
func (p *gostring) Overwrite() {
|
||||
p.overwrite = true
|
||||
}
|
||||
|
||||
func (p *gostring) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func (p *gostring) Generate(file *generator.FileDescriptor) {
|
||||
proto3 := gogoproto.IsProto3(file.FileDescriptorProto)
|
||||
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||
p.atleastOne = false
|
||||
|
||||
p.localName = generator.FileName(file)
|
||||
|
||||
fmtPkg := p.NewImport("fmt")
|
||||
stringsPkg := p.NewImport("strings")
|
||||
protoPkg := p.NewImport("github.com/gogo/protobuf/proto")
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
protoPkg = p.NewImport("github.com/golang/protobuf/proto")
|
||||
}
|
||||
sortPkg := p.NewImport("sort")
|
||||
strconvPkg := p.NewImport("strconv")
|
||||
reflectPkg := p.NewImport("reflect")
|
||||
sortKeysPkg := p.NewImport("github.com/gogo/protobuf/sortkeys")
|
||||
|
||||
extensionToGoStringUsed := false
|
||||
for _, message := range file.Messages() {
|
||||
if !p.overwrite && !gogoproto.HasGoString(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
p.atleastOne = true
|
||||
packageName := file.GoPackageName()
|
||||
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
p.P(`func (this *`, ccTypeName, `) GoString() string {`)
|
||||
p.In()
|
||||
p.P(`if this == nil {`)
|
||||
p.In()
|
||||
p.P(`return "nil"`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
p.P(`s := make([]string, 0, `, strconv.Itoa(len(message.Field)+4), `)`)
|
||||
p.P(`s = append(s, "&`, packageName, ".", ccTypeName, `{")`)
|
||||
|
||||
oneofs := make(map[string]struct{})
|
||||
for _, field := range message.Field {
|
||||
nullable := gogoproto.IsNullable(field)
|
||||
repeated := field.IsRepeated()
|
||||
fieldname := p.GetFieldName(message, field)
|
||||
oneof := field.OneofIndex != nil
|
||||
if oneof {
|
||||
if _, ok := oneofs[fieldname]; ok {
|
||||
continue
|
||||
} else {
|
||||
oneofs[fieldname] = struct{}{}
|
||||
}
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `) + ",\n")`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if p.IsMap(field) {
|
||||
m := p.GoMapType(nil, field)
|
||||
mapgoTyp, keyField, keyAliasField := m.GoType, m.KeyField, m.KeyAliasField
|
||||
keysName := `keysFor` + fieldname
|
||||
keygoTyp, _ := p.GoType(nil, keyField)
|
||||
keygoTyp = strings.Replace(keygoTyp, "*", "", 1)
|
||||
keygoAliasTyp, _ := p.GoType(nil, keyAliasField)
|
||||
keygoAliasTyp = strings.Replace(keygoAliasTyp, "*", "", 1)
|
||||
keyCapTyp := generator.CamelCase(keygoTyp)
|
||||
p.P(keysName, ` := make([]`, keygoTyp, `, 0, len(this.`, fieldname, `))`)
|
||||
p.P(`for k, _ := range this.`, fieldname, ` {`)
|
||||
p.In()
|
||||
if keygoAliasTyp == keygoTyp {
|
||||
p.P(keysName, ` = append(`, keysName, `, k)`)
|
||||
} else {
|
||||
p.P(keysName, ` = append(`, keysName, `, `, keygoTyp, `(k))`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(sortKeysPkg.Use(), `.`, keyCapTyp, `s(`, keysName, `)`)
|
||||
mapName := `mapStringFor` + fieldname
|
||||
p.P(mapName, ` := "`, mapgoTyp, `{"`)
|
||||
p.P(`for _, k := range `, keysName, ` {`)
|
||||
p.In()
|
||||
if keygoAliasTyp == keygoTyp {
|
||||
p.P(mapName, ` += fmt.Sprintf("%#v: %#v,", k, this.`, fieldname, `[k])`)
|
||||
} else {
|
||||
p.P(mapName, ` += fmt.Sprintf("%#v: %#v,", k, this.`, fieldname, `[`, keygoAliasTyp, `(k)])`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(mapName, ` += "}"`)
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, mapName, `+ ",\n")`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if (field.IsMessage() && !gogoproto.IsCustomType(field) && !gogoproto.IsStdType(field)) || p.IsGroup(field) {
|
||||
if nullable || repeated {
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
}
|
||||
if nullable {
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `) + ",\n")`)
|
||||
} else if repeated {
|
||||
if nullable {
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `) + ",\n")`)
|
||||
} else {
|
||||
goTyp, _ := p.GoType(message, field)
|
||||
goTyp = strings.Replace(goTyp, "[]", "", 1)
|
||||
p.P("vs := make([]*", goTyp, ", len(this.", fieldname, "))")
|
||||
p.P("for i := range vs {")
|
||||
p.In()
|
||||
p.P("vs[i] = &this.", fieldname, "[i]")
|
||||
p.Out()
|
||||
p.P("}")
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", vs) + ",\n")`)
|
||||
}
|
||||
} else {
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, stringsPkg.Use(), `.Replace(this.`, fieldname, `.GoString()`, ",`&`,``,1)", ` + ",\n")`)
|
||||
}
|
||||
if nullable || repeated {
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else {
|
||||
if !proto3 && (nullable || repeated) {
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
}
|
||||
if field.IsEnum() {
|
||||
if nullable && !repeated && !proto3 {
|
||||
goTyp, _ := p.GoType(message, field)
|
||||
p.P(`s = append(s, "`, fieldname, `: " + valueToGoString`, p.localName, `(this.`, fieldname, `,"`, generator.GoTypeToName(goTyp), `"`, `) + ",\n")`)
|
||||
} else {
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `) + ",\n")`)
|
||||
}
|
||||
} else {
|
||||
if nullable && !repeated && !proto3 {
|
||||
goTyp, _ := p.GoType(message, field)
|
||||
p.P(`s = append(s, "`, fieldname, `: " + valueToGoString`, p.localName, `(this.`, fieldname, `,"`, generator.GoTypeToName(goTyp), `"`, `) + ",\n")`)
|
||||
} else {
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `) + ",\n")`)
|
||||
}
|
||||
}
|
||||
if !proto3 && (nullable || repeated) {
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
if message.DescriptorProto.HasExtension() {
|
||||
if gogoproto.HasExtensionsMap(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
p.P(`s = append(s, "XXX_InternalExtensions: " + extensionToGoString`, p.localName, `(this) + ",\n")`)
|
||||
extensionToGoStringUsed = true
|
||||
} else {
|
||||
p.P(`if this.XXX_extensions != nil {`)
|
||||
p.In()
|
||||
p.P(`s = append(s, "XXX_extensions: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.XXX_extensions) + ",\n")`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
if gogoproto.HasUnrecognized(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
p.P(`if this.XXX_unrecognized != nil {`)
|
||||
p.In()
|
||||
p.P(`s = append(s, "XXX_unrecognized:" + `, fmtPkg.Use(), `.Sprintf("%#v", this.XXX_unrecognized) + ",\n")`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
p.P(`s = append(s, "}")`)
|
||||
p.P(`return `, stringsPkg.Use(), `.Join(s, "")`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
//Generate GoString methods for oneof fields
|
||||
for _, field := range message.Field {
|
||||
oneof := field.OneofIndex != nil
|
||||
if !oneof {
|
||||
continue
|
||||
}
|
||||
ccTypeName := p.OneOfTypeName(message, field)
|
||||
p.P(`func (this *`, ccTypeName, `) GoString() string {`)
|
||||
p.In()
|
||||
p.P(`if this == nil {`)
|
||||
p.In()
|
||||
p.P(`return "nil"`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
fieldname := p.GetOneOfFieldName(message, field)
|
||||
outStr := strings.Join([]string{
|
||||
"s := ",
|
||||
stringsPkg.Use(), ".Join([]string{`&", packageName, ".", ccTypeName, "{` + \n",
|
||||
"`", fieldname, ":` + ", fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `)`,
|
||||
" + `}`",
|
||||
`}`,
|
||||
`,", "`,
|
||||
`)`}, "")
|
||||
p.P(outStr)
|
||||
p.P(`return s`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
if !p.atleastOne {
|
||||
return
|
||||
}
|
||||
|
||||
p.P(`func valueToGoString`, p.localName, `(v interface{}, typ string) string {`)
|
||||
p.In()
|
||||
p.P(`rv := `, reflectPkg.Use(), `.ValueOf(v)`)
|
||||
p.P(`if rv.IsNil() {`)
|
||||
p.In()
|
||||
p.P(`return "nil"`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`pv := `, reflectPkg.Use(), `.Indirect(rv).Interface()`)
|
||||
p.P(`return `, fmtPkg.Use(), `.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
if extensionToGoStringUsed {
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
fmt.Fprintf(os.Stderr, "The GoString plugin for messages with extensions requires importing gogoprotobuf. Please see file %s", file.GetName())
|
||||
os.Exit(1)
|
||||
}
|
||||
p.P(`func extensionToGoString`, p.localName, `(m `, protoPkg.Use(), `.Message) string {`)
|
||||
p.In()
|
||||
p.P(`e := `, protoPkg.Use(), `.GetUnsafeExtensionsMap(m)`)
|
||||
p.P(`if e == nil { return "nil" }`)
|
||||
p.P(`s := "proto.NewUnsafeXXX_InternalExtensions(map[int32]proto.Extension{"`)
|
||||
p.P(`keys := make([]int, 0, len(e))`)
|
||||
p.P(`for k := range e {`)
|
||||
p.In()
|
||||
p.P(`keys = append(keys, int(k))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(sortPkg.Use(), `.Ints(keys)`)
|
||||
p.P(`ss := []string{}`)
|
||||
p.P(`for _, k := range keys {`)
|
||||
p.In()
|
||||
p.P(`ss = append(ss, `, strconvPkg.Use(), `.Itoa(k) + ": " + e[int32(k)].GoString())`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`s+=`, stringsPkg.Use(), `.Join(ss, ",") + "})"`)
|
||||
p.P(`return s`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewGoString())
|
||||
}
|
90
vendor/github.com/gogo/protobuf/plugin/gostring/gostringtest.go
generated
vendored
Normal file
90
vendor/github.com/gogo/protobuf/plugin/gostring/gostringtest.go
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// 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 gostring
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/plugin/testgen"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type test struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewTest(g *generator.Generator) testgen.TestPlugin {
|
||||
return &test{g}
|
||||
}
|
||||
|
||||
func (p *test) Generate(imports generator.PluginImports, file *generator.FileDescriptor) bool {
|
||||
used := false
|
||||
randPkg := imports.NewImport("math/rand")
|
||||
timePkg := imports.NewImport("time")
|
||||
testingPkg := imports.NewImport("testing")
|
||||
fmtPkg := imports.NewImport("fmt")
|
||||
parserPkg := imports.NewImport("go/parser")
|
||||
for _, message := range file.Messages() {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
if !gogoproto.HasGoString(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
|
||||
if gogoproto.HasTestGen(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
used = true
|
||||
p.P(`func Test`, ccTypeName, `GoString(t *`, testingPkg.Use(), `.T) {`)
|
||||
p.In()
|
||||
p.P(`popr := `, randPkg.Use(), `.New(`, randPkg.Use(), `.NewSource(`, timePkg.Use(), `.Now().UnixNano()))`)
|
||||
p.P(`p := NewPopulated`, ccTypeName, `(popr, false)`)
|
||||
p.P(`s1 := p.GoString()`)
|
||||
p.P(`s2 := `, fmtPkg.Use(), `.Sprintf("%#v", p)`)
|
||||
p.P(`if s1 != s2 {`)
|
||||
p.In()
|
||||
p.P(`t.Fatalf("GoString want %v got %v", s1, s2)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`_, err := `, parserPkg.Use(), `.ParseExpr(s1)`)
|
||||
p.P(`if err != nil {`)
|
||||
p.In()
|
||||
p.P(`t.Fatal(err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
}
|
||||
return used
|
||||
}
|
||||
|
||||
func init() {
|
||||
testgen.RegisterTestPlugin(NewTest)
|
||||
}
|
1357
vendor/github.com/gogo/protobuf/plugin/marshalto/marshalto.go
generated
vendored
Normal file
1357
vendor/github.com/gogo/protobuf/plugin/marshalto/marshalto.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
93
vendor/github.com/gogo/protobuf/plugin/oneofcheck/oneofcheck.go
generated
vendored
Normal file
93
vendor/github.com/gogo/protobuf/plugin/oneofcheck/oneofcheck.go
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The oneofcheck plugin is used to check whether oneof is not used incorrectly.
|
||||
For instance:
|
||||
An error is caused if a oneof field:
|
||||
- is used in a face
|
||||
- is an embedded field
|
||||
|
||||
*/
|
||||
package oneofcheck
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
"os"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewPlugin() *plugin {
|
||||
return &plugin{}
|
||||
}
|
||||
|
||||
func (p *plugin) Name() string {
|
||||
return "oneofcheck"
|
||||
}
|
||||
|
||||
func (p *plugin) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func (p *plugin) Generate(file *generator.FileDescriptor) {
|
||||
for _, msg := range file.Messages() {
|
||||
face := gogoproto.IsFace(file.FileDescriptorProto, msg.DescriptorProto)
|
||||
for _, field := range msg.GetField() {
|
||||
if field.OneofIndex == nil {
|
||||
continue
|
||||
}
|
||||
if face {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v cannot be in a face and oneof\n", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
if gogoproto.IsEmbed(field) {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v cannot be in an oneof and an embedded field\n", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
if !gogoproto.IsNullable(field) {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v cannot be in an oneof and a non-nullable field\n", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
if gogoproto.IsUnion(file.FileDescriptorProto, msg.DescriptorProto) {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: field %v.%v cannot be in an oneof and in an union (deprecated)\n", generator.CamelCase(*msg.Name), generator.CamelCase(*field.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) GenerateImports(*generator.FileDescriptor) {}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewPlugin())
|
||||
}
|
815
vendor/github.com/gogo/protobuf/plugin/populate/populate.go
generated
vendored
Normal file
815
vendor/github.com/gogo/protobuf/plugin/populate/populate.go
generated
vendored
Normal file
@ -0,0 +1,815 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The populate plugin generates a NewPopulated function.
|
||||
This function returns a newly populated structure.
|
||||
|
||||
It is enabled by the following extensions:
|
||||
|
||||
- populate
|
||||
- populate_all
|
||||
|
||||
Let us look at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/example.proto
|
||||
|
||||
Btw all the output can be seen at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/*
|
||||
|
||||
The following message:
|
||||
|
||||
option (gogoproto.populate_all) = true;
|
||||
|
||||
message B {
|
||||
optional A A = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
repeated bytes G = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
given to the populate plugin, will generate code the following code:
|
||||
|
||||
func NewPopulatedB(r randyExample, easy bool) *B {
|
||||
this := &B{}
|
||||
v2 := NewPopulatedA(r, easy)
|
||||
this.A = *v2
|
||||
if r.Intn(10) != 0 {
|
||||
v3 := r.Intn(10)
|
||||
this.G = make([]github_com_gogo_protobuf_test_custom.Uint128, v3)
|
||||
for i := 0; i < v3; i++ {
|
||||
v4 := github_com_gogo_protobuf_test_custom.NewPopulatedUint128(r)
|
||||
this.G[i] = *v4
|
||||
}
|
||||
}
|
||||
if !easy && r.Intn(10) != 0 {
|
||||
this.XXX_unrecognized = randUnrecognizedExample(r, 3)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
The idea that is useful for testing.
|
||||
Most of the other plugins' generated test code uses it.
|
||||
You will still be able to use the generated test code of other packages
|
||||
if you turn off the popluate plugin and write your own custom NewPopulated function.
|
||||
|
||||
If the easy flag is not set the XXX_unrecognized and XXX_extensions fields are also populated.
|
||||
These have caused problems with JSON marshalling and unmarshalling tests.
|
||||
|
||||
*/
|
||||
package populate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
"github.com/gogo/protobuf/vanity"
|
||||
)
|
||||
|
||||
type VarGen interface {
|
||||
Next() string
|
||||
Current() string
|
||||
}
|
||||
|
||||
type varGen struct {
|
||||
index int64
|
||||
}
|
||||
|
||||
func NewVarGen() VarGen {
|
||||
return &varGen{0}
|
||||
}
|
||||
|
||||
func (this *varGen) Next() string {
|
||||
this.index++
|
||||
return fmt.Sprintf("v%d", this.index)
|
||||
}
|
||||
|
||||
func (this *varGen) Current() string {
|
||||
return fmt.Sprintf("v%d", this.index)
|
||||
}
|
||||
|
||||
type plugin struct {
|
||||
*generator.Generator
|
||||
generator.PluginImports
|
||||
varGen VarGen
|
||||
atleastOne bool
|
||||
localName string
|
||||
typesPkg generator.Single
|
||||
}
|
||||
|
||||
func NewPlugin() *plugin {
|
||||
return &plugin{}
|
||||
}
|
||||
|
||||
func (p *plugin) Name() string {
|
||||
return "populate"
|
||||
}
|
||||
|
||||
func (p *plugin) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func value(typeName string, fieldType descriptor.FieldDescriptorProto_Type) string {
|
||||
switch fieldType {
|
||||
case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
|
||||
return typeName + "(r.Float64())"
|
||||
case descriptor.FieldDescriptorProto_TYPE_FLOAT:
|
||||
return typeName + "(r.Float32())"
|
||||
case descriptor.FieldDescriptorProto_TYPE_INT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_SFIXED64,
|
||||
descriptor.FieldDescriptorProto_TYPE_SINT64:
|
||||
return typeName + "(r.Int63())"
|
||||
case descriptor.FieldDescriptorProto_TYPE_UINT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED64:
|
||||
return typeName + "(uint64(r.Uint32()))"
|
||||
case descriptor.FieldDescriptorProto_TYPE_INT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_SINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_SFIXED32,
|
||||
descriptor.FieldDescriptorProto_TYPE_ENUM:
|
||||
return typeName + "(r.Int31())"
|
||||
case descriptor.FieldDescriptorProto_TYPE_UINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED32:
|
||||
return typeName + "(r.Uint32())"
|
||||
case descriptor.FieldDescriptorProto_TYPE_BOOL:
|
||||
return typeName + `(bool(r.Intn(2) == 0))`
|
||||
case descriptor.FieldDescriptorProto_TYPE_STRING,
|
||||
descriptor.FieldDescriptorProto_TYPE_GROUP,
|
||||
descriptor.FieldDescriptorProto_TYPE_MESSAGE,
|
||||
descriptor.FieldDescriptorProto_TYPE_BYTES:
|
||||
}
|
||||
panic(fmt.Errorf("unexpected type %v", typeName))
|
||||
}
|
||||
|
||||
func negative(fieldType descriptor.FieldDescriptorProto_Type) bool {
|
||||
switch fieldType {
|
||||
case descriptor.FieldDescriptorProto_TYPE_UINT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED64,
|
||||
descriptor.FieldDescriptorProto_TYPE_UINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED32,
|
||||
descriptor.FieldDescriptorProto_TYPE_BOOL:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *plugin) getFuncName(goTypName string, field *descriptor.FieldDescriptorProto) string {
|
||||
funcName := "NewPopulated" + goTypName
|
||||
goTypNames := strings.Split(goTypName, ".")
|
||||
if len(goTypNames) == 2 {
|
||||
funcName = goTypNames[0] + ".NewPopulated" + goTypNames[1]
|
||||
} else if len(goTypNames) != 1 {
|
||||
panic(fmt.Errorf("unreachable: too many dots in %v", goTypName))
|
||||
}
|
||||
if field != nil {
|
||||
switch {
|
||||
case gogoproto.IsStdTime(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdTime"
|
||||
case gogoproto.IsStdDuration(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdDuration"
|
||||
case gogoproto.IsStdDouble(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdDouble"
|
||||
case gogoproto.IsStdFloat(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdFloat"
|
||||
case gogoproto.IsStdInt64(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdInt64"
|
||||
case gogoproto.IsStdUInt64(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdUInt64"
|
||||
case gogoproto.IsStdInt32(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdInt32"
|
||||
case gogoproto.IsStdUInt32(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdUInt32"
|
||||
case gogoproto.IsStdBool(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdBool"
|
||||
case gogoproto.IsStdString(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdString"
|
||||
case gogoproto.IsStdBytes(field):
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdBytes"
|
||||
}
|
||||
}
|
||||
return funcName
|
||||
}
|
||||
|
||||
func (p *plugin) getFuncCall(goTypName string, field *descriptor.FieldDescriptorProto) string {
|
||||
funcName := p.getFuncName(goTypName, field)
|
||||
funcCall := funcName + "(r, easy)"
|
||||
return funcCall
|
||||
}
|
||||
|
||||
func (p *plugin) getCustomFuncCall(goTypName string) string {
|
||||
funcName := p.getFuncName(goTypName, nil)
|
||||
funcCall := funcName + "(r)"
|
||||
return funcCall
|
||||
}
|
||||
|
||||
func (p *plugin) getEnumVal(field *descriptor.FieldDescriptorProto, goTyp string) string {
|
||||
enum := p.ObjectNamed(field.GetTypeName()).(*generator.EnumDescriptor)
|
||||
l := len(enum.Value)
|
||||
values := make([]string, l)
|
||||
for i := range enum.Value {
|
||||
values[i] = strconv.Itoa(int(*enum.Value[i].Number))
|
||||
}
|
||||
arr := "[]int32{" + strings.Join(values, ",") + "}"
|
||||
val := strings.Join([]string{generator.GoTypeToName(goTyp), `(`, arr, `[r.Intn(`, fmt.Sprintf("%d", l), `)])`}, "")
|
||||
return val
|
||||
}
|
||||
|
||||
func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generator.Descriptor, field *descriptor.FieldDescriptorProto) {
|
||||
proto3 := gogoproto.IsProto3(file.FileDescriptorProto)
|
||||
goTyp, _ := p.GoType(message, field)
|
||||
fieldname := p.GetOneOfFieldName(message, field)
|
||||
goTypName := generator.GoTypeToName(goTyp)
|
||||
if p.IsMap(field) {
|
||||
m := p.GoMapType(nil, field)
|
||||
keygoTyp, _ := p.GoType(nil, m.KeyField)
|
||||
keygoTyp = strings.Replace(keygoTyp, "*", "", 1)
|
||||
keygoAliasTyp, _ := p.GoType(nil, m.KeyAliasField)
|
||||
keygoAliasTyp = strings.Replace(keygoAliasTyp, "*", "", 1)
|
||||
|
||||
valuegoTyp, _ := p.GoType(nil, m.ValueField)
|
||||
valuegoAliasTyp, _ := p.GoType(nil, m.ValueAliasField)
|
||||
keytypName := generator.GoTypeToName(keygoTyp)
|
||||
keygoAliasTyp = generator.GoTypeToName(keygoAliasTyp)
|
||||
valuetypAliasName := generator.GoTypeToName(valuegoAliasTyp)
|
||||
|
||||
nullable, valuegoTyp, valuegoAliasTyp := generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp)
|
||||
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, m.GoType, `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
keyval := ""
|
||||
if m.KeyField.IsString() {
|
||||
keyval = fmt.Sprintf("randString%v(r)", p.localName)
|
||||
} else {
|
||||
keyval = value(keytypName, m.KeyField.GetType())
|
||||
}
|
||||
if keygoAliasTyp != keygoTyp {
|
||||
keyval = keygoAliasTyp + `(` + keyval + `)`
|
||||
}
|
||||
if m.ValueField.IsMessage() || p.IsGroup(field) ||
|
||||
(m.ValueField.IsBytes() && gogoproto.IsCustomType(field)) {
|
||||
s := `this.` + fieldname + `[` + keyval + `] = `
|
||||
if gogoproto.IsStdType(field) {
|
||||
valuegoTyp = valuegoAliasTyp
|
||||
}
|
||||
funcCall := p.getCustomFuncCall(goTypName)
|
||||
if !gogoproto.IsCustomType(field) {
|
||||
goTypName = generator.GoTypeToName(valuegoTyp)
|
||||
funcCall = p.getFuncCall(goTypName, m.ValueAliasField)
|
||||
}
|
||||
if !nullable {
|
||||
funcCall = `*` + funcCall
|
||||
}
|
||||
if valuegoTyp != valuegoAliasTyp {
|
||||
funcCall = `(` + valuegoAliasTyp + `)(` + funcCall + `)`
|
||||
}
|
||||
s += funcCall
|
||||
p.P(s)
|
||||
} else if m.ValueField.IsEnum() {
|
||||
s := `this.` + fieldname + `[` + keyval + `]` + ` = ` + p.getEnumVal(m.ValueField, valuegoTyp)
|
||||
p.P(s)
|
||||
} else if m.ValueField.IsBytes() {
|
||||
count := p.varGen.Next()
|
||||
p.P(count, ` := r.Intn(100)`)
|
||||
p.P(p.varGen.Next(), ` := `, keyval)
|
||||
p.P(`this.`, fieldname, `[`, p.varGen.Current(), `] = make(`, valuegoTyp, `, `, count, `)`)
|
||||
p.P(`for i := 0; i < `, count, `; i++ {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, `[`, p.varGen.Current(), `][i] = byte(r.Intn(256))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if m.ValueField.IsString() {
|
||||
s := `this.` + fieldname + `[` + keyval + `]` + ` = ` + fmt.Sprintf("randString%v(r)", p.localName)
|
||||
p.P(s)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), ` := `, keyval)
|
||||
p.P(`this.`, fieldname, `[`, p.varGen.Current(), `] = `, value(valuetypAliasName, m.ValueField.GetType()))
|
||||
if negative(m.ValueField.GetType()) {
|
||||
p.P(`if r.Intn(2) == 0 {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, `[`, p.varGen.Current(), `] *= -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if gogoproto.IsCustomType(field) {
|
||||
funcCall := p.getCustomFuncCall(goTypName)
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(p.varGen.Next(), `:= `, funcCall)
|
||||
p.P(`this.`, fieldname, `[i] = *`, p.varGen.Current())
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if gogoproto.IsNullable(field) {
|
||||
p.P(`this.`, fieldname, ` = `, funcCall)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), `:= `, funcCall)
|
||||
p.P(`this.`, fieldname, ` = *`, p.varGen.Current())
|
||||
}
|
||||
} else if field.IsMessage() || p.IsGroup(field) {
|
||||
funcCall := p.getFuncCall(goTypName, field)
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(5)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
if gogoproto.IsNullable(field) {
|
||||
p.P(`this.`, fieldname, `[i] = `, funcCall)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), `:= `, funcCall)
|
||||
p.P(`this.`, fieldname, `[i] = *`, p.varGen.Current())
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
if gogoproto.IsNullable(field) {
|
||||
p.P(`this.`, fieldname, ` = `, funcCall)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), `:= `, funcCall)
|
||||
p.P(`this.`, fieldname, ` = *`, p.varGen.Current())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if field.IsEnum() {
|
||||
val := p.getEnumVal(field, goTyp)
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, `[i] = `, val)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if !gogoproto.IsNullable(field) || proto3 {
|
||||
p.P(`this.`, fieldname, ` = `, val)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), ` := `, val)
|
||||
p.P(`this.`, fieldname, ` = &`, p.varGen.Current())
|
||||
}
|
||||
} else if field.IsBytes() {
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(p.varGen.Next(), ` := r.Intn(100)`)
|
||||
p.P(`this.`, fieldname, `[i] = make([]byte,`, p.varGen.Current(), `)`)
|
||||
p.P(`for j := 0; j < `, p.varGen.Current(), `; j++ {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, `[i][j] = byte(r.Intn(256))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(100)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, `[i] = byte(r.Intn(256))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else if field.IsString() {
|
||||
typName := generator.GoTypeToName(goTyp)
|
||||
val := fmt.Sprintf("%s(randString%v(r))", typName, p.localName)
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, `[i] = `, val)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if !gogoproto.IsNullable(field) || proto3 {
|
||||
p.P(`this.`, fieldname, ` = `, val)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), `:= `, val)
|
||||
p.P(`this.`, fieldname, ` = &`, p.varGen.Current())
|
||||
}
|
||||
} else {
|
||||
typName := generator.GoTypeToName(goTyp)
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, `[i] = `, value(typName, field.GetType()))
|
||||
if negative(field.GetType()) {
|
||||
p.P(`if r.Intn(2) == 0 {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, `[i] *= -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if !gogoproto.IsNullable(field) || proto3 {
|
||||
p.P(`this.`, fieldname, ` = `, value(typName, field.GetType()))
|
||||
if negative(field.GetType()) {
|
||||
p.P(`if r.Intn(2) == 0 {`)
|
||||
p.In()
|
||||
p.P(`this.`, fieldname, ` *= -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else {
|
||||
p.P(p.varGen.Next(), ` := `, value(typName, field.GetType()))
|
||||
if negative(field.GetType()) {
|
||||
p.P(`if r.Intn(2) == 0 {`)
|
||||
p.In()
|
||||
p.P(p.varGen.Current(), ` *= -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
p.P(`this.`, fieldname, ` = &`, p.varGen.Current())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plugin) hasLoop(pkg string, field *descriptor.FieldDescriptorProto, visited []*generator.Descriptor, excludes []*generator.Descriptor) *generator.Descriptor {
|
||||
if field.IsMessage() || p.IsGroup(field) || p.IsMap(field) {
|
||||
var fieldMessage *generator.Descriptor
|
||||
if p.IsMap(field) {
|
||||
m := p.GoMapType(nil, field)
|
||||
if !m.ValueField.IsMessage() {
|
||||
return nil
|
||||
}
|
||||
fieldMessage = p.ObjectNamed(m.ValueField.GetTypeName()).(*generator.Descriptor)
|
||||
} else {
|
||||
fieldMessage = p.ObjectNamed(field.GetTypeName()).(*generator.Descriptor)
|
||||
}
|
||||
fieldTypeName := generator.CamelCaseSlice(fieldMessage.TypeName())
|
||||
for _, message := range visited {
|
||||
messageTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
if fieldTypeName == messageTypeName {
|
||||
for _, e := range excludes {
|
||||
if fieldTypeName == generator.CamelCaseSlice(e.TypeName()) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fieldMessage
|
||||
}
|
||||
}
|
||||
|
||||
for _, f := range fieldMessage.Field {
|
||||
if strings.HasPrefix(f.GetTypeName(), "."+pkg) {
|
||||
visited = append(visited, fieldMessage)
|
||||
loopTo := p.hasLoop(pkg, f, visited, excludes)
|
||||
if loopTo != nil {
|
||||
return loopTo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *plugin) loops(pkg string, field *descriptor.FieldDescriptorProto, message *generator.Descriptor) int {
|
||||
//fmt.Fprintf(os.Stderr, "loops %v %v\n", field.GetTypeName(), generator.CamelCaseSlice(message.TypeName()))
|
||||
excludes := []*generator.Descriptor{}
|
||||
loops := 0
|
||||
for {
|
||||
visited := []*generator.Descriptor{}
|
||||
loopTo := p.hasLoop(pkg, field, visited, excludes)
|
||||
if loopTo == nil {
|
||||
break
|
||||
}
|
||||
//fmt.Fprintf(os.Stderr, "loopTo %v\n", generator.CamelCaseSlice(loopTo.TypeName()))
|
||||
excludes = append(excludes, loopTo)
|
||||
loops++
|
||||
}
|
||||
return loops
|
||||
}
|
||||
|
||||
func (p *plugin) Generate(file *generator.FileDescriptor) {
|
||||
p.atleastOne = false
|
||||
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||
p.varGen = NewVarGen()
|
||||
proto3 := gogoproto.IsProto3(file.FileDescriptorProto)
|
||||
p.typesPkg = p.NewImport("github.com/gogo/protobuf/types")
|
||||
p.localName = generator.FileName(file)
|
||||
protoPkg := p.NewImport("github.com/gogo/protobuf/proto")
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
protoPkg = p.NewImport("github.com/golang/protobuf/proto")
|
||||
}
|
||||
|
||||
for _, message := range file.Messages() {
|
||||
if !gogoproto.HasPopulate(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
p.atleastOne = true
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
loopLevels := make([]int, len(message.Field))
|
||||
maxLoopLevel := 0
|
||||
for i, field := range message.Field {
|
||||
loopLevels[i] = p.loops(file.GetPackage(), field, message)
|
||||
if loopLevels[i] > maxLoopLevel {
|
||||
maxLoopLevel = loopLevels[i]
|
||||
}
|
||||
}
|
||||
ranTotal := 0
|
||||
for i := range loopLevels {
|
||||
ranTotal += int(math.Pow10(maxLoopLevel - loopLevels[i]))
|
||||
}
|
||||
p.P(`func NewPopulated`, ccTypeName, `(r randy`, p.localName, `, easy bool) *`, ccTypeName, ` {`)
|
||||
p.In()
|
||||
p.P(`this := &`, ccTypeName, `{}`)
|
||||
if gogoproto.IsUnion(message.File().FileDescriptorProto, message.DescriptorProto) && len(message.Field) > 0 {
|
||||
p.P(`fieldNum := r.Intn(`, fmt.Sprintf("%d", ranTotal), `)`)
|
||||
p.P(`switch fieldNum {`)
|
||||
k := 0
|
||||
for i, field := range message.Field {
|
||||
is := []string{}
|
||||
ran := int(math.Pow10(maxLoopLevel - loopLevels[i]))
|
||||
for j := 0; j < ran; j++ {
|
||||
is = append(is, fmt.Sprintf("%d", j+k))
|
||||
}
|
||||
k += ran
|
||||
p.P(`case `, strings.Join(is, ","), `:`)
|
||||
p.In()
|
||||
p.GenerateField(file, message, field)
|
||||
p.Out()
|
||||
}
|
||||
p.P(`}`)
|
||||
} else {
|
||||
var maxFieldNumber int32
|
||||
oneofs := make(map[string]struct{})
|
||||
for fieldIndex, field := range message.Field {
|
||||
if field.GetNumber() > maxFieldNumber {
|
||||
maxFieldNumber = field.GetNumber()
|
||||
}
|
||||
oneof := field.OneofIndex != nil
|
||||
if !oneof {
|
||||
if field.IsRequired() || (!gogoproto.IsNullable(field) && !field.IsRepeated()) || (proto3 && !field.IsMessage()) {
|
||||
p.GenerateField(file, message, field)
|
||||
} else {
|
||||
if loopLevels[fieldIndex] > 0 {
|
||||
p.P(`if r.Intn(10) == 0 {`)
|
||||
} else {
|
||||
p.P(`if r.Intn(10) != 0 {`)
|
||||
}
|
||||
p.In()
|
||||
p.GenerateField(file, message, field)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
} else {
|
||||
fieldname := p.GetFieldName(message, field)
|
||||
if _, ok := oneofs[fieldname]; ok {
|
||||
continue
|
||||
} else {
|
||||
oneofs[fieldname] = struct{}{}
|
||||
}
|
||||
fieldNumbers := []int32{}
|
||||
for _, f := range message.Field {
|
||||
fname := p.GetFieldName(message, f)
|
||||
if fname == fieldname {
|
||||
fieldNumbers = append(fieldNumbers, f.GetNumber())
|
||||
}
|
||||
}
|
||||
|
||||
p.P(`oneofNumber_`, fieldname, ` := `, fmt.Sprintf("%#v", fieldNumbers), `[r.Intn(`, strconv.Itoa(len(fieldNumbers)), `)]`)
|
||||
p.P(`switch oneofNumber_`, fieldname, ` {`)
|
||||
for _, f := range message.Field {
|
||||
fname := p.GetFieldName(message, f)
|
||||
if fname != fieldname {
|
||||
continue
|
||||
}
|
||||
p.P(`case `, strconv.Itoa(int(f.GetNumber())), `:`)
|
||||
p.In()
|
||||
ccTypeName := p.OneOfTypeName(message, f)
|
||||
p.P(`this.`, fname, ` = NewPopulated`, ccTypeName, `(r, easy)`)
|
||||
p.Out()
|
||||
}
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
if message.DescriptorProto.HasExtension() {
|
||||
p.P(`if !easy && r.Intn(10) != 0 {`)
|
||||
p.In()
|
||||
p.P(`l := r.Intn(5)`)
|
||||
p.P(`for i := 0; i < l; i++ {`)
|
||||
p.In()
|
||||
if len(message.DescriptorProto.GetExtensionRange()) > 1 {
|
||||
p.P(`eIndex := r.Intn(`, strconv.Itoa(len(message.DescriptorProto.GetExtensionRange())), `)`)
|
||||
p.P(`fieldNumber := 0`)
|
||||
p.P(`switch eIndex {`)
|
||||
for i, e := range message.DescriptorProto.GetExtensionRange() {
|
||||
p.P(`case `, strconv.Itoa(i), `:`)
|
||||
p.In()
|
||||
p.P(`fieldNumber = r.Intn(`, strconv.Itoa(int(e.GetEnd()-e.GetStart())), `) + `, strconv.Itoa(int(e.GetStart())))
|
||||
p.Out()
|
||||
if e.GetEnd() > maxFieldNumber {
|
||||
maxFieldNumber = e.GetEnd()
|
||||
}
|
||||
}
|
||||
p.P(`}`)
|
||||
} else {
|
||||
e := message.DescriptorProto.GetExtensionRange()[0]
|
||||
p.P(`fieldNumber := r.Intn(`, strconv.Itoa(int(e.GetEnd()-e.GetStart())), `) + `, strconv.Itoa(int(e.GetStart())))
|
||||
if e.GetEnd() > maxFieldNumber {
|
||||
maxFieldNumber = e.GetEnd()
|
||||
}
|
||||
}
|
||||
p.P(`wire := r.Intn(4)`)
|
||||
p.P(`if wire == 3 { wire = 5 }`)
|
||||
p.P(`dAtA := randField`, p.localName, `(nil, r, fieldNumber, wire)`)
|
||||
p.P(protoPkg.Use(), `.SetRawExtension(this, int32(fieldNumber), dAtA)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
|
||||
if maxFieldNumber < (1 << 10) {
|
||||
p.P(`if !easy && r.Intn(10) != 0 {`)
|
||||
p.In()
|
||||
if gogoproto.HasUnrecognized(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
p.P(`this.XXX_unrecognized = randUnrecognized`, p.localName, `(r, `, strconv.Itoa(int(maxFieldNumber+1)), `)`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
p.P(`return this`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(``)
|
||||
|
||||
//Generate NewPopulated functions for oneof fields
|
||||
m := proto.Clone(message.DescriptorProto).(*descriptor.DescriptorProto)
|
||||
for _, f := range m.Field {
|
||||
oneof := f.OneofIndex != nil
|
||||
if !oneof {
|
||||
continue
|
||||
}
|
||||
ccTypeName := p.OneOfTypeName(message, f)
|
||||
p.P(`func NewPopulated`, ccTypeName, `(r randy`, p.localName, `, easy bool) *`, ccTypeName, ` {`)
|
||||
p.In()
|
||||
p.P(`this := &`, ccTypeName, `{}`)
|
||||
vanity.TurnOffNullableForNativeTypes(f)
|
||||
p.GenerateField(file, message, f)
|
||||
p.P(`return this`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
if !p.atleastOne {
|
||||
return
|
||||
}
|
||||
|
||||
p.P(`type randy`, p.localName, ` interface {`)
|
||||
p.In()
|
||||
p.P(`Float32() float32`)
|
||||
p.P(`Float64() float64`)
|
||||
p.P(`Int63() int64`)
|
||||
p.P(`Int31() int32`)
|
||||
p.P(`Uint32() uint32`)
|
||||
p.P(`Intn(n int) int`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
p.P(`func randUTF8Rune`, p.localName, `(r randy`, p.localName, `) rune {`)
|
||||
p.In()
|
||||
p.P(`ru := r.Intn(62)`)
|
||||
p.P(`if ru < 10 {`)
|
||||
p.In()
|
||||
p.P(`return rune(ru+48)`)
|
||||
p.Out()
|
||||
p.P(`} else if ru < 36 {`)
|
||||
p.In()
|
||||
p.P(`return rune(ru+55)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return rune(ru+61)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
p.P(`func randString`, p.localName, `(r randy`, p.localName, `) string {`)
|
||||
p.In()
|
||||
p.P(p.varGen.Next(), ` := r.Intn(100)`)
|
||||
p.P(`tmps := make([]rune, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(`tmps[i] = randUTF8Rune`, p.localName, `(r)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return string(tmps)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
p.P(`func randUnrecognized`, p.localName, `(r randy`, p.localName, `, maxFieldNumber int) (dAtA []byte) {`)
|
||||
p.In()
|
||||
p.P(`l := r.Intn(5)`)
|
||||
p.P(`for i := 0; i < l; i++ {`)
|
||||
p.In()
|
||||
p.P(`wire := r.Intn(4)`)
|
||||
p.P(`if wire == 3 { wire = 5 }`)
|
||||
p.P(`fieldNumber := maxFieldNumber + r.Intn(100)`)
|
||||
p.P(`dAtA = randField`, p.localName, `(dAtA, r, fieldNumber, wire)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return dAtA`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
p.P(`func randField`, p.localName, `(dAtA []byte, r randy`, p.localName, `, fieldNumber int, wire int) []byte {`)
|
||||
p.In()
|
||||
p.P(`key := uint32(fieldNumber)<<3 | uint32(wire)`)
|
||||
p.P(`switch wire {`)
|
||||
p.P(`case 0:`)
|
||||
p.In()
|
||||
p.P(`dAtA = encodeVarintPopulate`, p.localName, `(dAtA, uint64(key))`)
|
||||
p.P(p.varGen.Next(), ` := r.Int63()`)
|
||||
p.P(`if r.Intn(2) == 0 {`)
|
||||
p.In()
|
||||
p.P(p.varGen.Current(), ` *= -1`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`dAtA = encodeVarintPopulate`, p.localName, `(dAtA, uint64(`, p.varGen.Current(), `))`)
|
||||
p.Out()
|
||||
p.P(`case 1:`)
|
||||
p.In()
|
||||
p.P(`dAtA = encodeVarintPopulate`, p.localName, `(dAtA, uint64(key))`)
|
||||
p.P(`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)))`)
|
||||
p.Out()
|
||||
p.P(`case 2:`)
|
||||
p.In()
|
||||
p.P(`dAtA = encodeVarintPopulate`, p.localName, `(dAtA, uint64(key))`)
|
||||
p.P(`ll := r.Intn(100)`)
|
||||
p.P(`dAtA = encodeVarintPopulate`, p.localName, `(dAtA, uint64(ll))`)
|
||||
p.P(`for j := 0; j < ll; j++ {`)
|
||||
p.In()
|
||||
p.P(`dAtA = append(dAtA, byte(r.Intn(256)))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`default:`)
|
||||
p.In()
|
||||
p.P(`dAtA = encodeVarintPopulate`, p.localName, `(dAtA, uint64(key))`)
|
||||
p.P(`dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`return dAtA`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
p.P(`func encodeVarintPopulate`, p.localName, `(dAtA []byte, v uint64) []byte {`)
|
||||
p.In()
|
||||
p.P(`for v >= 1<<7 {`)
|
||||
p.In()
|
||||
p.P(`dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))`)
|
||||
p.P(`v >>= 7`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`dAtA = append(dAtA, uint8(v))`)
|
||||
p.P(`return dAtA`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewPlugin())
|
||||
}
|
701
vendor/github.com/gogo/protobuf/plugin/size/size.go
generated
vendored
Normal file
701
vendor/github.com/gogo/protobuf/plugin/size/size.go
generated
vendored
Normal file
@ -0,0 +1,701 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
The size plugin generates a Size or ProtoSize method for each message.
|
||||
This is useful with the MarshalTo method generated by the marshalto plugin and the
|
||||
gogoproto.marshaler and gogoproto.marshaler_all extensions.
|
||||
|
||||
It is enabled by the following extensions:
|
||||
|
||||
- sizer
|
||||
- sizer_all
|
||||
- protosizer
|
||||
- protosizer_all
|
||||
|
||||
The size plugin also generates a test given it is enabled using one of the following extensions:
|
||||
|
||||
- testgen
|
||||
- testgen_all
|
||||
|
||||
And a benchmark given it is enabled using one of the following extensions:
|
||||
|
||||
- benchgen
|
||||
- benchgen_all
|
||||
|
||||
Let us look at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/example.proto
|
||||
|
||||
Btw all the output can be seen at:
|
||||
|
||||
github.com/gogo/protobuf/test/example/*
|
||||
|
||||
The following message:
|
||||
|
||||
option (gogoproto.sizer_all) = true;
|
||||
|
||||
message B {
|
||||
option (gogoproto.description) = true;
|
||||
optional A A = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
repeated bytes G = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
given to the size plugin, will generate the following code:
|
||||
|
||||
func (m *B) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = m.A.Size()
|
||||
n += 1 + l + sovExample(uint64(l))
|
||||
if len(m.G) > 0 {
|
||||
for _, e := range m.G {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovExample(uint64(l))
|
||||
}
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
and the following test code:
|
||||
|
||||
func TestBSize(t *testing5.T) {
|
||||
popr := math_rand5.New(math_rand5.NewSource(time5.Now().UnixNano()))
|
||||
p := NewPopulatedB(popr, true)
|
||||
dAtA, err := github_com_gogo_protobuf_proto2.Marshal(p)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
size := p.Size()
|
||||
if len(dAtA) != size {
|
||||
t.Fatalf("size %v != marshalled size %v", size, len(dAtA))
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkBSize(b *testing5.B) {
|
||||
popr := math_rand5.New(math_rand5.NewSource(616))
|
||||
total := 0
|
||||
pops := make([]*B, 1000)
|
||||
for i := 0; i < 1000; i++ {
|
||||
pops[i] = NewPopulatedB(popr, false)
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
total += pops[i%1000].Size()
|
||||
}
|
||||
b.SetBytes(int64(total / b.N))
|
||||
}
|
||||
|
||||
The sovExample function is a size of varint function for the example.pb.go file.
|
||||
|
||||
*/
|
||||
package size
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
"github.com/gogo/protobuf/vanity"
|
||||
)
|
||||
|
||||
type size struct {
|
||||
*generator.Generator
|
||||
generator.PluginImports
|
||||
atleastOne bool
|
||||
localName string
|
||||
typesPkg generator.Single
|
||||
}
|
||||
|
||||
func NewSize() *size {
|
||||
return &size{}
|
||||
}
|
||||
|
||||
func (p *size) Name() string {
|
||||
return "size"
|
||||
}
|
||||
|
||||
func (p *size) Init(g *generator.Generator) {
|
||||
p.Generator = g
|
||||
}
|
||||
|
||||
func wireToType(wire string) int {
|
||||
switch wire {
|
||||
case "fixed64":
|
||||
return proto.WireFixed64
|
||||
case "fixed32":
|
||||
return proto.WireFixed32
|
||||
case "varint":
|
||||
return proto.WireVarint
|
||||
case "bytes":
|
||||
return proto.WireBytes
|
||||
case "group":
|
||||
return proto.WireBytes
|
||||
case "zigzag32":
|
||||
return proto.WireVarint
|
||||
case "zigzag64":
|
||||
return proto.WireVarint
|
||||
}
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
func keySize(fieldNumber int32, wireType int) int {
|
||||
x := uint32(fieldNumber)<<3 | uint32(wireType)
|
||||
size := 0
|
||||
for size = 0; x > 127; size++ {
|
||||
x >>= 7
|
||||
}
|
||||
size++
|
||||
return size
|
||||
}
|
||||
|
||||
func (p *size) sizeVarint() {
|
||||
p.P(`
|
||||
func sov`, p.localName, `(x uint64) (n int) {
|
||||
for {
|
||||
n++
|
||||
x >>= 7
|
||||
if x == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return n
|
||||
}`)
|
||||
}
|
||||
|
||||
func (p *size) sizeZigZag() {
|
||||
p.P(`func soz`, p.localName, `(x uint64) (n int) {
|
||||
return sov`, p.localName, `(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}`)
|
||||
}
|
||||
|
||||
func (p *size) std(field *descriptor.FieldDescriptorProto, name string) (string, bool) {
|
||||
ptr := ""
|
||||
if gogoproto.IsNullable(field) {
|
||||
ptr = "*"
|
||||
}
|
||||
if gogoproto.IsStdTime(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdTime(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdDuration(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdDuration(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdDouble(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdDouble(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdFloat(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdFloat(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdInt64(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdInt64(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdUInt64(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdUInt64(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdInt32(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdInt32(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdUInt32(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdUInt32(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdBool(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdBool(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdString(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdString(` + ptr + name + `)`, true
|
||||
} else if gogoproto.IsStdBytes(field) {
|
||||
return p.typesPkg.Use() + `.SizeOfStdBytes(` + ptr + name + `)`, true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (p *size) generateField(proto3 bool, file *generator.FileDescriptor, message *generator.Descriptor, field *descriptor.FieldDescriptorProto, sizeName string) {
|
||||
fieldname := p.GetOneOfFieldName(message, field)
|
||||
nullable := gogoproto.IsNullable(field)
|
||||
repeated := field.IsRepeated()
|
||||
doNilCheck := gogoproto.NeedsNilCheck(proto3, field)
|
||||
if repeated {
|
||||
p.P(`if len(m.`, fieldname, `) > 0 {`)
|
||||
p.In()
|
||||
} else if doNilCheck {
|
||||
p.P(`if m.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
}
|
||||
packed := field.IsPacked() || (proto3 && field.IsPacked3())
|
||||
_, wire := p.GoType(message, field)
|
||||
wireType := wireToType(wire)
|
||||
fieldNumber := field.GetNumber()
|
||||
if packed {
|
||||
wireType = proto.WireBytes
|
||||
}
|
||||
key := keySize(fieldNumber, wireType)
|
||||
switch *field.Type {
|
||||
case descriptor.FieldDescriptorProto_TYPE_DOUBLE,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED64,
|
||||
descriptor.FieldDescriptorProto_TYPE_SFIXED64:
|
||||
if packed {
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(len(m.`, fieldname, `)*8))`, `+len(m.`, fieldname, `)*8`)
|
||||
} else if repeated {
|
||||
p.P(`n+=`, strconv.Itoa(key+8), `*len(m.`, fieldname, `)`)
|
||||
} else if proto3 {
|
||||
p.P(`if m.`, fieldname, ` != 0 {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key+8))
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if nullable {
|
||||
p.P(`n+=`, strconv.Itoa(key+8))
|
||||
} else {
|
||||
p.P(`n+=`, strconv.Itoa(key+8))
|
||||
}
|
||||
case descriptor.FieldDescriptorProto_TYPE_FLOAT,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED32,
|
||||
descriptor.FieldDescriptorProto_TYPE_SFIXED32:
|
||||
if packed {
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(len(m.`, fieldname, `)*4))`, `+len(m.`, fieldname, `)*4`)
|
||||
} else if repeated {
|
||||
p.P(`n+=`, strconv.Itoa(key+4), `*len(m.`, fieldname, `)`)
|
||||
} else if proto3 {
|
||||
p.P(`if m.`, fieldname, ` != 0 {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key+4))
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if nullable {
|
||||
p.P(`n+=`, strconv.Itoa(key+4))
|
||||
} else {
|
||||
p.P(`n+=`, strconv.Itoa(key+4))
|
||||
}
|
||||
case descriptor.FieldDescriptorProto_TYPE_INT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_UINT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_UINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_ENUM,
|
||||
descriptor.FieldDescriptorProto_TYPE_INT32:
|
||||
if packed {
|
||||
p.P(`l = 0`)
|
||||
p.P(`for _, e := range m.`, fieldname, ` {`)
|
||||
p.In()
|
||||
p.P(`l+=sov`, p.localName, `(uint64(e))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(l))+l`)
|
||||
} else if repeated {
|
||||
p.P(`for _, e := range m.`, fieldname, ` {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(e))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if proto3 {
|
||||
p.P(`if m.`, fieldname, ` != 0 {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(m.`, fieldname, `))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if nullable {
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(*m.`, fieldname, `))`)
|
||||
} else {
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(m.`, fieldname, `))`)
|
||||
}
|
||||
case descriptor.FieldDescriptorProto_TYPE_BOOL:
|
||||
if packed {
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(len(m.`, fieldname, `)))`, `+len(m.`, fieldname, `)*1`)
|
||||
} else if repeated {
|
||||
p.P(`n+=`, strconv.Itoa(key+1), `*len(m.`, fieldname, `)`)
|
||||
} else if proto3 {
|
||||
p.P(`if m.`, fieldname, ` {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key+1))
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if nullable {
|
||||
p.P(`n+=`, strconv.Itoa(key+1))
|
||||
} else {
|
||||
p.P(`n+=`, strconv.Itoa(key+1))
|
||||
}
|
||||
case descriptor.FieldDescriptorProto_TYPE_STRING:
|
||||
if repeated {
|
||||
p.P(`for _, s := range m.`, fieldname, ` { `)
|
||||
p.In()
|
||||
p.P(`l = len(s)`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if proto3 {
|
||||
p.P(`l=len(m.`, fieldname, `)`)
|
||||
p.P(`if l > 0 {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if nullable {
|
||||
p.P(`l=len(*m.`, fieldname, `)`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
} else {
|
||||
p.P(`l=len(m.`, fieldname, `)`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
}
|
||||
case descriptor.FieldDescriptorProto_TYPE_GROUP:
|
||||
panic(fmt.Errorf("size does not support group %v", fieldname))
|
||||
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
||||
if p.IsMap(field) {
|
||||
m := p.GoMapType(nil, field)
|
||||
_, keywire := p.GoType(nil, m.KeyAliasField)
|
||||
valuegoTyp, _ := p.GoType(nil, m.ValueField)
|
||||
valuegoAliasTyp, valuewire := p.GoType(nil, m.ValueAliasField)
|
||||
_, fieldwire := p.GoType(nil, field)
|
||||
|
||||
nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp)
|
||||
|
||||
fieldKeySize := keySize(field.GetNumber(), wireToType(fieldwire))
|
||||
keyKeySize := keySize(1, wireToType(keywire))
|
||||
valueKeySize := keySize(2, wireToType(valuewire))
|
||||
p.P(`for k, v := range m.`, fieldname, ` { `)
|
||||
p.In()
|
||||
p.P(`_ = k`)
|
||||
p.P(`_ = v`)
|
||||
sum := []string{strconv.Itoa(keyKeySize)}
|
||||
switch m.KeyField.GetType() {
|
||||
case descriptor.FieldDescriptorProto_TYPE_DOUBLE,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED64,
|
||||
descriptor.FieldDescriptorProto_TYPE_SFIXED64:
|
||||
sum = append(sum, `8`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_FLOAT,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED32,
|
||||
descriptor.FieldDescriptorProto_TYPE_SFIXED32:
|
||||
sum = append(sum, `4`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_INT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_UINT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_UINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_ENUM,
|
||||
descriptor.FieldDescriptorProto_TYPE_INT32:
|
||||
sum = append(sum, `sov`+p.localName+`(uint64(k))`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_BOOL:
|
||||
sum = append(sum, `1`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_STRING,
|
||||
descriptor.FieldDescriptorProto_TYPE_BYTES:
|
||||
sum = append(sum, `len(k)+sov`+p.localName+`(uint64(len(k)))`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_SINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_SINT64:
|
||||
sum = append(sum, `soz`+p.localName+`(uint64(k))`)
|
||||
}
|
||||
switch m.ValueField.GetType() {
|
||||
case descriptor.FieldDescriptorProto_TYPE_DOUBLE,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED64,
|
||||
descriptor.FieldDescriptorProto_TYPE_SFIXED64:
|
||||
sum = append(sum, strconv.Itoa(valueKeySize))
|
||||
sum = append(sum, strconv.Itoa(8))
|
||||
case descriptor.FieldDescriptorProto_TYPE_FLOAT,
|
||||
descriptor.FieldDescriptorProto_TYPE_FIXED32,
|
||||
descriptor.FieldDescriptorProto_TYPE_SFIXED32:
|
||||
sum = append(sum, strconv.Itoa(valueKeySize))
|
||||
sum = append(sum, strconv.Itoa(4))
|
||||
case descriptor.FieldDescriptorProto_TYPE_INT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_UINT64,
|
||||
descriptor.FieldDescriptorProto_TYPE_UINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_ENUM,
|
||||
descriptor.FieldDescriptorProto_TYPE_INT32:
|
||||
sum = append(sum, strconv.Itoa(valueKeySize))
|
||||
sum = append(sum, `sov`+p.localName+`(uint64(v))`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_BOOL:
|
||||
sum = append(sum, strconv.Itoa(valueKeySize))
|
||||
sum = append(sum, `1`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_STRING:
|
||||
sum = append(sum, strconv.Itoa(valueKeySize))
|
||||
sum = append(sum, `len(v)+sov`+p.localName+`(uint64(len(v)))`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_BYTES:
|
||||
if gogoproto.IsCustomType(field) {
|
||||
p.P(`l = 0`)
|
||||
if nullable {
|
||||
p.P(`if v != nil {`)
|
||||
p.In()
|
||||
}
|
||||
p.P(`l = v.`, sizeName, `()`)
|
||||
p.P(`l += `, strconv.Itoa(valueKeySize), ` + sov`+p.localName+`(uint64(l))`)
|
||||
if nullable {
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
sum = append(sum, `l`)
|
||||
} else {
|
||||
p.P(`l = 0`)
|
||||
if proto3 {
|
||||
p.P(`if len(v) > 0 {`)
|
||||
} else {
|
||||
p.P(`if v != nil {`)
|
||||
}
|
||||
p.In()
|
||||
p.P(`l = `, strconv.Itoa(valueKeySize), ` + len(v)+sov`+p.localName+`(uint64(len(v)))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
sum = append(sum, `l`)
|
||||
}
|
||||
case descriptor.FieldDescriptorProto_TYPE_SINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_SINT64:
|
||||
sum = append(sum, strconv.Itoa(valueKeySize))
|
||||
sum = append(sum, `soz`+p.localName+`(uint64(v))`)
|
||||
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
||||
stdSizeCall, stdOk := p.std(m.ValueAliasField, "v")
|
||||
if nullable {
|
||||
p.P(`l = 0`)
|
||||
p.P(`if v != nil {`)
|
||||
p.In()
|
||||
if stdOk {
|
||||
p.P(`l = `, stdSizeCall)
|
||||
} else if valuegoTyp != valuegoAliasTyp {
|
||||
p.P(`l = ((`, valuegoTyp, `)(v)).`, sizeName, `()`)
|
||||
} else {
|
||||
p.P(`l = v.`, sizeName, `()`)
|
||||
}
|
||||
p.P(`l += `, strconv.Itoa(valueKeySize), ` + sov`+p.localName+`(uint64(l))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
sum = append(sum, `l`)
|
||||
} else {
|
||||
if stdOk {
|
||||
p.P(`l = `, stdSizeCall)
|
||||
} else if valuegoTyp != valuegoAliasTyp {
|
||||
p.P(`l = ((*`, valuegoTyp, `)(&v)).`, sizeName, `()`)
|
||||
} else {
|
||||
p.P(`l = v.`, sizeName, `()`)
|
||||
}
|
||||
sum = append(sum, strconv.Itoa(valueKeySize))
|
||||
sum = append(sum, `l+sov`+p.localName+`(uint64(l))`)
|
||||
}
|
||||
}
|
||||
p.P(`mapEntrySize := `, strings.Join(sum, "+"))
|
||||
p.P(`n+=mapEntrySize+`, fieldKeySize, `+sov`, p.localName, `(uint64(mapEntrySize))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if repeated {
|
||||
p.P(`for _, e := range m.`, fieldname, ` { `)
|
||||
p.In()
|
||||
stdSizeCall, stdOk := p.std(field, "e")
|
||||
if stdOk {
|
||||
p.P(`l=`, stdSizeCall)
|
||||
} else {
|
||||
p.P(`l=e.`, sizeName, `()`)
|
||||
}
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
stdSizeCall, stdOk := p.std(field, "m."+fieldname)
|
||||
if stdOk {
|
||||
p.P(`l=`, stdSizeCall)
|
||||
} else {
|
||||
p.P(`l=m.`, fieldname, `.`, sizeName, `()`)
|
||||
}
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
}
|
||||
case descriptor.FieldDescriptorProto_TYPE_BYTES:
|
||||
if !gogoproto.IsCustomType(field) {
|
||||
if repeated {
|
||||
p.P(`for _, b := range m.`, fieldname, ` { `)
|
||||
p.In()
|
||||
p.P(`l = len(b)`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if proto3 {
|
||||
p.P(`l=len(m.`, fieldname, `)`)
|
||||
p.P(`if l > 0 {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.P(`l=len(m.`, fieldname, `)`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
}
|
||||
} else {
|
||||
if repeated {
|
||||
p.P(`for _, e := range m.`, fieldname, ` { `)
|
||||
p.In()
|
||||
p.P(`l=e.`, sizeName, `()`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else {
|
||||
p.P(`l=m.`, fieldname, `.`, sizeName, `()`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+l+sov`, p.localName, `(uint64(l))`)
|
||||
}
|
||||
}
|
||||
case descriptor.FieldDescriptorProto_TYPE_SINT32,
|
||||
descriptor.FieldDescriptorProto_TYPE_SINT64:
|
||||
if packed {
|
||||
p.P(`l = 0`)
|
||||
p.P(`for _, e := range m.`, fieldname, ` {`)
|
||||
p.In()
|
||||
p.P(`l+=soz`, p.localName, `(uint64(e))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`n+=`, strconv.Itoa(key), `+sov`, p.localName, `(uint64(l))+l`)
|
||||
} else if repeated {
|
||||
p.P(`for _, e := range m.`, fieldname, ` {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key), `+soz`, p.localName, `(uint64(e))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if proto3 {
|
||||
p.P(`if m.`, fieldname, ` != 0 {`)
|
||||
p.In()
|
||||
p.P(`n+=`, strconv.Itoa(key), `+soz`, p.localName, `(uint64(m.`, fieldname, `))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if nullable {
|
||||
p.P(`n+=`, strconv.Itoa(key), `+soz`, p.localName, `(uint64(*m.`, fieldname, `))`)
|
||||
} else {
|
||||
p.P(`n+=`, strconv.Itoa(key), `+soz`, p.localName, `(uint64(m.`, fieldname, `))`)
|
||||
}
|
||||
default:
|
||||
panic("not implemented")
|
||||
}
|
||||
if repeated || doNilCheck {
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *size) Generate(file *generator.FileDescriptor) {
|
||||
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||
p.atleastOne = false
|
||||
p.localName = generator.FileName(file)
|
||||
p.typesPkg = p.NewImport("github.com/gogo/protobuf/types")
|
||||
protoPkg := p.NewImport("github.com/gogo/protobuf/proto")
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
protoPkg = p.NewImport("github.com/golang/protobuf/proto")
|
||||
}
|
||||
for _, message := range file.Messages() {
|
||||
sizeName := ""
|
||||
if gogoproto.IsSizer(file.FileDescriptorProto, message.DescriptorProto) && gogoproto.IsProtoSizer(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: message %v cannot support both sizer and protosizer plugins\n", generator.CamelCase(*message.Name))
|
||||
os.Exit(1)
|
||||
}
|
||||
if gogoproto.IsSizer(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
sizeName = "Size"
|
||||
} else if gogoproto.IsProtoSizer(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
sizeName = "ProtoSize"
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
p.atleastOne = true
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`)
|
||||
p.In()
|
||||
p.P(`if m == nil {`)
|
||||
p.In()
|
||||
p.P(`return 0`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`var l int`)
|
||||
p.P(`_ = l`)
|
||||
oneofs := make(map[string]struct{})
|
||||
for _, field := range message.Field {
|
||||
oneof := field.OneofIndex != nil
|
||||
if !oneof {
|
||||
proto3 := gogoproto.IsProto3(file.FileDescriptorProto)
|
||||
p.generateField(proto3, file, message, field, sizeName)
|
||||
} else {
|
||||
fieldname := p.GetFieldName(message, field)
|
||||
if _, ok := oneofs[fieldname]; ok {
|
||||
continue
|
||||
} else {
|
||||
oneofs[fieldname] = struct{}{}
|
||||
}
|
||||
p.P(`if m.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
p.P(`n+=m.`, fieldname, `.`, sizeName, `()`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
if message.DescriptorProto.HasExtension() {
|
||||
if gogoproto.HasExtensionsMap(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
p.P(`n += `, protoPkg.Use(), `.SizeOfInternalExtension(m)`)
|
||||
} else {
|
||||
p.P(`if m.XXX_extensions != nil {`)
|
||||
p.In()
|
||||
p.P(`n+=len(m.XXX_extensions)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
if gogoproto.HasUnrecognized(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
p.P(`if m.XXX_unrecognized != nil {`)
|
||||
p.In()
|
||||
p.P(`n+=len(m.XXX_unrecognized)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
p.P(`return n`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P()
|
||||
|
||||
//Generate Size methods for oneof fields
|
||||
m := proto.Clone(message.DescriptorProto).(*descriptor.DescriptorProto)
|
||||
for _, f := range m.Field {
|
||||
oneof := f.OneofIndex != nil
|
||||
if !oneof {
|
||||
continue
|
||||
}
|
||||
ccTypeName := p.OneOfTypeName(message, f)
|
||||
p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`)
|
||||
p.In()
|
||||
p.P(`if m == nil {`)
|
||||
p.In()
|
||||
p.P(`return 0`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`var l int`)
|
||||
p.P(`_ = l`)
|
||||
vanity.TurnOffNullableForNativeTypes(f)
|
||||
p.generateField(false, file, message, f, sizeName)
|
||||
p.P(`return n`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
if !p.atleastOne {
|
||||
return
|
||||
}
|
||||
|
||||
p.sizeVarint()
|
||||
p.sizeZigZag()
|
||||
|
||||
}
|
||||
|
||||
func init() {
|
||||
generator.RegisterPlugin(NewSize())
|
||||
}
|
134
vendor/github.com/gogo/protobuf/plugin/size/sizetest.go
generated
vendored
Normal file
134
vendor/github.com/gogo/protobuf/plugin/size/sizetest.go
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
// 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 size
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/plugin/testgen"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
)
|
||||
|
||||
type test struct {
|
||||
*generator.Generator
|
||||
}
|
||||
|
||||
func NewTest(g *generator.Generator) testgen.TestPlugin {
|
||||
return &test{g}
|
||||
}
|
||||
|
||||
func (p *test) Generate(imports generator.PluginImports, file *generator.FileDescriptor) bool {
|
||||
used := false
|
||||
randPkg := imports.NewImport("math/rand")
|
||||
timePkg := imports.NewImport("time")
|
||||
testingPkg := imports.NewImport("testing")
|
||||
protoPkg := imports.NewImport("github.com/gogo/protobuf/proto")
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
protoPkg = imports.NewImport("github.com/golang/protobuf/proto")
|
||||
}
|
||||
for _, message := range file.Messages() {
|
||||
ccTypeName := generator.CamelCaseSlice(message.TypeName())
|
||||
sizeName := ""
|
||||
if gogoproto.IsSizer(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
sizeName = "Size"
|
||||
} else if gogoproto.IsProtoSizer(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
sizeName = "ProtoSize"
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
if message.DescriptorProto.GetOptions().GetMapEntry() {
|
||||
continue
|
||||
}
|
||||
|
||||
if gogoproto.HasTestGen(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
used = true
|
||||
p.P(`func Test`, ccTypeName, sizeName, `(t *`, testingPkg.Use(), `.T) {`)
|
||||
p.In()
|
||||
p.P(`seed := `, timePkg.Use(), `.Now().UnixNano()`)
|
||||
p.P(`popr := `, randPkg.Use(), `.New(`, randPkg.Use(), `.NewSource(seed))`)
|
||||
p.P(`p := NewPopulated`, ccTypeName, `(popr, true)`)
|
||||
p.P(`size2 := `, protoPkg.Use(), `.Size(p)`)
|
||||
p.P(`dAtA, err := `, protoPkg.Use(), `.Marshal(p)`)
|
||||
p.P(`if err != nil {`)
|
||||
p.In()
|
||||
p.P(`t.Fatalf("seed = %d, err = %v", seed, err)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`size := p.`, sizeName, `()`)
|
||||
p.P(`if len(dAtA) != size {`)
|
||||
p.In()
|
||||
p.P(`t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`if size2 != size {`)
|
||||
p.In()
|
||||
p.P(`t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`size3 := `, protoPkg.Use(), `.Size(p)`)
|
||||
p.P(`if size3 != size {`)
|
||||
p.In()
|
||||
p.P(`t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P()
|
||||
}
|
||||
|
||||
if gogoproto.HasBenchGen(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
used = true
|
||||
p.P(`func Benchmark`, ccTypeName, sizeName, `(b *`, testingPkg.Use(), `.B) {`)
|
||||
p.In()
|
||||
p.P(`popr := `, randPkg.Use(), `.New(`, randPkg.Use(), `.NewSource(616))`)
|
||||
p.P(`total := 0`)
|
||||
p.P(`pops := make([]*`, ccTypeName, `, 1000)`)
|
||||
p.P(`for i := 0; i < 1000; i++ {`)
|
||||
p.In()
|
||||
p.P(`pops[i] = NewPopulated`, ccTypeName, `(popr, false)`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`b.ResetTimer()`)
|
||||
p.P(`for i := 0; i < b.N; i++ {`)
|
||||
p.In()
|
||||
p.P(`total += pops[i%1000].`, sizeName, `()`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`b.SetBytes(int64(total / b.N))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P()
|
||||
}
|
||||
|
||||
}
|
||||
return used
|
||||
}
|
||||
|
||||
func init() {
|
||||
testgen.RegisterTestPlugin(NewTest)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user