Add X-Registry-Config support

* Refactor auth pkg to support X-Registry-Config
* Refactor build endpoint to support X-Registry-Config. Supports:
  * --creds
  * --authfile
* Added X-Reference-Id Header to http.Request to support log event
  correlation
* Log headers from http.Request

Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
Jhon Honce
2020-09-23 08:19:05 -07:00
parent 2ee415be90
commit 5aead1509c
85 changed files with 3208 additions and 984 deletions

11
go.mod
View File

@ -35,6 +35,7 @@ require (
github.com/hashicorp/go-multierror v1.1.0
github.com/hpcloud/tail v1.0.0
github.com/json-iterator/go v1.1.10
github.com/kr/text v0.2.0 // indirect
github.com/moby/sys/mount v0.1.1 // indirect
github.com/moby/term v0.0.0-20200915141129-7f0af18e79f2
github.com/mrunalp/fileutils v0.0.0-20171103030105-7d4729fb3618
@ -53,6 +54,7 @@ require (
github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.6.1
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2
github.com/uber/jaeger-client-go v2.25.0+incompatible
@ -60,10 +62,15 @@ require (
github.com/varlink/go v0.0.0-20190502142041-0f1d566d194b
github.com/vishvananda/netlink v1.1.0
go.etcd.io/bbolt v1.3.5
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
golang.org/x/net v0.0.0-20200707034311-ab3426394381
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
k8s.io/api v0.0.0-20190620084959-7cf5895f2711
k8s.io/apimachinery v0.19.2
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab

21
go.sum
View File

@ -208,6 +208,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
@ -282,6 +284,8 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
@ -451,6 +455,8 @@ github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/y
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
@ -523,6 +529,8 @@ golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg=
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@ -540,6 +548,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
@ -549,6 +558,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA=
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -556,6 +567,8 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -614,6 +627,8 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@ -639,6 +654,8 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@ -655,6 +672,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4=
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w=
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
@ -666,6 +685,8 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2 h1:kG1BFyqVHuQoVQiR1bWGnfz/fmHvvuiSPIV7rvl360E=

View File

@ -93,7 +93,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
})
}
//FIXME/TODO to do this exactly correct, pruneimages needs to return idrs and space-reclaimed, then we are golden
// FIXME/TODO to do this exactly correct, pruneimages needs to return idrs and space-reclaimed, then we are golden
ipr := types.ImagesPruneReport{
ImagesDeleted: idr,
SpaceReclaimed: 1, // TODO we cannot supply this right now
@ -113,7 +113,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
Changes string `schema:"changes"`
Comment string `schema:"comment"`
Container string `schema:"container"`
//fromSrc string # fromSrc is currently unused
// fromSrc string # fromSrc is currently unused
Pause bool `schema:"pause"`
Repo string `schema:"repo"`
Tag string `schema:"tag"`
@ -224,7 +224,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
Status string `json:"status"`
Progress string `json:"progress"`
ProgressDetail map[string]string `json:"progressDetail"`
Id string `json:"id"` //nolint
Id string `json:"id"` // nolint
}{
Status: iid,
ProgressDetail: map[string]string{},
@ -257,9 +257,9 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) {
fromImage = fmt.Sprintf("%s:%s", fromImage, query.Tag)
}
authConf, authfile, err := auth.GetCredentials(r)
authConf, authfile, key, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", auth.XRegistryAuthHeader, r.URL.String()))
utils.Error(w, "Failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", key, r.URL.String()))
return
}
defer auth.RemoveAuthfile(authfile)
@ -299,7 +299,7 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) {
Error string `json:"error"`
Progress string `json:"progress"`
ProgressDetail map[string]string `json:"progressDetail"`
Id string `json:"id"` //nolint
Id string `json:"id"` // nolint
}{
Status: fmt.Sprintf("pulling image (%s) from %s", img.Tag, strings.Join(img.Names(), ", ")),
ProgressDetail: map[string]string{},

View File

@ -2,7 +2,6 @@ package compat
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io"
@ -11,13 +10,13 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"github.com/containers/buildah"
"github.com/containers/buildah/imagebuildah"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v2/libpod"
"github.com/containers/podman/v2/pkg/api/handlers"
"github.com/containers/podman/v2/pkg/api/handlers/utils"
"github.com/containers/podman/v2/pkg/auth"
"github.com/containers/podman/v2/pkg/channel"
"github.com/containers/storage/pkg/archive"
"github.com/gorilla/schema"
@ -26,15 +25,6 @@ import (
)
func BuildImage(w http.ResponseWriter, r *http.Request) {
authConfigs := map[string]handlers.AuthConfig{}
if hdr, found := r.Header["X-Registry-Config"]; found && len(hdr) > 0 {
authConfigsJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(hdr[0]))
if json.NewDecoder(authConfigsJSON).Decode(&authConfigs) != nil {
utils.BadRequest(w, "X-Registry-Config", hdr[0], json.NewDecoder(authConfigsJSON).Decode(&authConfigs))
return
}
}
if hdr, found := r.Header["Content-Type"]; found && len(hdr) > 0 {
contentType := hdr[0]
switch contentType {
@ -151,6 +141,14 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
}
}
creds, authfile, key, err := auth.GetCredentials(r)
if err != nil {
// Credential value(s) not returned as their value is not human readable
utils.BadRequest(w, key.String(), "n/a", err)
return
}
defer auth.RemoveAuthfile(authfile)
// Channels all mux'ed in select{} below to follow API build protocol
stdout := channel.NewWriter(make(chan []byte, 1))
defer stdout.Close()
@ -179,6 +177,10 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Err: auxout,
ReportWriter: reporter,
OutputFormat: buildah.Dockerv2ImageManifest,
SystemContext: &types.SystemContext{
AuthFilePath: authfile,
DockerAuthConfig: creds,
},
CommonBuildOpts: &buildah.CommonBuildOptions{
CPUPeriod: query.CpuPeriod,
CPUQuota: query.CpuQuota,

View File

@ -49,9 +49,9 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
return
}
authConf, authfile, err := auth.GetCredentials(r)
authConf, authfile, key, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", auth.XRegistryAuthHeader, r.URL.String()))
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", key, r.URL.String()))
return
}
defer auth.RemoveAuthfile(authfile)

View File

@ -438,9 +438,9 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
return
}
authConf, authfile, err := auth.GetCredentials(r)
authConf, authfile, key, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", auth.XRegistryAuthHeader, r.URL.String()))
utils.Error(w, "Failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", key, r.URL.String()))
return
}
defer auth.RemoveAuthfile(authfile)

View File

@ -74,9 +74,9 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
return
}
authConf, authfile, err := auth.GetCredentials(r)
authConf, authfile, key, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", auth.XRegistryAuthHeader, r.URL.String()))
utils.Error(w, "Failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", key, r.URL.String()))
return
}
defer auth.RemoveAuthfile(authfile)

View File

@ -48,9 +48,9 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error closing temporary file"))
return
}
authConf, authfile, err := auth.GetCredentials(r)
authConf, authfile, key, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", auth.XRegistryAuthHeader, r.URL.String()))
utils.Error(w, "Failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse %q header for %s", key, r.URL.String()))
return
}
defer auth.RemoveAuthfile(authfile)

View File

@ -7,7 +7,9 @@ import (
"runtime"
"github.com/containers/podman/v2/pkg/api/handlers/utils"
log "github.com/sirupsen/logrus"
"github.com/containers/podman/v2/pkg/auth"
"github.com/google/uuid"
"github.com/sirupsen/logrus"
)
// APIHandler is a wrapper to enhance HandlerFunc's and remove redundant code
@ -19,7 +21,7 @@ func (s *APIServer) APIHandler(h http.HandlerFunc) http.HandlerFunc {
if err != nil {
buf := make([]byte, 1<<20)
n := runtime.Stack(buf, true)
log.Warnf("Recovering from API handler panic: %v, %s", err, buf[:n])
logrus.Warnf("Recovering from API handler panic: %v, %s", err, buf[:n])
// Try to inform client things went south... won't work if handler already started writing response body
utils.InternalServerError(w, fmt.Errorf("%v", err))
}
@ -27,10 +29,23 @@ func (s *APIServer) APIHandler(h http.HandlerFunc) http.HandlerFunc {
// Wrapper to hide some boiler plate
fn := func(w http.ResponseWriter, r *http.Request) {
log.Debugf("APIHandler -- Method: %s URL: %s", r.Method, r.URL.String())
rid := uuid.New().String()
if logrus.IsLevelEnabled(logrus.DebugLevel) {
logrus.Debugf("APIHandler(%s) -- Method: %s URL: %s", rid, r.Method, r.URL.String())
for k, v := range r.Header {
switch auth.HeaderAuthName(k) {
case auth.XRegistryConfigHeader, auth.XRegistryAuthHeader:
logrus.Debugf("APIHandler(%s) -- Header: %s: <hidden>", rid, k)
default:
logrus.Debugf("APIHandler(%s) -- Header: %s: %v", rid, k, v)
}
}
}
// Set in case handler wishes to correlate logging events
r.Header.Set("X-Reference-Id", rid)
if err := r.ParseForm(); err != nil {
log.Infof("Failed Request: unable to parse form: %q", err)
logrus.Infof("Failed Request: unable to parse form: %q (%s)", err, rid)
}
// TODO: Use r.ConnContext when ported to go 1.13

View File

@ -3,6 +3,7 @@ package auth
import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
@ -15,21 +16,98 @@ import (
"github.com/sirupsen/logrus"
)
// XRegistryAuthHeader is the key to the encoded registry authentication
// configuration in an http-request header.
const XRegistryAuthHeader = "X-Registry-Auth"
type HeaderAuthName string
// GetCredentials extracts one or more DockerAuthConfigs from the request's
func (h HeaderAuthName) String() string { return string(h) }
// XRegistryAuthHeader is the key to the encoded registry authentication configuration in an http-request header.
// This header supports one registry per header occurrence. To support N registries provided N headers, one per registry.
// As of Docker API 1.40 and Libpod API 1.0.0, this header is supported by all endpoints.
const XRegistryAuthHeader HeaderAuthName = "X-Registry-Auth"
// XRegistryConfigHeader is the key to the encoded registry authentication configuration in an http-request header.
// This header supports N registries in one header via a Base64 encoded, JSON map.
// As of Docker API 1.40 and Libpod API 2.0.0, this header is supported by build endpoints.
const XRegistryConfigHeader HeaderAuthName = "X-Registry-Config"
// GetCredentials queries the http.Request for X-Registry-.* headers and extracts
// the necessary authentication information for libpod operations
func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, HeaderAuthName, error) {
has := func(key HeaderAuthName) bool { hdr, found := r.Header[string(key)]; return found && len(hdr) > 0 }
switch {
case has(XRegistryConfigHeader):
c, f, err := getConfigCredentials(r)
return c, f, XRegistryConfigHeader, err
case has(XRegistryAuthHeader):
c, f, err := getAuthCredentials(r)
return c, f, XRegistryAuthHeader, err
}
return nil, "", "", nil
}
// getConfigCredentials extracts one or more docker.AuthConfig from the request's
// header. An empty key will be used as default while a named registry will be
// returned as types.DockerAuthConfig
func getConfigCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) {
var auth *types.DockerAuthConfig
configs := make(map[string]types.DockerAuthConfig)
for _, h := range r.Header[string(XRegistryConfigHeader)] {
param, err := base64.URLEncoding.DecodeString(h)
if err != nil {
return nil, "", errors.Wrapf(err, "failed to decode %q", XRegistryConfigHeader)
}
ac := make(map[string]dockerAPITypes.AuthConfig)
err = json.Unmarshal(param, &ac)
if err != nil {
return nil, "", errors.Wrapf(err, "failed to unmarshal %q", XRegistryConfigHeader)
}
for k, v := range ac {
configs[k] = dockerAuthToImageAuth(v)
}
}
// Empty key implies no registry given in API
if c, found := configs[""]; found {
auth = &c
}
// Override any default given above if specialized credentials provided
if registries, found := r.URL.Query()["registry"]; found {
for _, r := range registries {
for k, v := range configs {
if strings.Contains(k, r) {
v := v
auth = &v
break
}
}
if auth != nil {
break
}
}
if auth == nil {
logrus.Debugf("%q header found in request, but \"registry=%v\" query parameter not provided",
XRegistryConfigHeader, registries)
} else {
logrus.Debugf("%q header found in request for username %q", XRegistryConfigHeader, auth.Username)
}
}
authfile, err := authConfigsToAuthFile(configs)
return auth, authfile, err
}
// getAuthCredentials extracts one or more DockerAuthConfigs from the request's
// header. The header could specify a single-auth config in which case the
// first return value is set. In case of a multi-auth header, the contents are
// stored in a temporary auth file (2nd return value). Note that the auth file
// should be removed after usage.
func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) {
authHeader := r.Header.Get(XRegistryAuthHeader)
if len(authHeader) == 0 {
return nil, "", nil
}
func getAuthCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) {
// First look for a multi-auth header (i.e., a map).
authConfigs, err := multiAuthHeader(r)
if err == nil {
@ -51,18 +129,33 @@ func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) {
return conf, "", nil
}
// Header returns a map with the XRegistryAuthHeader set which can
// conveniently be used in the http stack.
func Header(sys *types.SystemContext, authfile, username, password string) (map[string]string, error) {
var content string
var err error
if username != "" {
content, err = encodeSingleAuthConfig(types.DockerAuthConfig{Username: username, Password: password})
// Header builds the requested Authentication Header
func Header(sys *types.SystemContext, headerName HeaderAuthName, authfile, username, password string) (map[string]string, error) {
var (
content string
err error
)
switch headerName {
case XRegistryAuthHeader:
content, err = headerAuth(sys, authfile, username, password)
case XRegistryConfigHeader:
content, err = headerConfig(sys, authfile, username, password)
default:
err = fmt.Errorf("unsupported authentication header: %q", headerName)
}
if err != nil {
return nil, err
}
} else {
if len(content) > 0 {
return map[string]string{string(headerName): content}, nil
}
return nil, nil
}
// headerConfig returns a map with the XRegistryConfigHeader set which can
// conveniently be used in the http stack.
func headerConfig(sys *types.SystemContext, authfile, username, password string) (string, error) {
if sys == nil {
sys = &types.SystemContext{}
}
@ -71,18 +164,40 @@ func Header(sys *types.SystemContext, authfile, username, password string) (map[
}
authConfigs, err := imageAuth.GetAllCredentials(sys)
if err != nil {
return nil, err
return "", err
}
content, err = encodeMultiAuthConfigs(authConfigs)
if username != "" {
authConfigs[""] = types.DockerAuthConfig{
Username: username,
Password: password,
}
}
if len(authConfigs) == 0 {
return "", nil
}
return encodeMultiAuthConfigs(authConfigs)
}
// headerAuth returns a base64 encoded map with the XRegistryAuthHeader set which can
// conveniently be used in the http stack.
func headerAuth(sys *types.SystemContext, authfile, username, password string) (string, error) {
if username != "" {
return encodeSingleAuthConfig(types.DockerAuthConfig{Username: username, Password: password})
}
if sys == nil {
sys = &types.SystemContext{}
}
if authfile != "" {
sys.AuthFilePath = authfile
}
authConfigs, err := imageAuth.GetAllCredentials(sys)
if err != nil {
return nil, err
return "", err
}
}
header := make(map[string]string)
header[XRegistryAuthHeader] = content
return header, nil
return encodeMultiAuthConfigs(authConfigs)
}
// RemoveAuthfile is a convenience function that is meant to be called in a
@ -180,7 +295,7 @@ func imageAuthToDockerAuth(authConfig types.DockerAuthConfig) dockerAPITypes.Aut
// singleAuthHeader extracts a DockerAuthConfig from the request's header.
// The header content is a single DockerAuthConfig.
func singleAuthHeader(r *http.Request) (map[string]types.DockerAuthConfig, error) {
authHeader := r.Header.Get(XRegistryAuthHeader)
authHeader := r.Header.Get(string(XRegistryAuthHeader))
authConfig := dockerAPITypes.AuthConfig{}
if len(authHeader) > 0 {
authJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authHeader))
@ -196,7 +311,7 @@ func singleAuthHeader(r *http.Request) (map[string]types.DockerAuthConfig, error
// multiAuthHeader extracts a DockerAuthConfig from the request's header.
// The header content is a map[string]DockerAuthConfigs.
func multiAuthHeader(r *http.Request) (map[string]types.DockerAuthConfig, error) {
authHeader := r.Header.Get(XRegistryAuthHeader)
authHeader := r.Header.Get(string(XRegistryAuthHeader))
if len(authHeader) == 0 {
return nil, nil
}

View File

@ -15,6 +15,7 @@ import (
"strings"
"github.com/containers/buildah"
"github.com/containers/podman/v2/pkg/auth"
"github.com/containers/podman/v2/pkg/bindings"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/docker/go-units"
@ -93,6 +94,23 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
params.Set("labels", l)
}
var (
headers map[string]string
err error
)
if options.SystemContext == nil {
headers, err = auth.Header(options.SystemContext, auth.XRegistryConfigHeader, "", "", "")
} else {
if options.SystemContext.DockerAuthConfig != nil {
headers, err = auth.Header(options.SystemContext, auth.XRegistryAuthHeader, options.SystemContext.AuthFilePath, options.SystemContext.DockerAuthConfig.Username, options.SystemContext.DockerAuthConfig.Password)
} else {
headers, err = auth.Header(options.SystemContext, auth.XRegistryConfigHeader, options.SystemContext.AuthFilePath, "", "")
}
}
if err != nil {
return nil, err
}
stdout := io.Writer(os.Stdout)
if options.Out != nil {
stdout = options.Out
@ -125,7 +143,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
if err != nil {
return nil, err
}
response, err := conn.DoRequest(tarfile, http.MethodPost, "/build", params, nil)
response, err := conn.DoRequest(tarfile, http.MethodPost, "/build", params, headers)
if err != nil {
return nil, err
}

View File

@ -282,7 +282,7 @@ func Push(ctx context.Context, source string, destination string, options entiti
}
// TODO: have a global system context we can pass around (1st argument)
header, err := auth.Header(nil, options.Authfile, options.Username, options.Password)
header, err := auth.Header(nil, auth.XRegistryAuthHeader, options.Authfile, options.Username, options.Password)
if err != nil {
return err
}
@ -325,7 +325,7 @@ func Search(ctx context.Context, term string, opts entities.ImageSearchOptions)
}
// TODO: have a global system context we can pass around (1st argument)
header, err := auth.Header(nil, opts.Authfile, "", "")
header, err := auth.Header(nil, auth.XRegistryAuthHeader, opts.Authfile, "", "")
if err != nil {
return nil, err
}

View File

@ -42,7 +42,7 @@ func Pull(ctx context.Context, rawImage string, options entities.ImagePullOption
params.Set("allTags", strconv.FormatBool(options.AllTags))
// TODO: have a global system context we can pass around (1st argument)
header, err := auth.Header(nil, options.Authfile, options.Username, options.Password)
header, err := auth.Header(nil, auth.XRegistryAuthHeader, options.Authfile, options.Username, options.Password)
if err != nil {
return nil, err
}

View File

@ -33,7 +33,7 @@ func Kube(ctx context.Context, path string, options entities.PlayKubeOptions) (*
}
// TODO: have a global system context we can pass around (1st argument)
header, err := auth.Header(nil, options.Authfile, options.Username, options.Password)
header, err := auth.Header(nil, auth.XRegistryAuthHeader, options.Authfile, options.Username, options.Password)
if err != nil {
return nil, err
}

13
vendor/golang.org/x/oauth2/README.md generated vendored
View File

@ -16,15 +16,16 @@ Or you can manually git clone the repository to
See godoc for further documentation and examples.
* [godoc.org/golang.org/x/oauth2](http://godoc.org/golang.org/x/oauth2)
* [godoc.org/golang.org/x/oauth2/google](http://godoc.org/golang.org/x/oauth2/google)
* [godoc.org/golang.org/x/oauth2](https://godoc.org/golang.org/x/oauth2)
* [godoc.org/golang.org/x/oauth2/google](https://godoc.org/golang.org/x/oauth2/google)
## Policy for new packages
We no longer accept new provider-specific packages in this repo. For
defining provider endpoints and provider-specific OAuth2 behavior, we
encourage you to create packages elsewhere. We'll keep the existing
packages for compatibility.
We no longer accept new provider-specific packages in this repo if all
they do is add a single endpoint variable. If you just want to add a
single endpoint, add it to the
[godoc.org/golang.org/x/oauth2/endpoints](https://godoc.org/golang.org/x/oauth2/endpoints)
package.
## Report Issues / Send Patches

View File

@ -117,7 +117,7 @@ var (
// ApprovalForce forces the users to view the consent dialog
// and confirm the permissions request at the URL returned
// from AuthCodeURL, even if they've already done so.
ApprovalForce AuthCodeOption = SetAuthURLParam("approval_prompt", "force")
ApprovalForce AuthCodeOption = SetAuthURLParam("prompt", "consent")
)
// An AuthCodeOption is passed to Config.AuthCodeURL.

View File

@ -6,7 +6,7 @@ package oauth2
import (
"errors"
"io"
"log"
"net/http"
"sync"
)
@ -25,9 +25,6 @@ type Transport struct {
// Base is the base RoundTripper used to make HTTP requests.
// If nil, http.DefaultTransport is used.
Base http.RoundTripper
mu sync.Mutex // guards modReq
modReq map[*http.Request]*http.Request // original -> modified
}
// RoundTrip authorizes and authenticates the request with an
@ -52,35 +49,22 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
req2 := cloneRequest(req) // per RoundTripper contract
token.SetAuthHeader(req2)
t.setModReq(req, req2)
res, err := t.base().RoundTrip(req2)
// req.Body is assumed to have been closed by the base RoundTripper.
// req.Body is assumed to be closed by the base RoundTripper.
reqBodyClosed = true
if err != nil {
t.setModReq(req, nil)
return nil, err
}
res.Body = &onEOFReader{
rc: res.Body,
fn: func() { t.setModReq(req, nil) },
}
return res, nil
return t.base().RoundTrip(req2)
}
// CancelRequest cancels an in-flight request by closing its connection.
var cancelOnce sync.Once
// CancelRequest does nothing. It used to be a legacy cancellation mechanism
// but now only it only logs on first use to warn that it's deprecated.
//
// Deprecated: use contexts for cancellation instead.
func (t *Transport) CancelRequest(req *http.Request) {
type canceler interface {
CancelRequest(*http.Request)
}
if cr, ok := t.base().(canceler); ok {
t.mu.Lock()
modReq := t.modReq[req]
delete(t.modReq, req)
t.mu.Unlock()
cr.CancelRequest(modReq)
}
cancelOnce.Do(func() {
log.Printf("deprecated: golang.org/x/oauth2: Transport.CancelRequest no longer does anything; use contexts")
})
}
func (t *Transport) base() http.RoundTripper {
@ -90,19 +74,6 @@ func (t *Transport) base() http.RoundTripper {
return http.DefaultTransport
}
func (t *Transport) setModReq(orig, mod *http.Request) {
t.mu.Lock()
defer t.mu.Unlock()
if t.modReq == nil {
t.modReq = make(map[*http.Request]*http.Request)
}
if mod == nil {
delete(t.modReq, orig)
} else {
t.modReq[orig] = mod
}
}
// cloneRequest returns a clone of the provided *http.Request.
// The clone is a shallow copy of the struct and its Header map.
func cloneRequest(r *http.Request) *http.Request {
@ -116,29 +87,3 @@ func cloneRequest(r *http.Request) *http.Request {
}
return r2
}
type onEOFReader struct {
rc io.ReadCloser
fn func()
}
func (r *onEOFReader) Read(p []byte) (n int, err error) {
n, err = r.rc.Read(p)
if err == io.EOF {
r.runFunc()
}
return
}
func (r *onEOFReader) Close() error {
err := r.rc.Close()
r.runFunc()
return err
}
func (r *onEOFReader) runFunc() {
if fn := r.fn; fn != nil {
fn()
r.fn = nil
}
}

View File

@ -60,6 +60,9 @@ var (
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: limitDial,
MaxIdleConns: 1000,
MaxIdleConnsPerHost: 10000,
IdleConnTimeout: 90 * time.Second,
},
}

View File

@ -32,7 +32,7 @@ func limitDial(network, addr string) (net.Conn, error) {
// Dial with a timeout in case the API host is MIA.
// The connection should normally be very fast.
conn, err := net.DialTimeout(network, addr, 500*time.Millisecond)
conn, err := net.DialTimeout(network, addr, 10*time.Second)
if err != nil {
limitRelease()
return nil, err

View File

@ -12,8 +12,8 @@ import (
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/encoding/text"
"google.golang.org/protobuf/internal/errors"
"google.golang.org/protobuf/internal/fieldnum"
"google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/internal/set"
"google.golang.org/protobuf/internal/strs"
@ -108,7 +108,7 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
return errors.New("no support for proto1 MessageSets")
}
if messageDesc.FullName() == "google.protobuf.Any" {
if messageDesc.FullName() == genid.Any_message_fullname {
return d.unmarshalAny(m, checkDelims)
}
@ -538,14 +538,13 @@ Loop:
return d.unexpectedTokenError(tok)
}
name := tok.IdentName()
switch name {
case "key":
switch name := pref.Name(tok.IdentName()); name {
case genid.MapEntry_Key_field_name:
if !tok.HasSeparator() {
return d.syntaxError(tok.Pos(), "missing field separator :")
}
if key.IsValid() {
return d.newError(tok.Pos(), `map entry "key" cannot be repeated`)
return d.newError(tok.Pos(), "map entry %q cannot be repeated", name)
}
val, err := d.unmarshalScalar(fd.MapKey())
if err != nil {
@ -553,14 +552,14 @@ Loop:
}
key = val.MapKey()
case "value":
case genid.MapEntry_Value_field_name:
if kind := fd.MapValue().Kind(); (kind != pref.MessageKind) && (kind != pref.GroupKind) {
if !tok.HasSeparator() {
return d.syntaxError(tok.Pos(), "missing field separator :")
}
}
if pval.IsValid() {
return d.newError(tok.Pos(), `map entry "value" cannot be repeated`)
return d.newError(tok.Pos(), "map entry %q cannot be repeated", name)
}
pval, err = unmarshalMapValue()
if err != nil {
@ -597,13 +596,9 @@ Loop:
func (d decoder) unmarshalAny(m pref.Message, checkDelims bool) error {
var typeURL string
var bValue []byte
// hasFields tracks which valid fields have been seen in the loop below in
// order to flag an error if there are duplicates or conflicts. It may
// contain the strings "type_url", "value" and "expanded". The literal
// "expanded" is used to indicate that the expanded form has been
// encountered already.
hasFields := map[string]bool{}
var seenTypeUrl bool
var seenValue bool
var isExpanded bool
if checkDelims {
tok, err := d.Read()
@ -642,12 +637,12 @@ Loop:
return d.syntaxError(tok.Pos(), "missing field separator :")
}
switch tok.IdentName() {
case "type_url":
if hasFields["type_url"] {
return d.newError(tok.Pos(), "duplicate Any type_url field")
switch name := pref.Name(tok.IdentName()); name {
case genid.Any_TypeUrl_field_name:
if seenTypeUrl {
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_TypeUrl_field_fullname)
}
if hasFields["expanded"] {
if isExpanded {
return d.newError(tok.Pos(), "conflict with [%s] field", typeURL)
}
tok, err := d.Read()
@ -657,15 +652,15 @@ Loop:
var ok bool
typeURL, ok = tok.String()
if !ok {
return d.newError(tok.Pos(), "invalid Any type_url: %v", tok.RawString())
return d.newError(tok.Pos(), "invalid %v field value: %v", genid.Any_TypeUrl_field_fullname, tok.RawString())
}
hasFields["type_url"] = true
seenTypeUrl = true
case "value":
if hasFields["value"] {
return d.newError(tok.Pos(), "duplicate Any value field")
case genid.Any_Value_field_name:
if seenValue {
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_Value_field_fullname)
}
if hasFields["expanded"] {
if isExpanded {
return d.newError(tok.Pos(), "conflict with [%s] field", typeURL)
}
tok, err := d.Read()
@ -674,22 +669,22 @@ Loop:
}
s, ok := tok.String()
if !ok {
return d.newError(tok.Pos(), "invalid Any value: %v", tok.RawString())
return d.newError(tok.Pos(), "invalid %v field value: %v", genid.Any_Value_field_fullname, tok.RawString())
}
bValue = []byte(s)
hasFields["value"] = true
seenValue = true
default:
if !d.opts.DiscardUnknown {
return d.newError(tok.Pos(), "invalid field name %q in google.protobuf.Any message", tok.RawString())
return d.newError(tok.Pos(), "invalid field name %q in %v message", tok.RawString(), genid.Any_message_fullname)
}
}
case text.TypeName:
if hasFields["expanded"] {
if isExpanded {
return d.newError(tok.Pos(), "cannot have more than one type")
}
if hasFields["type_url"] {
if seenTypeUrl {
return d.newError(tok.Pos(), "conflict with type_url field")
}
typeURL = tok.TypeName()
@ -698,21 +693,21 @@ Loop:
if err != nil {
return err
}
hasFields["expanded"] = true
isExpanded = true
default:
if !d.opts.DiscardUnknown {
return d.newError(tok.Pos(), "invalid field name %q in google.protobuf.Any message", tok.RawString())
return d.newError(tok.Pos(), "invalid field name %q in %v message", tok.RawString(), genid.Any_message_fullname)
}
}
}
fds := m.Descriptor().Fields()
if len(typeURL) > 0 {
m.Set(fds.ByNumber(fieldnum.Any_TypeUrl), pref.ValueOfString(typeURL))
m.Set(fds.ByNumber(genid.Any_TypeUrl_field_number), pref.ValueOfString(typeURL))
}
if len(bValue) > 0 {
m.Set(fds.ByNumber(fieldnum.Any_Value), pref.ValueOfBytes(bValue))
m.Set(fds.ByNumber(genid.Any_Value_field_number), pref.ValueOfBytes(bValue))
}
return nil
}

View File

@ -14,8 +14,8 @@ import (
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/encoding/text"
"google.golang.org/protobuf/internal/errors"
"google.golang.org/protobuf/internal/fieldnum"
"google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/mapsort"
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/internal/strs"
@ -162,7 +162,7 @@ func (e encoder) marshalMessage(m pref.Message, inclDelims bool) error {
}
// Handle Any expansion.
if messageDesc.FullName() == "google.protobuf.Any" {
if messageDesc.FullName() == genid.Any_message_fullname {
if e.marshalAny(m) {
return nil
}
@ -295,13 +295,13 @@ func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor)
e.StartMessage()
defer e.EndMessage()
e.WriteName("key")
e.WriteName(string(genid.MapEntry_Key_field_name))
err = e.marshalSingular(key.Value(), fd.MapKey())
if err != nil {
return false
}
e.WriteName("value")
e.WriteName(string(genid.MapEntry_Value_field_name))
err = e.marshalSingular(val, fd.MapValue())
if err != nil {
return false
@ -399,7 +399,7 @@ func (e encoder) marshalUnknown(b []byte) {
func (e encoder) marshalAny(any pref.Message) bool {
// Construct the embedded message.
fds := any.Descriptor().Fields()
fdType := fds.ByNumber(fieldnum.Any_TypeUrl)
fdType := fds.ByNumber(genid.Any_TypeUrl_field_number)
typeURL := any.Get(fdType).String()
mt, err := e.opts.Resolver.FindMessageByURL(typeURL)
if err != nil {
@ -408,7 +408,7 @@ func (e encoder) marshalAny(any pref.Message) bool {
m := mt.New().Interface()
// Unmarshal bytes into embedded message.
fdValue := fds.ByNumber(fieldnum.Any_Value)
fdValue := fds.ByNumber(genid.Any_Value_field_number)
value := any.Get(fdValue)
err = proto.UnmarshalOptions{
AllowPartial: true,

View File

@ -1,13 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.Any.
const (
Any_TypeUrl = 1 // optional string
Any_Value = 2 // optional bytes
)

View File

@ -1,35 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.Api.
const (
Api_Name = 1 // optional string
Api_Methods = 2 // repeated google.protobuf.Method
Api_Options = 3 // repeated google.protobuf.Option
Api_Version = 4 // optional string
Api_SourceContext = 5 // optional google.protobuf.SourceContext
Api_Mixins = 6 // repeated google.protobuf.Mixin
Api_Syntax = 7 // optional google.protobuf.Syntax
)
// Field numbers for google.protobuf.Method.
const (
Method_Name = 1 // optional string
Method_RequestTypeUrl = 2 // optional string
Method_RequestStreaming = 3 // optional bool
Method_ResponseTypeUrl = 4 // optional string
Method_ResponseStreaming = 5 // optional bool
Method_Options = 6 // repeated google.protobuf.Option
Method_Syntax = 7 // optional google.protobuf.Syntax
)
// Field numbers for google.protobuf.Mixin.
const (
Mixin_Name = 1 // optional string
Mixin_Root = 2 // optional string
)

View File

@ -1,240 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.FileDescriptorSet.
const (
FileDescriptorSet_File = 1 // repeated google.protobuf.FileDescriptorProto
)
// Field numbers for google.protobuf.FileDescriptorProto.
const (
FileDescriptorProto_Name = 1 // optional string
FileDescriptorProto_Package = 2 // optional string
FileDescriptorProto_Dependency = 3 // repeated string
FileDescriptorProto_PublicDependency = 10 // repeated int32
FileDescriptorProto_WeakDependency = 11 // repeated int32
FileDescriptorProto_MessageType = 4 // repeated google.protobuf.DescriptorProto
FileDescriptorProto_EnumType = 5 // repeated google.protobuf.EnumDescriptorProto
FileDescriptorProto_Service = 6 // repeated google.protobuf.ServiceDescriptorProto
FileDescriptorProto_Extension = 7 // repeated google.protobuf.FieldDescriptorProto
FileDescriptorProto_Options = 8 // optional google.protobuf.FileOptions
FileDescriptorProto_SourceCodeInfo = 9 // optional google.protobuf.SourceCodeInfo
FileDescriptorProto_Syntax = 12 // optional string
)
// Field numbers for google.protobuf.DescriptorProto.
const (
DescriptorProto_Name = 1 // optional string
DescriptorProto_Field = 2 // repeated google.protobuf.FieldDescriptorProto
DescriptorProto_Extension = 6 // repeated google.protobuf.FieldDescriptorProto
DescriptorProto_NestedType = 3 // repeated google.protobuf.DescriptorProto
DescriptorProto_EnumType = 4 // repeated google.protobuf.EnumDescriptorProto
DescriptorProto_ExtensionRange = 5 // repeated google.protobuf.DescriptorProto.ExtensionRange
DescriptorProto_OneofDecl = 8 // repeated google.protobuf.OneofDescriptorProto
DescriptorProto_Options = 7 // optional google.protobuf.MessageOptions
DescriptorProto_ReservedRange = 9 // repeated google.protobuf.DescriptorProto.ReservedRange
DescriptorProto_ReservedName = 10 // repeated string
)
// Field numbers for google.protobuf.DescriptorProto.ExtensionRange.
const (
DescriptorProto_ExtensionRange_Start = 1 // optional int32
DescriptorProto_ExtensionRange_End = 2 // optional int32
DescriptorProto_ExtensionRange_Options = 3 // optional google.protobuf.ExtensionRangeOptions
)
// Field numbers for google.protobuf.DescriptorProto.ReservedRange.
const (
DescriptorProto_ReservedRange_Start = 1 // optional int32
DescriptorProto_ReservedRange_End = 2 // optional int32
)
// Field numbers for google.protobuf.ExtensionRangeOptions.
const (
ExtensionRangeOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.FieldDescriptorProto.
const (
FieldDescriptorProto_Name = 1 // optional string
FieldDescriptorProto_Number = 3 // optional int32
FieldDescriptorProto_Label = 4 // optional google.protobuf.FieldDescriptorProto.Label
FieldDescriptorProto_Type = 5 // optional google.protobuf.FieldDescriptorProto.Type
FieldDescriptorProto_TypeName = 6 // optional string
FieldDescriptorProto_Extendee = 2 // optional string
FieldDescriptorProto_DefaultValue = 7 // optional string
FieldDescriptorProto_OneofIndex = 9 // optional int32
FieldDescriptorProto_JsonName = 10 // optional string
FieldDescriptorProto_Options = 8 // optional google.protobuf.FieldOptions
FieldDescriptorProto_Proto3Optional = 17 // optional bool
)
// Field numbers for google.protobuf.OneofDescriptorProto.
const (
OneofDescriptorProto_Name = 1 // optional string
OneofDescriptorProto_Options = 2 // optional google.protobuf.OneofOptions
)
// Field numbers for google.protobuf.EnumDescriptorProto.
const (
EnumDescriptorProto_Name = 1 // optional string
EnumDescriptorProto_Value = 2 // repeated google.protobuf.EnumValueDescriptorProto
EnumDescriptorProto_Options = 3 // optional google.protobuf.EnumOptions
EnumDescriptorProto_ReservedRange = 4 // repeated google.protobuf.EnumDescriptorProto.EnumReservedRange
EnumDescriptorProto_ReservedName = 5 // repeated string
)
// Field numbers for google.protobuf.EnumDescriptorProto.EnumReservedRange.
const (
EnumDescriptorProto_EnumReservedRange_Start = 1 // optional int32
EnumDescriptorProto_EnumReservedRange_End = 2 // optional int32
)
// Field numbers for google.protobuf.EnumValueDescriptorProto.
const (
EnumValueDescriptorProto_Name = 1 // optional string
EnumValueDescriptorProto_Number = 2 // optional int32
EnumValueDescriptorProto_Options = 3 // optional google.protobuf.EnumValueOptions
)
// Field numbers for google.protobuf.ServiceDescriptorProto.
const (
ServiceDescriptorProto_Name = 1 // optional string
ServiceDescriptorProto_Method = 2 // repeated google.protobuf.MethodDescriptorProto
ServiceDescriptorProto_Options = 3 // optional google.protobuf.ServiceOptions
)
// Field numbers for google.protobuf.MethodDescriptorProto.
const (
MethodDescriptorProto_Name = 1 // optional string
MethodDescriptorProto_InputType = 2 // optional string
MethodDescriptorProto_OutputType = 3 // optional string
MethodDescriptorProto_Options = 4 // optional google.protobuf.MethodOptions
MethodDescriptorProto_ClientStreaming = 5 // optional bool
MethodDescriptorProto_ServerStreaming = 6 // optional bool
)
// Field numbers for google.protobuf.FileOptions.
const (
FileOptions_JavaPackage = 1 // optional string
FileOptions_JavaOuterClassname = 8 // optional string
FileOptions_JavaMultipleFiles = 10 // optional bool
FileOptions_JavaGenerateEqualsAndHash = 20 // optional bool
FileOptions_JavaStringCheckUtf8 = 27 // optional bool
FileOptions_OptimizeFor = 9 // optional google.protobuf.FileOptions.OptimizeMode
FileOptions_GoPackage = 11 // optional string
FileOptions_CcGenericServices = 16 // optional bool
FileOptions_JavaGenericServices = 17 // optional bool
FileOptions_PyGenericServices = 18 // optional bool
FileOptions_PhpGenericServices = 42 // optional bool
FileOptions_Deprecated = 23 // optional bool
FileOptions_CcEnableArenas = 31 // optional bool
FileOptions_ObjcClassPrefix = 36 // optional string
FileOptions_CsharpNamespace = 37 // optional string
FileOptions_SwiftPrefix = 39 // optional string
FileOptions_PhpClassPrefix = 40 // optional string
FileOptions_PhpNamespace = 41 // optional string
FileOptions_PhpMetadataNamespace = 44 // optional string
FileOptions_RubyPackage = 45 // optional string
FileOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.MessageOptions.
const (
MessageOptions_MessageSetWireFormat = 1 // optional bool
MessageOptions_NoStandardDescriptorAccessor = 2 // optional bool
MessageOptions_Deprecated = 3 // optional bool
MessageOptions_MapEntry = 7 // optional bool
MessageOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.FieldOptions.
const (
FieldOptions_Ctype = 1 // optional google.protobuf.FieldOptions.CType
FieldOptions_Packed = 2 // optional bool
FieldOptions_Jstype = 6 // optional google.protobuf.FieldOptions.JSType
FieldOptions_Lazy = 5 // optional bool
FieldOptions_Deprecated = 3 // optional bool
FieldOptions_Weak = 10 // optional bool
FieldOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.OneofOptions.
const (
OneofOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.EnumOptions.
const (
EnumOptions_AllowAlias = 2 // optional bool
EnumOptions_Deprecated = 3 // optional bool
EnumOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.EnumValueOptions.
const (
EnumValueOptions_Deprecated = 1 // optional bool
EnumValueOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.ServiceOptions.
const (
ServiceOptions_Deprecated = 33 // optional bool
ServiceOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.MethodOptions.
const (
MethodOptions_Deprecated = 33 // optional bool
MethodOptions_IdempotencyLevel = 34 // optional google.protobuf.MethodOptions.IdempotencyLevel
MethodOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
)
// Field numbers for google.protobuf.UninterpretedOption.
const (
UninterpretedOption_Name = 2 // repeated google.protobuf.UninterpretedOption.NamePart
UninterpretedOption_IdentifierValue = 3 // optional string
UninterpretedOption_PositiveIntValue = 4 // optional uint64
UninterpretedOption_NegativeIntValue = 5 // optional int64
UninterpretedOption_DoubleValue = 6 // optional double
UninterpretedOption_StringValue = 7 // optional bytes
UninterpretedOption_AggregateValue = 8 // optional string
)
// Field numbers for google.protobuf.UninterpretedOption.NamePart.
const (
UninterpretedOption_NamePart_NamePart = 1 // required string
UninterpretedOption_NamePart_IsExtension = 2 // required bool
)
// Field numbers for google.protobuf.SourceCodeInfo.
const (
SourceCodeInfo_Location = 1 // repeated google.protobuf.SourceCodeInfo.Location
)
// Field numbers for google.protobuf.SourceCodeInfo.Location.
const (
SourceCodeInfo_Location_Path = 1 // repeated int32
SourceCodeInfo_Location_Span = 2 // repeated int32
SourceCodeInfo_Location_LeadingComments = 3 // optional string
SourceCodeInfo_Location_TrailingComments = 4 // optional string
SourceCodeInfo_Location_LeadingDetachedComments = 6 // repeated string
)
// Field numbers for google.protobuf.GeneratedCodeInfo.
const (
GeneratedCodeInfo_Annotation = 1 // repeated google.protobuf.GeneratedCodeInfo.Annotation
)
// Field numbers for google.protobuf.GeneratedCodeInfo.Annotation.
const (
GeneratedCodeInfo_Annotation_Path = 1 // repeated int32
GeneratedCodeInfo_Annotation_SourceFile = 2 // optional string
GeneratedCodeInfo_Annotation_Begin = 3 // optional int32
GeneratedCodeInfo_Annotation_End = 4 // optional int32
)

View File

@ -1,7 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package fieldnum contains constants for field numbers of fields in messages
// declared in descriptor.proto and any of the well-known types.
package fieldnum

View File

@ -1,13 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.Duration.
const (
Duration_Seconds = 1 // optional int64
Duration_Nanos = 2 // optional int32
)

View File

@ -1,10 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.Empty.
const ()

View File

@ -1,12 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.FieldMask.
const (
FieldMask_Paths = 1 // repeated string
)

View File

@ -1,12 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.SourceContext.
const (
SourceContext_FileName = 1 // optional string
)

View File

@ -1,33 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.Struct.
const (
Struct_Fields = 1 // repeated google.protobuf.Struct.FieldsEntry
)
// Field numbers for google.protobuf.Struct.FieldsEntry.
const (
Struct_FieldsEntry_Key = 1 // optional string
Struct_FieldsEntry_Value = 2 // optional google.protobuf.Value
)
// Field numbers for google.protobuf.Value.
const (
Value_NullValue = 1 // optional google.protobuf.NullValue
Value_NumberValue = 2 // optional double
Value_StringValue = 3 // optional string
Value_BoolValue = 4 // optional bool
Value_StructValue = 5 // optional google.protobuf.Struct
Value_ListValue = 6 // optional google.protobuf.ListValue
)
// Field numbers for google.protobuf.ListValue.
const (
ListValue_Values = 1 // repeated google.protobuf.Value
)

View File

@ -1,13 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.Timestamp.
const (
Timestamp_Seconds = 1 // optional int64
Timestamp_Nanos = 2 // optional int32
)

View File

@ -1,53 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.Type.
const (
Type_Name = 1 // optional string
Type_Fields = 2 // repeated google.protobuf.Field
Type_Oneofs = 3 // repeated string
Type_Options = 4 // repeated google.protobuf.Option
Type_SourceContext = 5 // optional google.protobuf.SourceContext
Type_Syntax = 6 // optional google.protobuf.Syntax
)
// Field numbers for google.protobuf.Field.
const (
Field_Kind = 1 // optional google.protobuf.Field.Kind
Field_Cardinality = 2 // optional google.protobuf.Field.Cardinality
Field_Number = 3 // optional int32
Field_Name = 4 // optional string
Field_TypeUrl = 6 // optional string
Field_OneofIndex = 7 // optional int32
Field_Packed = 8 // optional bool
Field_Options = 9 // repeated google.protobuf.Option
Field_JsonName = 10 // optional string
Field_DefaultValue = 11 // optional string
)
// Field numbers for google.protobuf.Enum.
const (
Enum_Name = 1 // optional string
Enum_Enumvalue = 2 // repeated google.protobuf.EnumValue
Enum_Options = 3 // repeated google.protobuf.Option
Enum_SourceContext = 4 // optional google.protobuf.SourceContext
Enum_Syntax = 5 // optional google.protobuf.Syntax
)
// Field numbers for google.protobuf.EnumValue.
const (
EnumValue_Name = 1 // optional string
EnumValue_Number = 2 // optional int32
EnumValue_Options = 3 // repeated google.protobuf.Option
)
// Field numbers for google.protobuf.Option.
const (
Option_Name = 1 // optional string
Option_Value = 2 // optional google.protobuf.Any
)

View File

@ -1,52 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package fieldnum
// Field numbers for google.protobuf.DoubleValue.
const (
DoubleValue_Value = 1 // optional double
)
// Field numbers for google.protobuf.FloatValue.
const (
FloatValue_Value = 1 // optional float
)
// Field numbers for google.protobuf.Int64Value.
const (
Int64Value_Value = 1 // optional int64
)
// Field numbers for google.protobuf.UInt64Value.
const (
UInt64Value_Value = 1 // optional uint64
)
// Field numbers for google.protobuf.Int32Value.
const (
Int32Value_Value = 1 // optional int32
)
// Field numbers for google.protobuf.UInt32Value.
const (
UInt32Value_Value = 1 // optional uint32
)
// Field numbers for google.protobuf.BoolValue.
const (
BoolValue_Value = 1 // optional bool
)
// Field numbers for google.protobuf.StringValue.
const (
StringValue_Value = 1 // optional string
)
// Field numbers for google.protobuf.BytesValue.
const (
BytesValue_Value = 1 // optional bytes
)

View File

@ -7,7 +7,7 @@ package filedesc
import (
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/fieldnum"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/reflect/protoreflect"
pref "google.golang.org/protobuf/reflect/protoreflect"
preg "google.golang.org/protobuf/reflect/protoregistry"
@ -126,24 +126,24 @@ func (db *Builder) unmarshalCounts(b []byte, isFile bool) {
b = b[m:]
if isFile {
switch num {
case fieldnum.FileDescriptorProto_EnumType:
case genid.FileDescriptorProto_EnumType_field_number:
db.NumEnums++
case fieldnum.FileDescriptorProto_MessageType:
case genid.FileDescriptorProto_MessageType_field_number:
db.unmarshalCounts(v, false)
db.NumMessages++
case fieldnum.FileDescriptorProto_Extension:
case genid.FileDescriptorProto_Extension_field_number:
db.NumExtensions++
case fieldnum.FileDescriptorProto_Service:
case genid.FileDescriptorProto_Service_field_number:
db.NumServices++
}
} else {
switch num {
case fieldnum.DescriptorProto_EnumType:
case genid.DescriptorProto_EnumType_field_number:
db.NumEnums++
case fieldnum.DescriptorProto_NestedType:
case genid.DescriptorProto_NestedType_field_number:
db.unmarshalCounts(v, false)
db.NumMessages++
case fieldnum.DescriptorProto_Extension:
case genid.DescriptorProto_Extension_field_number:
db.NumExtensions++
}
}

View File

@ -13,6 +13,7 @@ import (
"google.golang.org/protobuf/internal/descfmt"
"google.golang.org/protobuf/internal/descopts"
"google.golang.org/protobuf/internal/encoding/defval"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/internal/strs"
pref "google.golang.org/protobuf/reflect/protoreflect"
@ -302,13 +303,13 @@ func (fd *Field) MapKey() pref.FieldDescriptor {
if !fd.IsMap() {
return nil
}
return fd.Message().Fields().ByNumber(1)
return fd.Message().Fields().ByNumber(genid.MapEntry_Key_field_number)
}
func (fd *Field) MapValue() pref.FieldDescriptor {
if !fd.IsMap() {
return nil
}
return fd.Message().Fields().ByNumber(2)
return fd.Message().Fields().ByNumber(genid.MapEntry_Value_field_number)
}
func (fd *Field) HasDefault() bool { return fd.L1.Default.has }
func (fd *Field) Default() pref.Value { return fd.L1.Default.get(fd) }

View File

@ -8,7 +8,7 @@ import (
"sync"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/fieldnum"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/strs"
pref "google.golang.org/protobuf/reflect/protoreflect"
)
@ -107,7 +107,7 @@ func (fd *File) unmarshalSeed(b []byte) {
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.FileDescriptorProto_Syntax:
case genid.FileDescriptorProto_Syntax_field_number:
switch string(v) {
case "proto2":
fd.L1.Syntax = pref.Proto2
@ -116,36 +116,36 @@ func (fd *File) unmarshalSeed(b []byte) {
default:
panic("invalid syntax")
}
case fieldnum.FileDescriptorProto_Name:
case genid.FileDescriptorProto_Name_field_number:
fd.L1.Path = sb.MakeString(v)
case fieldnum.FileDescriptorProto_Package:
case genid.FileDescriptorProto_Package_field_number:
fd.L1.Package = pref.FullName(sb.MakeString(v))
case fieldnum.FileDescriptorProto_EnumType:
if prevField != fieldnum.FileDescriptorProto_EnumType {
case genid.FileDescriptorProto_EnumType_field_number:
if prevField != genid.FileDescriptorProto_EnumType_field_number {
if numEnums > 0 {
panic("non-contiguous repeated field")
}
posEnums = len(b0) - len(b) - n - m
}
numEnums++
case fieldnum.FileDescriptorProto_MessageType:
if prevField != fieldnum.FileDescriptorProto_MessageType {
case genid.FileDescriptorProto_MessageType_field_number:
if prevField != genid.FileDescriptorProto_MessageType_field_number {
if numMessages > 0 {
panic("non-contiguous repeated field")
}
posMessages = len(b0) - len(b) - n - m
}
numMessages++
case fieldnum.FileDescriptorProto_Extension:
if prevField != fieldnum.FileDescriptorProto_Extension {
case genid.FileDescriptorProto_Extension_field_number:
if prevField != genid.FileDescriptorProto_Extension_field_number {
if numExtensions > 0 {
panic("non-contiguous repeated field")
}
posExtensions = len(b0) - len(b) - n - m
}
numExtensions++
case fieldnum.FileDescriptorProto_Service:
if prevField != fieldnum.FileDescriptorProto_Service {
case genid.FileDescriptorProto_Service_field_number:
if prevField != genid.FileDescriptorProto_Service_field_number {
if numServices > 0 {
panic("non-contiguous repeated field")
}
@ -233,9 +233,9 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Desc
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.EnumDescriptorProto_Name:
case genid.EnumDescriptorProto_Name_field_number:
ed.L0.FullName = appendFullName(sb, pd.FullName(), v)
case fieldnum.EnumDescriptorProto_Value:
case genid.EnumDescriptorProto_Value_field_number:
numValues++
}
default:
@ -260,7 +260,7 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Desc
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.EnumDescriptorProto_Value:
case genid.EnumDescriptorProto_Value_field_number:
ed.L2.Values.List[i].unmarshalFull(v, sb, pf, ed, i)
i++
}
@ -288,33 +288,33 @@ func (md *Message) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.D
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.DescriptorProto_Name:
case genid.DescriptorProto_Name_field_number:
md.L0.FullName = appendFullName(sb, pd.FullName(), v)
case fieldnum.DescriptorProto_EnumType:
if prevField != fieldnum.DescriptorProto_EnumType {
case genid.DescriptorProto_EnumType_field_number:
if prevField != genid.DescriptorProto_EnumType_field_number {
if numEnums > 0 {
panic("non-contiguous repeated field")
}
posEnums = len(b0) - len(b) - n - m
}
numEnums++
case fieldnum.DescriptorProto_NestedType:
if prevField != fieldnum.DescriptorProto_NestedType {
case genid.DescriptorProto_NestedType_field_number:
if prevField != genid.DescriptorProto_NestedType_field_number {
if numMessages > 0 {
panic("non-contiguous repeated field")
}
posMessages = len(b0) - len(b) - n - m
}
numMessages++
case fieldnum.DescriptorProto_Extension:
if prevField != fieldnum.DescriptorProto_Extension {
case genid.DescriptorProto_Extension_field_number:
if prevField != genid.DescriptorProto_Extension_field_number {
if numExtensions > 0 {
panic("non-contiguous repeated field")
}
posExtensions = len(b0) - len(b) - n - m
}
numExtensions++
case fieldnum.DescriptorProto_Options:
case genid.DescriptorProto_Options_field_number:
md.unmarshalSeedOptions(v)
}
prevField = num
@ -375,9 +375,9 @@ func (md *Message) unmarshalSeedOptions(b []byte) {
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.MessageOptions_MapEntry:
case genid.MessageOptions_MapEntry_field_number:
md.L1.IsMapEntry = protowire.DecodeBool(v)
case fieldnum.MessageOptions_MessageSetWireFormat:
case genid.MessageOptions_MessageSetWireFormat_field_number:
md.L1.IsMessageSet = protowire.DecodeBool(v)
}
default:
@ -400,20 +400,20 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.FieldDescriptorProto_Number:
case genid.FieldDescriptorProto_Number_field_number:
xd.L1.Number = pref.FieldNumber(v)
case fieldnum.FieldDescriptorProto_Label:
case genid.FieldDescriptorProto_Label_field_number:
xd.L1.Cardinality = pref.Cardinality(v)
case fieldnum.FieldDescriptorProto_Type:
case genid.FieldDescriptorProto_Type_field_number:
xd.L1.Kind = pref.Kind(v)
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.FieldDescriptorProto_Name:
case genid.FieldDescriptorProto_Name_field_number:
xd.L0.FullName = appendFullName(sb, pd.FullName(), v)
case fieldnum.FieldDescriptorProto_Extendee:
case genid.FieldDescriptorProto_Extendee_field_number:
xd.L1.Extendee = PlaceholderMessage(makeFullName(sb, v))
}
default:
@ -436,7 +436,7 @@ func (sd *Service) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.D
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.ServiceDescriptorProto_Name:
case genid.ServiceDescriptorProto_Name_field_number:
sd.L0.FullName = appendFullName(sb, pd.FullName(), v)
}
default:

View File

@ -10,7 +10,7 @@ import (
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/descopts"
"google.golang.org/protobuf/internal/fieldnum"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/strs"
"google.golang.org/protobuf/proto"
pref "google.golang.org/protobuf/reflect/protoreflect"
@ -143,35 +143,35 @@ func (fd *File) unmarshalFull(b []byte) {
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.FileDescriptorProto_PublicDependency:
case genid.FileDescriptorProto_PublicDependency_field_number:
fd.L2.Imports[v].IsPublic = true
case fieldnum.FileDescriptorProto_WeakDependency:
case genid.FileDescriptorProto_WeakDependency_field_number:
fd.L2.Imports[v].IsWeak = true
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.FileDescriptorProto_Dependency:
case genid.FileDescriptorProto_Dependency_field_number:
path := sb.MakeString(v)
imp, _ := fd.builder.FileRegistry.FindFileByPath(path)
if imp == nil {
imp = PlaceholderFile(path)
}
fd.L2.Imports = append(fd.L2.Imports, pref.FileImport{FileDescriptor: imp})
case fieldnum.FileDescriptorProto_EnumType:
case genid.FileDescriptorProto_EnumType_field_number:
fd.L1.Enums.List[enumIdx].unmarshalFull(v, sb)
enumIdx++
case fieldnum.FileDescriptorProto_MessageType:
case genid.FileDescriptorProto_MessageType_field_number:
fd.L1.Messages.List[messageIdx].unmarshalFull(v, sb)
messageIdx++
case fieldnum.FileDescriptorProto_Extension:
case genid.FileDescriptorProto_Extension_field_number:
fd.L1.Extensions.List[extensionIdx].unmarshalFull(v, sb)
extensionIdx++
case fieldnum.FileDescriptorProto_Service:
case genid.FileDescriptorProto_Service_field_number:
fd.L1.Services.List[serviceIdx].unmarshalFull(v, sb)
serviceIdx++
case fieldnum.FileDescriptorProto_Options:
case genid.FileDescriptorProto_Options_field_number:
rawOptions = appendOptions(rawOptions, v)
}
default:
@ -196,13 +196,13 @@ func (ed *Enum) unmarshalFull(b []byte, sb *strs.Builder) {
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.EnumDescriptorProto_Value:
case genid.EnumDescriptorProto_Value_field_number:
rawValues = append(rawValues, v)
case fieldnum.EnumDescriptorProto_ReservedName:
case genid.EnumDescriptorProto_ReservedName_field_number:
ed.L2.ReservedNames.List = append(ed.L2.ReservedNames.List, pref.Name(sb.MakeString(v)))
case fieldnum.EnumDescriptorProto_ReservedRange:
case genid.EnumDescriptorProto_ReservedRange_field_number:
ed.L2.ReservedRanges.List = append(ed.L2.ReservedRanges.List, unmarshalEnumReservedRange(v))
case fieldnum.EnumDescriptorProto_Options:
case genid.EnumDescriptorProto_Options_field_number:
rawOptions = appendOptions(rawOptions, v)
}
default:
@ -228,9 +228,9 @@ func unmarshalEnumReservedRange(b []byte) (r [2]pref.EnumNumber) {
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.EnumDescriptorProto_EnumReservedRange_Start:
case genid.EnumDescriptorProto_EnumReservedRange_Start_field_number:
r[0] = pref.EnumNumber(v)
case fieldnum.EnumDescriptorProto_EnumReservedRange_End:
case genid.EnumDescriptorProto_EnumReservedRange_End_field_number:
r[1] = pref.EnumNumber(v)
}
default:
@ -255,17 +255,17 @@ func (vd *EnumValue) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.EnumValueDescriptorProto_Number:
case genid.EnumValueDescriptorProto_Number_field_number:
vd.L1.Number = pref.EnumNumber(v)
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.EnumValueDescriptorProto_Name:
case genid.EnumValueDescriptorProto_Name_field_number:
// NOTE: Enum values are in the same scope as the enum parent.
vd.L0.FullName = appendFullName(sb, pd.Parent().FullName(), v)
case fieldnum.EnumValueDescriptorProto_Options:
case genid.EnumValueDescriptorProto_Options_field_number:
rawOptions = appendOptions(rawOptions, v)
}
default:
@ -289,29 +289,29 @@ func (md *Message) unmarshalFull(b []byte, sb *strs.Builder) {
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.DescriptorProto_Field:
case genid.DescriptorProto_Field_field_number:
rawFields = append(rawFields, v)
case fieldnum.DescriptorProto_OneofDecl:
case genid.DescriptorProto_OneofDecl_field_number:
rawOneofs = append(rawOneofs, v)
case fieldnum.DescriptorProto_ReservedName:
case genid.DescriptorProto_ReservedName_field_number:
md.L2.ReservedNames.List = append(md.L2.ReservedNames.List, pref.Name(sb.MakeString(v)))
case fieldnum.DescriptorProto_ReservedRange:
case genid.DescriptorProto_ReservedRange_field_number:
md.L2.ReservedRanges.List = append(md.L2.ReservedRanges.List, unmarshalMessageReservedRange(v))
case fieldnum.DescriptorProto_ExtensionRange:
case genid.DescriptorProto_ExtensionRange_field_number:
r, rawOptions := unmarshalMessageExtensionRange(v)
opts := md.L0.ParentFile.builder.optionsUnmarshaler(&descopts.ExtensionRange, rawOptions)
md.L2.ExtensionRanges.List = append(md.L2.ExtensionRanges.List, r)
md.L2.ExtensionRangeOptions = append(md.L2.ExtensionRangeOptions, opts)
case fieldnum.DescriptorProto_EnumType:
case genid.DescriptorProto_EnumType_field_number:
md.L1.Enums.List[enumIdx].unmarshalFull(v, sb)
enumIdx++
case fieldnum.DescriptorProto_NestedType:
case genid.DescriptorProto_NestedType_field_number:
md.L1.Messages.List[messageIdx].unmarshalFull(v, sb)
messageIdx++
case fieldnum.DescriptorProto_Extension:
case genid.DescriptorProto_Extension_field_number:
md.L1.Extensions.List[extensionIdx].unmarshalFull(v, sb)
extensionIdx++
case fieldnum.DescriptorProto_Options:
case genid.DescriptorProto_Options_field_number:
md.unmarshalOptions(v)
rawOptions = appendOptions(rawOptions, v)
}
@ -347,9 +347,9 @@ func (md *Message) unmarshalOptions(b []byte) {
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.MessageOptions_MapEntry:
case genid.MessageOptions_MapEntry_field_number:
md.L1.IsMapEntry = protowire.DecodeBool(v)
case fieldnum.MessageOptions_MessageSetWireFormat:
case genid.MessageOptions_MessageSetWireFormat_field_number:
md.L1.IsMessageSet = protowire.DecodeBool(v)
}
default:
@ -368,9 +368,9 @@ func unmarshalMessageReservedRange(b []byte) (r [2]pref.FieldNumber) {
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.DescriptorProto_ReservedRange_Start:
case genid.DescriptorProto_ReservedRange_Start_field_number:
r[0] = pref.FieldNumber(v)
case fieldnum.DescriptorProto_ReservedRange_End:
case genid.DescriptorProto_ReservedRange_End_field_number:
r[1] = pref.FieldNumber(v)
}
default:
@ -390,16 +390,16 @@ func unmarshalMessageExtensionRange(b []byte) (r [2]pref.FieldNumber, rawOptions
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.DescriptorProto_ExtensionRange_Start:
case genid.DescriptorProto_ExtensionRange_Start_field_number:
r[0] = pref.FieldNumber(v)
case fieldnum.DescriptorProto_ExtensionRange_End:
case genid.DescriptorProto_ExtensionRange_End_field_number:
r[1] = pref.FieldNumber(v)
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.DescriptorProto_ExtensionRange_Options:
case genid.DescriptorProto_ExtensionRange_Options_field_number:
rawOptions = appendOptions(rawOptions, v)
}
default:
@ -425,13 +425,13 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.FieldDescriptorProto_Number:
case genid.FieldDescriptorProto_Number_field_number:
fd.L1.Number = pref.FieldNumber(v)
case fieldnum.FieldDescriptorProto_Label:
case genid.FieldDescriptorProto_Label_field_number:
fd.L1.Cardinality = pref.Cardinality(v)
case fieldnum.FieldDescriptorProto_Type:
case genid.FieldDescriptorProto_Type_field_number:
fd.L1.Kind = pref.Kind(v)
case fieldnum.FieldDescriptorProto_OneofIndex:
case genid.FieldDescriptorProto_OneofIndex_field_number:
// In Message.unmarshalFull, we allocate slices for both
// the field and oneof descriptors before unmarshaling either
// of them. This ensures pointers to slice elements are stable.
@ -441,22 +441,22 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
panic("oneof type already set")
}
fd.L1.ContainingOneof = od
case fieldnum.FieldDescriptorProto_Proto3Optional:
case genid.FieldDescriptorProto_Proto3Optional_field_number:
fd.L1.IsProto3Optional = protowire.DecodeBool(v)
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.FieldDescriptorProto_Name:
case genid.FieldDescriptorProto_Name_field_number:
fd.L0.FullName = appendFullName(sb, pd.FullName(), v)
case fieldnum.FieldDescriptorProto_JsonName:
case genid.FieldDescriptorProto_JsonName_field_number:
fd.L1.JSONName.Init(sb.MakeString(v))
case fieldnum.FieldDescriptorProto_DefaultValue:
case genid.FieldDescriptorProto_DefaultValue_field_number:
fd.L1.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
case fieldnum.FieldDescriptorProto_TypeName:
case genid.FieldDescriptorProto_TypeName_field_number:
rawTypeName = v
case fieldnum.FieldDescriptorProto_Options:
case genid.FieldDescriptorProto_Options_field_number:
fd.unmarshalOptions(v)
rawOptions = appendOptions(rawOptions, v)
}
@ -488,10 +488,10 @@ func (fd *Field) unmarshalOptions(b []byte) {
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.FieldOptions_Packed:
case genid.FieldOptions_Packed_field_number:
fd.L1.HasPacked = true
fd.L1.IsPacked = protowire.DecodeBool(v)
case fieldnum.FieldOptions_Weak:
case genid.FieldOptions_Weak_field_number:
fd.L1.IsWeak = protowire.DecodeBool(v)
case FieldOptions_EnforceUTF8:
fd.L1.HasEnforceUTF8 = true
@ -518,9 +518,9 @@ func (od *Oneof) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.OneofDescriptorProto_Name:
case genid.OneofDescriptorProto_Name_field_number:
od.L0.FullName = appendFullName(sb, pd.FullName(), v)
case fieldnum.OneofDescriptorProto_Options:
case genid.OneofDescriptorProto_Options_field_number:
rawOptions = appendOptions(rawOptions, v)
}
default:
@ -543,20 +543,20 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.FieldDescriptorProto_Proto3Optional:
case genid.FieldDescriptorProto_Proto3Optional_field_number:
xd.L2.IsProto3Optional = protowire.DecodeBool(v)
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.FieldDescriptorProto_JsonName:
case genid.FieldDescriptorProto_JsonName_field_number:
xd.L2.JSONName.Init(sb.MakeString(v))
case fieldnum.FieldDescriptorProto_DefaultValue:
case genid.FieldDescriptorProto_DefaultValue_field_number:
xd.L2.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
case fieldnum.FieldDescriptorProto_TypeName:
case genid.FieldDescriptorProto_TypeName_field_number:
rawTypeName = v
case fieldnum.FieldDescriptorProto_Options:
case genid.FieldDescriptorProto_Options_field_number:
xd.unmarshalOptions(v)
rawOptions = appendOptions(rawOptions, v)
}
@ -586,7 +586,7 @@ func (xd *Extension) unmarshalOptions(b []byte) {
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.FieldOptions_Packed:
case genid.FieldOptions_Packed_field_number:
xd.L2.IsPacked = protowire.DecodeBool(v)
}
default:
@ -608,9 +608,9 @@ func (sd *Service) unmarshalFull(b []byte, sb *strs.Builder) {
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.ServiceDescriptorProto_Method:
case genid.ServiceDescriptorProto_Method_field_number:
rawMethods = append(rawMethods, v)
case fieldnum.ServiceDescriptorProto_Options:
case genid.ServiceDescriptorProto_Options_field_number:
rawOptions = appendOptions(rawOptions, v)
}
default:
@ -641,22 +641,22 @@ func (md *Method) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.De
v, m := protowire.ConsumeVarint(b)
b = b[m:]
switch num {
case fieldnum.MethodDescriptorProto_ClientStreaming:
case genid.MethodDescriptorProto_ClientStreaming_field_number:
md.L1.IsStreamingClient = protowire.DecodeBool(v)
case fieldnum.MethodDescriptorProto_ServerStreaming:
case genid.MethodDescriptorProto_ServerStreaming_field_number:
md.L1.IsStreamingServer = protowire.DecodeBool(v)
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
b = b[m:]
switch num {
case fieldnum.MethodDescriptorProto_Name:
case genid.MethodDescriptorProto_Name_field_number:
md.L0.FullName = appendFullName(sb, pd.FullName(), v)
case fieldnum.MethodDescriptorProto_InputType:
case genid.MethodDescriptorProto_InputType_field_number:
md.L1.Input = PlaceholderMessage(makeFullName(sb, v))
case fieldnum.MethodDescriptorProto_OutputType:
case genid.MethodDescriptorProto_OutputType_field_number:
md.L1.Output = PlaceholderMessage(makeFullName(sb, v))
case fieldnum.MethodDescriptorProto_Options:
case genid.MethodDescriptorProto_Options_field_number:
rawOptions = appendOptions(rawOptions, v)
}
default:

View File

@ -6,7 +6,6 @@ package filedesc
import (
"fmt"
"math"
"sort"
"sync"
@ -185,10 +184,7 @@ func (p *FieldRanges) CheckValid(isMessageSet bool) error {
// Unlike the FieldNumber.IsValid method, it allows ranges that cover the
// reserved number range.
func isValidFieldNumber(n protoreflect.FieldNumber, isMessageSet bool) bool {
if isMessageSet {
return protowire.MinValidNumber <= n && n <= math.MaxInt32
}
return protowire.MinValidNumber <= n && n <= protowire.MaxValidNumber
return protowire.MinValidNumber <= n && (n <= protowire.MaxValidNumber || isMessageSet)
}
// CheckOverlap reports an error if p and q overlap.

View File

@ -0,0 +1,34 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_any_proto = "google/protobuf/any.proto"
// Names for google.protobuf.Any.
const (
Any_message_name protoreflect.Name = "Any"
Any_message_fullname protoreflect.FullName = "google.protobuf.Any"
)
// Field names for google.protobuf.Any.
const (
Any_TypeUrl_field_name protoreflect.Name = "type_url"
Any_Value_field_name protoreflect.Name = "value"
Any_TypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Any.type_url"
Any_Value_field_fullname protoreflect.FullName = "google.protobuf.Any.value"
)
// Field numbers for google.protobuf.Any.
const (
Any_TypeUrl_field_number protoreflect.FieldNumber = 1
Any_Value_field_number protoreflect.FieldNumber = 2
)

View File

@ -0,0 +1,106 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_api_proto = "google/protobuf/api.proto"
// Names for google.protobuf.Api.
const (
Api_message_name protoreflect.Name = "Api"
Api_message_fullname protoreflect.FullName = "google.protobuf.Api"
)
// Field names for google.protobuf.Api.
const (
Api_Name_field_name protoreflect.Name = "name"
Api_Methods_field_name protoreflect.Name = "methods"
Api_Options_field_name protoreflect.Name = "options"
Api_Version_field_name protoreflect.Name = "version"
Api_SourceContext_field_name protoreflect.Name = "source_context"
Api_Mixins_field_name protoreflect.Name = "mixins"
Api_Syntax_field_name protoreflect.Name = "syntax"
Api_Name_field_fullname protoreflect.FullName = "google.protobuf.Api.name"
Api_Methods_field_fullname protoreflect.FullName = "google.protobuf.Api.methods"
Api_Options_field_fullname protoreflect.FullName = "google.protobuf.Api.options"
Api_Version_field_fullname protoreflect.FullName = "google.protobuf.Api.version"
Api_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Api.source_context"
Api_Mixins_field_fullname protoreflect.FullName = "google.protobuf.Api.mixins"
Api_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Api.syntax"
)
// Field numbers for google.protobuf.Api.
const (
Api_Name_field_number protoreflect.FieldNumber = 1
Api_Methods_field_number protoreflect.FieldNumber = 2
Api_Options_field_number protoreflect.FieldNumber = 3
Api_Version_field_number protoreflect.FieldNumber = 4
Api_SourceContext_field_number protoreflect.FieldNumber = 5
Api_Mixins_field_number protoreflect.FieldNumber = 6
Api_Syntax_field_number protoreflect.FieldNumber = 7
)
// Names for google.protobuf.Method.
const (
Method_message_name protoreflect.Name = "Method"
Method_message_fullname protoreflect.FullName = "google.protobuf.Method"
)
// Field names for google.protobuf.Method.
const (
Method_Name_field_name protoreflect.Name = "name"
Method_RequestTypeUrl_field_name protoreflect.Name = "request_type_url"
Method_RequestStreaming_field_name protoreflect.Name = "request_streaming"
Method_ResponseTypeUrl_field_name protoreflect.Name = "response_type_url"
Method_ResponseStreaming_field_name protoreflect.Name = "response_streaming"
Method_Options_field_name protoreflect.Name = "options"
Method_Syntax_field_name protoreflect.Name = "syntax"
Method_Name_field_fullname protoreflect.FullName = "google.protobuf.Method.name"
Method_RequestTypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Method.request_type_url"
Method_RequestStreaming_field_fullname protoreflect.FullName = "google.protobuf.Method.request_streaming"
Method_ResponseTypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Method.response_type_url"
Method_ResponseStreaming_field_fullname protoreflect.FullName = "google.protobuf.Method.response_streaming"
Method_Options_field_fullname protoreflect.FullName = "google.protobuf.Method.options"
Method_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Method.syntax"
)
// Field numbers for google.protobuf.Method.
const (
Method_Name_field_number protoreflect.FieldNumber = 1
Method_RequestTypeUrl_field_number protoreflect.FieldNumber = 2
Method_RequestStreaming_field_number protoreflect.FieldNumber = 3
Method_ResponseTypeUrl_field_number protoreflect.FieldNumber = 4
Method_ResponseStreaming_field_number protoreflect.FieldNumber = 5
Method_Options_field_number protoreflect.FieldNumber = 6
Method_Syntax_field_number protoreflect.FieldNumber = 7
)
// Names for google.protobuf.Mixin.
const (
Mixin_message_name protoreflect.Name = "Mixin"
Mixin_message_fullname protoreflect.FullName = "google.protobuf.Mixin"
)
// Field names for google.protobuf.Mixin.
const (
Mixin_Name_field_name protoreflect.Name = "name"
Mixin_Root_field_name protoreflect.Name = "root"
Mixin_Name_field_fullname protoreflect.FullName = "google.protobuf.Mixin.name"
Mixin_Root_field_fullname protoreflect.FullName = "google.protobuf.Mixin.root"
)
// Field numbers for google.protobuf.Mixin.
const (
Mixin_Name_field_number protoreflect.FieldNumber = 1
Mixin_Root_field_number protoreflect.FieldNumber = 2
)

View File

@ -0,0 +1,829 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_descriptor_proto = "google/protobuf/descriptor.proto"
// Names for google.protobuf.FileDescriptorSet.
const (
FileDescriptorSet_message_name protoreflect.Name = "FileDescriptorSet"
FileDescriptorSet_message_fullname protoreflect.FullName = "google.protobuf.FileDescriptorSet"
)
// Field names for google.protobuf.FileDescriptorSet.
const (
FileDescriptorSet_File_field_name protoreflect.Name = "file"
FileDescriptorSet_File_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorSet.file"
)
// Field numbers for google.protobuf.FileDescriptorSet.
const (
FileDescriptorSet_File_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.FileDescriptorProto.
const (
FileDescriptorProto_message_name protoreflect.Name = "FileDescriptorProto"
FileDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto"
)
// Field names for google.protobuf.FileDescriptorProto.
const (
FileDescriptorProto_Name_field_name protoreflect.Name = "name"
FileDescriptorProto_Package_field_name protoreflect.Name = "package"
FileDescriptorProto_Dependency_field_name protoreflect.Name = "dependency"
FileDescriptorProto_PublicDependency_field_name protoreflect.Name = "public_dependency"
FileDescriptorProto_WeakDependency_field_name protoreflect.Name = "weak_dependency"
FileDescriptorProto_MessageType_field_name protoreflect.Name = "message_type"
FileDescriptorProto_EnumType_field_name protoreflect.Name = "enum_type"
FileDescriptorProto_Service_field_name protoreflect.Name = "service"
FileDescriptorProto_Extension_field_name protoreflect.Name = "extension"
FileDescriptorProto_Options_field_name protoreflect.Name = "options"
FileDescriptorProto_SourceCodeInfo_field_name protoreflect.Name = "source_code_info"
FileDescriptorProto_Syntax_field_name protoreflect.Name = "syntax"
FileDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.name"
FileDescriptorProto_Package_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.package"
FileDescriptorProto_Dependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.dependency"
FileDescriptorProto_PublicDependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.public_dependency"
FileDescriptorProto_WeakDependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.weak_dependency"
FileDescriptorProto_MessageType_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.message_type"
FileDescriptorProto_EnumType_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.enum_type"
FileDescriptorProto_Service_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.service"
FileDescriptorProto_Extension_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.extension"
FileDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.options"
FileDescriptorProto_SourceCodeInfo_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.source_code_info"
FileDescriptorProto_Syntax_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.syntax"
)
// Field numbers for google.protobuf.FileDescriptorProto.
const (
FileDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
FileDescriptorProto_Package_field_number protoreflect.FieldNumber = 2
FileDescriptorProto_Dependency_field_number protoreflect.FieldNumber = 3
FileDescriptorProto_PublicDependency_field_number protoreflect.FieldNumber = 10
FileDescriptorProto_WeakDependency_field_number protoreflect.FieldNumber = 11
FileDescriptorProto_MessageType_field_number protoreflect.FieldNumber = 4
FileDescriptorProto_EnumType_field_number protoreflect.FieldNumber = 5
FileDescriptorProto_Service_field_number protoreflect.FieldNumber = 6
FileDescriptorProto_Extension_field_number protoreflect.FieldNumber = 7
FileDescriptorProto_Options_field_number protoreflect.FieldNumber = 8
FileDescriptorProto_SourceCodeInfo_field_number protoreflect.FieldNumber = 9
FileDescriptorProto_Syntax_field_number protoreflect.FieldNumber = 12
)
// Names for google.protobuf.DescriptorProto.
const (
DescriptorProto_message_name protoreflect.Name = "DescriptorProto"
DescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.DescriptorProto"
)
// Field names for google.protobuf.DescriptorProto.
const (
DescriptorProto_Name_field_name protoreflect.Name = "name"
DescriptorProto_Field_field_name protoreflect.Name = "field"
DescriptorProto_Extension_field_name protoreflect.Name = "extension"
DescriptorProto_NestedType_field_name protoreflect.Name = "nested_type"
DescriptorProto_EnumType_field_name protoreflect.Name = "enum_type"
DescriptorProto_ExtensionRange_field_name protoreflect.Name = "extension_range"
DescriptorProto_OneofDecl_field_name protoreflect.Name = "oneof_decl"
DescriptorProto_Options_field_name protoreflect.Name = "options"
DescriptorProto_ReservedRange_field_name protoreflect.Name = "reserved_range"
DescriptorProto_ReservedName_field_name protoreflect.Name = "reserved_name"
DescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.name"
DescriptorProto_Field_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.field"
DescriptorProto_Extension_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.extension"
DescriptorProto_NestedType_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.nested_type"
DescriptorProto_EnumType_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.enum_type"
DescriptorProto_ExtensionRange_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.extension_range"
DescriptorProto_OneofDecl_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.oneof_decl"
DescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.options"
DescriptorProto_ReservedRange_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.reserved_range"
DescriptorProto_ReservedName_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.reserved_name"
)
// Field numbers for google.protobuf.DescriptorProto.
const (
DescriptorProto_Name_field_number protoreflect.FieldNumber = 1
DescriptorProto_Field_field_number protoreflect.FieldNumber = 2
DescriptorProto_Extension_field_number protoreflect.FieldNumber = 6
DescriptorProto_NestedType_field_number protoreflect.FieldNumber = 3
DescriptorProto_EnumType_field_number protoreflect.FieldNumber = 4
DescriptorProto_ExtensionRange_field_number protoreflect.FieldNumber = 5
DescriptorProto_OneofDecl_field_number protoreflect.FieldNumber = 8
DescriptorProto_Options_field_number protoreflect.FieldNumber = 7
DescriptorProto_ReservedRange_field_number protoreflect.FieldNumber = 9
DescriptorProto_ReservedName_field_number protoreflect.FieldNumber = 10
)
// Names for google.protobuf.DescriptorProto.ExtensionRange.
const (
DescriptorProto_ExtensionRange_message_name protoreflect.Name = "ExtensionRange"
DescriptorProto_ExtensionRange_message_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ExtensionRange"
)
// Field names for google.protobuf.DescriptorProto.ExtensionRange.
const (
DescriptorProto_ExtensionRange_Start_field_name protoreflect.Name = "start"
DescriptorProto_ExtensionRange_End_field_name protoreflect.Name = "end"
DescriptorProto_ExtensionRange_Options_field_name protoreflect.Name = "options"
DescriptorProto_ExtensionRange_Start_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ExtensionRange.start"
DescriptorProto_ExtensionRange_End_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ExtensionRange.end"
DescriptorProto_ExtensionRange_Options_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ExtensionRange.options"
)
// Field numbers for google.protobuf.DescriptorProto.ExtensionRange.
const (
DescriptorProto_ExtensionRange_Start_field_number protoreflect.FieldNumber = 1
DescriptorProto_ExtensionRange_End_field_number protoreflect.FieldNumber = 2
DescriptorProto_ExtensionRange_Options_field_number protoreflect.FieldNumber = 3
)
// Names for google.protobuf.DescriptorProto.ReservedRange.
const (
DescriptorProto_ReservedRange_message_name protoreflect.Name = "ReservedRange"
DescriptorProto_ReservedRange_message_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ReservedRange"
)
// Field names for google.protobuf.DescriptorProto.ReservedRange.
const (
DescriptorProto_ReservedRange_Start_field_name protoreflect.Name = "start"
DescriptorProto_ReservedRange_End_field_name protoreflect.Name = "end"
DescriptorProto_ReservedRange_Start_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ReservedRange.start"
DescriptorProto_ReservedRange_End_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ReservedRange.end"
)
// Field numbers for google.protobuf.DescriptorProto.ReservedRange.
const (
DescriptorProto_ReservedRange_Start_field_number protoreflect.FieldNumber = 1
DescriptorProto_ReservedRange_End_field_number protoreflect.FieldNumber = 2
)
// Names for google.protobuf.ExtensionRangeOptions.
const (
ExtensionRangeOptions_message_name protoreflect.Name = "ExtensionRangeOptions"
ExtensionRangeOptions_message_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions"
)
// Field names for google.protobuf.ExtensionRangeOptions.
const (
ExtensionRangeOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
ExtensionRangeOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.ExtensionRangeOptions.
const (
ExtensionRangeOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Names for google.protobuf.FieldDescriptorProto.
const (
FieldDescriptorProto_message_name protoreflect.Name = "FieldDescriptorProto"
FieldDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto"
)
// Field names for google.protobuf.FieldDescriptorProto.
const (
FieldDescriptorProto_Name_field_name protoreflect.Name = "name"
FieldDescriptorProto_Number_field_name protoreflect.Name = "number"
FieldDescriptorProto_Label_field_name protoreflect.Name = "label"
FieldDescriptorProto_Type_field_name protoreflect.Name = "type"
FieldDescriptorProto_TypeName_field_name protoreflect.Name = "type_name"
FieldDescriptorProto_Extendee_field_name protoreflect.Name = "extendee"
FieldDescriptorProto_DefaultValue_field_name protoreflect.Name = "default_value"
FieldDescriptorProto_OneofIndex_field_name protoreflect.Name = "oneof_index"
FieldDescriptorProto_JsonName_field_name protoreflect.Name = "json_name"
FieldDescriptorProto_Options_field_name protoreflect.Name = "options"
FieldDescriptorProto_Proto3Optional_field_name protoreflect.Name = "proto3_optional"
FieldDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.name"
FieldDescriptorProto_Number_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.number"
FieldDescriptorProto_Label_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.label"
FieldDescriptorProto_Type_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.type"
FieldDescriptorProto_TypeName_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.type_name"
FieldDescriptorProto_Extendee_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.extendee"
FieldDescriptorProto_DefaultValue_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.default_value"
FieldDescriptorProto_OneofIndex_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.oneof_index"
FieldDescriptorProto_JsonName_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.json_name"
FieldDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.options"
FieldDescriptorProto_Proto3Optional_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.proto3_optional"
)
// Field numbers for google.protobuf.FieldDescriptorProto.
const (
FieldDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
FieldDescriptorProto_Number_field_number protoreflect.FieldNumber = 3
FieldDescriptorProto_Label_field_number protoreflect.FieldNumber = 4
FieldDescriptorProto_Type_field_number protoreflect.FieldNumber = 5
FieldDescriptorProto_TypeName_field_number protoreflect.FieldNumber = 6
FieldDescriptorProto_Extendee_field_number protoreflect.FieldNumber = 2
FieldDescriptorProto_DefaultValue_field_number protoreflect.FieldNumber = 7
FieldDescriptorProto_OneofIndex_field_number protoreflect.FieldNumber = 9
FieldDescriptorProto_JsonName_field_number protoreflect.FieldNumber = 10
FieldDescriptorProto_Options_field_number protoreflect.FieldNumber = 8
FieldDescriptorProto_Proto3Optional_field_number protoreflect.FieldNumber = 17
)
// Full and short names for google.protobuf.FieldDescriptorProto.Type.
const (
FieldDescriptorProto_Type_enum_fullname = "google.protobuf.FieldDescriptorProto.Type"
FieldDescriptorProto_Type_enum_name = "Type"
)
// Full and short names for google.protobuf.FieldDescriptorProto.Label.
const (
FieldDescriptorProto_Label_enum_fullname = "google.protobuf.FieldDescriptorProto.Label"
FieldDescriptorProto_Label_enum_name = "Label"
)
// Names for google.protobuf.OneofDescriptorProto.
const (
OneofDescriptorProto_message_name protoreflect.Name = "OneofDescriptorProto"
OneofDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.OneofDescriptorProto"
)
// Field names for google.protobuf.OneofDescriptorProto.
const (
OneofDescriptorProto_Name_field_name protoreflect.Name = "name"
OneofDescriptorProto_Options_field_name protoreflect.Name = "options"
OneofDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.OneofDescriptorProto.name"
OneofDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.OneofDescriptorProto.options"
)
// Field numbers for google.protobuf.OneofDescriptorProto.
const (
OneofDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
OneofDescriptorProto_Options_field_number protoreflect.FieldNumber = 2
)
// Names for google.protobuf.EnumDescriptorProto.
const (
EnumDescriptorProto_message_name protoreflect.Name = "EnumDescriptorProto"
EnumDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto"
)
// Field names for google.protobuf.EnumDescriptorProto.
const (
EnumDescriptorProto_Name_field_name protoreflect.Name = "name"
EnumDescriptorProto_Value_field_name protoreflect.Name = "value"
EnumDescriptorProto_Options_field_name protoreflect.Name = "options"
EnumDescriptorProto_ReservedRange_field_name protoreflect.Name = "reserved_range"
EnumDescriptorProto_ReservedName_field_name protoreflect.Name = "reserved_name"
EnumDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.name"
EnumDescriptorProto_Value_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.value"
EnumDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.options"
EnumDescriptorProto_ReservedRange_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.reserved_range"
EnumDescriptorProto_ReservedName_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.reserved_name"
)
// Field numbers for google.protobuf.EnumDescriptorProto.
const (
EnumDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
EnumDescriptorProto_Value_field_number protoreflect.FieldNumber = 2
EnumDescriptorProto_Options_field_number protoreflect.FieldNumber = 3
EnumDescriptorProto_ReservedRange_field_number protoreflect.FieldNumber = 4
EnumDescriptorProto_ReservedName_field_number protoreflect.FieldNumber = 5
)
// Names for google.protobuf.EnumDescriptorProto.EnumReservedRange.
const (
EnumDescriptorProto_EnumReservedRange_message_name protoreflect.Name = "EnumReservedRange"
EnumDescriptorProto_EnumReservedRange_message_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.EnumReservedRange"
)
// Field names for google.protobuf.EnumDescriptorProto.EnumReservedRange.
const (
EnumDescriptorProto_EnumReservedRange_Start_field_name protoreflect.Name = "start"
EnumDescriptorProto_EnumReservedRange_End_field_name protoreflect.Name = "end"
EnumDescriptorProto_EnumReservedRange_Start_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.EnumReservedRange.start"
EnumDescriptorProto_EnumReservedRange_End_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.EnumReservedRange.end"
)
// Field numbers for google.protobuf.EnumDescriptorProto.EnumReservedRange.
const (
EnumDescriptorProto_EnumReservedRange_Start_field_number protoreflect.FieldNumber = 1
EnumDescriptorProto_EnumReservedRange_End_field_number protoreflect.FieldNumber = 2
)
// Names for google.protobuf.EnumValueDescriptorProto.
const (
EnumValueDescriptorProto_message_name protoreflect.Name = "EnumValueDescriptorProto"
EnumValueDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.EnumValueDescriptorProto"
)
// Field names for google.protobuf.EnumValueDescriptorProto.
const (
EnumValueDescriptorProto_Name_field_name protoreflect.Name = "name"
EnumValueDescriptorProto_Number_field_name protoreflect.Name = "number"
EnumValueDescriptorProto_Options_field_name protoreflect.Name = "options"
EnumValueDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.EnumValueDescriptorProto.name"
EnumValueDescriptorProto_Number_field_fullname protoreflect.FullName = "google.protobuf.EnumValueDescriptorProto.number"
EnumValueDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.EnumValueDescriptorProto.options"
)
// Field numbers for google.protobuf.EnumValueDescriptorProto.
const (
EnumValueDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
EnumValueDescriptorProto_Number_field_number protoreflect.FieldNumber = 2
EnumValueDescriptorProto_Options_field_number protoreflect.FieldNumber = 3
)
// Names for google.protobuf.ServiceDescriptorProto.
const (
ServiceDescriptorProto_message_name protoreflect.Name = "ServiceDescriptorProto"
ServiceDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.ServiceDescriptorProto"
)
// Field names for google.protobuf.ServiceDescriptorProto.
const (
ServiceDescriptorProto_Name_field_name protoreflect.Name = "name"
ServiceDescriptorProto_Method_field_name protoreflect.Name = "method"
ServiceDescriptorProto_Options_field_name protoreflect.Name = "options"
ServiceDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.ServiceDescriptorProto.name"
ServiceDescriptorProto_Method_field_fullname protoreflect.FullName = "google.protobuf.ServiceDescriptorProto.method"
ServiceDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.ServiceDescriptorProto.options"
)
// Field numbers for google.protobuf.ServiceDescriptorProto.
const (
ServiceDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
ServiceDescriptorProto_Method_field_number protoreflect.FieldNumber = 2
ServiceDescriptorProto_Options_field_number protoreflect.FieldNumber = 3
)
// Names for google.protobuf.MethodDescriptorProto.
const (
MethodDescriptorProto_message_name protoreflect.Name = "MethodDescriptorProto"
MethodDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto"
)
// Field names for google.protobuf.MethodDescriptorProto.
const (
MethodDescriptorProto_Name_field_name protoreflect.Name = "name"
MethodDescriptorProto_InputType_field_name protoreflect.Name = "input_type"
MethodDescriptorProto_OutputType_field_name protoreflect.Name = "output_type"
MethodDescriptorProto_Options_field_name protoreflect.Name = "options"
MethodDescriptorProto_ClientStreaming_field_name protoreflect.Name = "client_streaming"
MethodDescriptorProto_ServerStreaming_field_name protoreflect.Name = "server_streaming"
MethodDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.name"
MethodDescriptorProto_InputType_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.input_type"
MethodDescriptorProto_OutputType_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.output_type"
MethodDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.options"
MethodDescriptorProto_ClientStreaming_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.client_streaming"
MethodDescriptorProto_ServerStreaming_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.server_streaming"
)
// Field numbers for google.protobuf.MethodDescriptorProto.
const (
MethodDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
MethodDescriptorProto_InputType_field_number protoreflect.FieldNumber = 2
MethodDescriptorProto_OutputType_field_number protoreflect.FieldNumber = 3
MethodDescriptorProto_Options_field_number protoreflect.FieldNumber = 4
MethodDescriptorProto_ClientStreaming_field_number protoreflect.FieldNumber = 5
MethodDescriptorProto_ServerStreaming_field_number protoreflect.FieldNumber = 6
)
// Names for google.protobuf.FileOptions.
const (
FileOptions_message_name protoreflect.Name = "FileOptions"
FileOptions_message_fullname protoreflect.FullName = "google.protobuf.FileOptions"
)
// Field names for google.protobuf.FileOptions.
const (
FileOptions_JavaPackage_field_name protoreflect.Name = "java_package"
FileOptions_JavaOuterClassname_field_name protoreflect.Name = "java_outer_classname"
FileOptions_JavaMultipleFiles_field_name protoreflect.Name = "java_multiple_files"
FileOptions_JavaGenerateEqualsAndHash_field_name protoreflect.Name = "java_generate_equals_and_hash"
FileOptions_JavaStringCheckUtf8_field_name protoreflect.Name = "java_string_check_utf8"
FileOptions_OptimizeFor_field_name protoreflect.Name = "optimize_for"
FileOptions_GoPackage_field_name protoreflect.Name = "go_package"
FileOptions_CcGenericServices_field_name protoreflect.Name = "cc_generic_services"
FileOptions_JavaGenericServices_field_name protoreflect.Name = "java_generic_services"
FileOptions_PyGenericServices_field_name protoreflect.Name = "py_generic_services"
FileOptions_PhpGenericServices_field_name protoreflect.Name = "php_generic_services"
FileOptions_Deprecated_field_name protoreflect.Name = "deprecated"
FileOptions_CcEnableArenas_field_name protoreflect.Name = "cc_enable_arenas"
FileOptions_ObjcClassPrefix_field_name protoreflect.Name = "objc_class_prefix"
FileOptions_CsharpNamespace_field_name protoreflect.Name = "csharp_namespace"
FileOptions_SwiftPrefix_field_name protoreflect.Name = "swift_prefix"
FileOptions_PhpClassPrefix_field_name protoreflect.Name = "php_class_prefix"
FileOptions_PhpNamespace_field_name protoreflect.Name = "php_namespace"
FileOptions_PhpMetadataNamespace_field_name protoreflect.Name = "php_metadata_namespace"
FileOptions_RubyPackage_field_name protoreflect.Name = "ruby_package"
FileOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
FileOptions_JavaPackage_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_package"
FileOptions_JavaOuterClassname_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_outer_classname"
FileOptions_JavaMultipleFiles_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_multiple_files"
FileOptions_JavaGenerateEqualsAndHash_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_generate_equals_and_hash"
FileOptions_JavaStringCheckUtf8_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_string_check_utf8"
FileOptions_OptimizeFor_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.optimize_for"
FileOptions_GoPackage_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.go_package"
FileOptions_CcGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.cc_generic_services"
FileOptions_JavaGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_generic_services"
FileOptions_PyGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.py_generic_services"
FileOptions_PhpGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_generic_services"
FileOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.deprecated"
FileOptions_CcEnableArenas_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.cc_enable_arenas"
FileOptions_ObjcClassPrefix_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.objc_class_prefix"
FileOptions_CsharpNamespace_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.csharp_namespace"
FileOptions_SwiftPrefix_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.swift_prefix"
FileOptions_PhpClassPrefix_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_class_prefix"
FileOptions_PhpNamespace_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_namespace"
FileOptions_PhpMetadataNamespace_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_metadata_namespace"
FileOptions_RubyPackage_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.ruby_package"
FileOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.FileOptions.
const (
FileOptions_JavaPackage_field_number protoreflect.FieldNumber = 1
FileOptions_JavaOuterClassname_field_number protoreflect.FieldNumber = 8
FileOptions_JavaMultipleFiles_field_number protoreflect.FieldNumber = 10
FileOptions_JavaGenerateEqualsAndHash_field_number protoreflect.FieldNumber = 20
FileOptions_JavaStringCheckUtf8_field_number protoreflect.FieldNumber = 27
FileOptions_OptimizeFor_field_number protoreflect.FieldNumber = 9
FileOptions_GoPackage_field_number protoreflect.FieldNumber = 11
FileOptions_CcGenericServices_field_number protoreflect.FieldNumber = 16
FileOptions_JavaGenericServices_field_number protoreflect.FieldNumber = 17
FileOptions_PyGenericServices_field_number protoreflect.FieldNumber = 18
FileOptions_PhpGenericServices_field_number protoreflect.FieldNumber = 42
FileOptions_Deprecated_field_number protoreflect.FieldNumber = 23
FileOptions_CcEnableArenas_field_number protoreflect.FieldNumber = 31
FileOptions_ObjcClassPrefix_field_number protoreflect.FieldNumber = 36
FileOptions_CsharpNamespace_field_number protoreflect.FieldNumber = 37
FileOptions_SwiftPrefix_field_number protoreflect.FieldNumber = 39
FileOptions_PhpClassPrefix_field_number protoreflect.FieldNumber = 40
FileOptions_PhpNamespace_field_number protoreflect.FieldNumber = 41
FileOptions_PhpMetadataNamespace_field_number protoreflect.FieldNumber = 44
FileOptions_RubyPackage_field_number protoreflect.FieldNumber = 45
FileOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Full and short names for google.protobuf.FileOptions.OptimizeMode.
const (
FileOptions_OptimizeMode_enum_fullname = "google.protobuf.FileOptions.OptimizeMode"
FileOptions_OptimizeMode_enum_name = "OptimizeMode"
)
// Names for google.protobuf.MessageOptions.
const (
MessageOptions_message_name protoreflect.Name = "MessageOptions"
MessageOptions_message_fullname protoreflect.FullName = "google.protobuf.MessageOptions"
)
// Field names for google.protobuf.MessageOptions.
const (
MessageOptions_MessageSetWireFormat_field_name protoreflect.Name = "message_set_wire_format"
MessageOptions_NoStandardDescriptorAccessor_field_name protoreflect.Name = "no_standard_descriptor_accessor"
MessageOptions_Deprecated_field_name protoreflect.Name = "deprecated"
MessageOptions_MapEntry_field_name protoreflect.Name = "map_entry"
MessageOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
MessageOptions_MessageSetWireFormat_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.message_set_wire_format"
MessageOptions_NoStandardDescriptorAccessor_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.no_standard_descriptor_accessor"
MessageOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.deprecated"
MessageOptions_MapEntry_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.map_entry"
MessageOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.MessageOptions.
const (
MessageOptions_MessageSetWireFormat_field_number protoreflect.FieldNumber = 1
MessageOptions_NoStandardDescriptorAccessor_field_number protoreflect.FieldNumber = 2
MessageOptions_Deprecated_field_number protoreflect.FieldNumber = 3
MessageOptions_MapEntry_field_number protoreflect.FieldNumber = 7
MessageOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Names for google.protobuf.FieldOptions.
const (
FieldOptions_message_name protoreflect.Name = "FieldOptions"
FieldOptions_message_fullname protoreflect.FullName = "google.protobuf.FieldOptions"
)
// Field names for google.protobuf.FieldOptions.
const (
FieldOptions_Ctype_field_name protoreflect.Name = "ctype"
FieldOptions_Packed_field_name protoreflect.Name = "packed"
FieldOptions_Jstype_field_name protoreflect.Name = "jstype"
FieldOptions_Lazy_field_name protoreflect.Name = "lazy"
FieldOptions_Deprecated_field_name protoreflect.Name = "deprecated"
FieldOptions_Weak_field_name protoreflect.Name = "weak"
FieldOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
FieldOptions_Ctype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.ctype"
FieldOptions_Packed_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.packed"
FieldOptions_Jstype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.jstype"
FieldOptions_Lazy_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.lazy"
FieldOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.deprecated"
FieldOptions_Weak_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.weak"
FieldOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.FieldOptions.
const (
FieldOptions_Ctype_field_number protoreflect.FieldNumber = 1
FieldOptions_Packed_field_number protoreflect.FieldNumber = 2
FieldOptions_Jstype_field_number protoreflect.FieldNumber = 6
FieldOptions_Lazy_field_number protoreflect.FieldNumber = 5
FieldOptions_Deprecated_field_number protoreflect.FieldNumber = 3
FieldOptions_Weak_field_number protoreflect.FieldNumber = 10
FieldOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Full and short names for google.protobuf.FieldOptions.CType.
const (
FieldOptions_CType_enum_fullname = "google.protobuf.FieldOptions.CType"
FieldOptions_CType_enum_name = "CType"
)
// Full and short names for google.protobuf.FieldOptions.JSType.
const (
FieldOptions_JSType_enum_fullname = "google.protobuf.FieldOptions.JSType"
FieldOptions_JSType_enum_name = "JSType"
)
// Names for google.protobuf.OneofOptions.
const (
OneofOptions_message_name protoreflect.Name = "OneofOptions"
OneofOptions_message_fullname protoreflect.FullName = "google.protobuf.OneofOptions"
)
// Field names for google.protobuf.OneofOptions.
const (
OneofOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
OneofOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.OneofOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.OneofOptions.
const (
OneofOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Names for google.protobuf.EnumOptions.
const (
EnumOptions_message_name protoreflect.Name = "EnumOptions"
EnumOptions_message_fullname protoreflect.FullName = "google.protobuf.EnumOptions"
)
// Field names for google.protobuf.EnumOptions.
const (
EnumOptions_AllowAlias_field_name protoreflect.Name = "allow_alias"
EnumOptions_Deprecated_field_name protoreflect.Name = "deprecated"
EnumOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
EnumOptions_AllowAlias_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.allow_alias"
EnumOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.deprecated"
EnumOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.EnumOptions.
const (
EnumOptions_AllowAlias_field_number protoreflect.FieldNumber = 2
EnumOptions_Deprecated_field_number protoreflect.FieldNumber = 3
EnumOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Names for google.protobuf.EnumValueOptions.
const (
EnumValueOptions_message_name protoreflect.Name = "EnumValueOptions"
EnumValueOptions_message_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions"
)
// Field names for google.protobuf.EnumValueOptions.
const (
EnumValueOptions_Deprecated_field_name protoreflect.Name = "deprecated"
EnumValueOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
EnumValueOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.deprecated"
EnumValueOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.EnumValueOptions.
const (
EnumValueOptions_Deprecated_field_number protoreflect.FieldNumber = 1
EnumValueOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Names for google.protobuf.ServiceOptions.
const (
ServiceOptions_message_name protoreflect.Name = "ServiceOptions"
ServiceOptions_message_fullname protoreflect.FullName = "google.protobuf.ServiceOptions"
)
// Field names for google.protobuf.ServiceOptions.
const (
ServiceOptions_Deprecated_field_name protoreflect.Name = "deprecated"
ServiceOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
ServiceOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.ServiceOptions.deprecated"
ServiceOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.ServiceOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.ServiceOptions.
const (
ServiceOptions_Deprecated_field_number protoreflect.FieldNumber = 33
ServiceOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Names for google.protobuf.MethodOptions.
const (
MethodOptions_message_name protoreflect.Name = "MethodOptions"
MethodOptions_message_fullname protoreflect.FullName = "google.protobuf.MethodOptions"
)
// Field names for google.protobuf.MethodOptions.
const (
MethodOptions_Deprecated_field_name protoreflect.Name = "deprecated"
MethodOptions_IdempotencyLevel_field_name protoreflect.Name = "idempotency_level"
MethodOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
MethodOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.deprecated"
MethodOptions_IdempotencyLevel_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.idempotency_level"
MethodOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.uninterpreted_option"
)
// Field numbers for google.protobuf.MethodOptions.
const (
MethodOptions_Deprecated_field_number protoreflect.FieldNumber = 33
MethodOptions_IdempotencyLevel_field_number protoreflect.FieldNumber = 34
MethodOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
)
// Full and short names for google.protobuf.MethodOptions.IdempotencyLevel.
const (
MethodOptions_IdempotencyLevel_enum_fullname = "google.protobuf.MethodOptions.IdempotencyLevel"
MethodOptions_IdempotencyLevel_enum_name = "IdempotencyLevel"
)
// Names for google.protobuf.UninterpretedOption.
const (
UninterpretedOption_message_name protoreflect.Name = "UninterpretedOption"
UninterpretedOption_message_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption"
)
// Field names for google.protobuf.UninterpretedOption.
const (
UninterpretedOption_Name_field_name protoreflect.Name = "name"
UninterpretedOption_IdentifierValue_field_name protoreflect.Name = "identifier_value"
UninterpretedOption_PositiveIntValue_field_name protoreflect.Name = "positive_int_value"
UninterpretedOption_NegativeIntValue_field_name protoreflect.Name = "negative_int_value"
UninterpretedOption_DoubleValue_field_name protoreflect.Name = "double_value"
UninterpretedOption_StringValue_field_name protoreflect.Name = "string_value"
UninterpretedOption_AggregateValue_field_name protoreflect.Name = "aggregate_value"
UninterpretedOption_Name_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.name"
UninterpretedOption_IdentifierValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.identifier_value"
UninterpretedOption_PositiveIntValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.positive_int_value"
UninterpretedOption_NegativeIntValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.negative_int_value"
UninterpretedOption_DoubleValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.double_value"
UninterpretedOption_StringValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.string_value"
UninterpretedOption_AggregateValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.aggregate_value"
)
// Field numbers for google.protobuf.UninterpretedOption.
const (
UninterpretedOption_Name_field_number protoreflect.FieldNumber = 2
UninterpretedOption_IdentifierValue_field_number protoreflect.FieldNumber = 3
UninterpretedOption_PositiveIntValue_field_number protoreflect.FieldNumber = 4
UninterpretedOption_NegativeIntValue_field_number protoreflect.FieldNumber = 5
UninterpretedOption_DoubleValue_field_number protoreflect.FieldNumber = 6
UninterpretedOption_StringValue_field_number protoreflect.FieldNumber = 7
UninterpretedOption_AggregateValue_field_number protoreflect.FieldNumber = 8
)
// Names for google.protobuf.UninterpretedOption.NamePart.
const (
UninterpretedOption_NamePart_message_name protoreflect.Name = "NamePart"
UninterpretedOption_NamePart_message_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.NamePart"
)
// Field names for google.protobuf.UninterpretedOption.NamePart.
const (
UninterpretedOption_NamePart_NamePart_field_name protoreflect.Name = "name_part"
UninterpretedOption_NamePart_IsExtension_field_name protoreflect.Name = "is_extension"
UninterpretedOption_NamePart_NamePart_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.NamePart.name_part"
UninterpretedOption_NamePart_IsExtension_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.NamePart.is_extension"
)
// Field numbers for google.protobuf.UninterpretedOption.NamePart.
const (
UninterpretedOption_NamePart_NamePart_field_number protoreflect.FieldNumber = 1
UninterpretedOption_NamePart_IsExtension_field_number protoreflect.FieldNumber = 2
)
// Names for google.protobuf.SourceCodeInfo.
const (
SourceCodeInfo_message_name protoreflect.Name = "SourceCodeInfo"
SourceCodeInfo_message_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo"
)
// Field names for google.protobuf.SourceCodeInfo.
const (
SourceCodeInfo_Location_field_name protoreflect.Name = "location"
SourceCodeInfo_Location_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.location"
)
// Field numbers for google.protobuf.SourceCodeInfo.
const (
SourceCodeInfo_Location_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.SourceCodeInfo.Location.
const (
SourceCodeInfo_Location_message_name protoreflect.Name = "Location"
SourceCodeInfo_Location_message_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location"
)
// Field names for google.protobuf.SourceCodeInfo.Location.
const (
SourceCodeInfo_Location_Path_field_name protoreflect.Name = "path"
SourceCodeInfo_Location_Span_field_name protoreflect.Name = "span"
SourceCodeInfo_Location_LeadingComments_field_name protoreflect.Name = "leading_comments"
SourceCodeInfo_Location_TrailingComments_field_name protoreflect.Name = "trailing_comments"
SourceCodeInfo_Location_LeadingDetachedComments_field_name protoreflect.Name = "leading_detached_comments"
SourceCodeInfo_Location_Path_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.path"
SourceCodeInfo_Location_Span_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.span"
SourceCodeInfo_Location_LeadingComments_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.leading_comments"
SourceCodeInfo_Location_TrailingComments_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.trailing_comments"
SourceCodeInfo_Location_LeadingDetachedComments_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"
)
// Field numbers for google.protobuf.SourceCodeInfo.Location.
const (
SourceCodeInfo_Location_Path_field_number protoreflect.FieldNumber = 1
SourceCodeInfo_Location_Span_field_number protoreflect.FieldNumber = 2
SourceCodeInfo_Location_LeadingComments_field_number protoreflect.FieldNumber = 3
SourceCodeInfo_Location_TrailingComments_field_number protoreflect.FieldNumber = 4
SourceCodeInfo_Location_LeadingDetachedComments_field_number protoreflect.FieldNumber = 6
)
// Names for google.protobuf.GeneratedCodeInfo.
const (
GeneratedCodeInfo_message_name protoreflect.Name = "GeneratedCodeInfo"
GeneratedCodeInfo_message_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo"
)
// Field names for google.protobuf.GeneratedCodeInfo.
const (
GeneratedCodeInfo_Annotation_field_name protoreflect.Name = "annotation"
GeneratedCodeInfo_Annotation_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.annotation"
)
// Field numbers for google.protobuf.GeneratedCodeInfo.
const (
GeneratedCodeInfo_Annotation_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.GeneratedCodeInfo.Annotation.
const (
GeneratedCodeInfo_Annotation_message_name protoreflect.Name = "Annotation"
GeneratedCodeInfo_Annotation_message_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation"
)
// Field names for google.protobuf.GeneratedCodeInfo.Annotation.
const (
GeneratedCodeInfo_Annotation_Path_field_name protoreflect.Name = "path"
GeneratedCodeInfo_Annotation_SourceFile_field_name protoreflect.Name = "source_file"
GeneratedCodeInfo_Annotation_Begin_field_name protoreflect.Name = "begin"
GeneratedCodeInfo_Annotation_End_field_name protoreflect.Name = "end"
GeneratedCodeInfo_Annotation_Path_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.path"
GeneratedCodeInfo_Annotation_SourceFile_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.source_file"
GeneratedCodeInfo_Annotation_Begin_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.begin"
GeneratedCodeInfo_Annotation_End_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.end"
)
// Field numbers for google.protobuf.GeneratedCodeInfo.Annotation.
const (
GeneratedCodeInfo_Annotation_Path_field_number protoreflect.FieldNumber = 1
GeneratedCodeInfo_Annotation_SourceFile_field_number protoreflect.FieldNumber = 2
GeneratedCodeInfo_Annotation_Begin_field_number protoreflect.FieldNumber = 3
GeneratedCodeInfo_Annotation_End_field_number protoreflect.FieldNumber = 4
)

View File

@ -0,0 +1,11 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package genid contains constants for declarations in descriptor.proto
// and the well-known types.
package genid
import protoreflect "google.golang.org/protobuf/reflect/protoreflect"
const GoogleProtobuf_package protoreflect.FullName = "google.protobuf"

View File

@ -0,0 +1,34 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_duration_proto = "google/protobuf/duration.proto"
// Names for google.protobuf.Duration.
const (
Duration_message_name protoreflect.Name = "Duration"
Duration_message_fullname protoreflect.FullName = "google.protobuf.Duration"
)
// Field names for google.protobuf.Duration.
const (
Duration_Seconds_field_name protoreflect.Name = "seconds"
Duration_Nanos_field_name protoreflect.Name = "nanos"
Duration_Seconds_field_fullname protoreflect.FullName = "google.protobuf.Duration.seconds"
Duration_Nanos_field_fullname protoreflect.FullName = "google.protobuf.Duration.nanos"
)
// Field numbers for google.protobuf.Duration.
const (
Duration_Seconds_field_number protoreflect.FieldNumber = 1
Duration_Nanos_field_number protoreflect.FieldNumber = 2
)

View File

@ -0,0 +1,19 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_empty_proto = "google/protobuf/empty.proto"
// Names for google.protobuf.Empty.
const (
Empty_message_name protoreflect.Name = "Empty"
Empty_message_fullname protoreflect.FullName = "google.protobuf.Empty"
)

View File

@ -0,0 +1,31 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_field_mask_proto = "google/protobuf/field_mask.proto"
// Names for google.protobuf.FieldMask.
const (
FieldMask_message_name protoreflect.Name = "FieldMask"
FieldMask_message_fullname protoreflect.FullName = "google.protobuf.FieldMask"
)
// Field names for google.protobuf.FieldMask.
const (
FieldMask_Paths_field_name protoreflect.Name = "paths"
FieldMask_Paths_field_fullname protoreflect.FullName = "google.protobuf.FieldMask.paths"
)
// Field numbers for google.protobuf.FieldMask.
const (
FieldMask_Paths_field_number protoreflect.FieldNumber = 1
)

View File

@ -0,0 +1,25 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package genid
// Go names of implementation-specific struct fields in generated messages.
const (
State_goname = "state"
SizeCache_goname = "sizeCache"
SizeCacheA_goname = "XXX_sizecache"
WeakFields_goname = "weakFields"
WeakFieldsA_goname = "XXX_weak"
UnknownFields_goname = "unknownFields"
UnknownFieldsA_goname = "XXX_unrecognized"
ExtensionFields_goname = "extensionFields"
ExtensionFieldsA_goname = "XXX_InternalExtensions"
ExtensionFieldsB_goname = "XXX_extensions"
WeakFieldPrefix_goname = "XXX_weak_"
)

View File

@ -0,0 +1,16 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package genid
import protoreflect "google.golang.org/protobuf/reflect/protoreflect"
// Generic field names and numbers for synthetic map entry messages.
const (
MapEntry_Key_field_name protoreflect.Name = "key"
MapEntry_Value_field_name protoreflect.Name = "value"
MapEntry_Key_field_number protoreflect.FieldNumber = 1
MapEntry_Value_field_number protoreflect.FieldNumber = 2
)

View File

@ -0,0 +1,31 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_source_context_proto = "google/protobuf/source_context.proto"
// Names for google.protobuf.SourceContext.
const (
SourceContext_message_name protoreflect.Name = "SourceContext"
SourceContext_message_fullname protoreflect.FullName = "google.protobuf.SourceContext"
)
// Field names for google.protobuf.SourceContext.
const (
SourceContext_FileName_field_name protoreflect.Name = "file_name"
SourceContext_FileName_field_fullname protoreflect.FullName = "google.protobuf.SourceContext.file_name"
)
// Field numbers for google.protobuf.SourceContext.
const (
SourceContext_FileName_field_number protoreflect.FieldNumber = 1
)

View File

@ -0,0 +1,116 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_struct_proto = "google/protobuf/struct.proto"
// Full and short names for google.protobuf.NullValue.
const (
NullValue_enum_fullname = "google.protobuf.NullValue"
NullValue_enum_name = "NullValue"
)
// Names for google.protobuf.Struct.
const (
Struct_message_name protoreflect.Name = "Struct"
Struct_message_fullname protoreflect.FullName = "google.protobuf.Struct"
)
// Field names for google.protobuf.Struct.
const (
Struct_Fields_field_name protoreflect.Name = "fields"
Struct_Fields_field_fullname protoreflect.FullName = "google.protobuf.Struct.fields"
)
// Field numbers for google.protobuf.Struct.
const (
Struct_Fields_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.Struct.FieldsEntry.
const (
Struct_FieldsEntry_message_name protoreflect.Name = "FieldsEntry"
Struct_FieldsEntry_message_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry"
)
// Field names for google.protobuf.Struct.FieldsEntry.
const (
Struct_FieldsEntry_Key_field_name protoreflect.Name = "key"
Struct_FieldsEntry_Value_field_name protoreflect.Name = "value"
Struct_FieldsEntry_Key_field_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry.key"
Struct_FieldsEntry_Value_field_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry.value"
)
// Field numbers for google.protobuf.Struct.FieldsEntry.
const (
Struct_FieldsEntry_Key_field_number protoreflect.FieldNumber = 1
Struct_FieldsEntry_Value_field_number protoreflect.FieldNumber = 2
)
// Names for google.protobuf.Value.
const (
Value_message_name protoreflect.Name = "Value"
Value_message_fullname protoreflect.FullName = "google.protobuf.Value"
)
// Field names for google.protobuf.Value.
const (
Value_NullValue_field_name protoreflect.Name = "null_value"
Value_NumberValue_field_name protoreflect.Name = "number_value"
Value_StringValue_field_name protoreflect.Name = "string_value"
Value_BoolValue_field_name protoreflect.Name = "bool_value"
Value_StructValue_field_name protoreflect.Name = "struct_value"
Value_ListValue_field_name protoreflect.Name = "list_value"
Value_NullValue_field_fullname protoreflect.FullName = "google.protobuf.Value.null_value"
Value_NumberValue_field_fullname protoreflect.FullName = "google.protobuf.Value.number_value"
Value_StringValue_field_fullname protoreflect.FullName = "google.protobuf.Value.string_value"
Value_BoolValue_field_fullname protoreflect.FullName = "google.protobuf.Value.bool_value"
Value_StructValue_field_fullname protoreflect.FullName = "google.protobuf.Value.struct_value"
Value_ListValue_field_fullname protoreflect.FullName = "google.protobuf.Value.list_value"
)
// Field numbers for google.protobuf.Value.
const (
Value_NullValue_field_number protoreflect.FieldNumber = 1
Value_NumberValue_field_number protoreflect.FieldNumber = 2
Value_StringValue_field_number protoreflect.FieldNumber = 3
Value_BoolValue_field_number protoreflect.FieldNumber = 4
Value_StructValue_field_number protoreflect.FieldNumber = 5
Value_ListValue_field_number protoreflect.FieldNumber = 6
)
// Oneof names for google.protobuf.Value.
const (
Value_Kind_oneof_name protoreflect.Name = "kind"
Value_Kind_oneof_fullname protoreflect.FullName = "google.protobuf.Value.kind"
)
// Names for google.protobuf.ListValue.
const (
ListValue_message_name protoreflect.Name = "ListValue"
ListValue_message_fullname protoreflect.FullName = "google.protobuf.ListValue"
)
// Field names for google.protobuf.ListValue.
const (
ListValue_Values_field_name protoreflect.Name = "values"
ListValue_Values_field_fullname protoreflect.FullName = "google.protobuf.ListValue.values"
)
// Field numbers for google.protobuf.ListValue.
const (
ListValue_Values_field_number protoreflect.FieldNumber = 1
)

View File

@ -0,0 +1,34 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_timestamp_proto = "google/protobuf/timestamp.proto"
// Names for google.protobuf.Timestamp.
const (
Timestamp_message_name protoreflect.Name = "Timestamp"
Timestamp_message_fullname protoreflect.FullName = "google.protobuf.Timestamp"
)
// Field names for google.protobuf.Timestamp.
const (
Timestamp_Seconds_field_name protoreflect.Name = "seconds"
Timestamp_Nanos_field_name protoreflect.Name = "nanos"
Timestamp_Seconds_field_fullname protoreflect.FullName = "google.protobuf.Timestamp.seconds"
Timestamp_Nanos_field_fullname protoreflect.FullName = "google.protobuf.Timestamp.nanos"
)
// Field numbers for google.protobuf.Timestamp.
const (
Timestamp_Seconds_field_number protoreflect.FieldNumber = 1
Timestamp_Nanos_field_number protoreflect.FieldNumber = 2
)

View File

@ -0,0 +1,184 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_type_proto = "google/protobuf/type.proto"
// Full and short names for google.protobuf.Syntax.
const (
Syntax_enum_fullname = "google.protobuf.Syntax"
Syntax_enum_name = "Syntax"
)
// Names for google.protobuf.Type.
const (
Type_message_name protoreflect.Name = "Type"
Type_message_fullname protoreflect.FullName = "google.protobuf.Type"
)
// Field names for google.protobuf.Type.
const (
Type_Name_field_name protoreflect.Name = "name"
Type_Fields_field_name protoreflect.Name = "fields"
Type_Oneofs_field_name protoreflect.Name = "oneofs"
Type_Options_field_name protoreflect.Name = "options"
Type_SourceContext_field_name protoreflect.Name = "source_context"
Type_Syntax_field_name protoreflect.Name = "syntax"
Type_Name_field_fullname protoreflect.FullName = "google.protobuf.Type.name"
Type_Fields_field_fullname protoreflect.FullName = "google.protobuf.Type.fields"
Type_Oneofs_field_fullname protoreflect.FullName = "google.protobuf.Type.oneofs"
Type_Options_field_fullname protoreflect.FullName = "google.protobuf.Type.options"
Type_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Type.source_context"
Type_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Type.syntax"
)
// Field numbers for google.protobuf.Type.
const (
Type_Name_field_number protoreflect.FieldNumber = 1
Type_Fields_field_number protoreflect.FieldNumber = 2
Type_Oneofs_field_number protoreflect.FieldNumber = 3
Type_Options_field_number protoreflect.FieldNumber = 4
Type_SourceContext_field_number protoreflect.FieldNumber = 5
Type_Syntax_field_number protoreflect.FieldNumber = 6
)
// Names for google.protobuf.Field.
const (
Field_message_name protoreflect.Name = "Field"
Field_message_fullname protoreflect.FullName = "google.protobuf.Field"
)
// Field names for google.protobuf.Field.
const (
Field_Kind_field_name protoreflect.Name = "kind"
Field_Cardinality_field_name protoreflect.Name = "cardinality"
Field_Number_field_name protoreflect.Name = "number"
Field_Name_field_name protoreflect.Name = "name"
Field_TypeUrl_field_name protoreflect.Name = "type_url"
Field_OneofIndex_field_name protoreflect.Name = "oneof_index"
Field_Packed_field_name protoreflect.Name = "packed"
Field_Options_field_name protoreflect.Name = "options"
Field_JsonName_field_name protoreflect.Name = "json_name"
Field_DefaultValue_field_name protoreflect.Name = "default_value"
Field_Kind_field_fullname protoreflect.FullName = "google.protobuf.Field.kind"
Field_Cardinality_field_fullname protoreflect.FullName = "google.protobuf.Field.cardinality"
Field_Number_field_fullname protoreflect.FullName = "google.protobuf.Field.number"
Field_Name_field_fullname protoreflect.FullName = "google.protobuf.Field.name"
Field_TypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Field.type_url"
Field_OneofIndex_field_fullname protoreflect.FullName = "google.protobuf.Field.oneof_index"
Field_Packed_field_fullname protoreflect.FullName = "google.protobuf.Field.packed"
Field_Options_field_fullname protoreflect.FullName = "google.protobuf.Field.options"
Field_JsonName_field_fullname protoreflect.FullName = "google.protobuf.Field.json_name"
Field_DefaultValue_field_fullname protoreflect.FullName = "google.protobuf.Field.default_value"
)
// Field numbers for google.protobuf.Field.
const (
Field_Kind_field_number protoreflect.FieldNumber = 1
Field_Cardinality_field_number protoreflect.FieldNumber = 2
Field_Number_field_number protoreflect.FieldNumber = 3
Field_Name_field_number protoreflect.FieldNumber = 4
Field_TypeUrl_field_number protoreflect.FieldNumber = 6
Field_OneofIndex_field_number protoreflect.FieldNumber = 7
Field_Packed_field_number protoreflect.FieldNumber = 8
Field_Options_field_number protoreflect.FieldNumber = 9
Field_JsonName_field_number protoreflect.FieldNumber = 10
Field_DefaultValue_field_number protoreflect.FieldNumber = 11
)
// Full and short names for google.protobuf.Field.Kind.
const (
Field_Kind_enum_fullname = "google.protobuf.Field.Kind"
Field_Kind_enum_name = "Kind"
)
// Full and short names for google.protobuf.Field.Cardinality.
const (
Field_Cardinality_enum_fullname = "google.protobuf.Field.Cardinality"
Field_Cardinality_enum_name = "Cardinality"
)
// Names for google.protobuf.Enum.
const (
Enum_message_name protoreflect.Name = "Enum"
Enum_message_fullname protoreflect.FullName = "google.protobuf.Enum"
)
// Field names for google.protobuf.Enum.
const (
Enum_Name_field_name protoreflect.Name = "name"
Enum_Enumvalue_field_name protoreflect.Name = "enumvalue"
Enum_Options_field_name protoreflect.Name = "options"
Enum_SourceContext_field_name protoreflect.Name = "source_context"
Enum_Syntax_field_name protoreflect.Name = "syntax"
Enum_Name_field_fullname protoreflect.FullName = "google.protobuf.Enum.name"
Enum_Enumvalue_field_fullname protoreflect.FullName = "google.protobuf.Enum.enumvalue"
Enum_Options_field_fullname protoreflect.FullName = "google.protobuf.Enum.options"
Enum_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Enum.source_context"
Enum_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Enum.syntax"
)
// Field numbers for google.protobuf.Enum.
const (
Enum_Name_field_number protoreflect.FieldNumber = 1
Enum_Enumvalue_field_number protoreflect.FieldNumber = 2
Enum_Options_field_number protoreflect.FieldNumber = 3
Enum_SourceContext_field_number protoreflect.FieldNumber = 4
Enum_Syntax_field_number protoreflect.FieldNumber = 5
)
// Names for google.protobuf.EnumValue.
const (
EnumValue_message_name protoreflect.Name = "EnumValue"
EnumValue_message_fullname protoreflect.FullName = "google.protobuf.EnumValue"
)
// Field names for google.protobuf.EnumValue.
const (
EnumValue_Name_field_name protoreflect.Name = "name"
EnumValue_Number_field_name protoreflect.Name = "number"
EnumValue_Options_field_name protoreflect.Name = "options"
EnumValue_Name_field_fullname protoreflect.FullName = "google.protobuf.EnumValue.name"
EnumValue_Number_field_fullname protoreflect.FullName = "google.protobuf.EnumValue.number"
EnumValue_Options_field_fullname protoreflect.FullName = "google.protobuf.EnumValue.options"
)
// Field numbers for google.protobuf.EnumValue.
const (
EnumValue_Name_field_number protoreflect.FieldNumber = 1
EnumValue_Number_field_number protoreflect.FieldNumber = 2
EnumValue_Options_field_number protoreflect.FieldNumber = 3
)
// Names for google.protobuf.Option.
const (
Option_message_name protoreflect.Name = "Option"
Option_message_fullname protoreflect.FullName = "google.protobuf.Option"
)
// Field names for google.protobuf.Option.
const (
Option_Name_field_name protoreflect.Name = "name"
Option_Value_field_name protoreflect.Name = "value"
Option_Name_field_fullname protoreflect.FullName = "google.protobuf.Option.name"
Option_Value_field_fullname protoreflect.FullName = "google.protobuf.Option.value"
)
// Field numbers for google.protobuf.Option.
const (
Option_Name_field_number protoreflect.FieldNumber = 1
Option_Value_field_number protoreflect.FieldNumber = 2
)

View File

@ -0,0 +1,13 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package genid
import protoreflect "google.golang.org/protobuf/reflect/protoreflect"
// Generic field name and number for messages in wrappers.proto.
const (
WrapperValue_Value_field_name protoreflect.Name = "value"
WrapperValue_Value_field_number protoreflect.FieldNumber = 1
)

View File

@ -0,0 +1,175 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package genid
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
)
const File_google_protobuf_wrappers_proto = "google/protobuf/wrappers.proto"
// Names for google.protobuf.DoubleValue.
const (
DoubleValue_message_name protoreflect.Name = "DoubleValue"
DoubleValue_message_fullname protoreflect.FullName = "google.protobuf.DoubleValue"
)
// Field names for google.protobuf.DoubleValue.
const (
DoubleValue_Value_field_name protoreflect.Name = "value"
DoubleValue_Value_field_fullname protoreflect.FullName = "google.protobuf.DoubleValue.value"
)
// Field numbers for google.protobuf.DoubleValue.
const (
DoubleValue_Value_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.FloatValue.
const (
FloatValue_message_name protoreflect.Name = "FloatValue"
FloatValue_message_fullname protoreflect.FullName = "google.protobuf.FloatValue"
)
// Field names for google.protobuf.FloatValue.
const (
FloatValue_Value_field_name protoreflect.Name = "value"
FloatValue_Value_field_fullname protoreflect.FullName = "google.protobuf.FloatValue.value"
)
// Field numbers for google.protobuf.FloatValue.
const (
FloatValue_Value_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.Int64Value.
const (
Int64Value_message_name protoreflect.Name = "Int64Value"
Int64Value_message_fullname protoreflect.FullName = "google.protobuf.Int64Value"
)
// Field names for google.protobuf.Int64Value.
const (
Int64Value_Value_field_name protoreflect.Name = "value"
Int64Value_Value_field_fullname protoreflect.FullName = "google.protobuf.Int64Value.value"
)
// Field numbers for google.protobuf.Int64Value.
const (
Int64Value_Value_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.UInt64Value.
const (
UInt64Value_message_name protoreflect.Name = "UInt64Value"
UInt64Value_message_fullname protoreflect.FullName = "google.protobuf.UInt64Value"
)
// Field names for google.protobuf.UInt64Value.
const (
UInt64Value_Value_field_name protoreflect.Name = "value"
UInt64Value_Value_field_fullname protoreflect.FullName = "google.protobuf.UInt64Value.value"
)
// Field numbers for google.protobuf.UInt64Value.
const (
UInt64Value_Value_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.Int32Value.
const (
Int32Value_message_name protoreflect.Name = "Int32Value"
Int32Value_message_fullname protoreflect.FullName = "google.protobuf.Int32Value"
)
// Field names for google.protobuf.Int32Value.
const (
Int32Value_Value_field_name protoreflect.Name = "value"
Int32Value_Value_field_fullname protoreflect.FullName = "google.protobuf.Int32Value.value"
)
// Field numbers for google.protobuf.Int32Value.
const (
Int32Value_Value_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.UInt32Value.
const (
UInt32Value_message_name protoreflect.Name = "UInt32Value"
UInt32Value_message_fullname protoreflect.FullName = "google.protobuf.UInt32Value"
)
// Field names for google.protobuf.UInt32Value.
const (
UInt32Value_Value_field_name protoreflect.Name = "value"
UInt32Value_Value_field_fullname protoreflect.FullName = "google.protobuf.UInt32Value.value"
)
// Field numbers for google.protobuf.UInt32Value.
const (
UInt32Value_Value_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.BoolValue.
const (
BoolValue_message_name protoreflect.Name = "BoolValue"
BoolValue_message_fullname protoreflect.FullName = "google.protobuf.BoolValue"
)
// Field names for google.protobuf.BoolValue.
const (
BoolValue_Value_field_name protoreflect.Name = "value"
BoolValue_Value_field_fullname protoreflect.FullName = "google.protobuf.BoolValue.value"
)
// Field numbers for google.protobuf.BoolValue.
const (
BoolValue_Value_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.StringValue.
const (
StringValue_message_name protoreflect.Name = "StringValue"
StringValue_message_fullname protoreflect.FullName = "google.protobuf.StringValue"
)
// Field names for google.protobuf.StringValue.
const (
StringValue_Value_field_name protoreflect.Name = "value"
StringValue_Value_field_fullname protoreflect.FullName = "google.protobuf.StringValue.value"
)
// Field numbers for google.protobuf.StringValue.
const (
StringValue_Value_field_number protoreflect.FieldNumber = 1
)
// Names for google.protobuf.BytesValue.
const (
BytesValue_message_name protoreflect.Name = "BytesValue"
BytesValue_message_fullname protoreflect.FullName = "google.protobuf.BytesValue"
)
// Field names for google.protobuf.BytesValue.
const (
BytesValue_Value_field_name protoreflect.Name = "value"
BytesValue_Value_field_fullname protoreflect.FullName = "google.protobuf.BytesValue.value"
)
// Field numbers for google.protobuf.BytesValue.
const (
BytesValue_Value_field_number protoreflect.FieldNumber = 1
)

View File

@ -1,25 +0,0 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package genname contains constants for generated names.
package genname
const (
State = "state"
SizeCache = "sizeCache"
SizeCacheA = "XXX_sizecache"
WeakFields = "weakFields"
WeakFieldsA = "XXX_weak"
UnknownFields = "unknownFields"
UnknownFieldsA = "XXX_unrecognized"
ExtensionFields = "extensionFields"
ExtensionFieldsA = "XXX_InternalExtensions"
ExtensionFieldsB = "XXX_extensions"
WeakFieldPrefix = "XXX_weak_"
)

View File

@ -10,6 +10,7 @@ import (
"strconv"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/internal/errors"
"google.golang.org/protobuf/proto"
pref "google.golang.org/protobuf/reflect/protoreflect"
piface "google.golang.org/protobuf/runtime/protoiface"
@ -19,6 +20,12 @@ import (
// functions that we do not want to appear in godoc.
type Export struct{}
// NewError formats a string according to the format specifier and arguments and
// returns an error that has a "proto" prefix.
func (Export) NewError(f string, x ...interface{}) error {
return errors.New(f, x...)
}
// enum is any enum type generated by protoc-gen-go
// and must be a named int32 type.
type enum = interface{}

View File

@ -10,6 +10,7 @@ import (
"sort"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/genid"
pref "google.golang.org/protobuf/reflect/protoreflect"
)
@ -134,7 +135,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
b = b[n:]
err := errUnknown
switch num {
case 1:
case genid.MapEntry_Key_field_number:
var v pref.Value
var o unmarshalOutput
v, o, err = mapi.keyFuncs.unmarshal(b, key, num, wtyp, opts)
@ -143,7 +144,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
}
key = v
n = o.n
case 2:
case genid.MapEntry_Value_field_number:
var v pref.Value
var o unmarshalOutput
v, o, err = mapi.valFuncs.unmarshal(b, val, num, wtyp, opts)

View File

@ -12,7 +12,7 @@ import (
"sync"
"sync/atomic"
"google.golang.org/protobuf/internal/genname"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/reflect/protoreflect"
pref "google.golang.org/protobuf/reflect/protoreflect"
)
@ -148,19 +148,19 @@ func (mi *MessageInfo) makeStructInfo(t reflect.Type) structInfo {
fieldLoop:
for i := 0; i < t.NumField(); i++ {
switch f := t.Field(i); f.Name {
case genname.SizeCache, genname.SizeCacheA:
case genid.SizeCache_goname, genid.SizeCacheA_goname:
if f.Type == sizecacheType {
si.sizecacheOffset = offsetOf(f, mi.Exporter)
}
case genname.WeakFields, genname.WeakFieldsA:
case genid.WeakFields_goname, genid.WeakFieldsA_goname:
if f.Type == weakFieldsType {
si.weakOffset = offsetOf(f, mi.Exporter)
}
case genname.UnknownFields, genname.UnknownFieldsA:
case genid.UnknownFields_goname, genid.UnknownFieldsA_goname:
if f.Type == unknownFieldsType {
si.unknownOffset = offsetOf(f, mi.Exporter)
}
case genname.ExtensionFields, genname.ExtensionFieldsA, genname.ExtensionFieldsB:
case genid.ExtensionFields_goname, genid.ExtensionFieldsA_goname, genid.ExtensionFieldsB_goname:
if f.Type == extensionFieldsType {
si.extensionOffset = offsetOf(f, mi.Exporter)
}

View File

@ -14,6 +14,7 @@ import (
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/strs"
pref "google.golang.org/protobuf/reflect/protoreflect"
preg "google.golang.org/protobuf/reflect/protoregistry"
@ -282,9 +283,9 @@ State:
switch {
case st.typ == validationTypeMap:
switch num {
case 1:
case genid.MapEntry_Key_field_number:
vi.typ = st.keyType
case 2:
case genid.MapEntry_Value_field_number:
vi.typ = st.valType
vi.mi = st.mi
vi.requiredBit = 1

View File

@ -52,7 +52,7 @@ import (
// 10. Send out the CL for review and submit it.
const (
Major = 1
Minor = 24
Minor = 25
Patch = 0
PreRelease = ""
)

View File

@ -9,6 +9,7 @@ import (
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/errors"
"google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
@ -220,13 +221,13 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
b = b[n:]
err = errUnknown
switch num {
case 1:
case genid.MapEntry_Key_field_number:
key, n, err = o.unmarshalScalar(b, wtyp, keyField)
if err != nil {
break
}
haveKey = true
case 2:
case genid.MapEntry_Value_field_number:
var v protoreflect.Value
v, n, err = o.unmarshalScalar(b, wtyp, valField)
if err != nil {

View File

@ -128,7 +128,6 @@ package protoreflect
import (
"fmt"
"regexp"
"strings"
"google.golang.org/protobuf/encoding/protowire"
@ -408,19 +407,14 @@ type EnumRanges interface {
doNotImplement
}
var (
regexName = regexp.MustCompile(`^[_a-zA-Z][_a-zA-Z0-9]*$`)
regexFullName = regexp.MustCompile(`^[_a-zA-Z][_a-zA-Z0-9]*(\.[_a-zA-Z][_a-zA-Z0-9]*)*$`)
)
// Name is the short name for a proto declaration. This is not the name
// as used in Go source code, which might not be identical to the proto name.
type Name string // e.g., "Kind"
// IsValid reports whether n is a syntactically valid name.
// IsValid reports whether s is a syntactically valid name.
// An empty name is invalid.
func (n Name) IsValid() bool {
return regexName.MatchString(string(n))
func (s Name) IsValid() bool {
return consumeIdent(string(s)) == len(s)
}
// Names represent a list of names.
@ -443,10 +437,42 @@ type Names interface {
// This should not have any leading or trailing dots.
type FullName string // e.g., "google.protobuf.Field.Kind"
// IsValid reports whether n is a syntactically valid full name.
// IsValid reports whether s is a syntactically valid full name.
// An empty full name is invalid.
func (n FullName) IsValid() bool {
return regexFullName.MatchString(string(n))
func (s FullName) IsValid() bool {
i := consumeIdent(string(s))
if i < 0 {
return false
}
for len(s) > i {
if s[i] != '.' {
return false
}
i++
n := consumeIdent(string(s[i:]))
if n < 0 {
return false
}
i += n
}
return true
}
func consumeIdent(s string) (i int) {
if len(s) == 0 || !isLetter(s[i]) {
return -1
}
i++
for len(s) > i && isLetterDigit(s[i]) {
i++
}
return i
}
func isLetter(c byte) bool {
return c == '_' || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
}
func isLetterDigit(c byte) bool {
return isLetter(c) || ('0' <= c && c <= '9')
}
// Name returns the short name, which is the last identifier segment.

View File

@ -31,12 +31,100 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google/protobuf/any.proto
// Package anypb contains generated types for google/protobuf/any.proto.
//
// The Any message is a dynamic representation of any other message value.
// It is functionally a tuple of the full name of the remote message type and
// the serialized bytes of the remote message value.
//
//
// Constructing an Any
//
// An Any message containing another message value is constructed using New:
//
// any, err := anypb.New(m)
// if err != nil {
// ... // handle error
// }
// ... // make use of any
//
//
// Unmarshaling an Any
//
// With a populated Any message, the underlying message can be serialized into
// a remote concrete message value in a few ways.
//
// If the exact concrete type is known, then a new (or pre-existing) instance
// of that message can be passed to the UnmarshalTo method:
//
// m := new(foopb.MyMessage)
// if err := any.UnmarshalTo(m); err != nil {
// ... // handle error
// }
// ... // make use of m
//
// If the exact concrete type is not known, then the UnmarshalNew method can be
// used to unmarshal the contents into a new instance of the remote message type:
//
// m, err := any.UnmarshalNew()
// if err != nil {
// ... // handle error
// }
// ... // make use of m
//
// UnmarshalNew uses the global type registry to resolve the message type and
// construct a new instance of that message to unmarshal into. In order for a
// message type to appear in the global registry, the Go type representing that
// protobuf message type must be linked into the Go binary. For messages
// generated by protoc-gen-go, this is achieved through an import of the
// generated Go package representing a .proto file.
//
// A common pattern with UnmarshalNew is to use a type switch with the resulting
// proto.Message value:
//
// switch m := m.(type) {
// case *foopb.MyMessage:
// ... // make use of m as a *foopb.MyMessage
// case *barpb.OtherMessage:
// ... // make use of m as a *barpb.OtherMessage
// case *bazpb.SomeMessage:
// ... // make use of m as a *bazpb.SomeMessage
// }
//
// This pattern ensures that the generated packages containing the message types
// listed in the case clauses are linked into the Go binary and therefore also
// registered in the global registry.
//
//
// Type checking an Any
//
// In order to type check whether an Any message represents some other message,
// then use the MessageIs method:
//
// if any.MessageIs((*foopb.MyMessage)(nil)) {
// ... // make use of any, knowing that it contains a foopb.MyMessage
// }
//
// The MessageIs method can also be used with an allocated instance of the target
// message type if the intention is to unmarshal into it if the type matches:
//
// m := new(foopb.MyMessage)
// if any.MessageIs(m) {
// if err := any.UnmarshalTo(m); err != nil {
// ... // handle error
// }
// ... // make use of m
// }
//
package anypb
import (
proto "google.golang.org/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoregistry "google.golang.org/protobuf/reflect/protoregistry"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
strings "strings"
sync "sync"
)
@ -158,6 +246,125 @@ type Any struct {
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}
// New marshals src into a new Any instance.
func New(src proto.Message) (*Any, error) {
dst := new(Any)
if err := dst.MarshalFrom(src); err != nil {
return nil, err
}
return dst, nil
}
// MarshalFrom marshals src into dst as the underlying message
// using the provided marshal options.
//
// If no options are specified, call dst.MarshalFrom instead.
func MarshalFrom(dst *Any, src proto.Message, opts proto.MarshalOptions) error {
const urlPrefix = "type.googleapis.com/"
if src == nil {
return protoimpl.X.NewError("invalid nil source message")
}
b, err := opts.Marshal(src)
if err != nil {
return err
}
dst.TypeUrl = urlPrefix + string(src.ProtoReflect().Descriptor().FullName())
dst.Value = b
return nil
}
// UnmarshalTo unmarshals the underlying message from src into dst
// using the provided unmarshal options.
// It reports an error if dst is not of the right message type.
//
// If no options are specified, call src.UnmarshalTo instead.
func UnmarshalTo(src *Any, dst proto.Message, opts proto.UnmarshalOptions) error {
if src == nil {
return protoimpl.X.NewError("invalid nil source message")
}
if !src.MessageIs(dst) {
got := dst.ProtoReflect().Descriptor().FullName()
want := src.MessageName()
return protoimpl.X.NewError("mismatched message type: got %q, want %q", got, want)
}
return opts.Unmarshal(src.GetValue(), dst)
}
// UnmarshalNew unmarshals the underlying message from src into dst,
// which is newly created message using a type resolved from the type URL.
// The message type is resolved according to opt.Resolver,
// which should implement protoregistry.MessageTypeResolver.
// It reports an error if the underlying message type could not be resolved.
//
// If no options are specified, call src.UnmarshalNew instead.
func UnmarshalNew(src *Any, opts proto.UnmarshalOptions) (dst proto.Message, err error) {
if src.GetTypeUrl() == "" {
return nil, protoimpl.X.NewError("invalid empty type URL")
}
if opts.Resolver == nil {
opts.Resolver = protoregistry.GlobalTypes
}
r, ok := opts.Resolver.(protoregistry.MessageTypeResolver)
if !ok {
return nil, protoregistry.NotFound
}
mt, err := r.FindMessageByURL(src.GetTypeUrl())
if err != nil {
if err == protoregistry.NotFound {
return nil, err
}
return nil, protoimpl.X.NewError("could not resolve %q: %v", src.GetTypeUrl(), err)
}
dst = mt.New().Interface()
return dst, opts.Unmarshal(src.GetValue(), dst)
}
// MessageIs reports whether the underlying message is of the same type as m.
func (x *Any) MessageIs(m proto.Message) bool {
if m == nil {
return false
}
url := x.GetTypeUrl()
name := string(m.ProtoReflect().Descriptor().FullName())
if !strings.HasSuffix(url, name) {
return false
}
return len(url) == len(name) || url[len(url)-len(name)-1] == '/'
}
// MessageName reports the full name of the underlying message,
// returning an empty string if invalid.
func (x *Any) MessageName() protoreflect.FullName {
url := x.GetTypeUrl()
name := protoreflect.FullName(url)
if i := strings.LastIndexByte(url, '/'); i >= 0 {
name = name[i+len("/"):]
}
if !name.IsValid() {
return ""
}
return name
}
// MarshalFrom marshals m into x as the underlying message.
func (x *Any) MarshalFrom(m proto.Message) error {
return MarshalFrom(x, m, proto.MarshalOptions{})
}
// UnmarshalTo unmarshals the contents of the underlying message of x into m.
// It resets m before performing the unmarshal operation.
// It reports an error if m is not of the right message type.
func (x *Any) UnmarshalTo(m proto.Message) error {
return UnmarshalTo(x, m, proto.UnmarshalOptions{})
}
// UnmarshalNew unmarshals the contents of the underlying message of x into
// a newly allocated message of the specified type.
// It reports an error if the underlying message type could not be resolved.
func (x *Any) UnmarshalNew() (proto.Message, error) {
return UnmarshalNew(x, proto.UnmarshalOptions{})
}
func (x *Any) Reset() {
*x = Any{}
if protoimpl.UnsafeEnabled {

View File

@ -31,13 +31,58 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google/protobuf/duration.proto
// Package durationpb contains generated types for google/protobuf/duration.proto.
//
// The Duration message represents a signed span of time.
//
//
// Conversion to a Go Duration
//
// The AsDuration method can be used to convert a Duration message to a
// standard Go time.Duration value:
//
// d := dur.AsDuration()
// ... // make use of d as a time.Duration
//
// Converting to a time.Duration is a common operation so that the extensive
// set of time-based operations provided by the time package can be leveraged.
// See https://golang.org/pkg/time for more information.
//
// The AsDuration method performs the conversion on a best-effort basis.
// Durations with denormal values (e.g., nanoseconds beyond -99999999 and
// +99999999, inclusive; or seconds and nanoseconds with opposite signs)
// are normalized during the conversion to a time.Duration. To manually check for
// invalid Duration per the documented limitations in duration.proto,
// additionally call the CheckValid method:
//
// if err := dur.CheckValid(); err != nil {
// ... // handle error
// }
//
// Note that the documented limitations in duration.proto does not protect a
// Duration from overflowing the representable range of a time.Duration in Go.
// The AsDuration method uses saturation arithmetic such that an overflow clamps
// the resulting value to the closest representable value (e.g., math.MaxInt64
// for positive overflow and math.MinInt64 for negative overflow).
//
//
// Conversion from a Go Duration
//
// The durationpb.New function can be used to construct a Duration message
// from a standard Go time.Duration value:
//
// dur := durationpb.New(d)
// ... // make use of d as a *durationpb.Duration
//
package durationpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
math "math"
reflect "reflect"
sync "sync"
time "time"
)
// A Duration represents a signed, fixed-length span of time represented
@ -118,6 +163,91 @@ type Duration struct {
Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
}
// New constructs a new Duration from the provided time.Duration.
func New(d time.Duration) *Duration {
nanos := d.Nanoseconds()
secs := nanos / 1e9
nanos -= secs * 1e9
return &Duration{Seconds: int64(secs), Nanos: int32(nanos)}
}
// AsDuration converts x to a time.Duration,
// returning the closest duration value in the event of overflow.
func (x *Duration) AsDuration() time.Duration {
secs := x.GetSeconds()
nanos := x.GetNanos()
d := time.Duration(secs) * time.Second
overflow := d/time.Second != time.Duration(secs)
d += time.Duration(nanos) * time.Nanosecond
overflow = overflow || (secs < 0 && nanos < 0 && d > 0)
overflow = overflow || (secs > 0 && nanos > 0 && d < 0)
if overflow {
switch {
case secs < 0:
return time.Duration(math.MinInt64)
case secs > 0:
return time.Duration(math.MaxInt64)
}
}
return d
}
// IsValid reports whether the duration is valid.
// It is equivalent to CheckValid == nil.
func (x *Duration) IsValid() bool {
return x.check() == 0
}
// CheckValid returns an error if the duration is invalid.
// In particular, it checks whether the value is within the range of
// -10000 years to +10000 years inclusive.
// An error is reported for a nil Duration.
func (x *Duration) CheckValid() error {
switch x.check() {
case invalidNil:
return protoimpl.X.NewError("invalid nil Duration")
case invalidUnderflow:
return protoimpl.X.NewError("duration (%v) exceeds -10000 years", x)
case invalidOverflow:
return protoimpl.X.NewError("duration (%v) exceeds +10000 years", x)
case invalidNanosRange:
return protoimpl.X.NewError("duration (%v) has out-of-range nanos", x)
case invalidNanosSign:
return protoimpl.X.NewError("duration (%v) has seconds and nanos with different signs", x)
default:
return nil
}
}
const (
_ = iota
invalidNil
invalidUnderflow
invalidOverflow
invalidNanosRange
invalidNanosSign
)
func (x *Duration) check() uint {
const absDuration = 315576000000 // 10000yr * 365.25day/yr * 24hr/day * 60min/hr * 60sec/min
secs := x.GetSeconds()
nanos := x.GetNanos()
switch {
case x == nil:
return invalidNil
case secs < -absDuration:
return invalidUnderflow
case secs > +absDuration:
return invalidOverflow
case nanos <= -1e9 || nanos >= +1e9:
return invalidNanosRange
case (secs > 0 && nanos < 0) || (secs < 0 && nanos > 0):
return invalidNanosSign
default:
return 0
}
}
func (x *Duration) Reset() {
*x = Duration{}
if protoimpl.UnsafeEnabled {

View File

@ -31,6 +31,48 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google/protobuf/timestamp.proto
// Package timestamppb contains generated types for google/protobuf/timestamp.proto.
//
// The Timestamp message represents a timestamp,
// an instant in time since the Unix epoch (January 1st, 1970).
//
//
// Conversion to a Go Time
//
// The AsTime method can be used to convert a Timestamp message to a
// standard Go time.Time value in UTC:
//
// t := ts.AsTime()
// ... // make use of t as a time.Time
//
// Converting to a time.Time is a common operation so that the extensive
// set of time-based operations provided by the time package can be leveraged.
// See https://golang.org/pkg/time for more information.
//
// The AsTime method performs the conversion on a best-effort basis. Timestamps
// with denormal values (e.g., nanoseconds beyond 0 and 99999999, inclusive)
// are normalized during the conversion to a time.Time. To manually check for
// invalid Timestamps per the documented limitations in timestamp.proto,
// additionally call the CheckValid method:
//
// if err := ts.CheckValid(); err != nil {
// ... // handle error
// }
//
//
// Conversion from a Go Time
//
// The timestamppb.New function can be used to construct a Timestamp message
// from a standard Go time.Time value:
//
// ts := timestamppb.New(t)
// ... // make use of ts as a *timestamppb.Timestamp
//
// In order to construct a Timestamp representing the current time, use Now:
//
// ts := timestamppb.Now()
// ... // make use of ts as a *timestamppb.Timestamp
//
package timestamppb
import (
@ -38,6 +80,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
time "time"
)
// A Timestamp represents a point in time independent of any time zone or local
@ -140,6 +183,73 @@ type Timestamp struct {
Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
}
// Now constructs a new Timestamp from the current time.
func Now() *Timestamp {
return New(time.Now())
}
// New constructs a new Timestamp from the provided time.Time.
func New(t time.Time) *Timestamp {
return &Timestamp{Seconds: int64(t.Unix()), Nanos: int32(t.Nanosecond())}
}
// AsTime converts x to a time.Time.
func (x *Timestamp) AsTime() time.Time {
return time.Unix(int64(x.GetSeconds()), int64(x.GetNanos())).UTC()
}
// IsValid reports whether the timestamp is valid.
// It is equivalent to CheckValid == nil.
func (x *Timestamp) IsValid() bool {
return x.check() == 0
}
// CheckValid returns an error if the timestamp is invalid.
// In particular, it checks whether the value represents a date that is
// in the range of 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.
// An error is reported for a nil Timestamp.
func (x *Timestamp) CheckValid() error {
switch x.check() {
case invalidNil:
return protoimpl.X.NewError("invalid nil Timestamp")
case invalidUnderflow:
return protoimpl.X.NewError("timestamp (%v) before 0001-01-01", x)
case invalidOverflow:
return protoimpl.X.NewError("timestamp (%v) after 9999-12-31", x)
case invalidNanos:
return protoimpl.X.NewError("timestamp (%v) has out-of-range nanos", x)
default:
return nil
}
}
const (
_ = iota
invalidNil
invalidUnderflow
invalidOverflow
invalidNanos
)
func (x *Timestamp) check() uint {
const minTimestamp = -62135596800 // Seconds between 1970-01-01T00:00:00Z and 0001-01-01T00:00:00Z, inclusive
const maxTimestamp = +253402300799 // Seconds between 1970-01-01T00:00:00Z and 9999-12-31T23:59:59Z, inclusive
secs := x.GetSeconds()
nanos := x.GetNanos()
switch {
case x == nil:
return invalidNil
case secs < minTimestamp:
return invalidUnderflow
case secs > maxTimestamp:
return invalidOverflow
case nanos < 0 || nanos >= 1e9:
return invalidNanos
default:
return 0
}
}
func (x *Timestamp) Reset() {
*x = Timestamp{}
if protoimpl.UnsafeEnabled {

View File

@ -5,3 +5,4 @@
*.pem
*.cov
jose-util/jose-util
jose-util.t.err

View File

@ -8,11 +8,9 @@ matrix:
- go: tip
go:
- '1.7.x'
- '1.8.x'
- '1.9.x'
- '1.10.x'
- '1.11.x'
- '1.12.x'
- tip
go_import_path: gopkg.in/square/go-jose.v2
@ -28,6 +26,8 @@ before_install:
- go get github.com/wadey/gocovmerge
- go get github.com/mattn/goveralls
- go get github.com/stretchr/testify/assert
- go get github.com/stretchr/testify/require
- go get github.com/google/go-cmp/cmp
- go get golang.org/x/tools/cmd/cover || true
- go get code.google.com/p/go.tools/cmd/cover || true
- pip install cram --user
@ -37,10 +37,9 @@ script:
- go test ./cipher -v -covermode=count -coverprofile=cipher/profile.cov
- go test ./jwt -v -covermode=count -coverprofile=jwt/profile.cov
- go test ./json -v # no coverage for forked encoding/json package
- cd jose-util && go build && PATH=$PWD:$PATH cram -v jose-util.t
- cd jose-util && go build && PATH=$PWD:$PATH cram -v jose-util.t # cram tests jose-util
- cd ..
after_success:
- gocovmerge *.cov */*.cov > merged.coverprofile
- $HOME/gopath/bin/goveralls -coverprofile merged.coverprofile -service=travis-ci

View File

@ -29,7 +29,7 @@ import (
"math/big"
"golang.org/x/crypto/ed25519"
"gopkg.in/square/go-jose.v2/cipher"
josecipher "gopkg.in/square/go-jose.v2/cipher"
"gopkg.in/square/go-jose.v2/json"
)
@ -288,7 +288,7 @@ func (ctx rsaDecrypterSigner) signPayload(payload []byte, alg SignatureAlgorithm
out, err = rsa.SignPKCS1v15(RandReader, ctx.privateKey, hash, hashed)
case PS256, PS384, PS512:
out, err = rsa.SignPSS(RandReader, ctx.privateKey, hash, hashed, &rsa.PSSOptions{
SaltLength: rsa.PSSSaltLengthAuto,
SaltLength: rsa.PSSSaltLengthEqualsHash,
})
}

View File

@ -17,8 +17,10 @@
package josecipher
import (
"bytes"
"crypto"
"crypto/ecdsa"
"crypto/elliptic"
"encoding/binary"
)
@ -44,16 +46,38 @@ func DeriveECDHES(alg string, apuData, apvData []byte, priv *ecdsa.PrivateKey, p
panic("public key not on same curve as private key")
}
z, _ := priv.PublicKey.Curve.ScalarMult(pub.X, pub.Y, priv.D.Bytes())
reader := NewConcatKDF(crypto.SHA256, z.Bytes(), algID, ptyUInfo, ptyVInfo, supPubInfo, []byte{})
z, _ := priv.Curve.ScalarMult(pub.X, pub.Y, priv.D.Bytes())
zBytes := z.Bytes()
// Note that calling z.Bytes() on a big.Int may strip leading zero bytes from
// the returned byte array. This can lead to a problem where zBytes will be
// shorter than expected which breaks the key derivation. Therefore we must pad
// to the full length of the expected coordinate here before calling the KDF.
octSize := dSize(priv.Curve)
if len(zBytes) != octSize {
zBytes = append(bytes.Repeat([]byte{0}, octSize-len(zBytes)), zBytes...)
}
reader := NewConcatKDF(crypto.SHA256, zBytes, algID, ptyUInfo, ptyVInfo, supPubInfo, []byte{})
key := make([]byte, size)
// Read on the KDF will never fail
_, _ = reader.Read(key)
return key
}
// dSize returns the size in octets for a coordinate on a elliptic curve.
func dSize(curve elliptic.Curve) int {
order := curve.Params().P
bitLen := order.BitLen()
size := bitLen / 8
if bitLen%8 != 0 {
size++
}
return size
}
func lengthPrefixed(data []byte) []byte {
out := make([]byte, len(data)+4)
binary.BigEndian.PutUint32(out, uint32(len(data)))

View File

@ -141,6 +141,8 @@ func NewEncrypter(enc ContentEncryption, rcpt Recipient, opts *EncrypterOptions)
keyID, rawKey = encryptionKey.KeyID, encryptionKey.Key
case *JSONWebKey:
keyID, rawKey = encryptionKey.KeyID, encryptionKey.Key
case OpaqueKeyEncrypter:
keyID, rawKey = encryptionKey.KeyID(), encryptionKey
default:
rawKey = encryptionKey
}
@ -267,9 +269,11 @@ func makeJWERecipient(alg KeyAlgorithm, encryptionKey interface{}) (recipientKey
recipient, err := makeJWERecipient(alg, encryptionKey.Key)
recipient.keyID = encryptionKey.KeyID
return recipient, err
default:
return recipientKeyInfo{}, ErrUnsupportedKeyType
}
if encrypter, ok := encryptionKey.(OpaqueKeyEncrypter); ok {
return newOpaqueKeyEncrypter(alg, encrypter)
}
return recipientKeyInfo{}, ErrUnsupportedKeyType
}
// newDecrypter creates an appropriate decrypter based on the key type
@ -295,9 +299,11 @@ func newDecrypter(decryptionKey interface{}) (keyDecrypter, error) {
return newDecrypter(decryptionKey.Key)
case *JSONWebKey:
return newDecrypter(decryptionKey.Key)
default:
return nil, ErrUnsupportedKeyType
}
if okd, ok := decryptionKey.(OpaqueKeyDecrypter); ok {
return &opaqueKeyDecrypter{decrypter: okd}, nil
}
return nil, ErrUnsupportedKeyType
}
// Implementation of encrypt method producing a JWE object.

View File

@ -23,13 +23,12 @@ import (
"encoding/binary"
"io"
"math/big"
"regexp"
"strings"
"unicode"
"gopkg.in/square/go-jose.v2/json"
)
var stripWhitespaceRegex = regexp.MustCompile("\\s")
// Helper function to serialize known-good objects.
// Precondition: value is not a nil pointer.
func mustSerializeJSON(value interface{}) []byte {
@ -56,7 +55,14 @@ func mustSerializeJSON(value interface{}) []byte {
// Strip all newlines and whitespace
func stripWhitespace(data string) string {
return stripWhitespaceRegex.ReplaceAllString(data, "")
buf := strings.Builder{}
buf.Grow(len(data))
for _, r := range data {
if !unicode.IsSpace(r) {
buf.WriteRune(r)
}
}
return buf.String()
}
// Perform compression based on algorithm

View File

@ -17,15 +17,20 @@
package jose
import (
"bytes"
"crypto"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rsa"
"crypto/sha1"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"math/big"
"net/url"
"reflect"
"strings"
@ -58,15 +63,30 @@ type rawJSONWebKey struct {
Qi *byteBuffer `json:"qi,omitempty"`
// Certificates
X5c []string `json:"x5c,omitempty"`
X5u *url.URL `json:"x5u,omitempty"`
X5tSHA1 string `json:"x5t,omitempty"`
X5tSHA256 string `json:"x5t#S256,omitempty"`
}
// JSONWebKey represents a public or private key in JWK format.
type JSONWebKey struct {
// Cryptographic key, can be a symmetric or asymmetric key.
Key interface{}
Certificates []*x509.Certificate
// Key identifier, parsed from `kid` header.
KeyID string
// Key algorithm, parsed from `alg` header.
Algorithm string
// Key use, parsed from `use` header.
Use string
// X.509 certificate chain, parsed from `x5c` header.
Certificates []*x509.Certificate
// X.509 certificate URL, parsed from `x5u` header.
CertificatesURL *url.URL
// X.509 certificate thumbprint (SHA-1), parsed from `x5t` header.
CertificateThumbprintSHA1 []byte
// X.509 certificate thumbprint (SHA-256), parsed from `x5t#S256` header.
CertificateThumbprintSHA256 []byte
}
// MarshalJSON serializes the given key to its JSON representation.
@ -105,6 +125,39 @@ func (k JSONWebKey) MarshalJSON() ([]byte, error) {
raw.X5c = append(raw.X5c, base64.StdEncoding.EncodeToString(cert.Raw))
}
x5tSHA1Len := len(k.CertificateThumbprintSHA1)
x5tSHA256Len := len(k.CertificateThumbprintSHA256)
if x5tSHA1Len > 0 {
if x5tSHA1Len != sha1.Size {
return nil, fmt.Errorf("square/go-jose: invalid SHA-1 thumbprint (must be %d bytes, not %d)", sha1.Size, x5tSHA1Len)
}
raw.X5tSHA1 = base64.RawURLEncoding.EncodeToString(k.CertificateThumbprintSHA1)
}
if x5tSHA256Len > 0 {
if x5tSHA256Len != sha256.Size {
return nil, fmt.Errorf("square/go-jose: invalid SHA-256 thumbprint (must be %d bytes, not %d)", sha256.Size, x5tSHA256Len)
}
raw.X5tSHA256 = base64.RawURLEncoding.EncodeToString(k.CertificateThumbprintSHA256)
}
// If cert chain is attached (as opposed to being behind a URL), check the
// keys thumbprints to make sure they match what is expected. This is to
// ensure we don't accidentally produce a JWK with semantically inconsistent
// data in the headers.
if len(k.Certificates) > 0 {
expectedSHA1 := sha1.Sum(k.Certificates[0].Raw)
expectedSHA256 := sha256.Sum256(k.Certificates[0].Raw)
if len(k.CertificateThumbprintSHA1) > 0 && !bytes.Equal(k.CertificateThumbprintSHA1, expectedSHA1[:]) {
return nil, errors.New("square/go-jose: invalid SHA-1 thumbprint, does not match cert chain")
}
if len(k.CertificateThumbprintSHA256) > 0 && !bytes.Equal(k.CertificateThumbprintSHA256, expectedSHA256[:]) {
return nil, errors.New("square/go-jose: invalid or SHA-256 thumbprint, does not match cert chain")
}
}
raw.X5u = k.CertificatesURL
return json.Marshal(raw)
}
@ -116,28 +169,61 @@ func (k *JSONWebKey) UnmarshalJSON(data []byte) (err error) {
return err
}
certs, err := parseCertificateChain(raw.X5c)
if err != nil {
return fmt.Errorf("square/go-jose: failed to unmarshal x5c field: %s", err)
}
var key interface{}
var certPub interface{}
var keyPub interface{}
if len(certs) > 0 {
// We need to check that leaf public key matches the key embedded in this
// JWK, as required by the standard (see RFC 7517, Section 4.7). Otherwise
// the JWK parsed could be semantically invalid. Technically, should also
// check key usage fields and other extensions on the cert here, but the
// standard doesn't exactly explain how they're supposed to map from the
// JWK representation to the X.509 extensions.
certPub = certs[0].PublicKey
}
switch raw.Kty {
case "EC":
if raw.D != nil {
key, err = raw.ecPrivateKey()
if err == nil {
keyPub = key.(*ecdsa.PrivateKey).Public()
}
} else {
key, err = raw.ecPublicKey()
keyPub = key
}
case "RSA":
if raw.D != nil {
key, err = raw.rsaPrivateKey()
if err == nil {
keyPub = key.(*rsa.PrivateKey).Public()
}
} else {
key, err = raw.rsaPublicKey()
keyPub = key
}
case "oct":
if certPub != nil {
return errors.New("square/go-jose: invalid JWK, found 'oct' (symmetric) key with cert chain")
}
key, err = raw.symmetricKey()
case "OKP":
if raw.Crv == "Ed25519" && raw.X != nil {
if raw.D != nil {
key, err = raw.edPrivateKey()
if err == nil {
keyPub = key.(ed25519.PrivateKey).Public()
}
} else {
key, err = raw.edPublicKey()
keyPub = key
}
} else {
err = fmt.Errorf("square/go-jose: unknown curve %s'", raw.Crv)
@ -146,12 +232,78 @@ func (k *JSONWebKey) UnmarshalJSON(data []byte) (err error) {
err = fmt.Errorf("square/go-jose: unknown json web key type '%s'", raw.Kty)
}
if err == nil {
*k = JSONWebKey{Key: key, KeyID: raw.Kid, Algorithm: raw.Alg, Use: raw.Use}
k.Certificates, err = parseCertificateChain(raw.X5c)
if err != nil {
return fmt.Errorf("failed to unmarshal x5c field: %s", err)
return
}
if certPub != nil && keyPub != nil {
if !reflect.DeepEqual(certPub, keyPub) {
return errors.New("square/go-jose: invalid JWK, public keys in key and x5c fields to not match")
}
}
*k = JSONWebKey{Key: key, KeyID: raw.Kid, Algorithm: raw.Alg, Use: raw.Use, Certificates: certs}
k.CertificatesURL = raw.X5u
// x5t parameters are base64url-encoded SHA thumbprints
// See RFC 7517, Section 4.8, https://tools.ietf.org/html/rfc7517#section-4.8
x5tSHA1bytes, err := base64.RawURLEncoding.DecodeString(raw.X5tSHA1)
if err != nil {
return errors.New("square/go-jose: invalid JWK, x5t header has invalid encoding")
}
// RFC 7517, Section 4.8 is ambiguous as to whether the digest output should be byte or hex,
// for this reason, after base64 decoding, if the size is sha1.Size it's likely that the value is a byte encoded
// checksum so we skip this. Otherwise if the checksum was hex encoded we expect a 40 byte sized array so we'll
// try to hex decode it. When Marshalling this value we'll always use a base64 encoded version of byte format checksum.
if len(x5tSHA1bytes) == 2*sha1.Size {
hx, err := hex.DecodeString(string(x5tSHA1bytes))
if err != nil {
return fmt.Errorf("square/go-jose: invalid JWK, unable to hex decode x5t: %v", err)
}
x5tSHA1bytes = hx
}
k.CertificateThumbprintSHA1 = x5tSHA1bytes
x5tSHA256bytes, err := base64.RawURLEncoding.DecodeString(raw.X5tSHA256)
if err != nil {
return errors.New("square/go-jose: invalid JWK, x5t#S256 header has invalid encoding")
}
if len(x5tSHA256bytes) == 2*sha256.Size {
hx256, err := hex.DecodeString(string(x5tSHA256bytes))
if err != nil {
return fmt.Errorf("square/go-jose: invalid JWK, unable to hex decode x5t#S256: %v", err)
}
x5tSHA256bytes = hx256
}
k.CertificateThumbprintSHA256 = x5tSHA256bytes
x5tSHA1Len := len(k.CertificateThumbprintSHA1)
x5tSHA256Len := len(k.CertificateThumbprintSHA256)
if x5tSHA1Len > 0 && x5tSHA1Len != sha1.Size {
return errors.New("square/go-jose: invalid JWK, x5t header is of incorrect size")
}
if x5tSHA256Len > 0 && x5tSHA256Len != sha256.Size {
return errors.New("square/go-jose: invalid JWK, x5t#S256 header is of incorrect size")
}
// If certificate chain *and* thumbprints are set, verify correctness.
if len(k.Certificates) > 0 {
leaf := k.Certificates[0]
sha1sum := sha1.Sum(leaf.Raw)
sha256sum := sha256.Sum256(leaf.Raw)
if len(k.CertificateThumbprintSHA1) > 0 && !bytes.Equal(sha1sum[:], k.CertificateThumbprintSHA1) {
return errors.New("square/go-jose: invalid JWK, x5c thumbprint does not match x5t value")
}
if len(k.CertificateThumbprintSHA256) > 0 && !bytes.Equal(sha256sum[:], k.CertificateThumbprintSHA256) {
return errors.New("square/go-jose: invalid JWK, x5c thumbprint does not match x5t#S256 value")
}
}
@ -357,11 +509,11 @@ func (key rawJSONWebKey) ecPublicKey() (*ecdsa.PublicKey, error) {
// the curve specified in the "crv" parameter.
// https://tools.ietf.org/html/rfc7518#section-6.2.1.2
if curveSize(curve) != len(key.X.data) {
return nil, fmt.Errorf("square/go-jose: invalid EC private key, wrong length for x")
return nil, fmt.Errorf("square/go-jose: invalid EC public key, wrong length for x")
}
if curveSize(curve) != len(key.Y.data) {
return nil, fmt.Errorf("square/go-jose: invalid EC private key, wrong length for y")
return nil, fmt.Errorf("square/go-jose: invalid EC public key, wrong length for y")
}
x := key.X.bigInt()

View File

@ -17,6 +17,7 @@
package jose
import (
"bytes"
"encoding/base64"
"errors"
"fmt"
@ -75,13 +76,21 @@ type Signature struct {
}
// ParseSigned parses a signed message in compact or full serialization format.
func ParseSigned(input string) (*JSONWebSignature, error) {
input = stripWhitespace(input)
if strings.HasPrefix(input, "{") {
return parseSignedFull(input)
func ParseSigned(signature string) (*JSONWebSignature, error) {
signature = stripWhitespace(signature)
if strings.HasPrefix(signature, "{") {
return parseSignedFull(signature)
}
return parseSignedCompact(input)
return parseSignedCompact(signature, nil)
}
// ParseDetached parses a signed message in compact serialization format with detached payload.
func ParseDetached(signature string, payload []byte) (*JSONWebSignature, error) {
if payload == nil {
return nil, errors.New("square/go-jose: nil payload")
}
return parseSignedCompact(stripWhitespace(signature), payload)
}
// Get a header value
@ -93,20 +102,39 @@ func (sig Signature) mergedHeaders() rawHeader {
}
// Compute data to be signed
func (obj JSONWebSignature) computeAuthData(payload []byte, signature *Signature) []byte {
var serializedProtected string
func (obj JSONWebSignature) computeAuthData(payload []byte, signature *Signature) ([]byte, error) {
var authData bytes.Buffer
protectedHeader := new(rawHeader)
if signature.original != nil && signature.original.Protected != nil {
serializedProtected = signature.original.Protected.base64()
if err := json.Unmarshal(signature.original.Protected.bytes(), protectedHeader); err != nil {
return nil, err
}
authData.WriteString(signature.original.Protected.base64())
} else if signature.protected != nil {
serializedProtected = base64.RawURLEncoding.EncodeToString(mustSerializeJSON(signature.protected))
} else {
serializedProtected = ""
protectedHeader = signature.protected
authData.WriteString(base64.RawURLEncoding.EncodeToString(mustSerializeJSON(protectedHeader)))
}
return []byte(fmt.Sprintf("%s.%s",
serializedProtected,
base64.RawURLEncoding.EncodeToString(payload)))
needsBase64 := true
if protectedHeader != nil {
var err error
if needsBase64, err = protectedHeader.getB64(); err != nil {
needsBase64 = true
}
}
authData.WriteByte('.')
if needsBase64 {
authData.WriteString(base64.RawURLEncoding.EncodeToString(payload))
} else {
authData.Write(payload)
}
return authData.Bytes(), nil
}
// parseSignedFull parses a message in full format.
@ -246,21 +274,27 @@ func (parsed *rawJSONWebSignature) sanitized() (*JSONWebSignature, error) {
}
// parseSignedCompact parses a message in compact format.
func parseSignedCompact(input string) (*JSONWebSignature, error) {
func parseSignedCompact(input string, payload []byte) (*JSONWebSignature, error) {
parts := strings.Split(input, ".")
if len(parts) != 3 {
return nil, fmt.Errorf("square/go-jose: compact JWS format must have three parts")
}
if parts[1] != "" && payload != nil {
return nil, fmt.Errorf("square/go-jose: payload is not detached")
}
rawProtected, err := base64.RawURLEncoding.DecodeString(parts[0])
if err != nil {
return nil, err
}
payload, err := base64.RawURLEncoding.DecodeString(parts[1])
if payload == nil {
payload, err = base64.RawURLEncoding.DecodeString(parts[1])
if err != nil {
return nil, err
}
}
signature, err := base64.RawURLEncoding.DecodeString(parts[2])
if err != nil {
@ -275,19 +309,30 @@ func parseSignedCompact(input string) (*JSONWebSignature, error) {
return raw.sanitized()
}
// CompactSerialize serializes an object using the compact serialization format.
func (obj JSONWebSignature) CompactSerialize() (string, error) {
func (obj JSONWebSignature) compactSerialize(detached bool) (string, error) {
if len(obj.Signatures) != 1 || obj.Signatures[0].header != nil || obj.Signatures[0].protected == nil {
return "", ErrNotSupported
}
serializedProtected := mustSerializeJSON(obj.Signatures[0].protected)
serializedProtected := base64.RawURLEncoding.EncodeToString(mustSerializeJSON(obj.Signatures[0].protected))
payload := ""
signature := base64.RawURLEncoding.EncodeToString(obj.Signatures[0].Signature)
return fmt.Sprintf(
"%s.%s.%s",
base64.RawURLEncoding.EncodeToString(serializedProtected),
base64.RawURLEncoding.EncodeToString(obj.payload),
base64.RawURLEncoding.EncodeToString(obj.Signatures[0].Signature)), nil
if !detached {
payload = base64.RawURLEncoding.EncodeToString(obj.payload)
}
return fmt.Sprintf("%s.%s.%s", serializedProtected, payload, signature), nil
}
// CompactSerialize serializes an object using the compact serialization format.
func (obj JSONWebSignature) CompactSerialize() (string, error) {
return obj.compactSerialize(false)
}
// DetachedCompactSerialize serializes an object using the compact serialization format with detached payload.
func (obj JSONWebSignature) DetachedCompactSerialize() (string, error) {
return obj.compactSerialize(true)
}
// FullSerialize serializes an object using the full JSON serialization format.

View File

@ -81,3 +81,64 @@ type opaqueVerifier struct {
func (o *opaqueVerifier) verifyPayload(payload []byte, signature []byte, alg SignatureAlgorithm) error {
return o.verifier.VerifyPayload(payload, signature, alg)
}
// OpaqueKeyEncrypter is an interface that supports encrypting keys with an opaque key.
type OpaqueKeyEncrypter interface {
// KeyID returns the kid
KeyID() string
// Algs returns a list of supported key encryption algorithms.
Algs() []KeyAlgorithm
// encryptKey encrypts the CEK using the given algorithm.
encryptKey(cek []byte, alg KeyAlgorithm) (recipientInfo, error)
}
type opaqueKeyEncrypter struct {
encrypter OpaqueKeyEncrypter
}
func newOpaqueKeyEncrypter(alg KeyAlgorithm, encrypter OpaqueKeyEncrypter) (recipientKeyInfo, error) {
var algSupported bool
for _, salg := range encrypter.Algs() {
if alg == salg {
algSupported = true
break
}
}
if !algSupported {
return recipientKeyInfo{}, ErrUnsupportedAlgorithm
}
return recipientKeyInfo{
keyID: encrypter.KeyID(),
keyAlg: alg,
keyEncrypter: &opaqueKeyEncrypter{
encrypter: encrypter,
},
}, nil
}
func (oke *opaqueKeyEncrypter) encryptKey(cek []byte, alg KeyAlgorithm) (recipientInfo, error) {
return oke.encrypter.encryptKey(cek, alg)
}
//OpaqueKeyDecrypter is an interface that supports decrypting keys with an opaque key.
type OpaqueKeyDecrypter interface {
DecryptKey(encryptedKey []byte, header Header) ([]byte, error)
}
type opaqueKeyDecrypter struct {
decrypter OpaqueKeyDecrypter
}
func (okd *opaqueKeyDecrypter) decryptKey(headers rawHeader, recipient *recipientInfo, generator keyGenerator) ([]byte, error) {
mergedHeaders := rawHeader{}
mergedHeaders.merge(&headers)
mergedHeaders.merge(recipient.header)
header, err := mergedHeaders.sanitized()
if err != nil {
return nil, err
}
return okd.decrypter.DecryptKey(recipient.encryptedKey, header)
}

View File

@ -153,12 +153,18 @@ const (
headerJWK = "jwk" // *JSONWebKey
headerKeyID = "kid" // string
headerNonce = "nonce" // string
headerB64 = "b64" // bool
headerP2C = "p2c" // *byteBuffer (int)
headerP2S = "p2s" // *byteBuffer ([]byte)
)
// supportedCritical is the set of supported extensions that are understood and processed.
var supportedCritical = map[string]bool{
headerB64: true,
}
// rawHeader represents the JOSE header for JWE/JWS objects (used for parsing).
//
// The decoding of the constituent items is deferred because we want to marshal
@ -349,6 +355,21 @@ func (parsed rawHeader) getP2S() (*byteBuffer, error) {
return parsed.getByteBuffer(headerP2S)
}
// getB64 extracts parsed "b64" from the raw JSON, defaulting to true.
func (parsed rawHeader) getB64() (bool, error) {
v := parsed[headerB64]
if v == nil {
return true, nil
}
var b64 bool
err := json.Unmarshal(*v, &b64)
if err != nil {
return true, err
}
return b64, nil
}
// sanitized produces a cleaned-up header object from the raw JSON.
func (parsed rawHeader) sanitized() (h Header, err error) {
for k, v := range parsed {

View File

@ -17,6 +17,7 @@
package jose
import (
"bytes"
"crypto/ecdsa"
"crypto/rsa"
"encoding/base64"
@ -77,6 +78,27 @@ func (so *SignerOptions) WithType(typ ContentType) *SignerOptions {
return so.WithHeader(HeaderType, typ)
}
// WithCritical adds the given names to the critical ("crit") header and returns
// the updated SignerOptions.
func (so *SignerOptions) WithCritical(names ...string) *SignerOptions {
if so.ExtraHeaders[headerCritical] == nil {
so.WithHeader(headerCritical, make([]string, 0, len(names)))
}
crit := so.ExtraHeaders[headerCritical].([]string)
so.ExtraHeaders[headerCritical] = append(crit, names...)
return so
}
// WithBase64 adds a base64url-encode payload ("b64") header and returns the updated
// SignerOptions. When the "b64" value is "false", the payload is not base64 encoded.
func (so *SignerOptions) WithBase64(b64 bool) *SignerOptions {
if !b64 {
so.WithHeader(headerB64, b64)
so.WithCritical(headerB64)
}
return so
}
type payloadSigner interface {
signPayload(payload []byte, alg SignatureAlgorithm) (Signature, error)
}
@ -233,7 +255,10 @@ func (ctx *genericSigner) Sign(payload []byte) (*JSONWebSignature, error) {
if ctx.embedJWK {
protected[headerJWK] = recipient.publicKey()
} else {
protected[headerKeyID] = recipient.publicKey().KeyID
keyID := recipient.publicKey().KeyID
if keyID != "" {
protected[headerKeyID] = keyID
}
}
}
@ -250,12 +275,26 @@ func (ctx *genericSigner) Sign(payload []byte) (*JSONWebSignature, error) {
}
serializedProtected := mustSerializeJSON(protected)
needsBase64 := true
input := []byte(fmt.Sprintf("%s.%s",
base64.RawURLEncoding.EncodeToString(serializedProtected),
base64.RawURLEncoding.EncodeToString(payload)))
if b64, ok := protected[headerB64]; ok {
if needsBase64, ok = b64.(bool); !ok {
return nil, errors.New("square/go-jose: Invalid b64 header parameter")
}
}
signatureInfo, err := recipient.signer.signPayload(input, recipient.sigAlg)
var input bytes.Buffer
input.WriteString(base64.RawURLEncoding.EncodeToString(serializedProtected))
input.WriteByte('.')
if needsBase64 {
input.WriteString(base64.RawURLEncoding.EncodeToString(payload))
} else {
input.Write(payload)
}
signatureInfo, err := recipient.signer.signPayload(input.Bytes(), recipient.sigAlg)
if err != nil {
return nil, err
}
@ -324,12 +363,18 @@ func (obj JSONWebSignature) DetachedVerify(payload []byte, verificationKey inter
if err != nil {
return err
}
if len(critical) > 0 {
// Unsupported crit header
for _, name := range critical {
if !supportedCritical[name] {
return ErrCryptoFailure
}
}
input, err := obj.computeAuthData(payload, &signature)
if err != nil {
return ErrCryptoFailure
}
input := obj.computeAuthData(payload, &signature)
alg := headers.getSignatureAlgorithm()
err = verifier.verifyPayload(input, signature.Signature, alg)
if err == nil {
@ -366,18 +411,25 @@ func (obj JSONWebSignature) DetachedVerifyMulti(payload []byte, verificationKey
return -1, Signature{}, err
}
outer:
for i, signature := range obj.Signatures {
headers := signature.mergedHeaders()
critical, err := headers.getCritical()
if err != nil {
continue
}
if len(critical) > 0 {
// Unsupported crit header
for _, name := range critical {
if !supportedCritical[name] {
continue outer
}
}
input, err := obj.computeAuthData(payload, &signature)
if err != nil {
continue
}
input := obj.computeAuthData(payload, &signature)
alg := headers.getSignatureAlgorithm()
err = verifier.verifyPayload(input, signature.Signature, alg)
if err == nil {

View File

@ -11,6 +11,7 @@ go:
- "1.11.x"
- "1.12.x"
- "1.13.x"
- "1.14.x"
- "tip"
go_import_path: gopkg.in/yaml.v3

1
vendor/gopkg.in/yaml.v3/apic.go generated vendored
View File

@ -108,6 +108,7 @@ func yaml_emitter_initialize(emitter *yaml_emitter_t) {
raw_buffer: make([]byte, 0, output_raw_buffer_size),
states: make([]yaml_emitter_state_t, 0, initial_stack_size),
events: make([]yaml_event_t, 0, initial_queue_size),
best_width: -1,
}
}

55
vendor/gopkg.in/yaml.v3/decode.go generated vendored
View File

@ -35,6 +35,7 @@ type parser struct {
doc *Node
anchors map[string]*Node
doneInit bool
textless bool
}
func newParser(b []byte) *parser {
@ -108,14 +109,18 @@ func (p *parser) peek() yaml_event_type_t {
func (p *parser) fail() {
var where string
var line int
if p.parser.problem_mark.line != 0 {
if p.parser.context_mark.line != 0 {
line = p.parser.context_mark.line
// Scanner errors don't iterate line before returning error
if p.parser.error == yaml_SCANNER_ERROR {
line++
}
} else if p.parser.problem_mark.line != 0 {
line = p.parser.problem_mark.line
// Scanner errors don't iterate line before returning error
if p.parser.error == yaml_SCANNER_ERROR {
line++
}
} else if p.parser.context_mark.line != 0 {
line = p.parser.context_mark.line
}
if line != 0 {
where = "line " + strconv.Itoa(line) + ": "
@ -169,17 +174,20 @@ func (p *parser) node(kind Kind, defaultTag, tag, value string) *Node {
} else if kind == ScalarNode {
tag, _ = resolve("", value)
}
return &Node{
n := &Node{
Kind: kind,
Tag: tag,
Value: value,
Style: style,
Line: p.event.start_mark.line + 1,
Column: p.event.start_mark.column + 1,
HeadComment: string(p.event.head_comment),
LineComment: string(p.event.line_comment),
FootComment: string(p.event.foot_comment),
}
if !p.textless {
n.Line = p.event.start_mark.line + 1
n.Column = p.event.start_mark.column + 1
n.HeadComment = string(p.event.head_comment)
n.LineComment = string(p.event.line_comment)
n.FootComment = string(p.event.foot_comment)
}
return n
}
func (p *parser) parseChild(parent *Node) *Node {
@ -391,7 +399,7 @@ func (d *decoder) callObsoleteUnmarshaler(n *Node, u obsoleteUnmarshaler) (good
//
// If n holds a null value, prepare returns before doing anything.
func (d *decoder) prepare(n *Node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) {
if n.ShortTag() == nullTag {
if n.ShortTag() == nullTag || n.Kind == 0 && n.IsZero() {
return out, false, false
}
again := true
@ -497,8 +505,13 @@ func (d *decoder) unmarshal(n *Node, out reflect.Value) (good bool) {
good = d.mapping(n, out)
case SequenceNode:
good = d.sequence(n, out)
case 0:
if n.IsZero() {
return d.null(out)
}
fallthrough
default:
panic("internal error: unknown node kind: " + strconv.Itoa(int(n.Kind)))
failf("cannot decode node with unknown kind %d", n.Kind)
}
return good
}
@ -533,6 +546,17 @@ func resetMap(out reflect.Value) {
}
}
func (d *decoder) null(out reflect.Value) bool {
if out.CanAddr() {
switch out.Kind() {
case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice:
out.Set(reflect.Zero(out.Type()))
return true
}
}
return false
}
func (d *decoder) scalar(n *Node, out reflect.Value) bool {
var tag string
var resolved interface{}
@ -550,14 +574,7 @@ func (d *decoder) scalar(n *Node, out reflect.Value) bool {
}
}
if resolved == nil {
if out.CanAddr() {
switch out.Kind() {
case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice:
out.Set(reflect.Zero(out.Type()))
return true
}
}
return false
return d.null(out)
}
if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() {
// We've resolved to exactly the type we want, so use that.

54
vendor/gopkg.in/yaml.v3/emitterc.go generated vendored
View File

@ -235,10 +235,13 @@ func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool
emitter.indent = 0
}
} else if !indentless {
emitter.indent += emitter.best_indent
// [Go] If inside a block sequence item, discount the space taken by the indicator.
if emitter.best_indent > 2 && emitter.states[len(emitter.states)-1] == yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE {
emitter.indent -= 2
// [Go] This was changed so that indentations are more regular.
if emitter.states[len(emitter.states)-1] == yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE {
// The first indent inside a sequence will just skip the "- " indicator.
emitter.indent += 2
} else {
// Everything else aligns to the chosen indentation.
emitter.indent = emitter.best_indent*((emitter.indent+emitter.best_indent)/emitter.best_indent)
}
}
return true
@ -725,16 +728,9 @@ func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_e
// Expect a block item node.
func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
if first {
// [Go] The original logic here would not indent the sequence when inside a mapping.
// In Go we always indent it, but take the sequence indicator out of the indentation.
indentless := emitter.best_indent == 2 && emitter.mapping_context && (emitter.column == 0 || !emitter.indention)
original := emitter.indent
if !yaml_emitter_increase_indent(emitter, false, indentless) {
if !yaml_emitter_increase_indent(emitter, false, false) {
return false
}
if emitter.indent > original+2 {
emitter.indent -= 2
}
}
if event.typ == yaml_SEQUENCE_END_EVENT {
emitter.indent = emitter.indents[len(emitter.indents)-1]
@ -785,6 +781,13 @@ func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_ev
if !yaml_emitter_write_indent(emitter) {
return false
}
if len(emitter.line_comment) > 0 {
// [Go] A line comment was provided for the key. That's unusual as the
// scanner associates line comments with the value. Either way,
// save the line comment and render it appropriately later.
emitter.key_line_comment = emitter.line_comment
emitter.line_comment = nil
}
if yaml_emitter_check_simple_key(emitter) {
emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE)
return yaml_emitter_emit_node(emitter, event, false, false, true, true)
@ -810,6 +813,29 @@ func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_
return false
}
}
if len(emitter.key_line_comment) > 0 {
// [Go] A line comment was previously provided for the key. Handle it before
// the value so the inline comments are placed correctly.
if yaml_emitter_silent_nil_event(emitter, event) && len(emitter.line_comment) == 0 {
// Nothing other than the line comment will be written on the line.
emitter.line_comment = emitter.key_line_comment
emitter.key_line_comment = nil
} else {
// An actual value is coming, so emit the comment line.
emitter.line_comment, emitter.key_line_comment = emitter.key_line_comment, emitter.line_comment
if !yaml_emitter_process_line_comment(emitter) {
return false
}
emitter.line_comment, emitter.key_line_comment = emitter.key_line_comment, emitter.line_comment
// Indent in unless it's a block that will reindent anyway.
if event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || (event.typ != yaml_MAPPING_START_EVENT && event.typ != yaml_SEQUENCE_START_EVENT) {
emitter.indent = emitter.best_indent*((emitter.indent+emitter.best_indent)/emitter.best_indent)
if !yaml_emitter_write_indent(emitter) {
return false
}
}
}
}
emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE)
if !yaml_emitter_emit_node(emitter, event, false, false, true, false) {
return false
@ -823,6 +849,10 @@ func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_
return true
}
func yaml_emitter_silent_nil_event(emitter *yaml_emitter_t, event *yaml_event_t) bool {
return event.typ == yaml_SCALAR_EVENT && event.implicit && !emitter.canonical && len(emitter.scalar_data.value) == 0
}
// Expect a node.
func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t,
root bool, sequence bool, mapping bool, simple_key bool) bool {

25
vendor/gopkg.in/yaml.v3/encode.go generated vendored
View File

@ -119,6 +119,9 @@ func (e *encoder) marshal(tag string, in reflect.Value) {
case *Node:
e.nodev(in)
return
case Node:
e.nodev(in.Addr())
return
case time.Time:
e.timev(tag, in)
return
@ -422,18 +425,23 @@ func (e *encoder) nodev(in reflect.Value) {
}
func (e *encoder) node(node *Node, tail string) {
// Zero nodes behave as nil.
if node.Kind == 0 && node.IsZero() {
e.nilv()
return
}
// If the tag was not explicitly requested, and dropping it won't change the
// implicit tag of the value, don't include it in the presentation.
var tag = node.Tag
var stag = shortTag(tag)
var rtag string
var forceQuoting bool
if tag != "" && node.Style&TaggedStyle == 0 {
if node.Kind == ScalarNode {
if stag == strTag && node.Style&(SingleQuotedStyle|DoubleQuotedStyle|LiteralStyle|FoldedStyle) != 0 {
tag = ""
} else {
rtag, _ = resolve("", node.Value)
rtag, _ := resolve("", node.Value)
if rtag == stag {
tag = ""
} else if stag == strTag {
@ -442,6 +450,7 @@ func (e *encoder) node(node *Node, tail string) {
}
}
} else {
var rtag string
switch node.Kind {
case MappingNode:
rtag = mapTag
@ -471,7 +480,7 @@ func (e *encoder) node(node *Node, tail string) {
if node.Style&FlowStyle != 0 {
style = yaml_FLOW_SEQUENCE_STYLE
}
e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style))
e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style))
e.event.head_comment = []byte(node.HeadComment)
e.emit()
for _, node := range node.Content {
@ -487,7 +496,7 @@ func (e *encoder) node(node *Node, tail string) {
if node.Style&FlowStyle != 0 {
style = yaml_FLOW_MAPPING_STYLE
}
yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style)
yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style)
e.event.tail_comment = []byte(tail)
e.event.head_comment = []byte(node.HeadComment)
e.emit()
@ -528,11 +537,11 @@ func (e *encoder) node(node *Node, tail string) {
case ScalarNode:
value := node.Value
if !utf8.ValidString(value) {
if tag == binaryTag {
if stag == binaryTag {
failf("explicitly tagged !!binary data must be base64-encoded")
}
if tag != "" {
failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag))
if stag != "" {
failf("cannot marshal invalid UTF-8 data as %s", stag)
}
// It can't be encoded directly as YAML so use a binary tag
// and encode it as base64.
@ -557,5 +566,7 @@ func (e *encoder) node(node *Node, tail string) {
}
e.emitScalar(value, node.Anchor, tag, style, []byte(node.HeadComment), []byte(node.LineComment), []byte(node.FootComment), []byte(tail))
default:
failf("cannot encode node with unknown kind %d", node.Kind)
}
}

48
vendor/gopkg.in/yaml.v3/parserc.go generated vendored
View File

@ -648,6 +648,10 @@ func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, i
implicit: implicit,
style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE),
}
if parser.stem_comment != nil {
event.head_comment = parser.stem_comment
parser.stem_comment = nil
}
return true
}
if len(anchor) > 0 || len(tag) > 0 {
@ -694,25 +698,13 @@ func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_e
if token.typ == yaml_BLOCK_ENTRY_TOKEN {
mark := token.end_mark
prior_head := len(parser.head_comment)
prior_head_len := len(parser.head_comment)
skip_token(parser)
yaml_parser_split_stem_comment(parser, prior_head_len)
token = peek_token(parser)
if token == nil {
return false
}
if prior_head > 0 && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN {
// [Go] It's a sequence under a sequence entry, so the former head comment
// is for the list itself, not the first list item under it.
parser.stem_comment = parser.head_comment[:prior_head]
if len(parser.head_comment) == prior_head {
parser.head_comment = nil
} else {
// Copy suffix to prevent very strange bugs if someone ever appends
// further bytes to the prefix in the stem_comment slice above.
parser.head_comment = append([]byte(nil), parser.head_comment[prior_head+1:]...)
}
}
if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN {
parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE)
return yaml_parser_parse_node(parser, event, true, false)
@ -754,7 +746,9 @@ func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *y
if token.typ == yaml_BLOCK_ENTRY_TOKEN {
mark := token.end_mark
prior_head_len := len(parser.head_comment)
skip_token(parser)
yaml_parser_split_stem_comment(parser, prior_head_len)
token = peek_token(parser)
if token == nil {
return false
@ -780,6 +774,32 @@ func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *y
return true
}
// Split stem comment from head comment.
//
// When a sequence or map is found under a sequence entry, the former head comment
// is assigned to the underlying sequence or map as a whole, not the individual
// sequence or map entry as would be expected otherwise. To handle this case the
// previous head comment is moved aside as the stem comment.
func yaml_parser_split_stem_comment(parser *yaml_parser_t, stem_len int) {
if stem_len == 0 {
return
}
token := peek_token(parser)
if token.typ != yaml_BLOCK_SEQUENCE_START_TOKEN && token.typ != yaml_BLOCK_MAPPING_START_TOKEN {
return
}
parser.stem_comment = parser.head_comment[:stem_len]
if len(parser.head_comment) == stem_len {
parser.head_comment = nil
} else {
// Copy suffix to prevent very strange bugs if someone ever appends
// further bytes to the prefix in the stem_comment slice above.
parser.head_comment = append([]byte(nil), parser.head_comment[stem_len+1:]...)
}
}
// Parse the productions:
// block_mapping ::= BLOCK-MAPPING_START
// *******************

17
vendor/gopkg.in/yaml.v3/scannerc.go generated vendored
View File

@ -749,6 +749,11 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) (ok bool) {
if !ok {
return
}
if len(parser.tokens) > 0 && parser.tokens[len(parser.tokens)-1].typ == yaml_BLOCK_ENTRY_TOKEN {
// Sequence indicators alone have no line comments. It becomes
// a head comment for whatever follows.
return
}
if !yaml_parser_scan_line_comment(parser, comment_mark) {
ok = false
return
@ -2856,13 +2861,12 @@ func yaml_parser_scan_line_comment(parser *yaml_parser_t, token_mark yaml_mark_t
return false
}
skip_line(parser)
} else {
if parser.mark.index >= seen {
} else if parser.mark.index >= seen {
if len(text) == 0 {
start_mark = parser.mark
}
text = append(text, parser.buffer[parser.buffer_pos])
}
text = read(parser, text)
} else {
skip(parser)
}
}
@ -2999,10 +3003,9 @@ func yaml_parser_scan_comments(parser *yaml_parser_t, scan_mark yaml_mark_t) boo
return false
}
skip_line(parser)
} else if parser.mark.index >= seen {
text = read(parser, text)
} else {
if parser.mark.index >= seen {
text = append(text, parser.buffer[parser.buffer_pos])
}
skip(parser)
}
}

35
vendor/gopkg.in/yaml.v3/yaml.go generated vendored
View File

@ -89,7 +89,7 @@ func Unmarshal(in []byte, out interface{}) (err error) {
return unmarshal(in, out, false)
}
// A Decorder reads and decodes YAML values from an input stream.
// A Decoder reads and decodes YAML values from an input stream.
type Decoder struct {
parser *parser
knownFields bool
@ -194,7 +194,7 @@ func unmarshal(in []byte, out interface{}, strict bool) (err error) {
// Zero valued structs will be omitted if all their public
// fields are zero, unless they implement an IsZero
// method (see the IsZeroer interface type), in which
// case the field will be included if that method returns true.
// case the field will be excluded if IsZero returns true.
//
// flow Marshal using a flow style (useful for structs,
// sequences and maps).
@ -252,6 +252,24 @@ func (e *Encoder) Encode(v interface{}) (err error) {
return nil
}
// Encode encodes value v and stores its representation in n.
//
// See the documentation for Marshal for details about the
// conversion of Go values into YAML.
func (n *Node) Encode(v interface{}) (err error) {
defer handleErr(&err)
e := newEncoder()
defer e.destroy()
e.marshalDoc("", reflect.ValueOf(v))
e.finish()
p := newParser(e.out)
p.textless = true
defer p.destroy()
doc := p.parse()
*n = *doc.Content[0]
return nil
}
// SetIndent changes the used indentation used when encoding.
func (e *Encoder) SetIndent(spaces int) {
if spaces < 0 {
@ -328,6 +346,12 @@ const (
// and maps, Node is an intermediate representation that allows detailed
// control over the content being decoded or encoded.
//
// It's worth noting that although Node offers access into details such as
// line numbers, colums, and comments, the content when re-encoded will not
// have its original textual representation preserved. An effort is made to
// render the data plesantly, and to preserve comments near the data they
// describe, though.
//
// Values that make use of the Node type interact with the yaml package in the
// same way any other type would do, by encoding and decoding yaml data
// directly or indirectly into them.
@ -391,6 +415,13 @@ type Node struct {
Column int
}
// IsZero returns whether the node has all of its fields unset.
func (n *Node) IsZero() bool {
return n.Kind == 0 && n.Style == 0 && n.Tag == "" && n.Value == "" && n.Anchor == "" && n.Alias == nil && n.Content == nil &&
n.HeadComment == "" && n.LineComment == "" && n.FootComment == "" && n.Line == 0 && n.Column == 0
}
// LongTag returns the long form of the tag that indicates the data type for
// the node. If the Tag field isn't explicitly defined, one will be computed
// based on the node properties.

2
vendor/gopkg.in/yaml.v3/yamlh.go generated vendored
View File

@ -787,6 +787,8 @@ type yaml_emitter_t struct {
foot_comment []byte
tail_comment []byte
key_line_comment []byte
// Dumper stuff
opened bool // If the stream was already opened?

17
vendor/modules.txt vendored
View File

@ -570,7 +570,7 @@ go.opencensus.io/trace/internal
go.opencensus.io/trace/tracestate
# go.uber.org/atomic v1.4.0
go.uber.org/atomic
# golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
# golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
golang.org/x/crypto/blowfish
golang.org/x/crypto/cast5
golang.org/x/crypto/chacha20
@ -602,10 +602,10 @@ golang.org/x/net/http2/hpack
golang.org/x/net/idna
golang.org/x/net/internal/socks
golang.org/x/net/proxy
# golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
# golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/oauth2
golang.org/x/oauth2/internal
# golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
# golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/sync/errgroup
golang.org/x/sync/semaphore
# golang.org/x/sys v0.0.0-20200909081042-eff7692f9009
@ -639,7 +639,7 @@ golang.org/x/time/rate
# golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
golang.org/x/xerrors
golang.org/x/xerrors/internal
# google.golang.org/appengine v1.5.0
# google.golang.org/appengine v1.6.6
google.golang.org/appengine/internal
google.golang.org/appengine/internal/base
google.golang.org/appengine/internal/datastore
@ -655,7 +655,7 @@ google.golang.org/grpc/connectivity
google.golang.org/grpc/grpclog
google.golang.org/grpc/internal
google.golang.org/grpc/status
# google.golang.org/protobuf v1.24.0
# google.golang.org/protobuf v1.25.0
google.golang.org/protobuf/encoding/prototext
google.golang.org/protobuf/encoding/protowire
google.golang.org/protobuf/internal/descfmt
@ -666,12 +666,11 @@ google.golang.org/protobuf/internal/encoding/messageset
google.golang.org/protobuf/internal/encoding/tag
google.golang.org/protobuf/internal/encoding/text
google.golang.org/protobuf/internal/errors
google.golang.org/protobuf/internal/fieldnum
google.golang.org/protobuf/internal/fieldsort
google.golang.org/protobuf/internal/filedesc
google.golang.org/protobuf/internal/filetype
google.golang.org/protobuf/internal/flags
google.golang.org/protobuf/internal/genname
google.golang.org/protobuf/internal/genid
google.golang.org/protobuf/internal/impl
google.golang.org/protobuf/internal/mapsort
google.golang.org/protobuf/internal/pragma
@ -690,7 +689,7 @@ google.golang.org/protobuf/types/known/timestamppb
gopkg.in/fsnotify.v1
# gopkg.in/inf.v0 v0.9.1
gopkg.in/inf.v0
# gopkg.in/square/go-jose.v2 v2.3.1
# gopkg.in/square/go-jose.v2 v2.5.1
gopkg.in/square/go-jose.v2
gopkg.in/square/go-jose.v2/cipher
gopkg.in/square/go-jose.v2/json
@ -698,7 +697,7 @@ gopkg.in/square/go-jose.v2/json
gopkg.in/tomb.v1
# gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v2
# gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
# gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
gopkg.in/yaml.v3
# k8s.io/api v0.0.0-20190620084959-7cf5895f2711
k8s.io/api/apps/v1