Clean up vendoring

This doesn't perform any actual updates. (While that is something that
we should consider eventually, it leads down a rabbit hole and would
be too risky just before the 2.0.0 release.)

This is really just a clean-up. In particular:

- The following packages are not really used and thus removed:
  - github.com/blang/semver
  - github.com/coreos/go-oidc/http
  - github.com/coreos/go-oidc/jose
  - github.com/coreos/go-oidc/key
  - github.com/coreos/go-oidc/oauth2
  - github.com/coreos/go-oidc/oidc
  - github.com/coreos/pkg/health
  - github.com/coreos/pkg/httputil
  - github.com/coreos/pkg/timeutil
  - github.com/gophercloud/gophercloud/openstack/compute/v2/extensions
  - github.com/pborman/uuid

- For unclear reasons, the checksum for the following packages were
  wrong. The only change in this commit is to adjust the checksum in
  vendor.json. No changes of source code involved.
  - github.com/cespare/xxhash
  - github.com/dgryski/go-bits
  - github.com/golang/snappy

- Various packages from the github.com/gogo/protobuf repository are
  used throughout the code. They are vendored from various sources
  (different sub-vendoring of cockroachdb/cockroach and
  k8s.io/client-go) and revisions. I made them all consistently
  referring to the current version of the github.com/gogo/protobuf
  repository. This _is_ a change of code, but a necessary one to clean
  up the inconsistencies.

- For the github.com/influxdata/influxdb/... packages, the license
  files were missing. Also, the revision time was wrong, again for
  unknown reason.

This tries to avoid any real updates (as that would lead down a rabbit
hole, although I think we should check what dependencies need an
update one day) but at least tries to remove unused packages.
This commit is contained in:
beorn7 2017-11-02 17:15:40 +01:00
parent e4167a5ca8
commit 8093122782
19 changed files with 564 additions and 414 deletions

View file

@ -1,7 +1,7 @@
Extensions for Protocol Buffers to create more go like structures. Protocol Buffers for Go with Gadgets
Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. Copyright (c) 2013, The GoGo Authors. All rights reserved.
http://github.com/gogo/protobuf/gogoproto http://github.com/gogo/protobuf
Go support for Protocol Buffers - Google's data interchange format Go support for Protocol Buffers - Google's data interchange format

View file

@ -44,6 +44,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"math"
"reflect" "reflect"
"sort" "sort"
"strconv" "strconv"
@ -71,6 +72,47 @@ type Marshaler struct {
// Whether to use the original (.proto) name for fields. // Whether to use the original (.proto) name for fields.
OrigName bool OrigName bool
// A custom URL resolver to use when marshaling Any messages to JSON.
// If unset, the default resolution strategy is to extract the
// fully-qualified type name from the type URL and pass that to
// proto.MessageType(string).
AnyResolver AnyResolver
}
// AnyResolver takes a type URL, present in an Any message, and resolves it into
// an instance of the associated message.
type AnyResolver interface {
Resolve(typeUrl string) (proto.Message, error)
}
func defaultResolveAny(typeUrl string) (proto.Message, error) {
// Only the part of typeUrl after the last slash is relevant.
mname := typeUrl
if slash := strings.LastIndex(mname, "/"); slash >= 0 {
mname = mname[slash+1:]
}
mt := proto.MessageType(mname)
if mt == nil {
return nil, fmt.Errorf("unknown message type %q", mname)
}
return reflect.New(mt.Elem()).Interface().(proto.Message), nil
}
// JSONPBMarshaler is implemented by protobuf messages that customize the
// way they are marshaled to JSON. Messages that implement this should
// also implement JSONPBUnmarshaler so that the custom format can be
// parsed.
type JSONPBMarshaler interface {
MarshalJSONPB(*Marshaler) ([]byte, error)
}
// JSONPBUnmarshaler is implemented by protobuf messages that customize
// the way they are unmarshaled from JSON. Messages that implement this
// should also implement JSONPBMarshaler so that the custom format can be
// produced.
type JSONPBUnmarshaler interface {
UnmarshalJSONPB(*Unmarshaler, []byte) error
} }
// Marshal marshals a protocol buffer into JSON. // Marshal marshals a protocol buffer into JSON.
@ -90,6 +132,12 @@ func (m *Marshaler) MarshalToString(pb proto.Message) (string, error) {
type int32Slice []int32 type int32Slice []int32
var nonFinite = map[string]float64{
`"NaN"`: math.NaN(),
`"Infinity"`: math.Inf(1),
`"-Infinity"`: math.Inf(-1),
}
// For sorting extensions ids to ensure stable output. // For sorting extensions ids to ensure stable output.
func (s int32Slice) Len() int { return len(s) } func (s int32Slice) Len() int { return len(s) }
func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] }
@ -101,6 +149,31 @@ type isWkt interface {
// marshalObject writes a struct to the Writer. // marshalObject writes a struct to the Writer.
func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeURL string) error { func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeURL string) error {
if jsm, ok := v.(JSONPBMarshaler); ok {
b, err := jsm.MarshalJSONPB(m)
if err != nil {
return err
}
if typeURL != "" {
// we are marshaling this object to an Any type
var js map[string]*json.RawMessage
if err = json.Unmarshal(b, &js); err != nil {
return fmt.Errorf("type %T produced invalid JSON: %v", v, err)
}
turl, err := json.Marshal(typeURL)
if err != nil {
return fmt.Errorf("failed to marshal type URL %q to JSON: %v", typeURL, err)
}
js["@type"] = (*json.RawMessage)(&turl)
if b, err = json.Marshal(js); err != nil {
return err
}
}
out.write(string(b))
return out.err
}
s := reflect.ValueOf(v).Elem() s := reflect.ValueOf(v).Elem()
// Handle well-known types. // Handle well-known types.
@ -127,8 +200,8 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU
out.write(x) out.write(x)
out.write(`s"`) out.write(`s"`)
return out.err return out.err
case "Struct": case "Struct", "ListValue":
// Let marshalValue handle the `fields` map. // Let marshalValue handle the `Struct.fields` map or the `ListValue.values` slice.
// TODO: pass the correct Properties if needed. // TODO: pass the correct Properties if needed.
return m.marshalValue(out, &proto.Properties{}, s.Field(0), indent) return m.marshalValue(out, &proto.Properties{}, s.Field(0), indent)
case "Timestamp": case "Timestamp":
@ -179,9 +252,14 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU
continue continue
} }
//this is not a protobuf field
if valueField.Tag.Get("protobuf") == "" && valueField.Tag.Get("protobuf_oneof") == "" {
continue
}
// IsNil will panic on most value kinds. // IsNil will panic on most value kinds.
switch value.Kind() { switch value.Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: case reflect.Chan, reflect.Func, reflect.Interface:
if value.IsNil() { if value.IsNil() {
continue continue
} }
@ -209,6 +287,10 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU
if value.Len() == 0 { if value.Len() == 0 {
continue continue
} }
case reflect.Map, reflect.Ptr, reflect.Slice:
if value.IsNil() {
continue
}
} }
} }
@ -307,16 +389,17 @@ func (m *Marshaler) marshalAny(out *errWriter, any proto.Message, indent string)
turl := v.Field(0).String() turl := v.Field(0).String()
val := v.Field(1).Bytes() val := v.Field(1).Bytes()
// Only the part of type_url after the last slash is relevant. var msg proto.Message
mname := turl var err error
if slash := strings.LastIndex(mname, "/"); slash >= 0 { if m.AnyResolver != nil {
mname = mname[slash+1:] msg, err = m.AnyResolver.Resolve(turl)
} else {
msg, err = defaultResolveAny(turl)
} }
mt := proto.MessageType(mname) if err != nil {
if mt == nil { return err
return fmt.Errorf("unknown message type %q", mname)
} }
msg := reflect.New(mt.Elem()).Interface().(proto.Message)
if err := proto.Unmarshal(val, msg); err != nil { if err := proto.Unmarshal(val, msg); err != nil {
return err return err
} }
@ -391,6 +474,12 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle
v = reflect.Indirect(v) v = reflect.Indirect(v)
// Handle nil pointer
if v.Kind() == reflect.Invalid {
out.write("null")
return out.err
}
// Handle repeated elements. // Handle repeated elements.
if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 { if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 {
out.write("[") out.write("[")
@ -571,6 +660,24 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle
return out.err return out.err
} }
// Handle non-finite floats, e.g. NaN, Infinity and -Infinity.
if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 {
f := v.Float()
var sval string
switch {
case math.IsInf(f, 1):
sval = `"Infinity"`
case math.IsInf(f, -1):
sval = `"-Infinity"`
case math.IsNaN(f):
sval = `"NaN"`
}
if sval != "" {
out.write(sval)
return out.err
}
}
// Default handling defers to the encoding/json library. // Default handling defers to the encoding/json library.
b, err := json.Marshal(v.Interface()) b, err := json.Marshal(v.Interface())
if err != nil { if err != nil {
@ -593,6 +700,12 @@ type Unmarshaler struct {
// Whether to allow messages to contain unknown fields, as opposed to // Whether to allow messages to contain unknown fields, as opposed to
// failing to unmarshal. // failing to unmarshal.
AllowUnknownFields bool AllowUnknownFields bool
// A custom URL resolver to use when unmarshaling Any messages from JSON.
// If unset, the default resolution strategy is to extract the
// fully-qualified type name from the type URL and pass that to
// proto.MessageType(string).
AnyResolver AnyResolver
} }
// UnmarshalNext unmarshals the next protocol buffer from a JSON object stream. // UnmarshalNext unmarshals the next protocol buffer from a JSON object stream.
@ -642,38 +755,97 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
// Allocate memory for pointer fields. // Allocate memory for pointer fields.
if targetType.Kind() == reflect.Ptr { if targetType.Kind() == reflect.Ptr {
// If input value is "null" and target is a pointer type, then the field should be treated as not set
// UNLESS the target is structpb.Value, in which case it should be set to structpb.NullValue.
_, isJSONPBUnmarshaler := target.Interface().(JSONPBUnmarshaler)
if string(inputValue) == "null" && targetType != reflect.TypeOf(&types.Value{}) && !isJSONPBUnmarshaler {
return nil
}
target.Set(reflect.New(targetType.Elem())) target.Set(reflect.New(targetType.Elem()))
return u.unmarshalValue(target.Elem(), inputValue, prop) return u.unmarshalValue(target.Elem(), inputValue, prop)
} }
// Handle well-known types. if jsu, ok := target.Addr().Interface().(JSONPBUnmarshaler); ok {
if wkt, ok := target.Addr().Interface().(isWkt); ok { return jsu.UnmarshalJSONPB(u, []byte(inputValue))
switch wkt.XXX_WellKnownType() {
case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value",
"Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue":
// "Wrappers use the same representation in JSON
// as the wrapped primitive type, except that null is allowed."
// encoding/json will turn JSON `null` into Go `nil`,
// so we don't have to do any extra work.
return u.unmarshalValue(target.Field(0), inputValue, prop)
case "Any":
return fmt.Errorf("unmarshaling Any not supported yet")
case "Duration":
ivStr := string(inputValue)
if ivStr == "null" {
target.Field(0).SetInt(0)
target.Field(1).SetInt(0)
return nil
} }
unq, err := strconv.Unquote(ivStr) // Handle well-known types that are not pointers.
if w, ok := target.Addr().Interface().(isWkt); ok {
switch w.XXX_WellKnownType() {
case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value",
"Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue":
return u.unmarshalValue(target.Field(0), inputValue, prop)
case "Any":
// Use json.RawMessage pointer type instead of value to support pre-1.8 version.
// 1.8 changed RawMessage.MarshalJSON from pointer type to value type, see
// https://github.com/golang/go/issues/14493
var jsonFields map[string]*json.RawMessage
if err := json.Unmarshal(inputValue, &jsonFields); err != nil {
return err
}
val, ok := jsonFields["@type"]
if !ok || val == nil {
return errors.New("Any JSON doesn't have '@type'")
}
var turl string
if err := json.Unmarshal([]byte(*val), &turl); err != nil {
return fmt.Errorf("can't unmarshal Any's '@type': %q", *val)
}
target.Field(0).SetString(turl)
var m proto.Message
var err error
if u.AnyResolver != nil {
m, err = u.AnyResolver.Resolve(turl)
} else {
m, err = defaultResolveAny(turl)
}
if err != nil { if err != nil {
return err return err
} }
if _, ok := m.(isWkt); ok {
val, ok := jsonFields["value"]
if !ok {
return errors.New("Any JSON doesn't have 'value'")
}
if err = u.unmarshalValue(reflect.ValueOf(m).Elem(), *val, nil); err != nil {
return fmt.Errorf("can't unmarshal Any nested proto %T: %v", m, err)
}
} else {
delete(jsonFields, "@type")
nestedProto, uerr := json.Marshal(jsonFields)
if uerr != nil {
return fmt.Errorf("can't generate JSON for Any's nested proto to be unmarshaled: %v", uerr)
}
if err = u.unmarshalValue(reflect.ValueOf(m).Elem(), nestedProto, nil); err != nil {
return fmt.Errorf("can't unmarshal Any nested proto %T: %v", m, err)
}
}
b, err := proto.Marshal(m)
if err != nil {
return fmt.Errorf("can't marshal proto %T into Any.Value: %v", m, err)
}
target.Field(1).SetBytes(b)
return nil
case "Duration":
unq, err := strconv.Unquote(string(inputValue))
if err != nil {
return err
}
d, err := time.ParseDuration(unq) d, err := time.ParseDuration(unq)
if err != nil { if err != nil {
return fmt.Errorf("bad Duration: %v", err) return fmt.Errorf("bad Duration: %v", err)
} }
ns := d.Nanoseconds() ns := d.Nanoseconds()
s := ns / 1e9 s := ns / 1e9
ns %= 1e9 ns %= 1e9
@ -681,24 +853,68 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
target.Field(1).SetInt(ns) target.Field(1).SetInt(ns)
return nil return nil
case "Timestamp": case "Timestamp":
ivStr := string(inputValue) unq, err := strconv.Unquote(string(inputValue))
if ivStr == "null" {
target.Field(0).SetInt(0)
target.Field(1).SetInt(0)
return nil
}
unq, err := strconv.Unquote(ivStr)
if err != nil { if err != nil {
return err return err
} }
t, err := time.Parse(time.RFC3339Nano, unq) t, err := time.Parse(time.RFC3339Nano, unq)
if err != nil { if err != nil {
return fmt.Errorf("bad Timestamp: %v", err) return fmt.Errorf("bad Timestamp: %v", err)
} }
target.Field(0).SetInt(int64(t.Unix()))
target.Field(0).SetInt(t.Unix())
target.Field(1).SetInt(int64(t.Nanosecond())) target.Field(1).SetInt(int64(t.Nanosecond()))
return nil return nil
case "Struct":
var m map[string]json.RawMessage
if err := json.Unmarshal(inputValue, &m); err != nil {
return fmt.Errorf("bad StructValue: %v", err)
}
target.Field(0).Set(reflect.ValueOf(map[string]*types.Value{}))
for k, jv := range m {
pv := &types.Value{}
if err := u.unmarshalValue(reflect.ValueOf(pv).Elem(), jv, prop); err != nil {
return fmt.Errorf("bad value in StructValue for key %q: %v", k, err)
}
target.Field(0).SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(pv))
}
return nil
case "ListValue":
var s []json.RawMessage
if err := json.Unmarshal(inputValue, &s); err != nil {
return fmt.Errorf("bad ListValue: %v", err)
}
target.Field(0).Set(reflect.ValueOf(make([]*types.Value, len(s), len(s))))
for i, sv := range s {
if err := u.unmarshalValue(target.Field(0).Index(i), sv, prop); err != nil {
return err
}
}
return nil
case "Value":
ivStr := string(inputValue)
if ivStr == "null" {
target.Field(0).Set(reflect.ValueOf(&types.Value_NullValue{}))
} else if v, err := strconv.ParseFloat(ivStr, 0); err == nil {
target.Field(0).Set(reflect.ValueOf(&types.Value_NumberValue{NumberValue: v}))
} else if v, err := strconv.Unquote(ivStr); err == nil {
target.Field(0).Set(reflect.ValueOf(&types.Value_StringValue{StringValue: v}))
} else if v, err := strconv.ParseBool(ivStr); err == nil {
target.Field(0).Set(reflect.ValueOf(&types.Value_BoolValue{BoolValue: v}))
} else if err := json.Unmarshal(inputValue, &[]json.RawMessage{}); err == nil {
lv := &types.ListValue{}
target.Field(0).Set(reflect.ValueOf(&types.Value_ListValue{ListValue: lv}))
return u.unmarshalValue(reflect.ValueOf(lv).Elem(), inputValue, prop)
} else if err := json.Unmarshal(inputValue, &map[string]json.RawMessage{}); err == nil {
sv := &types.Struct{}
target.Field(0).Set(reflect.ValueOf(&types.Value_StructValue{StructValue: sv}))
return u.unmarshalValue(reflect.ValueOf(sv).Elem(), inputValue, prop)
} else {
return fmt.Errorf("unrecognized type for Value %q", ivStr)
}
return nil
} }
} }
@ -751,7 +967,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
// Handle nested messages. // Handle nested messages.
if targetType.Kind() == reflect.Struct { if targetType.Kind() == reflect.Struct {
if target.CanAddr() { if prop != nil && len(prop.CustomType) > 0 && target.CanAddr() {
if m, ok := target.Addr().Interface().(interface { if m, ok := target.Addr().Interface().(interface {
UnmarshalJSON([]byte) error UnmarshalJSON([]byte) error
}); ok { }); ok {
@ -815,6 +1031,26 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
} }
} }
} }
// Handle proto2 extensions.
if len(jsonFields) > 0 {
if ep, ok := target.Addr().Interface().(proto.Message); ok {
for _, ext := range proto.RegisteredExtensions(ep) {
name := fmt.Sprintf("[%s]", ext.Name)
raw, ok := jsonFields[name]
if !ok {
continue
}
delete(jsonFields, name)
nv := reflect.New(reflect.TypeOf(ext.ExtensionType).Elem())
if err := u.unmarshalValue(nv.Elem(), raw, nil); err != nil {
return err
}
if err := proto.SetExtension(ep, ext, nv.Interface()); err != nil {
return err
}
}
}
}
if !u.AllowUnknownFields && len(jsonFields) > 0 { if !u.AllowUnknownFields && len(jsonFields) > 0 {
// Pick any field to be the scapegoat. // Pick any field to be the scapegoat.
var f string var f string
@ -858,13 +1094,15 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
if err := json.Unmarshal(inputValue, &slc); err != nil { if err := json.Unmarshal(inputValue, &slc); err != nil {
return err return err
} }
len := len(slc) if slc != nil {
target.Set(reflect.MakeSlice(targetType, len, len)) l := len(slc)
for i := 0; i < len; i++ { target.Set(reflect.MakeSlice(targetType, l, l))
for i := 0; i < l; i++ {
if err := u.unmarshalValue(target.Index(i), slc[i], prop); err != nil { if err := u.unmarshalValue(target.Index(i), slc[i], prop); err != nil {
return err return err
} }
} }
}
return nil return nil
} }
@ -874,6 +1112,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
if err := json.Unmarshal(inputValue, &mp); err != nil { if err := json.Unmarshal(inputValue, &mp); err != nil {
return err return err
} }
if mp != nil {
target.Set(reflect.MakeMap(targetType)) target.Set(reflect.MakeMap(targetType))
var keyprop, valprop *proto.Properties var keyprop, valprop *proto.Properties
if prop != nil { if prop != nil {
@ -906,6 +1145,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
} }
target.SetMapIndex(k, v) target.SetMapIndex(k, v)
} }
}
return nil return nil
} }
@ -916,6 +1156,15 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
inputValue = inputValue[1 : len(inputValue)-1] inputValue = inputValue[1 : len(inputValue)-1]
} }
// Non-finite numbers can be encoded as strings.
isFloat := targetType.Kind() == reflect.Float32 || targetType.Kind() == reflect.Float64
if isFloat {
if num, ok := nonFinite[string(inputValue)]; ok {
target.SetFloat(num)
return nil
}
}
// Use the encoding/json for parsing other value types. // Use the encoding/json for parsing other value types.
return json.Unmarshal(inputValue, target.Addr().Interface()) return json.Unmarshal(inputValue, target.Addr().Interface())
} }

View file

@ -174,11 +174,11 @@ func sizeFixed32(x uint64) int {
// This is the format used for the sint64 protocol buffer type. // This is the format used for the sint64 protocol buffer type.
func (p *Buffer) EncodeZigzag64(x uint64) error { func (p *Buffer) EncodeZigzag64(x uint64) error {
// use signed number to get arithmetic right shift. // use signed number to get arithmetic right shift.
return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) return p.EncodeVarint((x << 1) ^ uint64((int64(x) >> 63)))
} }
func sizeZigzag64(x uint64) int { func sizeZigzag64(x uint64) int {
return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) return sizeVarint((x << 1) ^ uint64((int64(x) >> 63)))
} }
// EncodeZigzag32 writes a zigzag-encoded 32-bit integer // EncodeZigzag32 writes a zigzag-encoded 32-bit integer

View file

@ -73,7 +73,6 @@ for a protocol buffer variable v:
When the .proto file specifies `syntax="proto3"`, there are some differences: When the .proto file specifies `syntax="proto3"`, there are some differences:
- Non-repeated fields of non-message type are values instead of pointers. - Non-repeated fields of non-message type are values instead of pointers.
- Getters are only generated for message and oneof fields.
- Enum types do not get an Enum method. - Enum types do not get an Enum method.
The simplest way to describe this is to see an example. The simplest way to describe this is to see an example.

View file

@ -193,6 +193,7 @@ type Properties struct {
Default string // default value Default string // default value
HasDefault bool // whether an explicit default was provided HasDefault bool // whether an explicit default was provided
CustomType string CustomType string
CastType string
StdTime bool StdTime bool
StdDuration bool StdDuration bool
@ -341,6 +342,8 @@ func (p *Properties) Parse(s string) {
p.OrigName = strings.Split(f, "=")[1] p.OrigName = strings.Split(f, "=")[1]
case strings.HasPrefix(f, "customtype="): case strings.HasPrefix(f, "customtype="):
p.CustomType = strings.Split(f, "=")[1] p.CustomType = strings.Split(f, "=")[1]
case strings.HasPrefix(f, "casttype="):
p.CastType = strings.Split(f, "=")[1]
case f == "stdtime": case f == "stdtime":
p.StdTime = true p.StdTime = true
case f == "stdduration": case f == "stdduration":

View file

@ -522,6 +522,17 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
} }
return nil return nil
} }
} else if len(props.CastType) > 0 {
if _, ok := v.Interface().(interface {
String() string
}); ok {
switch v.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
_, err := fmt.Fprintf(w, "%d", v.Interface())
return err
}
}
} else if props.StdTime { } else if props.StdTime {
t, ok := v.Interface().(time.Time) t, ok := v.Interface().(time.Time)
if !ok { if !ok {
@ -531,9 +542,9 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
if err != nil { if err != nil {
return err return err
} }
props.StdTime = false propsCopy := *props // Make a copy so that this is goroutine-safe
err = tm.writeAny(w, reflect.ValueOf(tproto), props) propsCopy.StdTime = false
props.StdTime = true err = tm.writeAny(w, reflect.ValueOf(tproto), &propsCopy)
return err return err
} else if props.StdDuration { } else if props.StdDuration {
d, ok := v.Interface().(time.Duration) d, ok := v.Interface().(time.Duration)
@ -541,9 +552,9 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
return fmt.Errorf("stdtime is not time.Duration, but %T", v.Interface()) return fmt.Errorf("stdtime is not time.Duration, but %T", v.Interface())
} }
dproto := durationProto(d) dproto := durationProto(d)
props.StdDuration = false propsCopy := *props // Make a copy so that this is goroutine-safe
err := tm.writeAny(w, reflect.ValueOf(dproto), props) propsCopy.StdDuration = false
props.StdDuration = true err := tm.writeAny(w, reflect.ValueOf(dproto), &propsCopy)
return err return err
} }
} }

View file

@ -983,7 +983,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
return p.readStruct(fv, terminator) return p.readStruct(fv, terminator)
case reflect.Uint32: case reflect.Uint32:
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
fv.SetUint(uint64(x)) fv.SetUint(x)
return nil return nil
} }
case reflect.Uint64: case reflect.Uint64:

View file

@ -50,6 +50,9 @@ const googleApis = "type.googleapis.com/"
// function. AnyMessageName is provided for less common use cases like filtering a // function. AnyMessageName is provided for less common use cases like filtering a
// sequence of Any messages based on a set of allowed message type names. // sequence of Any messages based on a set of allowed message type names.
func AnyMessageName(any *Any) (string, error) { func AnyMessageName(any *Any) (string, error) {
if any == nil {
return "", fmt.Errorf("message is nil")
}
slash := strings.LastIndex(any.TypeUrl, "/") slash := strings.LastIndex(any.TypeUrl, "/")
if slash < 0 { if slash < 0 {
return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl) return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl)

View file

@ -1,6 +1,5 @@
// Code generated by protoc-gen-gogo. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: any.proto // source: any.proto
// DO NOT EDIT!
/* /*
Package types is a generated protocol buffer package. Package types is a generated protocol buffer package.
@ -70,6 +69,16 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// any.Unpack(foo) // any.Unpack(foo)
// ... // ...
// //
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }
//
// The pack methods provided by protobuf library will by default use // The pack methods provided by protobuf library will by default use
// 'type.googleapis.com/full.type.name' as the type URL and the unpack // 'type.googleapis.com/full.type.name' as the type URL and the unpack
// methods only use the fully qualified type name after the last '/' // methods only use the fully qualified type name after the last '/'
@ -273,24 +282,6 @@ func (m *Any) MarshalTo(dAtA []byte) (int, error) {
return i, nil return i, nil
} }
func encodeFixed64Any(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
dAtA[offset+4] = uint8(v >> 32)
dAtA[offset+5] = uint8(v >> 40)
dAtA[offset+6] = uint8(v >> 48)
dAtA[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Any(dAtA []byte, offset int, v uint32) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintAny(dAtA []byte, offset int, v uint64) int { func encodeVarintAny(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)

View file

@ -1,6 +1,5 @@
// Code generated by protoc-gen-gogo. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: duration.proto // source: duration.proto
// DO NOT EDIT!
/* /*
Package types is a generated protocol buffer package. Package types is a generated protocol buffer package.
@ -40,6 +39,8 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// two Timestamp values is a Duration and it can be added or subtracted // two Timestamp values is a Duration and it can be added or subtracted
// from a Timestamp. Range is approximately +-10,000 years. // from a Timestamp. Range is approximately +-10,000 years.
// //
// # Examples
//
// Example 1: Compute Duration from two Timestamps in pseudo code. // Example 1: Compute Duration from two Timestamps in pseudo code.
// //
// Timestamp start = ...; // Timestamp start = ...;
@ -80,10 +81,21 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// duration = Duration() // duration = Duration()
// duration.FromTimedelta(td) // duration.FromTimedelta(td)
// //
// # JSON Mapping
//
// In JSON format, the Duration type is encoded as a string rather than an
// object, where the string ends in the suffix "s" (indicating seconds) and
// is preceded by the number of seconds, with nanoseconds expressed as
// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
// microsecond should be expressed in JSON format as "3.000001s".
//
// //
type Duration struct { type Duration struct {
// Signed seconds of the span of time. Must be from -315,576,000,000 // Signed seconds of the span of time. Must be from -315,576,000,000
// to +315,576,000,000 inclusive. // to +315,576,000,000 inclusive. Note: these bounds are computed from:
// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
// Signed fractions of a second at nanosecond resolution of the span // Signed fractions of a second at nanosecond resolution of the span
// of time. Durations less than one second are represented with a 0 // of time. Durations less than one second are represented with a 0
@ -235,24 +247,6 @@ func (m *Duration) MarshalTo(dAtA []byte) (int, error) {
return i, nil return i, nil
} }
func encodeFixed64Duration(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
dAtA[offset+4] = uint8(v >> 32)
dAtA[offset+5] = uint8(v >> 40)
dAtA[offset+6] = uint8(v >> 48)
dAtA[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Duration(dAtA []byte, offset int, v uint32) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintDuration(dAtA []byte, offset int, v uint64) int { func encodeVarintDuration(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)

View file

@ -1,6 +1,5 @@
// Code generated by protoc-gen-gogo. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: empty.proto // source: empty.proto
// DO NOT EDIT!
/* /*
Package types is a generated protocol buffer package. Package types is a generated protocol buffer package.
@ -142,24 +141,6 @@ func (m *Empty) MarshalTo(dAtA []byte) (int, error) {
return i, nil return i, nil
} }
func encodeFixed64Empty(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
dAtA[offset+4] = uint8(v >> 32)
dAtA[offset+5] = uint8(v >> 40)
dAtA[offset+6] = uint8(v >> 48)
dAtA[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Empty(dAtA []byte, offset int, v uint32) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintEmpty(dAtA []byte, offset int, v uint64) int { func encodeVarintEmpty(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)

View file

@ -1,6 +1,5 @@
// Code generated by protoc-gen-gogo. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: field_mask.proto // source: field_mask.proto
// DO NOT EDIT!
/* /*
Package types is a generated protocol buffer package. Package types is a generated protocol buffer package.
@ -380,24 +379,6 @@ func (m *FieldMask) MarshalTo(dAtA []byte) (int, error) {
return i, nil return i, nil
} }
func encodeFixed64FieldMask(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
dAtA[offset+4] = uint8(v >> 32)
dAtA[offset+5] = uint8(v >> 40)
dAtA[offset+6] = uint8(v >> 48)
dAtA[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32FieldMask(dAtA []byte, offset int, v uint32) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintFieldMask(dAtA []byte, offset int, v uint64) int { func encodeVarintFieldMask(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)

View file

@ -1,6 +1,5 @@
// Code generated by protoc-gen-gogo. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: struct.proto // source: struct.proto
// DO NOT EDIT!
/* /*
Package types is a generated protocol buffer package. Package types is a generated protocol buffer package.
@ -25,6 +24,8 @@ import strings "strings"
import reflect "reflect" import reflect "reflect"
import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
import encoding_binary "encoding/binary"
import io "io" import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
@ -828,7 +829,8 @@ func (m *Value_NumberValue) MarshalTo(dAtA []byte) (int, error) {
i := 0 i := 0
dAtA[i] = 0x11 dAtA[i] = 0x11
i++ i++
i = encodeFixed64Struct(dAtA, i, uint64(math.Float64bits(float64(m.NumberValue)))) encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.NumberValue))))
i += 8
return i, nil return i, nil
} }
func (m *Value_StringValue) MarshalTo(dAtA []byte) (int, error) { func (m *Value_StringValue) MarshalTo(dAtA []byte) (int, error) {
@ -909,24 +911,6 @@ func (m *ListValue) MarshalTo(dAtA []byte) (int, error) {
return i, nil return i, nil
} }
func encodeFixed64Struct(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
dAtA[offset+4] = uint8(v >> 32)
dAtA[offset+5] = uint8(v >> 40)
dAtA[offset+6] = uint8(v >> 48)
dAtA[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Struct(dAtA []byte, offset int, v uint32) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintStruct(dAtA []byte, offset int, v uint64) int { func encodeVarintStruct(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)
@ -1350,7 +1334,14 @@ func (m *Struct) Unmarshal(dAtA []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
var keykey uint64 if m.Fields == nil {
m.Fields = make(map[string]*Value)
}
var mapkey string
var mapvalue *Value
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
if shift >= 64 { if shift >= 64 {
return ErrIntOverflowStruct return ErrIntOverflowStruct
@ -1360,11 +1351,13 @@ func (m *Struct) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
keykey |= (uint64(b) & 0x7F) << shift wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
} }
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
var stringLenmapkey uint64 var stringLenmapkey uint64
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
if shift >= 64 { if shift >= 64 {
@ -1388,27 +1381,9 @@ func (m *Struct) Unmarshal(dAtA []byte) error {
if postStringIndexmapkey > l { if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
mapkey := string(dAtA[iNdEx:postStringIndexmapkey]) mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
iNdEx = postStringIndexmapkey iNdEx = postStringIndexmapkey
if m.Fields == nil { } else if fieldNum == 2 {
m.Fields = make(map[string]*Value)
}
if iNdEx < postIndex {
var valuekey uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowStruct
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
valuekey |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
var mapmsglen int var mapmsglen int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
if shift >= 64 { if shift >= 64 {
@ -1434,16 +1409,27 @@ func (m *Struct) Unmarshal(dAtA []byte) error {
if postmsgIndex > l { if postmsgIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
mapvalue := &Value{} mapvalue = &Value{}
if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil {
return err return err
} }
iNdEx = postmsgIndex iNdEx = postmsgIndex
m.Fields[mapkey] = mapvalue
} else { } else {
var mapvalue *Value iNdEx = entryPreIndex
m.Fields[mapkey] = mapvalue skippy, err := skipStruct(dAtA[iNdEx:])
if err != nil {
return err
} }
if skippy < 0 {
return ErrInvalidLengthStruct
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.Fields[mapkey] = mapvalue
iNdEx = postIndex iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex
@ -1523,15 +1509,8 @@ func (m *Value) Unmarshal(dAtA []byte) error {
if (iNdEx + 8) > l { if (iNdEx + 8) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:]))
iNdEx += 8 iNdEx += 8
v = uint64(dAtA[iNdEx-8])
v |= uint64(dAtA[iNdEx-7]) << 8
v |= uint64(dAtA[iNdEx-6]) << 16
v |= uint64(dAtA[iNdEx-5]) << 24
v |= uint64(dAtA[iNdEx-4]) << 32
v |= uint64(dAtA[iNdEx-3]) << 40
v |= uint64(dAtA[iNdEx-2]) << 48
v |= uint64(dAtA[iNdEx-1]) << 56
m.Kind = &Value_NumberValue{float64(math.Float64frombits(v))} m.Kind = &Value_NumberValue{float64(math.Float64frombits(v))}
case 3: case 3:
if wireType != 2 { if wireType != 2 {

View file

@ -97,6 +97,15 @@ func TimestampFromProto(ts *Timestamp) (time.Time, error) {
return t, validateTimestamp(ts) return t, validateTimestamp(ts)
} }
// TimestampNow returns a google.protobuf.Timestamp for the current time.
func TimestampNow() *Timestamp {
ts, err := TimestampProto(time.Now())
if err != nil {
panic("ptypes: time.Now() out of Timestamp range")
}
return ts
}
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. // TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
// It returns an error if the resulting Timestamp is invalid. // It returns an error if the resulting Timestamp is invalid.
func TimestampProto(t time.Time) (*Timestamp, error) { func TimestampProto(t time.Time) (*Timestamp, error) {

View file

@ -1,6 +1,5 @@
// Code generated by protoc-gen-gogo. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: timestamp.proto // source: timestamp.proto
// DO NOT EDIT!
/* /*
Package types is a generated protocol buffer package. Package types is a generated protocol buffer package.
@ -45,6 +44,8 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// and from RFC 3339 date strings. // and from RFC 3339 date strings.
// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
// //
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`. // Example 1: Compute Timestamp from POSIX `time()`.
// //
// Timestamp timestamp; // Timestamp timestamp;
@ -85,6 +86,29 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
// timestamp = Timestamp() // timestamp = Timestamp()
// timestamp.GetCurrentTime() // timestamp.GetCurrentTime()
// //
// # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
// where {year} is always expressed using four digits while {month}, {day},
// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
// is required, though only UTC (as indicated by "Z") is presently supported.
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
// 01:30 UTC on January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the
// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
// method. In Python, a standard `datetime.datetime` object can be converted
// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
// to obtain a formatter capable of generating timestamps in this format.
//
// //
type Timestamp struct { type Timestamp struct {
// Represents seconds of UTC time since Unix epoch // Represents seconds of UTC time since Unix epoch
@ -239,24 +263,6 @@ func (m *Timestamp) MarshalTo(dAtA []byte) (int, error) {
return i, nil return i, nil
} }
func encodeFixed64Timestamp(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
dAtA[offset+4] = uint8(v >> 32)
dAtA[offset+5] = uint8(v >> 40)
dAtA[offset+6] = uint8(v >> 48)
dAtA[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Timestamp(dAtA []byte, offset int, v uint32) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintTimestamp(dAtA []byte, offset int, v uint64) int { func encodeVarintTimestamp(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)

View file

@ -1,6 +1,5 @@
// Code generated by protoc-gen-gogo. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: wrappers.proto // source: wrappers.proto
// DO NOT EDIT!
/* /*
Package types is a generated protocol buffer package. Package types is a generated protocol buffer package.
@ -30,6 +29,8 @@ import bytes "bytes"
import strings "strings" import strings "strings"
import reflect "reflect" import reflect "reflect"
import encoding_binary "encoding/binary"
import io "io" import io "io"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
@ -914,7 +915,8 @@ func (m *DoubleValue) MarshalTo(dAtA []byte) (int, error) {
if m.Value != 0 { if m.Value != 0 {
dAtA[i] = 0x9 dAtA[i] = 0x9
i++ i++
i = encodeFixed64Wrappers(dAtA, i, uint64(math.Float64bits(float64(m.Value)))) encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value))))
i += 8
} }
return i, nil return i, nil
} }
@ -937,7 +939,8 @@ func (m *FloatValue) MarshalTo(dAtA []byte) (int, error) {
if m.Value != 0 { if m.Value != 0 {
dAtA[i] = 0xd dAtA[i] = 0xd
i++ i++
i = encodeFixed32Wrappers(dAtA, i, uint32(math.Float32bits(float32(m.Value)))) encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Value))))
i += 4
} }
return i, nil return i, nil
} }
@ -1110,24 +1113,6 @@ func (m *BytesValue) MarshalTo(dAtA []byte) (int, error) {
return i, nil return i, nil
} }
func encodeFixed64Wrappers(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
dAtA[offset+4] = uint8(v >> 32)
dAtA[offset+5] = uint8(v >> 40)
dAtA[offset+6] = uint8(v >> 48)
dAtA[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Wrappers(dAtA []byte, offset int, v uint32) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
dAtA[offset+2] = uint8(v >> 16)
dAtA[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintWrappers(dAtA []byte, offset int, v uint64) int { func encodeVarintWrappers(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)
@ -1528,15 +1513,8 @@ func (m *DoubleValue) Unmarshal(dAtA []byte) error {
if (iNdEx + 8) > l { if (iNdEx + 8) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:]))
iNdEx += 8 iNdEx += 8
v = uint64(dAtA[iNdEx-8])
v |= uint64(dAtA[iNdEx-7]) << 8
v |= uint64(dAtA[iNdEx-6]) << 16
v |= uint64(dAtA[iNdEx-5]) << 24
v |= uint64(dAtA[iNdEx-4]) << 32
v |= uint64(dAtA[iNdEx-3]) << 40
v |= uint64(dAtA[iNdEx-2]) << 48
v |= uint64(dAtA[iNdEx-1]) << 56
m.Value = float64(math.Float64frombits(v)) m.Value = float64(math.Float64frombits(v))
default: default:
iNdEx = preIndex iNdEx = preIndex
@ -1596,11 +1574,8 @@ func (m *FloatValue) Unmarshal(dAtA []byte) error {
if (iNdEx + 4) > l { if (iNdEx + 4) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:]))
iNdEx += 4 iNdEx += 4
v = uint32(dAtA[iNdEx-4])
v |= uint32(dAtA[iNdEx-3]) << 8
v |= uint32(dAtA[iNdEx-2]) << 16
v |= uint32(dAtA[iNdEx-1]) << 24
m.Value = float32(math.Float32frombits(v)) m.Value = float32(math.Float32frombits(v))
default: default:
iNdEx = preIndex iNdEx = preIndex

20
vendor/github.com/influxdata/influxdb/LICENSE generated vendored Normal file
View file

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

View file

@ -0,0 +1,25 @@
# List
- bootstrap 3.3.5 [MIT LICENSE](https://github.com/twbs/bootstrap/blob/master/LICENSE)
- collectd.org [ISC LICENSE](https://github.com/collectd/go-collectd/blob/master/LICENSE)
- github.com/BurntSushi/toml [WTFPL LICENSE](https://github.com/BurntSushi/toml/blob/master/COPYING)
- github.com/bmizerany/pat [MIT LICENSE](https://github.com/bmizerany/pat#license)
- github.com/boltdb/bolt [MIT LICENSE](https://github.com/boltdb/bolt/blob/master/LICENSE)
- github.com/cespare/xxhash [MIT LICENSE](https://github.com/cespare/xxhash/blob/master/LICENSE.txt)
- github.com/davecgh/go-spew/spew [ISC LICENSE](https://github.com/davecgh/go-spew/blob/master/LICENSE)
- github.com/dgrijalva/jwt-go [MIT LICENSE](https://github.com/dgrijalva/jwt-go/blob/master/LICENSE)
- github.com/dgryski/go-bits [MIT LICENSE](https://github.com/dgryski/go-bits/blob/master/LICENSE)
- github.com/dgryski/go-bitstream [MIT LICENSE](https://github.com/dgryski/go-bitstream/blob/master/LICENSE)
- github.com/gogo/protobuf/proto [BSD LICENSE](https://github.com/gogo/protobuf/blob/master/LICENSE)
- github.com/golang/snappy [BSD LICENSE](https://github.com/golang/snappy/blob/master/LICENSE)
- github.com/influxdata/usage-client [MIT LICENSE](https://github.com/influxdata/usage-client/blob/master/LICENSE.txt)
- github.com/jwilder/encoding [MIT LICENSE](https://github.com/jwilder/encoding/blob/master/LICENSE)
- github.com/paulbellamy/ratecounter [MIT LICENSE](https://github.com/paulbellamy/ratecounter/blob/master/LICENSE)
- github.com/peterh/liner [MIT LICENSE](https://github.com/peterh/liner/blob/master/COPYING)
- github.com/rakyll/statik [APACHE LICENSE](https://github.com/rakyll/statik/blob/master/LICENSE)
- github.com/retailnext/hllpp [BSD LICENSE](https://github.com/retailnext/hllpp/blob/master/LICENSE)
- github.com/uber-go/atomic [MIT LICENSE](https://github.com/uber-go/atomic/blob/master/LICENSE.txt)
- github.com/uber-go/zap [MIT LICENSE](https://github.com/uber-go/zap/blob/master/LICENSE.txt)
- glyphicons [LICENSE](http://glyphicons.com/license/)
- golang.org/x/crypto [BSD LICENSE](https://github.com/golang/crypto/blob/master/LICENSE)
- jquery 2.1.4 [MIT LICENSE](https://github.com/jquery/jquery/blob/master/LICENSE.txt)
- react 0.13.3 [BSD LICENSE](https://github.com/facebook/react/blob/master/LICENSE)

116
vendor/vendor.json vendored
View file

@ -233,14 +233,7 @@
"revisionTime": "2016-02-29T21:34:45Z" "revisionTime": "2016-02-29T21:34:45Z"
}, },
{ {
"checksumSHA1": "n+s4YwtzpMWW5Rt0dEaQa7NHDGQ=", "checksumSHA1": "KUy1UUky9Gb/HcHArAP5NW6Taho=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/blang/semver",
"path": "github.com/blang/semver",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{
"checksumSHA1": "ki4pYDh/uURZV90biC7in/HIBsc=",
"path": "github.com/cespare/xxhash", "path": "github.com/cespare/xxhash",
"revision": "4a94f899c20bc44d4f5f807cb14529e72aca99d6", "revision": "4a94f899c20bc44d4f5f807cb14529e72aca99d6",
"revisionTime": "2016-11-18T03:48:13Z" "revisionTime": "2016-11-18T03:48:13Z"
@ -269,62 +262,6 @@
"revision": "84bc9597164f671c0130543778228928d6865c5c", "revision": "84bc9597164f671c0130543778228928d6865c5c",
"revisionTime": "2017-06-08T03:40:07Z" "revisionTime": "2017-06-08T03:40:07Z"
}, },
{
"checksumSHA1": "Z2AOGSmDKKvI6nuxa+UPjQWpIeM=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/coreos/go-oidc/http",
"path": "github.com/coreos/go-oidc/http",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{
"checksumSHA1": "8yvt1xKCgNwuuavJdxRnvaIjrIc=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/coreos/go-oidc/jose",
"path": "github.com/coreos/go-oidc/jose",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{
"checksumSHA1": "zhXKrWBSSJLqZxVE/Xsw0M9ynFQ=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/coreos/go-oidc/key",
"path": "github.com/coreos/go-oidc/key",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{
"checksumSHA1": "bkW0mnXvmHQwHprW/6wrbpP7lAk=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/coreos/go-oidc/oauth2",
"path": "github.com/coreos/go-oidc/oauth2",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{
"checksumSHA1": "E1x2k5FdhJ+dzFrh3kCmC6aJfVw=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/coreos/go-oidc/oidc",
"path": "github.com/coreos/go-oidc/oidc",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{
"checksumSHA1": "O0UMBRCOD9ItMayDqLQ2MJEjkVE=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/coreos/pkg/health",
"path": "github.com/coreos/pkg/health",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{
"checksumSHA1": "74vyZz/d49FZXMbFaHOfCGvSLj0=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/coreos/pkg/httputil",
"path": "github.com/coreos/pkg/httputil",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{
"checksumSHA1": "etBdQ0LN6ojGunfvUt6B5C3FNrQ=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/coreos/pkg/timeutil",
"path": "github.com/coreos/pkg/timeutil",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{ {
"checksumSHA1": "SdSd7pyjONWWTHc5XE3AhglLo34=", "checksumSHA1": "SdSd7pyjONWWTHc5XE3AhglLo34=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/davecgh/go-spew/spew", "origin": "k8s.io/client-go/1.5/vendor/github.com/davecgh/go-spew/spew",
@ -339,7 +276,7 @@
"revisionTime": "2016-11-01T19:39:35Z" "revisionTime": "2016-11-01T19:39:35Z"
}, },
{ {
"checksumSHA1": "GWTrxdwIeV3M12nwcX9MitYijqs=", "checksumSHA1": "ADZfj+c4ny5T+Y3Mlw77sXaRNHw=",
"path": "github.com/dgryski/go-bits", "path": "github.com/dgryski/go-bits",
"revision": "2ad8d707cc05b1815ce6ff2543bb5e8d8f9298ef", "revision": "2ad8d707cc05b1815ce6ff2543bb5e8d8f9298ef",
"revisionTime": "2016-06-01T07:36:36Z" "revisionTime": "2016-06-01T07:36:36Z"
@ -447,31 +384,28 @@
"versionExact": "v1.5.4" "versionExact": "v1.5.4"
}, },
{ {
"checksumSHA1": "+RHv6D0Db8Yke6G9cxGjEW61viM=", "checksumSHA1": "8UEp6v0Dczw/SlasE0DivB0mAHA=",
"origin": "github.com/cockroachdb/cockroach/vendor/github.com/gogo/protobuf/jsonpb",
"path": "github.com/gogo/protobuf/jsonpb", "path": "github.com/gogo/protobuf/jsonpb",
"revision": "84bc9597164f671c0130543778228928d6865c5c", "revision": "117892bf1866fbaa2318c03e50e40564c8845457",
"revisionTime": "2017-06-08T03:40:07Z" "revisionTime": "2017-10-18T11:19:13Z"
}, },
{ {
"checksumSHA1": "BIyZQL97iG7mzZ2UMR3XpiXbZdc=", "checksumSHA1": "wn2shNJMwRZpvuvkf1s7h0wvqHI=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/gogo/protobuf/proto",
"path": "github.com/gogo/protobuf/proto", "path": "github.com/gogo/protobuf/proto",
"revision": "30433562cfbf487fe1df7cd26c7bab168d2f14d0", "revision": "117892bf1866fbaa2318c03e50e40564c8845457",
"revisionTime": "2017-04-25T17:14:30Z" "revisionTime": "2017-10-18T11:19:13Z"
}, },
{ {
"checksumSHA1": "HPVQZu059/Rfw2bAWM538bVTcUc=", "checksumSHA1": "HPVQZu059/Rfw2bAWM538bVTcUc=",
"path": "github.com/gogo/protobuf/sortkeys", "path": "github.com/gogo/protobuf/sortkeys",
"revision": "30433562cfbf487fe1df7cd26c7bab168d2f14d0", "revision": "117892bf1866fbaa2318c03e50e40564c8845457",
"revisionTime": "2017-04-25T17:14:30Z" "revisionTime": "2017-10-18T11:19:13Z"
}, },
{ {
"checksumSHA1": "b1p91yJ1mx+abXDUtM5UV3xEiaw=", "checksumSHA1": "i5bzLJhJ7qoUaiFg95y9bfgyZv0=",
"origin": "github.com/cockroachdb/cockroach/vendor/github.com/gogo/protobuf/types",
"path": "github.com/gogo/protobuf/types", "path": "github.com/gogo/protobuf/types",
"revision": "30433562cfbf487fe1df7cd26c7bab168d2f14d0", "revision": "117892bf1866fbaa2318c03e50e40564c8845457",
"revisionTime": "2017-04-25T17:14:30Z" "revisionTime": "2017-10-18T11:19:13Z"
}, },
{ {
"checksumSHA1": "URsJa4y/sUUw/STmbeYx9EKqaYE=", "checksumSHA1": "URsJa4y/sUUw/STmbeYx9EKqaYE=",
@ -505,7 +439,7 @@
"revisionTime": "2017-06-08T03:40:07Z" "revisionTime": "2017-06-08T03:40:07Z"
}, },
{ {
"checksumSHA1": "2a/SsTUBMKtcM6VtpbdPGO+c6c8=", "checksumSHA1": "W+E/2xXcE1GmJ0Qb784ald0Fn6I=",
"path": "github.com/golang/snappy", "path": "github.com/golang/snappy",
"revision": "d9eb7a3d35ec988b8585d4a0068e462c27d28380", "revision": "d9eb7a3d35ec988b8585d4a0068e462c27d28380",
"revisionTime": "2016-05-29T05:00:41Z" "revisionTime": "2016-05-29T05:00:41Z"
@ -529,12 +463,6 @@
"revision": "caf34a65f60295108141f62929245943bd00f237", "revision": "caf34a65f60295108141f62929245943bd00f237",
"revisionTime": "2017-06-07T03:48:29Z" "revisionTime": "2017-06-07T03:48:29Z"
}, },
{
"checksumSHA1": "4XWDCGMYqipwJymi9xJo9UffD7g=",
"path": "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions",
"revision": "caf34a65f60295108141f62929245943bd00f237",
"revisionTime": "2017-06-07T03:48:29Z"
},
{ {
"checksumSHA1": "e7AW3YDVYJPKUjpqsB4AL9RRlTw=", "checksumSHA1": "e7AW3YDVYJPKUjpqsB4AL9RRlTw=",
"path": "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips", "path": "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips",
@ -650,19 +578,22 @@
"revisionTime": "2016-10-07T00:41:22Z" "revisionTime": "2016-10-07T00:41:22Z"
}, },
{ {
"checksumSHA1": "1kVa89e/yk8L2liYiFuJrNWiXfU=",
"path": "github.com/influxdata/influxdb/client/v2", "path": "github.com/influxdata/influxdb/client/v2",
"revision": "15e594fc09f112cb696c084a20beaca25538a5fa", "revision": "15e594fc09f112cb696c084a20beaca25538a5fa",
"revisionTime": "2017-03-31T16:09:02-05:00" "revisionTime": "2017-03-31T21:09:02Z"
}, },
{ {
"checksumSHA1": "FF7fzjW7yWl/ObniSAlidx2eXUE=",
"path": "github.com/influxdata/influxdb/models", "path": "github.com/influxdata/influxdb/models",
"revision": "15e594fc09f112cb696c084a20beaca25538a5fa", "revision": "15e594fc09f112cb696c084a20beaca25538a5fa",
"revisionTime": "2017-03-31T16:09:02-05:00" "revisionTime": "2017-03-31T21:09:02Z"
}, },
{ {
"checksumSHA1": "H/J/qLqzUONXIecHHKtVZmxJZZA=",
"path": "github.com/influxdata/influxdb/pkg/escape", "path": "github.com/influxdata/influxdb/pkg/escape",
"revision": "15e594fc09f112cb696c084a20beaca25538a5fa", "revision": "15e594fc09f112cb696c084a20beaca25538a5fa",
"revisionTime": "2017-03-31T16:09:02-05:00" "revisionTime": "2017-03-31T21:09:02Z"
}, },
{ {
"checksumSHA1": "0ZrwvB6KoGPj2PoDNSEJwxQ6Mog=", "checksumSHA1": "0ZrwvB6KoGPj2PoDNSEJwxQ6Mog=",
@ -764,13 +695,6 @@
"revision": "6edb48674bd9467b8e91fda004f2bd7202d60ce4", "revision": "6edb48674bd9467b8e91fda004f2bd7202d60ce4",
"revisionTime": "2017-02-06T22:16:52Z" "revisionTime": "2017-02-06T22:16:52Z"
}, },
{
"checksumSHA1": "3YJklSuzSE1Rt8A+2dhiWSmf/fw=",
"origin": "k8s.io/client-go/1.5/vendor/github.com/pborman/uuid",
"path": "github.com/pborman/uuid",
"revision": "c589d0c9f0d81640c518354c7bcae77d99820aa3",
"revisionTime": "2016-09-30T00:14:02Z"
},
{ {
"checksumSHA1": "jhWbikPpDRvfqYPOvEbZUXzg7KM=", "checksumSHA1": "jhWbikPpDRvfqYPOvEbZUXzg7KM=",
"origin": "github.com/cockroachdb/cockroach/vendor/github.com/petermattis/goid", "origin": "github.com/cockroachdb/cockroach/vendor/github.com/petermattis/goid",