aboutsummaryrefslogtreecommitdiff
path: root/vendor/google.golang.org
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org')
-rw-r--r--vendor/google.golang.org/api/gensupport/json.go28
-rw-r--r--vendor/google.golang.org/api/internal/settings.go15
-rw-r--r--vendor/google.golang.org/api/iterator/iterator.go231
-rw-r--r--vendor/google.golang.org/api/oauth2/v2/oauth2-gen.go40
-rw-r--r--vendor/google.golang.org/api/option/option.go15
-rw-r--r--vendor/google.golang.org/api/storage/v1/storage-api.json54
-rw-r--r--vendor/google.golang.org/api/storage/v1/storage-gen.go344
-rw-r--r--vendor/google.golang.org/api/transport/dial.go27
-rw-r--r--vendor/google.golang.org/appengine/README.md4
-rw-r--r--vendor/google.golang.org/appengine/internal/api.go28
-rw-r--r--vendor/google.golang.org/cloud/AUTHORS15
-rw-r--r--vendor/google.golang.org/cloud/CONTRIBUTING.md115
-rw-r--r--vendor/google.golang.org/cloud/CONTRIBUTORS31
-rw-r--r--vendor/google.golang.org/cloud/LICENSE202
-rw-r--r--vendor/google.golang.org/cloud/README.md202
-rw-r--r--vendor/google.golang.org/cloud/cloud.go56
-rw-r--r--vendor/google.golang.org/cloud/compute/metadata/metadata.go438
-rw-r--r--vendor/google.golang.org/cloud/internal/cloud.go128
-rw-r--r--vendor/google.golang.org/cloud/internal/transport/dial.go61
-rw-r--r--vendor/google.golang.org/cloud/key.json.encbin1248 -> 0 bytes
-rw-r--r--vendor/google.golang.org/cloud/option.go88
-rw-r--r--vendor/google.golang.org/cloud/storage/acl.go198
-rw-r--r--vendor/google.golang.org/cloud/storage/reader.go55
-rw-r--r--vendor/google.golang.org/cloud/storage/storage.go1204
-rw-r--r--vendor/google.golang.org/cloud/storage/writer.go129
-rw-r--r--vendor/google.golang.org/grpc/balancer.go20
-rw-r--r--vendor/google.golang.org/grpc/clientconn.go61
-rw-r--r--vendor/google.golang.org/grpc/credentials/credentials.go42
-rw-r--r--vendor/google.golang.org/grpc/metadata/metadata.go13
-rw-r--r--vendor/google.golang.org/grpc/server.go13
-rw-r--r--vendor/google.golang.org/grpc/stream.go4
-rw-r--r--vendor/google.golang.org/grpc/transport/http2_client.go27
-rw-r--r--vendor/google.golang.org/grpc/transport/http_util.go5
-rw-r--r--vendor/google.golang.org/grpc/transport/transport.go15
34 files changed, 743 insertions, 3165 deletions
diff --git a/vendor/google.golang.org/api/gensupport/json.go b/vendor/google.golang.org/api/gensupport/json.go
index dd7bcd2..53331b7 100644
--- a/vendor/google.golang.org/api/gensupport/json.go
+++ b/vendor/google.golang.org/api/gensupport/json.go
@@ -12,13 +12,13 @@ import (
)
// MarshalJSON returns a JSON encoding of schema containing only selected fields.
-// A field is selected if:
-// * it has a non-empty value, or
-// * its field name is present in forceSendFields, and
-// * it is not a nil pointer or nil interface.
+// A field is selected if any of the following is true:
+// * it has a non-empty value
+// * its field name is present in forceSendFields and it is not a nil pointer or nil interface
+// * its field name is present in nullFields.
// The JSON key for each selected field is taken from the field's json: struct tag.
-func MarshalJSON(schema interface{}, forceSendFields []string) ([]byte, error) {
- if len(forceSendFields) == 0 {
+func MarshalJSON(schema interface{}, forceSendFields, nullFields []string) ([]byte, error) {
+ if len(forceSendFields) == 0 && len(nullFields) == 0 {
return json.Marshal(schema)
}
@@ -26,15 +26,19 @@ func MarshalJSON(schema interface{}, forceSendFields []string) ([]byte, error) {
for _, f := range forceSendFields {
mustInclude[f] = struct{}{}
}
+ useNull := make(map[string]struct{})
+ for _, f := range nullFields {
+ useNull[f] = struct{}{}
+ }
- dataMap, err := schemaToMap(schema, mustInclude)
+ dataMap, err := schemaToMap(schema, mustInclude, useNull)
if err != nil {
return nil, err
}
return json.Marshal(dataMap)
}
-func schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[string]interface{}, error) {
+func schemaToMap(schema interface{}, mustInclude, useNull map[string]struct{}) (map[string]interface{}, error) {
m := make(map[string]interface{})
s := reflect.ValueOf(schema)
st := s.Type()
@@ -54,6 +58,14 @@ func schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[strin
v := s.Field(i)
f := st.Field(i)
+
+ if _, ok := useNull[f.Name]; ok {
+ if !isEmptyValue(v) {
+ return nil, fmt.Errorf("field %q in NullFields has non-empty value", f.Name)
+ }
+ m[tag.apiName] = nil
+ continue
+ }
if !includeField(v, f, mustInclude) {
continue
}
diff --git a/vendor/google.golang.org/api/internal/settings.go b/vendor/google.golang.org/api/internal/settings.go
index eb9300c..976280b 100644
--- a/vendor/google.golang.org/api/internal/settings.go
+++ b/vendor/google.golang.org/api/internal/settings.go
@@ -11,11 +11,12 @@ import (
// DialSettings holds information needed to establish a connection with a
// Google API service.
type DialSettings struct {
- Endpoint string
- Scopes []string
- TokenSource oauth2.TokenSource
- UserAgent string
- HTTPClient *http.Client
- GRPCDialOpts []grpc.DialOption
- GRPCConn *grpc.ClientConn
+ Endpoint string
+ Scopes []string
+ ServiceAccountJSONFilename string // if set, TokenSource is ignored.
+ TokenSource oauth2.TokenSource
+ UserAgent string
+ HTTPClient *http.Client
+ GRPCDialOpts []grpc.DialOption
+ GRPCConn *grpc.ClientConn
}
diff --git a/vendor/google.golang.org/api/iterator/iterator.go b/vendor/google.golang.org/api/iterator/iterator.go
new file mode 100644
index 0000000..0640c82
--- /dev/null
+++ b/vendor/google.golang.org/api/iterator/iterator.go
@@ -0,0 +1,231 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package iterator provides support for standard Google API iterators.
+// See https://github.com/GoogleCloudPlatform/gcloud-golang/wiki/Iterator-Guidelines.
+package iterator
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+)
+
+// Done is returned by an iterator's Next method when the iteration is
+// complete; when there are no more items to return.
+var Done = errors.New("no more items in iterator")
+
+// We don't support mixed calls to Next and NextPage because they play
+// with the paging state in incompatible ways.
+var errMixed = errors.New("iterator: Next and NextPage called on same iterator")
+
+// PageInfo contains information about an iterator's paging state.
+type PageInfo struct {
+ // Token is the token used to retrieve the next page of items from the
+ // API. You may set Token immediately after creating an iterator to
+ // begin iteration at a particular point. If Token is the empty string,
+ // the iterator will begin with the first eligible item.
+ //
+ // The result of setting Token after the first call to Next is undefined.
+ //
+ // After the underlying API method is called to retrieve a page of items,
+ // Token is set to the next-page token in the response.
+ Token string
+
+ // MaxSize is the maximum number of items returned by a call to the API.
+ // Set MaxSize as a hint to optimize the buffering behavior of the iterator.
+ // If zero, the page size is determined by the underlying service.
+ //
+ // Use Pager to retrieve a page of a specific, exact size.
+ MaxSize int
+
+ // The error state of the iterator. Manipulated by PageInfo.next and Pager.
+ // This is a latch: it starts as nil, and once set should never change.
+ err error
+
+ // If true, no more calls to fetch should be made. Set to true when fetch
+ // returns an empty page token. The iterator is Done when this is true AND
+ // the buffer is empty.
+ atEnd bool
+
+ // Function that fetches a page from the underlying service. It should pass
+ // the pageSize and pageToken arguments to the service, fill the buffer
+ // with the results from the call, and return the next-page token returned
+ // by the service. The function must not remove any existing items from the
+ // buffer. If the underlying RPC takes an int32 page size, pageSize should
+ // be silently truncated.
+ fetch func(pageSize int, pageToken string) (nextPageToken string, err error)
+
+ // Function that clears the iterator's buffer, returning any currently buffered items.
+ bufLen func() int
+
+ // Function that returns the buffer, after setting the buffer variable to nil.
+ takeBuf func() interface{}
+
+ // Set to true on first call to PageInfo.next or Pager.NextPage. Used to check
+ // for calls to both Next and NextPage with the same iterator.
+ nextCalled, nextPageCalled bool
+}
+
+// NewPageInfo exposes internals for iterator implementations.
+// It is not a stable interface.
+var NewPageInfo = newPageInfo
+
+// If an iterator can support paging, its iterator-creating method should call
+// this (via the NewPageInfo variable above).
+//
+// The fetch, bufLen and takeBuf arguments provide access to the
+// iterator's internal slice of buffered items. They behave as described in
+// PageInfo, above.
+//
+// The return value is the PageInfo.next method bound to the returned PageInfo value.
+// (Returning it avoids exporting PageInfo.next.)
+func newPageInfo(fetch func(int, string) (string, error), bufLen func() int, takeBuf func() interface{}) (*PageInfo, func() error) {
+ pi := &PageInfo{
+ fetch: fetch,
+ bufLen: bufLen,
+ takeBuf: takeBuf,
+ }
+ return pi, pi.next
+}
+
+// Remaining returns the number of items available before the iterator makes another API call.
+func (pi *PageInfo) Remaining() int { return pi.bufLen() }
+
+// next provides support for an iterator's Next function. An iterator's Next
+// should return the error returned by next if non-nil; else it can assume
+// there is at least one item in its buffer, and it should return that item and
+// remove it from the buffer.
+func (pi *PageInfo) next() error {
+ pi.nextCalled = true
+ if pi.err != nil { // Once we get an error, always return it.
+ // TODO(jba): fix so users can retry on transient errors? Probably not worth it.
+ return pi.err
+ }
+ if pi.nextPageCalled {
+ pi.err = errMixed
+ return pi.err
+ }
+ // Loop until we get some items or reach the end.
+ for pi.bufLen() == 0 && !pi.atEnd {
+ if err := pi.fill(pi.MaxSize); err != nil {
+ pi.err = err
+ return pi.err
+ }
+ if pi.Token == "" {
+ pi.atEnd = true
+ }
+ }
+ // Either the buffer is non-empty or pi.atEnd is true (or both).
+ if pi.bufLen() == 0 {
+ // The buffer is empty and pi.atEnd is true, i.e. the service has no
+ // more items.
+ pi.err = Done
+ }
+ return pi.err
+}
+
+// Call the service to fill the buffer, using size and pi.Token. Set pi.Token to the
+// next-page token returned by the call.
+// If fill returns a non-nil error, the buffer will be empty.
+func (pi *PageInfo) fill(size int) error {
+ tok, err := pi.fetch(size, pi.Token)
+ if err != nil {
+ pi.takeBuf() // clear the buffer
+ return err
+ }
+ pi.Token = tok
+ return nil
+}
+
+// Pageable is implemented by iterators that support paging.
+type Pageable interface {
+ // PageInfo returns paging information associated with the iterator.
+ PageInfo() *PageInfo
+}
+
+// Pager supports retrieving iterator items a page at a time.
+type Pager struct {
+ pageInfo *PageInfo
+ pageSize int
+}
+
+// NewPager returns a pager that uses iter. Calls to its NextPage method will
+// obtain exactly pageSize items, unless fewer remain. The pageToken argument
+// indicates where to start the iteration. Pass the empty string to start at
+// the beginning, or pass a token retrieved from a call to Pager.NextPage.
+//
+// If you use an iterator with a Pager, you must not call Next on the iterator.
+func NewPager(iter Pageable, pageSize int, pageToken string) *Pager {
+ p := &Pager{
+ pageInfo: iter.PageInfo(),
+ pageSize: pageSize,
+ }
+ p.pageInfo.Token = pageToken
+ if pageSize <= 0 {
+ p.pageInfo.err = errors.New("iterator: page size must be positive")
+ }
+ return p
+}
+
+// NextPage retrieves a sequence of items from the iterator and appends them
+// to slicep, which must be a pointer to a slice of the iterator's item type.
+// Exactly p.pageSize items will be appended, unless fewer remain.
+//
+// The first return value is the page token to use for the next page of items.
+// If empty, there are no more pages. Aside from checking for the end of the
+// iteration, the returned page token is only needed if the iteration is to be
+// resumed a later time, in another context (possibly another process).
+//
+// The second return value is non-nil if an error occurred. It will never be
+// the special iterator sentinel value Done. To recognize the end of the
+// iteration, compare nextPageToken to the empty string.
+//
+// It is possible for NextPage to return a single zero-length page along with
+// an empty page token when there are no more items in the iteration.
+func (p *Pager) NextPage(slicep interface{}) (nextPageToken string, err error) {
+ p.pageInfo.nextPageCalled = true
+ if p.pageInfo.err != nil {
+ return "", p.pageInfo.err
+ }
+ if p.pageInfo.nextCalled {
+ p.pageInfo.err = errMixed
+ return "", p.pageInfo.err
+ }
+ if p.pageInfo.bufLen() > 0 {
+ return "", errors.New("must call NextPage with an empty buffer")
+ }
+ // The buffer must be empty here, so takeBuf is a no-op. We call it just to get
+ // the buffer's type.
+ wantSliceType := reflect.PtrTo(reflect.ValueOf(p.pageInfo.takeBuf()).Type())
+ if slicep == nil {
+ return "", errors.New("nil passed to Pager.NextPage")
+ }
+ vslicep := reflect.ValueOf(slicep)
+ if vslicep.Type() != wantSliceType {
+ return "", fmt.Errorf("slicep should be of type %s, got %T", wantSliceType, slicep)
+ }
+ for p.pageInfo.bufLen() < p.pageSize {
+ if err := p.pageInfo.fill(p.pageSize - p.pageInfo.bufLen()); err != nil {
+ p.pageInfo.err = err
+ return "", p.pageInfo.err
+ }
+ if p.pageInfo.Token == "" {
+ break
+ }
+ }
+ e := vslicep.Elem()
+ e.Set(reflect.AppendSlice(e, reflect.ValueOf(p.pageInfo.takeBuf())))
+ return p.pageInfo.Token, nil
+}
diff --git a/vendor/google.golang.org/api/oauth2/v2/oauth2-gen.go b/vendor/google.golang.org/api/oauth2/v2/oauth2-gen.go
index 6b18fad..b1a7694 100644
--- a/vendor/google.golang.org/api/oauth2/v2/oauth2-gen.go
+++ b/vendor/google.golang.org/api/oauth2/v2/oauth2-gen.go
@@ -131,12 +131,20 @@ type Jwk struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Keys") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *Jwk) MarshalJSON() ([]byte, error) {
type noMethod Jwk
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type JwkKeys struct {
@@ -159,12 +167,20 @@ type JwkKeys struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Alg") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *JwkKeys) MarshalJSON() ([]byte, error) {
type noMethod JwkKeys
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type Tokeninfo struct {
@@ -212,12 +228,20 @@ type Tokeninfo struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "AccessType") to include in
+ // API requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *Tokeninfo) MarshalJSON() ([]byte, error) {
type noMethod Tokeninfo
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type Userinfoplus struct {
@@ -270,12 +294,20 @@ type Userinfoplus struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Email") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *Userinfoplus) MarshalJSON() ([]byte, error) {
type noMethod Userinfoplus
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// method id "oauth2.getCertForOpenIdConnect":
diff --git a/vendor/google.golang.org/api/option/option.go b/vendor/google.golang.org/api/option/option.go
index 556a6df..b935e6d 100644
--- a/vendor/google.golang.org/api/option/option.go
+++ b/vendor/google.golang.org/api/option/option.go
@@ -26,6 +26,21 @@ func (w withTokenSource) Apply(o *internal.DialSettings) {
o.TokenSource = w.ts
}
+// WithServiceAccountFile returns a ClientOption that uses a Google service
+// account credentials file to authenticate.
+// Use WithTokenSource with a token source created from
+// golang.org/x/oauth2/google.JWTConfigFromJSON
+// if reading the file from disk is not an option.
+func WithServiceAccountFile(filename string) ClientOption {
+ return withServiceAccountFile(filename)
+}
+
+type withServiceAccountFile string
+
+func (w withServiceAccountFile) Apply(o *internal.DialSettings) {
+ o.ServiceAccountJSONFilename = string(w)
+}
+
// WithEndpoint returns a ClientOption that overrides the default endpoint
// to be used for a service.
func WithEndpoint(url string) ClientOption {
diff --git a/vendor/google.golang.org/api/storage/v1/storage-api.json b/vendor/google.golang.org/api/storage/v1/storage-api.json
index 8d9118b..69bdf27 100644
--- a/vendor/google.golang.org/api/storage/v1/storage-api.json
+++ b/vendor/google.golang.org/api/storage/v1/storage-api.json
@@ -1,11 +1,11 @@
{
"kind": "discovery#restDescription",
- "etag": "\"C5oy1hgQsABtYOYIOXWcR3BgYqU/gtcWNCypj7VTDxrk1rvvuniNHZo\"",
+ "etag": "\"C5oy1hgQsABtYOYIOXWcR3BgYqU/HhsBn9wwz5D-d92BzzyinZOo-SY\"",
"discoveryVersion": "v1",
"id": "storage:v1",
"name": "storage",
"version": "v1",
- "revision": "20160802",
+ "revision": "20160923",
"title": "Cloud Storage JSON API",
"description": "Stores and retrieves potentially large, immutable data objects.",
"ownerDomain": "google.com",
@@ -150,15 +150,6 @@
"$ref": "ObjectAccessControl"
}
},
- "encryption": {
- "type": "object",
- "description": "Encryption configuration used by default for newly inserted objects, when no encryption config is specified.",
- "properties": {
- "default_kms_key_name": {
- "type": "string"
- }
- }
- },
"etag": {
"type": "string",
"description": "HTTP 1.1 Entity tag for the bucket."
@@ -621,10 +612,6 @@
"description": "The kind of item this is. For objects, this is always storage#object.",
"default": "storage#object"
},
- "kmsKeyName": {
- "type": "string",
- "description": "Cloud KMS Key used to encrypt this object, if the object is encrypted by such a key."
- },
"md5Hash": {
"type": "string",
"description": "MD5 hash of the data; encoded using base64. For more information about using the MD5 hash, see Hashes and ETags: Best Practices."
@@ -713,7 +700,13 @@
},
"entity": {
"type": "string",
- "description": "The entity holding the permission, in one of the following forms: \n- user-userId \n- user-email \n- group-groupId \n- group-email \n- domain-domain \n- project-team-projectId \n- allUsers \n- allAuthenticatedUsers Examples: \n- The user liz@example.com would be user-liz@example.com. \n- The group example@googlegroups.com would be group-example@googlegroups.com. \n- To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com."
+ "description": "The entity holding the permission, in one of the following forms: \n- user-userId \n- user-email \n- group-groupId \n- group-email \n- domain-domain \n- project-team-projectId \n- allUsers \n- allAuthenticatedUsers Examples: \n- The user liz@example.com would be user-liz@example.com. \n- The group example@googlegroups.com would be group-example@googlegroups.com. \n- To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.",
+ "annotations": {
+ "required": [
+ "storage.defaultObjectAccessControls.insert",
+ "storage.objectAccessControls.insert"
+ ]
+ }
},
"entityId": {
"type": "string",
@@ -725,7 +718,7 @@
},
"generation": {
"type": "string",
- "description": "The content generation of the object.",
+ "description": "The content generation of the object, if applied to an object.",
"format": "int64"
},
"id": {
@@ -739,7 +732,7 @@
},
"object": {
"type": "string",
- "description": "The name of the object."
+ "description": "The name of the object, if applied to an object."
},
"projectTeam": {
"type": "object",
@@ -757,7 +750,13 @@
},
"role": {
"type": "string",
- "description": "The access permission for the entity."
+ "description": "The access permission for the entity.",
+ "annotations": {
+ "required": [
+ "storage.defaultObjectAccessControls.insert",
+ "storage.objectAccessControls.insert"
+ ]
+ }
},
"selfLink": {
"type": "string",
@@ -774,7 +773,7 @@
"type": "array",
"description": "The list of items.",
"items": {
- "type": "any"
+ "$ref": "ObjectAccessControl"
}
},
"kind": {
@@ -1971,11 +1970,6 @@
"description": "Makes the operation conditional on whether the object's current metageneration matches the given value.",
"format": "int64",
"location": "query"
- },
- "kmsKeyName": {
- "type": "string",
- "description": "Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.",
- "location": "query"
}
},
"parameterOrder": [
@@ -2314,11 +2308,6 @@
"format": "int64",
"location": "query"
},
- "kmsKeyName": {
- "type": "string",
- "description": "Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.",
- "location": "query"
- },
"name": {
"type": "string",
"description": "Name of the object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.",
@@ -2570,11 +2559,6 @@
"required": true,
"location": "path"
},
- "destinationKmsKeyName": {
- "type": "string",
- "description": "Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.",
- "location": "query"
- },
"destinationObject": {
"type": "string",
"description": "Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.",
diff --git a/vendor/google.golang.org/api/storage/v1/storage-gen.go b/vendor/google.golang.org/api/storage/v1/storage-gen.go
index a74cad2..a7b6982 100644
--- a/vendor/google.golang.org/api/storage/v1/storage-gen.go
+++ b/vendor/google.golang.org/api/storage/v1/storage-gen.go
@@ -169,10 +169,6 @@ type Bucket struct {
// when no ACL is provided.
DefaultObjectAcl []*ObjectAccessControl `json:"defaultObjectAcl,omitempty"`
- // Encryption: Encryption configuration used by default for newly
- // inserted objects, when no encryption config is specified.
- Encryption *BucketEncryption `json:"encryption,omitempty"`
-
// Etag: HTTP 1.1 Entity tag for the bucket.
Etag string `json:"etag,omitempty"`
@@ -245,12 +241,20 @@ type Bucket struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Acl") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *Bucket) MarshalJSON() ([]byte, error) {
type noMethod Bucket
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type BucketCors struct {
@@ -280,32 +284,20 @@ type BucketCors struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "MaxAgeSeconds") to include
+ // in API requests with the JSON null value. By default, fields with
+ // empty values are omitted from API requests. However, any field with
+ // an empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketCors) MarshalJSON() ([]byte, error) {
type noMethod BucketCors
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
-}
-
-// BucketEncryption: Encryption configuration used by default for newly
-// inserted objects, when no encryption config is specified.
-type BucketEncryption struct {
- DefaultKmsKeyName string `json:"default_kms_key_name,omitempty"`
-
- // ForceSendFields is a list of field names (e.g. "DefaultKmsKeyName")
- // to unconditionally include in API requests. By default, fields with
- // empty values are omitted from API requests. However, any non-pointer,
- // non-interface field appearing in ForceSendFields will be sent to the
- // server regardless of whether the field is empty or not. This may be
- // used to include empty fields in Patch requests.
- ForceSendFields []string `json:"-"`
-}
-
-func (s *BucketEncryption) MarshalJSON() ([]byte, error) {
- type noMethod BucketEncryption
- raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketLifecycle: The bucket's lifecycle configuration. See lifecycle
@@ -322,12 +314,20 @@ type BucketLifecycle struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Rule") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketLifecycle) MarshalJSON() ([]byte, error) {
type noMethod BucketLifecycle
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type BucketLifecycleRule struct {
@@ -344,12 +344,20 @@ type BucketLifecycleRule struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Action") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketLifecycleRule) MarshalJSON() ([]byte, error) {
type noMethod BucketLifecycleRule
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketLifecycleRuleAction: The action to take.
@@ -364,12 +372,20 @@ type BucketLifecycleRuleAction struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Type") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketLifecycleRuleAction) MarshalJSON() ([]byte, error) {
type noMethod BucketLifecycleRuleAction
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketLifecycleRuleCondition: The condition(s) under which the action
@@ -401,12 +417,20 @@ type BucketLifecycleRuleCondition struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Age") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketLifecycleRuleCondition) MarshalJSON() ([]byte, error) {
type noMethod BucketLifecycleRuleCondition
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketLogging: The bucket's logging configuration, which defines the
@@ -427,12 +451,20 @@ type BucketLogging struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "LogBucket") to include in
+ // API requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketLogging) MarshalJSON() ([]byte, error) {
type noMethod BucketLogging
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketOwner: The owner of the bucket. This is always the project
@@ -451,12 +483,20 @@ type BucketOwner struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Entity") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketOwner) MarshalJSON() ([]byte, error) {
type noMethod BucketOwner
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketVersioning: The bucket's versioning configuration.
@@ -472,12 +512,20 @@ type BucketVersioning struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Enabled") to include in
+ // API requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketVersioning) MarshalJSON() ([]byte, error) {
type noMethod BucketVersioning
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketWebsite: The bucket's website configuration, controlling how
@@ -503,12 +551,21 @@ type BucketWebsite struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "MainPageSuffix") to
+ // include in API requests with the JSON null value. By default, fields
+ // with empty values are omitted from API requests. However, any field
+ // with an empty value appearing in NullFields will be sent to the
+ // server as null. It is an error if a field in this list has a
+ // non-empty value. This may be used to include null fields in Patch
+ // requests.
+ NullFields []string `json:"-"`
}
func (s *BucketWebsite) MarshalJSON() ([]byte, error) {
type noMethod BucketWebsite
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketAccessControl: An access-control entry.
@@ -572,12 +629,20 @@ type BucketAccessControl struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Bucket") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketAccessControl) MarshalJSON() ([]byte, error) {
type noMethod BucketAccessControl
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketAccessControlProjectTeam: The project team associated with the
@@ -596,12 +661,20 @@ type BucketAccessControlProjectTeam struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "ProjectNumber") to include
+ // in API requests with the JSON null value. By default, fields with
+ // empty values are omitted from API requests. However, any field with
+ // an empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketAccessControlProjectTeam) MarshalJSON() ([]byte, error) {
type noMethod BucketAccessControlProjectTeam
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// BucketAccessControls: An access-control list.
@@ -624,12 +697,20 @@ type BucketAccessControls struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Items") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *BucketAccessControls) MarshalJSON() ([]byte, error) {
type noMethod BucketAccessControls
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// Buckets: A list of buckets.
@@ -657,12 +738,20 @@ type Buckets struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Items") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *Buckets) MarshalJSON() ([]byte, error) {
type noMethod Buckets
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// Channel: An notification channel used to watch for resource changes.
@@ -715,12 +804,20 @@ type Channel struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Address") to include in
+ // API requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *Channel) MarshalJSON() ([]byte, error) {
type noMethod Channel
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ComposeRequest: A Compose request.
@@ -742,12 +839,20 @@ type ComposeRequest struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Destination") to include
+ // in API requests with the JSON null value. By default, fields with
+ // empty values are omitted from API requests. However, any field with
+ // an empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *ComposeRequest) MarshalJSON() ([]byte, error) {
type noMethod ComposeRequest
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type ComposeRequestSourceObjects struct {
@@ -769,12 +874,20 @@ type ComposeRequestSourceObjects struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Generation") to include in
+ // API requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *ComposeRequestSourceObjects) MarshalJSON() ([]byte, error) {
type noMethod ComposeRequestSourceObjects
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ComposeRequestSourceObjectsObjectPreconditions: Conditions that must
@@ -793,12 +906,21 @@ type ComposeRequestSourceObjectsObjectPreconditions struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "IfGenerationMatch") to
+ // include in API requests with the JSON null value. By default, fields
+ // with empty values are omitted from API requests. However, any field
+ // with an empty value appearing in NullFields will be sent to the
+ // server as null. It is an error if a field in this list has a
+ // non-empty value. This may be used to include null fields in Patch
+ // requests.
+ NullFields []string `json:"-"`
}
func (s *ComposeRequestSourceObjectsObjectPreconditions) MarshalJSON() ([]byte, error) {
type noMethod ComposeRequestSourceObjectsObjectPreconditions
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// Object: An object.
@@ -856,10 +978,6 @@ type Object struct {
// storage#object.
Kind string `json:"kind,omitempty"`
- // KmsKeyName: Cloud KMS Key used to encrypt this object, if the object
- // is encrypted by such a key.
- KmsKeyName string `json:"kmsKeyName,omitempty"`
-
// Md5Hash: MD5 hash of the data; encoded using base64. For more
// information about using the MD5 hash, see Hashes and ETags: Best
// Practices.
@@ -917,12 +1035,20 @@ type Object struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Acl") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *Object) MarshalJSON() ([]byte, error) {
type noMethod Object
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ObjectCustomerEncryption: Metadata of customer-supplied encryption
@@ -941,12 +1067,21 @@ type ObjectCustomerEncryption struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "EncryptionAlgorithm") to
+ // include in API requests with the JSON null value. By default, fields
+ // with empty values are omitted from API requests. However, any field
+ // with an empty value appearing in NullFields will be sent to the
+ // server as null. It is an error if a field in this list has a
+ // non-empty value. This may be used to include null fields in Patch
+ // requests.
+ NullFields []string `json:"-"`
}
func (s *ObjectCustomerEncryption) MarshalJSON() ([]byte, error) {
type noMethod ObjectCustomerEncryption
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ObjectOwner: The owner of the object. This will always be the
@@ -965,12 +1100,20 @@ type ObjectOwner struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Entity") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *ObjectOwner) MarshalJSON() ([]byte, error) {
type noMethod ObjectOwner
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ObjectAccessControl: An access-control entry.
@@ -1007,7 +1150,8 @@ type ObjectAccessControl struct {
// Etag: HTTP 1.1 Entity tag for the access-control entry.
Etag string `json:"etag,omitempty"`
- // Generation: The content generation of the object.
+ // Generation: The content generation of the object, if applied to an
+ // object.
Generation int64 `json:"generation,omitempty,string"`
// Id: The ID of the access-control entry.
@@ -1017,7 +1161,7 @@ type ObjectAccessControl struct {
// this is always storage#objectAccessControl.
Kind string `json:"kind,omitempty"`
- // Object: The name of the object.
+ // Object: The name of the object, if applied to an object.
Object string `json:"object,omitempty"`
// ProjectTeam: The project team associated with the entity, if any.
@@ -1040,12 +1184,20 @@ type ObjectAccessControl struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Bucket") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *ObjectAccessControl) MarshalJSON() ([]byte, error) {
type noMethod ObjectAccessControl
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ObjectAccessControlProjectTeam: The project team associated with the
@@ -1064,18 +1216,26 @@ type ObjectAccessControlProjectTeam struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "ProjectNumber") to include
+ // in API requests with the JSON null value. By default, fields with
+ // empty values are omitted from API requests. However, any field with
+ // an empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *ObjectAccessControlProjectTeam) MarshalJSON() ([]byte, error) {
type noMethod ObjectAccessControlProjectTeam
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ObjectAccessControls: An access-control list.
type ObjectAccessControls struct {
// Items: The list of items.
- Items []interface{} `json:"items,omitempty"`
+ Items []*ObjectAccessControl `json:"items,omitempty"`
// Kind: The kind of item this is. For lists of object access control
// entries, this is always storage#objectAccessControls.
@@ -1092,12 +1252,20 @@ type ObjectAccessControls struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Items") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *ObjectAccessControls) MarshalJSON() ([]byte, error) {
type noMethod ObjectAccessControls
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// Objects: A list of objects.
@@ -1129,12 +1297,20 @@ type Objects struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Items") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *Objects) MarshalJSON() ([]byte, error) {
type noMethod Objects
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// RewriteResponse: A rewrite response.
@@ -1176,12 +1352,20 @@ type RewriteResponse struct {
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
+
+ // NullFields is a list of field names (e.g. "Done") to include in API
+ // requests with the JSON null value. By default, fields with empty
+ // values are omitted from API requests. However, any field with an
+ // empty value appearing in NullFields will be sent to the server as
+ // null. It is an error if a field in this list has a non-empty value.
+ // This may be used to include null fields in Patch requests.
+ NullFields []string `json:"-"`
}
func (s *RewriteResponse) MarshalJSON() ([]byte, error) {
type noMethod RewriteResponse
raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
+ return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// method id "storage.bucketAccessControls.delete":
@@ -4947,16 +5131,6 @@ func (c *ObjectsComposeCall) IfMetagenerationMatch(ifMetagenerationMatch int64)
return c
}
-// KmsKeyName sets the optional parameter "kmsKeyName": Resource name of
-// the Cloud KMS key, of the form
-// projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key,
-// that will be used to encrypt the object. Overrides the object
-// metadata's kms_key_name value, if any.
-func (c *ObjectsComposeCall) KmsKeyName(kmsKeyName string) *ObjectsComposeCall {
- c.urlParams_.Set("kmsKeyName", kmsKeyName)
- return c
-}
-
// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
@@ -5100,11 +5274,6 @@ func (c *ObjectsComposeCall) Do(opts ...googleapi.CallOption) (*Object, error) {
// "format": "int64",
// "location": "query",
// "type": "string"
- // },
- // "kmsKeyName": {
- // "description": "Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.",
- // "location": "query",
- // "type": "string"
// }
// },
// "path": "b/{destinationBucket}/o/{destinationObject}/compose",
@@ -5980,16 +6149,6 @@ func (c *ObjectsInsertCall) IfMetagenerationNotMatch(ifMetagenerationNotMatch in
return c
}
-// KmsKeyName sets the optional parameter "kmsKeyName": Resource name of
-// the Cloud KMS key, of the form
-// projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key,
-// that will be used to encrypt the object. Overrides the object
-// metadata's kms_key_name value, if any.
-func (c *ObjectsInsertCall) KmsKeyName(kmsKeyName string) *ObjectsInsertCall {
- c.urlParams_.Set("kmsKeyName", kmsKeyName)
- return c
-}
-
// Name sets the optional parameter "name": Name of the object. Required
// when the object metadata is not otherwise provided. Overrides the
// object metadata's name value, if any. For information about how to
@@ -6261,11 +6420,6 @@ func (c *ObjectsInsertCall) Do(opts ...googleapi.CallOption) (*Object, error) {
// "location": "query",
// "type": "string"
// },
- // "kmsKeyName": {
- // "description": "Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.",
- // "location": "query",
- // "type": "string"
- // },
// "name": {
// "description": "Name of the object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.",
// "location": "query",
@@ -6862,17 +7016,6 @@ func (r *ObjectsService) Rewrite(sourceBucket string, sourceObject string, desti
return c
}
-// DestinationKmsKeyName sets the optional parameter
-// "destinationKmsKeyName": Resource name of the Cloud KMS key, of the
-// form
-// projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key,
-// that will be used to encrypt the object. Overrides the object
-// metadata's kms_key_name value, if any.
-func (c *ObjectsRewriteCall) DestinationKmsKeyName(destinationKmsKeyName string) *ObjectsRewriteCall {
- c.urlParams_.Set("destinationKmsKeyName", destinationKmsKeyName)
- return c
-}
-
// DestinationPredefinedAcl sets the optional parameter
// "destinationPredefinedAcl": Apply a predefined set of access controls
// to the destination object.
@@ -7102,11 +7245,6 @@ func (c *ObjectsRewriteCall) Do(opts ...googleapi.CallOption) (*RewriteResponse,
// "required": true,
// "type": "string"
// },
- // "destinationKmsKeyName": {
- // "description": "Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.",
- // "location": "query",
- // "type": "string"
- // },
// "destinationObject": {
// "description": "Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.",
// "location": "path",
diff --git a/vendor/google.golang.org/api/transport/dial.go b/vendor/google.golang.org/api/transport/dial.go
index a7d058b..c054460 100644
--- a/vendor/google.golang.org/api/transport/dial.go
+++ b/vendor/google.golang.org/api/transport/dial.go
@@ -20,6 +20,7 @@ package transport
import (
"errors"
"fmt"
+ "io/ioutil"
"net/http"
"golang.org/x/net/context"
@@ -48,6 +49,13 @@ func NewHTTPClient(ctx context.Context, opts ...option.ClientOption) (*http.Clie
if o.HTTPClient != nil {
return o.HTTPClient, o.Endpoint, nil
}
+ if o.ServiceAccountJSONFilename != "" {
+ ts, err := serviceAcctTokenSource(ctx, o.ServiceAccountJSONFilename, o.Scopes...)
+ if err != nil {
+ return nil, "", err
+ }
+ o.TokenSource = ts
+ }
if o.TokenSource == nil {
var err error
o.TokenSource, err = google.DefaultTokenSource(ctx, o.Scopes...)
@@ -74,6 +82,13 @@ func DialGRPC(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientCon
if o.GRPCConn != nil {
return o.GRPCConn, nil
}
+ if o.ServiceAccountJSONFilename != "" {
+ ts, err := serviceAcctTokenSource(ctx, o.ServiceAccountJSONFilename, o.Scopes...)
+ if err != nil {
+ return nil, err
+ }
+ o.TokenSource = ts
+ }
if o.TokenSource == nil {
var err error
o.TokenSource, err = google.DefaultTokenSource(ctx, o.Scopes...)
@@ -95,3 +110,15 @@ func DialGRPC(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientCon
}
return grpc.DialContext(ctx, o.Endpoint, grpcOpts...)
}
+
+func serviceAcctTokenSource(ctx context.Context, filename string, scope ...string) (oauth2.TokenSource, error) {
+ data, err := ioutil.ReadFile(filename)
+ if err != nil {
+ return nil, fmt.Errorf("cannot read service account file: %v", err)
+ }
+ cfg, err := google.JWTConfigFromJSON(data, scope...)
+ if err != nil {
+ return nil, fmt.Errorf("google.JWTConfigFromJSON: %v", err)
+ }
+ return cfg.TokenSource(ctx), nil
+}
diff --git a/vendor/google.golang.org/appengine/README.md b/vendor/google.golang.org/appengine/README.md
index 1efd955..b6b11d9 100644
--- a/vendor/google.golang.org/appengine/README.md
+++ b/vendor/google.golang.org/appengine/README.md
@@ -66,6 +66,8 @@ This list summarises the differences:
* `appengine.BackendHostname` and `appengine.BackendInstance` were for the deprecated backends feature.
Use `appengine.ModuleHostname`and `appengine.ModuleName` instead.
* Most of `appengine/file` and parts of `appengine/blobstore` are deprecated.
- Use [Google Cloud Storage](https://godoc.org/google.golang.org/cloud/storage) instead.
+ Use [Google Cloud Storage](https://godoc.org/cloud.google.com/go/storage) if the
+ feature you require is not present in the new
+ [blobstore package](https://google.golang.org/appengine/blobstore).
* `appengine/socket` is not required on App Engine flexible environment / Managed VMs.
Use the standard `net` package instead.
diff --git a/vendor/google.golang.org/appengine/internal/api.go b/vendor/google.golang.org/appengine/internal/api.go
index ec5aa59..e9c56d4 100644
--- a/vendor/google.golang.org/appengine/internal/api.go
+++ b/vendor/google.golang.org/appengine/internal/api.go
@@ -60,6 +60,9 @@ var (
Dial: limitDial,
},
}
+
+ defaultTicketOnce sync.Once
+ defaultTicket string
)
func apiURL() *url.URL {
@@ -266,6 +269,19 @@ func WithContext(parent netcontext.Context, req *http.Request) netcontext.Contex
return withContext(parent, c)
}
+func getDefaultTicket() string {
+ defaultTicketOnce.Do(func() {
+ appID := partitionlessAppID()
+ escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1)
+ majVersion := VersionID(nil)
+ if i := strings.Index(majVersion, "."); i > 0 {
+ majVersion = majVersion[:i]
+ }
+ defaultTicket = fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(nil), majVersion, InstanceID())
+ })
+ return defaultTicket
+}
+
func BackgroundContext() netcontext.Context {
ctxs.Lock()
defer ctxs.Unlock()
@@ -275,13 +291,7 @@ func BackgroundContext() netcontext.Context {
}
// Compute background security ticket.
- appID := partitionlessAppID()
- escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1)
- majVersion := VersionID(nil)
- if i := strings.Index(majVersion, "."); i > 0 {
- majVersion = majVersion[:i]
- }
- ticket := fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(nil), majVersion, InstanceID())
+ ticket := getDefaultTicket()
ctxs.bg = &context{
req: &http.Request{
@@ -475,6 +485,10 @@ func Call(ctx netcontext.Context, service, method string, in, out proto.Message)
}
ticket := c.req.Header.Get(ticketHeader)
+ // Fall back to use background ticket when the request ticket is not available in Flex.
+ if ticket == "" {
+ ticket = getDefaultTicket()
+ }
req := &remotepb.Request{
ServiceName: &service,
Method: &method,
diff --git a/vendor/google.golang.org/cloud/AUTHORS b/vendor/google.golang.org/cloud/AUTHORS
deleted file mode 100644
index c364af1..0000000
--- a/vendor/google.golang.org/cloud/AUTHORS
+++ /dev/null
@@ -1,15 +0,0 @@
-# This is the official list of cloud authors for copyright purposes.
-# This file is distinct from the CONTRIBUTORS files.
-# See the latter for an explanation.
-
-# Names should be added to this file as:
-# Name or Organization <email address>
-# The email address is not required for organizations.
-
-Filippo Valsorda <hi@filippo.io>
-Google Inc.
-Ingo Oeser <nightlyone@googlemail.com>
-Palm Stone Games, Inc.
-Paweł Knap <pawelknap88@gmail.com>
-Péter Szilágyi <peterke@gmail.com>
-Tyler Treat <ttreat31@gmail.com>
diff --git a/vendor/google.golang.org/cloud/CONTRIBUTING.md b/vendor/google.golang.org/cloud/CONTRIBUTING.md
deleted file mode 100644
index 135a1a1..0000000
--- a/vendor/google.golang.org/cloud/CONTRIBUTING.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# Contributing
-
-1. Sign one of the contributor license agreements below.
-1. `go get golang.org/x/review/git-codereview` to install the code reviewing tool.
-1. Get the cloud package by running `go get -d google.golang.org/cloud`.
- 1. If you have already checked out the source, make sure that the remote git
- origin is https://code.googlesource.com/gocloud:
-
- git remote set-url origin https://code.googlesource.com/gocloud
-1. Make sure your auth is configured correctly by visiting
- https://code.googlesource.com, clicking "Generate Password", and following
- the directions.
-1. Make changes and create a change by running `git codereview change <name>`,
-provide a commit message, and use `git codereview mail` to create a Gerrit CL.
-1. Keep amending to the change and mail as your receive feedback.
-
-## Integration Tests
-
-In addition to the unit tests, you may run the integration test suite.
-
-To run the integrations tests, creating and configuration of a project in the
-Google Developers Console is required. Once you create a project, set the
-following environment variables to be able to run the against the actual APIs.
-
-- **GCLOUD_TESTS_GOLANG_PROJECT_ID**: Developers Console project's ID (e.g. bamboo-shift-455)
-- **GCLOUD_TESTS_GOLANG_KEY**: The path to the JSON key file.
-
-Create a storage bucket with the same name as the project ID set in **GCLOUD_TESTS_GOLANG_PROJECT_ID**.
-The storage integration test will create and delete some objects in this bucket.
-
-Install the [gcloud command-line tool][gcloudcli] to your machine and use it
-to create the indexes used in the datastore integration tests with indexes
-found in `datastore/testdata/index.yaml`:
-
-From the project's root directory:
-
-``` sh
-# Set the default project in your env
-$ gcloud config set project $GCLOUD_TESTS_GOLANG_PROJECT_ID
-
-# Authenticate the gcloud tool with your account
-$ gcloud auth login
-
-# Create the indexes
-$ gcloud preview datastore create-indexes datastore/testdata/index.yaml
-
-```
-
-Once you've set the environment variables, you can run the integration tests by
-running:
-
-``` sh
-$ go test -v google.golang.org/cloud/...
-```
-
-## Contributor License Agreements
-
-Before we can accept your pull requests you'll need to sign a Contributor
-License Agreement (CLA):
-
-- **If you are an individual writing original source code** and **you own the
-- intellectual property**, then you'll need to sign an [individual CLA][indvcla].
-- **If you work for a company that wants to allow you to contribute your work**,
-then you'll need to sign a [corporate CLA][corpcla].
-
-You can sign these electronically (just scroll to the bottom). After that,
-we'll be able to accept your pull requests.
-
-## Contributor Code of Conduct
-
-As contributors and maintainers of this project,
-and in the interest of fostering an open and welcoming community,
-we pledge to respect all people who contribute through reporting issues,
-posting feature requests, updating documentation,
-submitting pull requests or patches, and other activities.
-
-We are committed to making participation in this project
-a harassment-free experience for everyone,
-regardless of level of experience, gender, gender identity and expression,
-sexual orientation, disability, personal appearance,
-body size, race, ethnicity, age, religion, or nationality.
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery
-* Personal attacks
-* Trolling or insulting/derogatory comments
-* Public or private harassment
-* Publishing other's private information,
-such as physical or electronic
-addresses, without explicit permission
-* Other unethical or unprofessional conduct.
-
-Project maintainers have the right and responsibility to remove, edit, or reject
-comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct.
-By adopting this Code of Conduct,
-project maintainers commit themselves to fairly and consistently
-applying these principles to every aspect of managing this project.
-Project maintainers who do not follow or enforce the Code of Conduct
-may be permanently removed from the project team.
-
-This code of conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community.
-
-Instances of abusive, harassing, or otherwise unacceptable behavior
-may be reported by opening an issue
-or contacting one or more of the project maintainers.
-
-This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
-available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
-
-[gcloudcli]: https://developers.google.com/cloud/sdk/gcloud/
-[indvcla]: https://developers.google.com/open-source/cla/individual
-[corpcla]: https://developers.google.com/open-source/cla/corporate
diff --git a/vendor/google.golang.org/cloud/CONTRIBUTORS b/vendor/google.golang.org/cloud/CONTRIBUTORS
deleted file mode 100644
index cfae12c..0000000
--- a/vendor/google.golang.org/cloud/CONTRIBUTORS
+++ /dev/null
@@ -1,31 +0,0 @@
-# People who have agreed to one of the CLAs and can contribute patches.
-# The AUTHORS file lists the copyright holders; this file
-# lists people. For example, Google employees are listed here
-# but not in AUTHORS, because Google holds the copyright.
-#
-# https://developers.google.com/open-source/cla/individual
-# https://developers.google.com/open-source/cla/corporate
-#
-# Names should be added to this file as:
-# Name <email address>
-
-# Keep the list alphabetically sorted.
-
-Andreas Litt <andreas.litt@gmail.com>
-Andrew Gerrand <adg@golang.org>
-Brad Fitzpatrick <bradfitz@golang.org>
-Burcu Dogan <jbd@google.com>
-Dave Day <djd@golang.org>
-David Sansome <me@davidsansome.com>
-David Symonds <dsymonds@golang.org>
-Filippo Valsorda <hi@filippo.io>
-Glenn Lewis <gmlewis@google.com>
-Ingo Oeser <nightlyone@googlemail.com>
-Johan Euphrosine <proppy@google.com>
-Luna Duclos <luna.duclos@palmstonegames.com>
-Michael McGreevy <mcgreevy@golang.org>
-Omar Jarjur <ojarjur@google.com>
-Paweł Knap <pawelknap88@gmail.com>
-Péter Szilágyi <peterke@gmail.com>
-Toby Burress <kurin@google.com>
-Tyler Treat <ttreat31@gmail.com>
diff --git a/vendor/google.golang.org/cloud/LICENSE b/vendor/google.golang.org/cloud/LICENSE
deleted file mode 100644
index a4c5efd..0000000
--- a/vendor/google.golang.org/cloud/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2014 Google Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/google.golang.org/cloud/README.md b/vendor/google.golang.org/cloud/README.md
deleted file mode 100644
index de29fb9..0000000
--- a/vendor/google.golang.org/cloud/README.md
+++ /dev/null
@@ -1,202 +0,0 @@
-# Google Cloud for Go
-
-**NOTE:** This repo exists solely to transition to the new import paths at
- cloud.google.com/go. It will be removed on September 12, 2016. Only emergency
- pull requests will be accepted.
-
-To migrate off this repo, change import paths beginning
-`google.golang.org/cloud` to `cloud.google.com/go`, except for the options in
-the `google.golang.org/cloud` package itself, which are now at
-`google.golang.org/api/option`. See details [here](https://groups.google.com/forum/#!topic/google-api-go-announce/nXY-DYZGqz8).
-
-
-[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-golang.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-golang)
-[![GoDoc](https://godoc.org/google.golang.org/cloud?status.svg)](https://godoc.org/google.golang.org/cloud)
-
-``` go
-import "google.golang.org/cloud"
-```
-
-**NOTE:** These packages are under development, and may occasionally make
-backwards-incompatible changes.
-
-**NOTE:** Github repo is a mirror of [https://code.googlesource.com/gocloud](https://code.googlesource.com/gocloud).
-
-Go packages for Google Cloud Platform services. Supported APIs are:
-
-Google API | Status | Package
--------------------------------|--------------|-----------------------------------------------------------
-[Datastore][cloud-datastore] | beta | [`google.golang.org/cloud/datastore`][cloud-datastore-ref]
-[Storage][cloud-storage] | beta | [`google.golang.org/cloud/storage`][cloud-storage-ref]
-[Pub/Sub][cloud-pubsub] | experimental | [`google.golang.org/cloud/pubsub`][cloud-pubsub-ref]
-[Bigtable][cloud-bigtable] | stable | [`google.golang.org/cloud/bigtable`][cloud-bigtable-ref]
-[BigQuery][cloud-bigquery] | experimental | [`google.golang.org/cloud/bigquery`][cloud-bigquery-ref]
-[Logging][cloud-logging] | experimental | [`google.golang.org/cloud/logging`][cloud-logging-ref]
-
-> **Experimental status**: the API is still being actively developed. As a
-> result, it might change in backward-incompatible ways and is not recommended
-> for production use.
->
-> **Beta status**: the API is largely complete, but still has outstanding
-> features and bugs to be addressed. There may be minor backwards-incompatible
-> changes where necessary.
->
-> **Stable status**: the API is mature and ready for production use. We will
-> continue addressing bugs and feature requests.
-
-Documentation and examples are available at
-https://godoc.org/google.golang.org/cloud
-
-Visit or join the
-[google-api-go-announce group](https://groups.google.com/forum/#!forum/google-api-go-announce)
-for updates on these packages.
-
-## Go Versions Supported
-
-We support the two most recent major versions of Go. If Google App Engine uses
-an older version, we support that as well. You can see which versions are
-currently supported by looking at the lines following `go:` in
-[`.travis.yml`](.travis.yml).
-
-## Authorization
-
-By default, each API will use [Google Application Default Credentials][default-creds]
-for authorization credentials used in calling the API endpoints. This will allow your
-application to run in many environments without requiring explicit configuration.
-
-Manually-configured authorization can be achieved using the
-[`golang.org/x/oauth2`](https://godoc.org/golang.org/x/oauth2) package to
-create an `oauth2.TokenSource`. This token source can be passed to the `NewClient`
-function for the relevant API using a
-[`cloud.WithTokenSource`](https://godoc.org/google.golang.org/cloud#WithTokenSource)
-option.
-
-## Google Cloud Datastore [![GoDoc](https://godoc.org/google.golang.org/cloud/datastore?status.svg)](https://godoc.org/google.golang.org/cloud/datastore)
-
-[Google Cloud Datastore][cloud-datastore] ([docs][cloud-datastore-docs]) is a fully-
-managed, schemaless database for storing non-relational data. Cloud Datastore
-automatically scales with your users and supports ACID transactions, high availability
-of reads and writes, strong consistency for reads and ancestor queries, and eventual
-consistency for all other queries.
-
-Follow the [activation instructions][cloud-datastore-activation] to use the Google
-Cloud Datastore API with your project.
-
-First create a `datastore.Client` to use throughout your application:
-
-```go
-client, err := datastore.NewClient(ctx, "my-project-id")
-if err != nil {
- log.Fatalln(err)
-}
-```
-
-Then use that client to interact with the API:
-
-```go
-type Post struct {
- Title string
- Body string `datastore:",noindex"`
- PublishedAt time.Time
-}
-keys := []*datastore.Key{
- datastore.NewKey(ctx, "Post", "post1", 0, nil),
- datastore.NewKey(ctx, "Post", "post2", 0, nil),
-}
-posts := []*Post{
- {Title: "Post 1", Body: "...", PublishedAt: time.Now()},
- {Title: "Post 2", Body: "...", PublishedAt: time.Now()},
-}
-if _, err := client.PutMulti(ctx, keys, posts); err != nil {
- log.Fatal(err)
-}
-```
-
-## Google Cloud Storage [![GoDoc](https://godoc.org/google.golang.org/cloud/storage?status.svg)](https://godoc.org/google.golang.org/cloud/storage)
-
-[Google Cloud Storage][cloud-storage] ([docs][cloud-storage-docs]) allows you to store
-data on Google infrastructure with very high reliability, performance and availability,
-and can be used to distribute large data objects to users via direct download.
-
-https://godoc.org/google.golang.org/cloud/storage
-
-First create a `storage.Client` to use throughout your application:
-
-```go
-client, err := storage.NewClient(ctx)
-if err != nil {
- log.Fatal(err)
-}
-```
-
-```go
-// Read the object1 from bucket.
-rc, err := client.Bucket("bucket").Object("object1").NewReader(ctx)
-if err != nil {
- log.Fatal(err)
-}
-defer rc.Close()
-body, err := ioutil.ReadAll(rc)
-if err != nil {
- log.Fatal(err)
-}
-```
-
-## Google Cloud Pub/Sub [![GoDoc](https://godoc.org/google.golang.org/cloud/pubsub?status.svg)](https://godoc.org/google.golang.org/cloud/pubsub)
-
-[Google Cloud Pub/Sub][cloud-pubsub] ([docs][cloud-pubsub-docs]) allows you to connect
-your services with reliable, many-to-many, asynchronous messaging hosted on Google's
-infrastructure. Cloud Pub/Sub automatically scales as you need it and provides a foundation
-for building your own robust, global services.
-
-```go
-// Publish "hello world" on topic1.
-msgIDs, err := pubsub.Publish(ctx, "topic1", &pubsub.Message{
- Data: []byte("hello world"),
-})
-if err != nil {
- log.Println(err)
-}
-// Pull messages via subscription1.
-msgs, err := pubsub.Pull(ctx, "subscription1", 1)
-if err != nil {
- log.Println(err)
-}
-```
-
-## Contributing
-
-Contributions are welcome. Please, see the
-[CONTRIBUTING](https://github.com/GoogleCloudPlatform/gcloud-golang/blob/master/CONTRIBUTING.md)
-document for details. We're using Gerrit for our code reviews. Please don't open pull
-requests against this repo, new pull requests will be automatically closed.
-
-Please note that this project is released with a Contributor Code of Conduct.
-By participating in this project you agree to abide by its terms.
-See [Contributor Code of Conduct](https://github.com/GoogleCloudPlatform/gcloud-golang/blob/master/CONTRIBUTING.md#contributor-code-of-conduct)
-for more information.
-
-[cloud-datastore]: https://cloud.google.com/datastore/
-[cloud-datastore-ref]: https://godoc.org/google.golang.org/cloud/datastore
-[cloud-datastore-docs]: https://cloud.google.com/datastore/docs
-[cloud-datastore-activation]: https://cloud.google.com/datastore/docs/activate
-
-[cloud-pubsub]: https://cloud.google.com/pubsub/
-[cloud-pubsub-ref]: https://godoc.org/google.golang.org/cloud/pubsub
-[cloud-pubsub-docs]: https://cloud.google.com/pubsub/docs
-
-[cloud-storage]: https://cloud.google.com/storage/
-[cloud-storage-ref]: https://godoc.org/google.golang.org/cloud/storage
-[cloud-storage-docs]: https://cloud.google.com/storage/docs/overview
-[cloud-storage-create-bucket]: https://cloud.google.com/storage/docs/cloud-console#_creatingbuckets
-
-[cloud-bigtable]: https://cloud.google.com/bigtable/
-[cloud-bigtable-ref]: https://godoc.org/google.golang.org/cloud/bigtable
-
-[cloud-bigquery]: https://cloud.google.com/bigquery/
-[cloud-bigquery-ref]: https://godoc.org/google.golang.org/cloud/bigquery
-
-[cloud-logging]: https://cloud.google.com/logging/
-[cloud-logging-ref]: https://godoc.org/google.golang.org/cloud/logging
-
-[default-creds]: https://developers.google.com/identity/protocols/application-default-credentials
diff --git a/vendor/google.golang.org/cloud/cloud.go b/vendor/google.golang.org/cloud/cloud.go
deleted file mode 100644
index 98be1f4..0000000
--- a/vendor/google.golang.org/cloud/cloud.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package cloud contains Google Cloud Platform APIs related types
-// and common functions.
-package cloud // import "google.golang.org/cloud"
-
-import (
- "net/http"
-
- "golang.org/x/net/context"
- "google.golang.org/cloud/internal"
-)
-
-// NewContext returns a new context that uses the provided http.Client.
-// Provided http.Client is responsible to authorize and authenticate
-// the requests made to the Google Cloud APIs.
-// It mutates the client's original Transport to append the cloud
-// package's user-agent to the outgoing requests.
-// You can obtain the project ID from the Google Developers Console,
-// https://console.developers.google.com.
-func NewContext(projID string, c *http.Client) context.Context {
- if c == nil {
- panic("invalid nil *http.Client passed to NewContext")
- }
- return WithContext(context.Background(), projID, c)
-}
-
-// WithContext returns a new context in a similar way NewContext does,
-// but initiates the new context with the specified parent.
-func WithContext(parent context.Context, projID string, c *http.Client) context.Context {
- // TODO(bradfitz): delete internal.Transport. It's too wrappy for what it does.
- // Do User-Agent some other way.
- if c == nil {
- panic("invalid nil *http.Client passed to WithContext")
- }
- if _, ok := c.Transport.(*internal.Transport); !ok {
- base := c.Transport
- if base == nil {
- base = http.DefaultTransport
- }
- c.Transport = &internal.Transport{Base: base}
- }
- return internal.WithContext(parent, projID, c)
-}
diff --git a/vendor/google.golang.org/cloud/compute/metadata/metadata.go b/vendor/google.golang.org/cloud/compute/metadata/metadata.go
deleted file mode 100644
index b791790..0000000
--- a/vendor/google.golang.org/cloud/compute/metadata/metadata.go
+++ /dev/null
@@ -1,438 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package metadata provides access to Google Compute Engine (GCE)
-// metadata and API service accounts.
-//
-// This package is a wrapper around the GCE metadata service,
-// as documented at https://developers.google.com/compute/docs/metadata.
-package metadata // import "google.golang.org/cloud/compute/metadata"
-
-import (
- "encoding/json"
- "fmt"
- "io/ioutil"
- "net"
- "net/http"
- "net/url"
- "os"
- "runtime"
- "strings"
- "sync"
- "time"
-
- "golang.org/x/net/context"
- "golang.org/x/net/context/ctxhttp"
-
- "google.golang.org/cloud/internal"
-)
-
-const (
- // metadataIP is the documented metadata server IP address.
- metadataIP = "169.254.169.254"
-
- // metadataHostEnv is the environment variable specifying the
- // GCE metadata hostname. If empty, the default value of
- // metadataIP ("169.254.169.254") is used instead.
- // This is variable name is not defined by any spec, as far as
- // I know; it was made up for the Go package.
- metadataHostEnv = "GCE_METADATA_HOST"
-)
-
-type cachedValue struct {
- k string
- trim bool
- mu sync.Mutex
- v string
-}
-
-var (
- projID = &cachedValue{k: "project/project-id", trim: true}
- projNum = &cachedValue{k: "project/numeric-project-id", trim: true}
- instID = &cachedValue{k: "instance/id", trim: true}
-)
-
-var (
- metaClient = &http.Client{
- Transport: &internal.Transport{
- Base: &http.Transport{
- Dial: (&net.Dialer{
- Timeout: 2 * time.Second,
- KeepAlive: 30 * time.Second,
- }).Dial,
- ResponseHeaderTimeout: 2 * time.Second,
- },
- },
- }
- subscribeClient = &http.Client{
- Transport: &internal.Transport{
- Base: &http.Transport{
- Dial: (&net.Dialer{
- Timeout: 2 * time.Second,
- KeepAlive: 30 * time.Second,
- }).Dial,
- },
- },
- }
-)
-
-// NotDefinedError is returned when requested metadata is not defined.
-//
-// The underlying string is the suffix after "/computeMetadata/v1/".
-//
-// This error is not returned if the value is defined to be the empty
-// string.
-type NotDefinedError string
-
-func (suffix NotDefinedError) Error() string {
- return fmt.Sprintf("metadata: GCE metadata %q not defined", string(suffix))
-}
-
-// Get returns a value from the metadata service.
-// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/".
-//
-// If the GCE_METADATA_HOST environment variable is not defined, a default of
-// 169.254.169.254 will be used instead.
-//
-// If the requested metadata is not defined, the returned error will
-// be of type NotDefinedError.
-func Get(suffix string) (string, error) {
- val, _, err := getETag(metaClient, suffix)
- return val, err
-}
-
-// getETag returns a value from the metadata service as well as the associated
-// ETag using the provided client. This func is otherwise equivalent to Get.
-func getETag(client *http.Client, suffix string) (value, etag string, err error) {
- // Using a fixed IP makes it very difficult to spoof the metadata service in
- // a container, which is an important use-case for local testing of cloud
- // deployments. To enable spoofing of the metadata service, the environment
- // variable GCE_METADATA_HOST is first inspected to decide where metadata
- // requests shall go.
- host := os.Getenv(metadataHostEnv)
- if host == "" {
- // Using 169.254.169.254 instead of "metadata" here because Go
- // binaries built with the "netgo" tag and without cgo won't
- // know the search suffix for "metadata" is
- // ".google.internal", and this IP address is documented as
- // being stable anyway.
- host = metadataIP
- }
- url := "http://" + host + "/computeMetadata/v1/" + suffix
- req, _ := http.NewRequest("GET", url, nil)
- req.Header.Set("Metadata-Flavor", "Google")
- res, err := client.Do(req)
- if err != nil {
- return "", "", err
- }
- defer res.Body.Close()
- if res.StatusCode == http.StatusNotFound {
- return "", "", NotDefinedError(suffix)
- }
- if res.StatusCode != 200 {
- return "", "", fmt.Errorf("status code %d trying to fetch %s", res.StatusCode, url)
- }
- all, err := ioutil.ReadAll(res.Body)
- if err != nil {
- return "", "", err
- }
- return string(all), res.Header.Get("Etag"), nil
-}
-
-func getTrimmed(suffix string) (s string, err error) {
- s, err = Get(suffix)
- s = strings.TrimSpace(s)
- return
-}
-
-func (c *cachedValue) get() (v string, err error) {
- defer c.mu.Unlock()
- c.mu.Lock()
- if c.v != "" {
- return c.v, nil
- }
- if c.trim {
- v, err = getTrimmed(c.k)
- } else {
- v, err = Get(c.k)
- }
- if err == nil {
- c.v = v
- }
- return
-}
-
-var (
- onGCEOnce sync.Once
- onGCE bool
-)
-
-// OnGCE reports whether this process is running on Google Compute Engine.
-func OnGCE() bool {
- onGCEOnce.Do(initOnGCE)
- return onGCE
-}
-
-func initOnGCE() {
- onGCE = testOnGCE()
-}
-
-func testOnGCE() bool {
- // The user explicitly said they're on GCE, so trust them.
- if os.Getenv(metadataHostEnv) != "" {
- return true
- }
-
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
-
- resc := make(chan bool, 2)
-
- // Try two strategies in parallel.
- // See https://github.com/GoogleCloudPlatform/gcloud-golang/issues/194
- go func() {
- res, err := ctxhttp.Get(ctx, metaClient, "http://"+metadataIP)
- if err != nil {
- resc <- false
- return
- }
- defer res.Body.Close()
- resc <- res.Header.Get("Metadata-Flavor") == "Google"
- }()
-
- go func() {
- addrs, err := net.LookupHost("metadata.google.internal")
- if err != nil || len(addrs) == 0 {
- resc <- false
- return
- }
- resc <- strsContains(addrs, metadataIP)
- }()
-
- tryHarder := systemInfoSuggestsGCE()
- if tryHarder {
- res := <-resc
- if res {
- // The first strategy succeeded, so let's use it.
- return true
- }
- // Wait for either the DNS or metadata server probe to
- // contradict the other one and say we are running on
- // GCE. Give it a lot of time to do so, since the system
- // info already suggests we're running on a GCE BIOS.
- timer := time.NewTimer(5 * time.Second)
- defer timer.Stop()
- select {
- case res = <-resc:
- return res
- case <-timer.C:
- // Too slow. Who knows what this system is.
- return false
- }
- }
-
- // There's no hint from the system info that we're running on
- // GCE, so use the first probe's result as truth, whether it's
- // true or false. The goal here is to optimize for speed for
- // users who are NOT running on GCE. We can't assume that
- // either a DNS lookup or an HTTP request to a blackholed IP
- // address is fast. Worst case this should return when the
- // metaClient's Transport.ResponseHeaderTimeout or
- // Transport.Dial.Timeout fires (in two seconds).
- return <-resc
-}
-
-// systemInfoSuggestsGCE reports whether the local system (without
-// doing network requests) suggests that we're running on GCE. If this
-// returns true, testOnGCE tries a bit harder to reach its metadata
-// server.
-func systemInfoSuggestsGCE() bool {
- if runtime.GOOS != "linux" {
- // We don't have any non-Linux clues available, at least yet.
- return false
- }
- slurp, _ := ioutil.ReadFile("/sys/class/dmi/id/product_name")
- name := strings.TrimSpace(string(slurp))
- return name == "Google" || name == "Google Compute Engine"
-}
-
-// Subscribe subscribes to a value from the metadata service.
-// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/".
-// The suffix may contain query parameters.
-//
-// Subscribe calls fn with the latest metadata value indicated by the provided
-// suffix. If the metadata value is deleted, fn is called with the empty string
-// and ok false. Subscribe blocks until fn returns a non-nil error or the value
-// is deleted. Subscribe returns the error value returned from the last call to
-// fn, which may be nil when ok == false.
-func Subscribe(suffix string, fn func(v string, ok bool) error) error {
- const failedSubscribeSleep = time.Second * 5
-
- // First check to see if the metadata value exists at all.
- val, lastETag, err := getETag(subscribeClient, suffix)
- if err != nil {
- return err
- }
-
- if err := fn(val, true); err != nil {
- return err
- }
-
- ok := true
- if strings.ContainsRune(suffix, '?') {
- suffix += "&wait_for_change=true&last_etag="
- } else {
- suffix += "?wait_for_change=true&last_etag="
- }
- for {
- val, etag, err := getETag(subscribeClient, suffix+url.QueryEscape(lastETag))
- if err != nil {
- if _, deleted := err.(NotDefinedError); !deleted {
- time.Sleep(failedSubscribeSleep)
- continue // Retry on other errors.
- }
- ok = false
- }
- lastETag = etag
-
- if err := fn(val, ok); err != nil || !ok {
- return err
- }
- }
-}
-
-// ProjectID returns the current instance's project ID string.
-func ProjectID() (string, error) { return projID.get() }
-
-// NumericProjectID returns the current instance's numeric project ID.
-func NumericProjectID() (string, error) { return projNum.get() }
-
-// InternalIP returns the instance's primary internal IP address.
-func InternalIP() (string, error) {
- return getTrimmed("instance/network-interfaces/0/ip")
-}
-
-// ExternalIP returns the instance's primary external (public) IP address.
-func ExternalIP() (string, error) {
- return getTrimmed("instance/network-interfaces/0/access-configs/0/external-ip")
-}
-
-// Hostname returns the instance's hostname. This will be of the form
-// "<instanceID>.c.<projID>.internal".
-func Hostname() (string, error) {
- return getTrimmed("instance/hostname")
-}
-
-// InstanceTags returns the list of user-defined instance tags,
-// assigned when initially creating a GCE instance.
-func InstanceTags() ([]string, error) {
- var s []string
- j, err := Get("instance/tags")
- if err != nil {
- return nil, err
- }
- if err := json.NewDecoder(strings.NewReader(j)).Decode(&s); err != nil {
- return nil, err
- }
- return s, nil
-}
-
-// InstanceID returns the current VM's numeric instance ID.
-func InstanceID() (string, error) {
- return instID.get()
-}
-
-// InstanceName returns the current VM's instance ID string.
-func InstanceName() (string, error) {
- host, err := Hostname()
- if err != nil {
- return "", err
- }
- return strings.Split(host, ".")[0], nil
-}
-
-// Zone returns the current VM's zone, such as "us-central1-b".
-func Zone() (string, error) {
- zone, err := getTrimmed("instance/zone")
- // zone is of the form "projects/<projNum>/zones/<zoneName>".
- if err != nil {
- return "", err
- }
- return zone[strings.LastIndex(zone, "/")+1:], nil
-}
-
-// InstanceAttributes returns the list of user-defined attributes,
-// assigned when initially creating a GCE VM instance. The value of an
-// attribute can be obtained with InstanceAttributeValue.
-func InstanceAttributes() ([]string, error) { return lines("instance/attributes/") }
-
-// ProjectAttributes returns the list of user-defined attributes
-// applying to the project as a whole, not just this VM. The value of
-// an attribute can be obtained with ProjectAttributeValue.
-func ProjectAttributes() ([]string, error) { return lines("project/attributes/") }
-
-func lines(suffix string) ([]string, error) {
- j, err := Get(suffix)
- if err != nil {
- return nil, err
- }
- s := strings.Split(strings.TrimSpace(j), "\n")
- for i := range s {
- s[i] = strings.TrimSpace(s[i])
- }
- return s, nil
-}
-
-// InstanceAttributeValue returns the value of the provided VM
-// instance attribute.
-//
-// If the requested attribute is not defined, the returned error will
-// be of type NotDefinedError.
-//
-// InstanceAttributeValue may return ("", nil) if the attribute was
-// defined to be the empty string.
-func InstanceAttributeValue(attr string) (string, error) {
- return Get("instance/attributes/" + attr)
-}
-
-// ProjectAttributeValue returns the value of the provided
-// project attribute.
-//
-// If the requested attribute is not defined, the returned error will
-// be of type NotDefinedError.
-//
-// ProjectAttributeValue may return ("", nil) if the attribute was
-// defined to be the empty string.
-func ProjectAttributeValue(attr string) (string, error) {
- return Get("project/attributes/" + attr)
-}
-
-// Scopes returns the service account scopes for the given account.
-// The account may be empty or the string "default" to use the instance's
-// main account.
-func Scopes(serviceAccount string) ([]string, error) {
- if serviceAccount == "" {
- serviceAccount = "default"
- }
- return lines("instance/service-accounts/" + serviceAccount + "/scopes")
-}
-
-func strsContains(ss []string, s string) bool {
- for _, v := range ss {
- if v == s {
- return true
- }
- }
- return false
-}
diff --git a/vendor/google.golang.org/cloud/internal/cloud.go b/vendor/google.golang.org/cloud/internal/cloud.go
deleted file mode 100644
index 5942880..0000000
--- a/vendor/google.golang.org/cloud/internal/cloud.go
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package internal provides support for the cloud packages.
-//
-// Users should not import this package directly.
-package internal
-
-import (
- "fmt"
- "net/http"
- "sync"
-
- "golang.org/x/net/context"
-)
-
-type contextKey struct{}
-
-func WithContext(parent context.Context, projID string, c *http.Client) context.Context {
- if c == nil {
- panic("nil *http.Client passed to WithContext")
- }
- if projID == "" {
- panic("empty project ID passed to WithContext")
- }
- return context.WithValue(parent, contextKey{}, &cloudContext{
- ProjectID: projID,
- HTTPClient: c,
- })
-}
-
-const userAgent = "gcloud-golang/0.1"
-
-type cloudContext struct {
- ProjectID string
- HTTPClient *http.Client
-
- mu sync.Mutex // guards svc
- svc map[string]interface{} // e.g. "storage" => *rawStorage.Service
-}
-
-// Service returns the result of the fill function if it's never been
-// called before for the given name (which is assumed to be an API
-// service name, like "datastore"). If it has already been cached, the fill
-// func is not run.
-// It's safe for concurrent use by multiple goroutines.
-func Service(ctx context.Context, name string, fill func(*http.Client) interface{}) interface{} {
- return cc(ctx).service(name, fill)
-}
-
-func (c *cloudContext) service(name string, fill func(*http.Client) interface{}) interface{} {
- c.mu.Lock()
- defer c.mu.Unlock()
-
- if c.svc == nil {
- c.svc = make(map[string]interface{})
- } else if v, ok := c.svc[name]; ok {
- return v
- }
- v := fill(c.HTTPClient)
- c.svc[name] = v
- return v
-}
-
-// Transport is an http.RoundTripper that appends
-// Google Cloud client's user-agent to the original
-// request's user-agent header.
-type Transport struct {
- // Base is the actual http.RoundTripper
- // requests will use. It must not be nil.
- Base http.RoundTripper
-}
-
-// RoundTrip appends a user-agent to the existing user-agent
-// header and delegates the request to the base http.RoundTripper.
-func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
- req = cloneRequest(req)
- ua := req.Header.Get("User-Agent")
- if ua == "" {
- ua = userAgent
- } else {
- ua = fmt.Sprintf("%s %s", ua, userAgent)
- }
- req.Header.Set("User-Agent", ua)
- return t.Base.RoundTrip(req)
-}
-
-// 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 {
- // shallow copy of the struct
- r2 := new(http.Request)
- *r2 = *r
- // deep copy of the Header
- r2.Header = make(http.Header)
- for k, s := range r.Header {
- r2.Header[k] = s
- }
- return r2
-}
-
-func ProjID(ctx context.Context) string {
- return cc(ctx).ProjectID
-}
-
-func HTTPClient(ctx context.Context) *http.Client {
- return cc(ctx).HTTPClient
-}
-
-// cc returns the internal *cloudContext (cc) state for a context.Context.
-// It panics if the user did it wrong.
-func cc(ctx context.Context) *cloudContext {
- if c, ok := ctx.Value(contextKey{}).(*cloudContext); ok {
- return c
- }
- panic("invalid context.Context type; it should be created with cloud.NewContext")
-}
diff --git a/vendor/google.golang.org/cloud/internal/transport/dial.go b/vendor/google.golang.org/cloud/internal/transport/dial.go
deleted file mode 100644
index f554953..0000000
--- a/vendor/google.golang.org/cloud/internal/transport/dial.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package transport
-
-import (
- "fmt"
- "net/http"
-
- "golang.org/x/net/context"
- "google.golang.org/api/option"
- "google.golang.org/api/transport"
- "google.golang.org/cloud"
- "google.golang.org/grpc"
-)
-
-// ErrHTTP is returned when on a non-200 HTTP response.
-type ErrHTTP struct {
- StatusCode int
- Body []byte
- err error
-}
-
-func (e *ErrHTTP) Error() string {
- if e.err == nil {
- return fmt.Sprintf("error during call, http status code: %v %s", e.StatusCode, e.Body)
- }
- return e.err.Error()
-}
-
-// NewHTTPClient returns an HTTP client for use communicating with a Google cloud
-// service, configured with the given ClientOptions. It also returns the endpoint
-// for the service as specified in the options.
-func NewHTTPClient(ctx context.Context, opt ...cloud.ClientOption) (*http.Client, string, error) {
- o := make([]option.ClientOption, 0, len(opt))
- for _, opt := range opt {
- o = append(o, opt.Resolve())
- }
- return transport.NewHTTPClient(ctx, o...)
-}
-
-// DialGRPC returns a GRPC connection for use communicating with a Google cloud
-// service, configured with the given ClientOptions.
-func DialGRPC(ctx context.Context, opt ...cloud.ClientOption) (*grpc.ClientConn, error) {
- o := make([]option.ClientOption, 0, len(opt))
- for _, opt := range opt {
- o = append(o, opt.Resolve())
- }
- return transport.DialGRPC(ctx, o...)
-}
diff --git a/vendor/google.golang.org/cloud/key.json.enc b/vendor/google.golang.org/cloud/key.json.enc
deleted file mode 100644
index 2f673a8..0000000
--- a/vendor/google.golang.org/cloud/key.json.enc
+++ /dev/null
Binary files differ
diff --git a/vendor/google.golang.org/cloud/option.go b/vendor/google.golang.org/cloud/option.go
deleted file mode 100644
index c012c73..0000000
--- a/vendor/google.golang.org/cloud/option.go
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package cloud
-
-import (
- "net/http"
-
- "golang.org/x/oauth2"
- "google.golang.org/api/option"
- "google.golang.org/grpc"
-)
-
-// ClientOption is used when construct clients for each cloud service.
-type ClientOption interface {
- // Resolve returns the equivalent option from the
- // google.golang.org/api/option package.
- Resolve() option.ClientOption
-}
-
-type wrapOpt struct {
- o option.ClientOption
-}
-
-func (w wrapOpt) Resolve() option.ClientOption {
- return w.o
-}
-
-// WithTokenSource returns a ClientOption that specifies an OAuth2 token
-// source to be used as the basis for authentication.
-func WithTokenSource(s oauth2.TokenSource) ClientOption {
- return wrapOpt{option.WithTokenSource(s)}
-}
-
-// WithEndpoint returns a ClientOption that overrides the default endpoint
-// to be used for a service.
-func WithEndpoint(url string) ClientOption {
- return wrapOpt{option.WithEndpoint(url)}
-}
-
-// WithScopes returns a ClientOption that overrides the default OAuth2 scopes
-// to be used for a service.
-func WithScopes(scope ...string) ClientOption {
- return wrapOpt{option.WithScopes(scope...)}
-}
-
-// WithUserAgent returns a ClientOption that sets the User-Agent.
-func WithUserAgent(ua string) ClientOption {
- return wrapOpt{option.WithUserAgent(ua)}
-}
-
-// WithBaseHTTP returns a ClientOption that specifies the HTTP client to
-// use as the basis of communications. This option may only be used with
-// services that support HTTP as their communication transport.
-func WithBaseHTTP(client *http.Client) ClientOption {
- return wrapOpt{option.WithHTTPClient(client)}
-}
-
-// WithBaseGRPC returns a ClientOption that specifies the gRPC client
-// connection to use as the basis of communications. This option many only be
-// used with services that support gRPC as their communication transport.
-func WithBaseGRPC(conn *grpc.ClientConn) ClientOption {
- return wrapOpt{option.WithGRPCConn(conn)}
-}
-
-// WithGRPCDialOption returns a ClientOption that appends a new grpc.DialOption
-// to an underlying gRPC dial. It does not work with WithBaseGRPC.
-func WithGRPCDialOption(o grpc.DialOption) ClientOption {
- return wrapOpt{option.WithGRPCDialOption(o)}
-}
-
-// WithGRPCConnectionPool returns a ClientOption that creates a pool of gRPC
-// connections that requests will be balanced between.
-// This is an EXPERIMENTAL API and may be changed or removed in the future.
-func WithGRPCConnectionPool(size int) ClientOption {
- return wrapOpt{option.WithGRPCConnectionPool(size)}
-}
diff --git a/vendor/google.golang.org/cloud/storage/acl.go b/vendor/google.golang.org/cloud/storage/acl.go
deleted file mode 100644
index e4d968b..0000000
--- a/vendor/google.golang.org/cloud/storage/acl.go
+++ /dev/null
@@ -1,198 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package storage
-
-import (
- "fmt"
-
- "golang.org/x/net/context"
- raw "google.golang.org/api/storage/v1"
-)
-
-// ACLRole is the level of access to grant.
-type ACLRole string
-
-const (
- RoleOwner ACLRole = "OWNER"
- RoleReader ACLRole = "READER"
-)
-
-// ACLEntity refers to a user or group.
-// They are sometimes referred to as grantees.
-//
-// It could be in the form of:
-// "user-<userId>", "user-<email>", "group-<groupId>", "group-<email>",
-// "domain-<domain>" and "project-team-<projectId>".
-//
-// Or one of the predefined constants: AllUsers, AllAuthenticatedUsers.
-type ACLEntity string
-
-const (
- AllUsers ACLEntity = "allUsers"
- AllAuthenticatedUsers ACLEntity = "allAuthenticatedUsers"
-)
-
-// ACLRule represents a grant for a role to an entity (user, group or team) for a Google Cloud Storage object or bucket.
-type ACLRule struct {
- Entity ACLEntity
- Role ACLRole
-}
-
-// ACLHandle provides operations on an access control list for a Google Cloud Storage bucket or object.
-type ACLHandle struct {
- c *Client
- bucket string
- object string
- isDefault bool
-}
-
-// Delete permanently deletes the ACL entry for the given entity.
-func (a *ACLHandle) Delete(ctx context.Context, entity ACLEntity) error {
- if a.object != "" {
- return a.objectDelete(ctx, entity)
- }
- if a.isDefault {
- return a.bucketDefaultDelete(ctx, entity)
- }
- return a.bucketDelete(ctx, entity)
-}
-
-// Set sets the permission level for the given entity.
-func (a *ACLHandle) Set(ctx context.Context, entity ACLEntity, role ACLRole) error {
- if a.object != "" {
- return a.objectSet(ctx, entity, role)
- }
- if a.isDefault {
- return a.bucketDefaultSet(ctx, entity, role)
- }
- return a.bucketSet(ctx, entity, role)
-}
-
-// List retrieves ACL entries.
-func (a *ACLHandle) List(ctx context.Context) ([]ACLRule, error) {
- if a.object != "" {
- return a.objectList(ctx)
- }
- if a.isDefault {
- return a.bucketDefaultList(ctx)
- }
- return a.bucketList(ctx)
-}
-
-func (a *ACLHandle) bucketDefaultList(ctx context.Context) ([]ACLRule, error) {
- acls, err := a.c.raw.DefaultObjectAccessControls.List(a.bucket).Context(ctx).Do()
- if err != nil {
- return nil, fmt.Errorf("storage: error listing default object ACL for bucket %q: %v", a.bucket, err)
- }
- return toACLRules(acls.Items), nil
-}
-
-func (a *ACLHandle) bucketDefaultSet(ctx context.Context, entity ACLEntity, role ACLRole) error {
- acl := &raw.ObjectAccessControl{
- Bucket: a.bucket,
- Entity: string(entity),
- Role: string(role),
- }
- _, err := a.c.raw.DefaultObjectAccessControls.Update(a.bucket, string(entity), acl).Context(ctx).Do()
- if err != nil {
- return fmt.Errorf("storage: error updating default ACL entry for bucket %q, entity %q: %v", a.bucket, entity, err)
- }
- return nil
-}
-
-func (a *ACLHandle) bucketDefaultDelete(ctx context.Context, entity ACLEntity) error {
- err := a.c.raw.DefaultObjectAccessControls.Delete(a.bucket, string(entity)).Context(ctx).Do()
- if err != nil {
- return fmt.Errorf("storage: error deleting default ACL entry for bucket %q, entity %q: %v", a.bucket, entity, err)
- }
- return nil
-}
-
-func (a *ACLHandle) bucketList(ctx context.Context) ([]ACLRule, error) {
- acls, err := a.c.raw.BucketAccessControls.List(a.bucket).Context(ctx).Do()
- if err != nil {
- return nil, fmt.Errorf("storage: error listing bucket ACL for bucket %q: %v", a.bucket, err)
- }
- r := make([]ACLRule, len(acls.Items))
- for i, v := range acls.Items {
- r[i].Entity = ACLEntity(v.Entity)
- r[i].Role = ACLRole(v.Role)
- }
- return r, nil
-}
-
-func (a *ACLHandle) bucketSet(ctx context.Context, entity ACLEntity, role ACLRole) error {
- acl := &raw.BucketAccessControl{
- Bucket: a.bucket,
- Entity: string(entity),
- Role: string(role),
- }
- _, err := a.c.raw.BucketAccessControls.Update(a.bucket, string(entity), acl).Context(ctx).Do()
- if err != nil {
- return fmt.Errorf("storage: error updating bucket ACL entry for bucket %q, entity %q: %v", a.bucket, entity, err)
- }
- return nil
-}
-
-func (a *ACLHandle) bucketDelete(ctx context.Context, entity ACLEntity) error {
- err := a.c.raw.BucketAccessControls.Delete(a.bucket, string(entity)).Context(ctx).Do()
- if err != nil {
- return fmt.Errorf("storage: error deleting bucket ACL entry for bucket %q, entity %q: %v", a.bucket, entity, err)
- }
- return nil
-}
-
-func (a *ACLHandle) objectList(ctx context.Context) ([]ACLRule, error) {
- acls, err := a.c.raw.ObjectAccessControls.List(a.bucket, a.object).Context(ctx).Do()
- if err != nil {
- return nil, fmt.Errorf("storage: error listing object ACL for bucket %q, file %q: %v", a.bucket, a.object, err)
- }
- return toACLRules(acls.Items), nil
-}
-
-func (a *ACLHandle) objectSet(ctx context.Context, entity ACLEntity, role ACLRole) error {
- acl := &raw.ObjectAccessControl{
- Bucket: a.bucket,
- Entity: string(entity),
- Role: string(role),
- }
- _, err := a.c.raw.ObjectAccessControls.Update(a.bucket, a.object, string(entity), acl).Context(ctx).Do()
- if err != nil {
- return fmt.Errorf("storage: error updating object ACL entry for bucket %q, file %q, entity %q: %v", a.bucket, a.object, entity, err)
- }
- return nil
-}
-
-func (a *ACLHandle) objectDelete(ctx context.Context, entity ACLEntity) error {
- err := a.c.raw.ObjectAccessControls.Delete(a.bucket, a.object, string(entity)).Context(ctx).Do()
- if err != nil {
- return fmt.Errorf("storage: error deleting object ACL entry for bucket %q, file %q, entity %q: %v", a.bucket, a.object, entity, err)
- }
- return nil
-}
-
-func toACLRules(items []interface{}) []ACLRule {
- r := make([]ACLRule, 0, len(items))
- for _, v := range items {
- if m, ok := v.(map[string]interface{}); ok {
- entity, ok1 := m["entity"].(string)
- role, ok2 := m["role"].(string)
- if ok1 && ok2 {
- r = append(r, ACLRule{Entity: ACLEntity(entity), Role: ACLRole(role)})
- }
- }
- }
- return r
-}
diff --git a/vendor/google.golang.org/cloud/storage/reader.go b/vendor/google.golang.org/cloud/storage/reader.go
deleted file mode 100644
index 9e21648..0000000
--- a/vendor/google.golang.org/cloud/storage/reader.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package storage
-
-import (
- "io"
-)
-
-// Reader reads a Cloud Storage object.
-type Reader struct {
- body io.ReadCloser
- remain, size int64
- contentType string
-}
-
-func (r *Reader) Close() error {
- return r.body.Close()
-}
-
-func (r *Reader) Read(p []byte) (int, error) {
- n, err := r.body.Read(p)
- if r.remain != -1 {
- r.remain -= int64(n)
- }
- return n, err
-}
-
-// Size returns the size of the object in bytes.
-// The returned value is always the same and is not affected by
-// calls to Read or Close.
-func (r *Reader) Size() int64 {
- return r.size
-}
-
-// Remain returns the number of bytes left to read, or -1 if unknown.
-func (r *Reader) Remain() int64 {
- return r.remain
-}
-
-// ContentType returns the content type of the object.
-func (r *Reader) ContentType() string {
- return r.contentType
-}
diff --git a/vendor/google.golang.org/cloud/storage/storage.go b/vendor/google.golang.org/cloud/storage/storage.go
deleted file mode 100644
index 85dca80..0000000
--- a/vendor/google.golang.org/cloud/storage/storage.go
+++ /dev/null
@@ -1,1204 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package storage contains a Google Cloud Storage client.
-//
-// This package is experimental and may make backwards-incompatible changes.
-package storage // import "google.golang.org/cloud/storage"
-
-import (
- "bytes"
- "crypto"
- "crypto/rand"
- "crypto/rsa"
- "crypto/sha256"
- "crypto/x509"
- "encoding/base64"
- "encoding/pem"
- "errors"
- "fmt"
- "io"
- "io/ioutil"
- "net/http"
- "net/url"
- "reflect"
- "strconv"
- "strings"
- "time"
- "unicode/utf8"
-
- "google.golang.org/cloud"
- "google.golang.org/cloud/internal/transport"
-
- "golang.org/x/net/context"
- "google.golang.org/api/googleapi"
- raw "google.golang.org/api/storage/v1"
-)
-
-var (
- ErrBucketNotExist = errors.New("storage: bucket doesn't exist")
- ErrObjectNotExist = errors.New("storage: object doesn't exist")
-
- // Done is returned by iterators in this package when they have no more items.
- Done = errors.New("storage: no more results")
-)
-
-const userAgent = "gcloud-golang-storage/20151204"
-
-const (
- // ScopeFullControl grants permissions to manage your
- // data and permissions in Google Cloud Storage.
- ScopeFullControl = raw.DevstorageFullControlScope
-
- // ScopeReadOnly grants permissions to
- // view your data in Google Cloud Storage.
- ScopeReadOnly = raw.DevstorageReadOnlyScope
-
- // ScopeReadWrite grants permissions to manage your
- // data in Google Cloud Storage.
- ScopeReadWrite = raw.DevstorageReadWriteScope
-)
-
-// AdminClient is a client type for performing admin operations on a project's
-// buckets.
-//
-// Deprecated: Client has all of AdminClient's methods.
-type AdminClient struct {
- c *Client
- projectID string
-}
-
-// NewAdminClient creates a new AdminClient for a given project.
-//
-// Deprecated: use NewClient instead.
-func NewAdminClient(ctx context.Context, projectID string, opts ...cloud.ClientOption) (*AdminClient, error) {
- c, err := NewClient(ctx, opts...)
- if err != nil {
- return nil, err
- }
- return &AdminClient{
- c: c,
- projectID: projectID,
- }, nil
-}
-
-// Close closes the AdminClient.
-func (c *AdminClient) Close() error {
- return c.c.Close()
-}
-
-// Create creates a Bucket in the project.
-// If attrs is nil the API defaults will be used.
-//
-// Deprecated: use BucketHandle.Create instead.
-func (c *AdminClient) CreateBucket(ctx context.Context, bucketName string, attrs *BucketAttrs) error {
- return c.c.Bucket(bucketName).Create(ctx, c.projectID, attrs)
-}
-
-// Delete deletes a Bucket in the project.
-//
-// Deprecated: use BucketHandle.Delete instead.
-func (c *AdminClient) DeleteBucket(ctx context.Context, bucketName string) error {
- return c.c.Bucket(bucketName).Delete(ctx)
-}
-
-// Client is a client for interacting with Google Cloud Storage.
-type Client struct {
- hc *http.Client
- raw *raw.Service
-}
-
-// NewClient creates a new Google Cloud Storage client.
-// The default scope is ScopeFullControl. To use a different scope, like ScopeReadOnly, use cloud.WithScopes.
-func NewClient(ctx context.Context, opts ...cloud.ClientOption) (*Client, error) {
- o := []cloud.ClientOption{
- cloud.WithScopes(ScopeFullControl),
- cloud.WithUserAgent(userAgent),
- }
- opts = append(o, opts...)
- hc, _, err := transport.NewHTTPClient(ctx, opts...)
- if err != nil {
- return nil, fmt.Errorf("dialing: %v", err)
- }
- rawService, err := raw.New(hc)
- if err != nil {
- return nil, fmt.Errorf("storage client: %v", err)
- }
- return &Client{
- hc: hc,
- raw: rawService,
- }, nil
-}
-
-// Close closes the Client.
-func (c *Client) Close() error {
- c.hc = nil
- return nil
-}
-
-// BucketHandle provides operations on a Google Cloud Storage bucket.
-// Use Client.Bucket to get a handle.
-type BucketHandle struct {
- acl *ACLHandle
- defaultObjectACL *ACLHandle
-
- c *Client
- name string
-}
-
-// Bucket returns a BucketHandle, which provides operations on the named bucket.
-// This call does not perform any network operations.
-//
-// name must contain only lowercase letters, numbers, dashes, underscores, and
-// dots. The full specification for valid bucket names can be found at:
-// https://cloud.google.com/storage/docs/bucket-naming
-func (c *Client) Bucket(name string) *BucketHandle {
- return &BucketHandle{
- c: c,
- name: name,
- acl: &ACLHandle{
- c: c,
- bucket: name,
- },
- defaultObjectACL: &ACLHandle{
- c: c,
- bucket: name,
- isDefault: true,
- },
- }
-}
-
-// Create creates the Bucket in the project.
-// If attrs is nil the API defaults will be used.
-func (b *BucketHandle) Create(ctx context.Context, projectID string, attrs *BucketAttrs) error {
- var bkt *raw.Bucket
- if attrs != nil {
- bkt = attrs.toRawBucket()
- } else {
- bkt = &raw.Bucket{}
- }
- bkt.Name = b.name
- req := b.c.raw.Buckets.Insert(projectID, bkt)
- _, err := req.Context(ctx).Do()
- return err
-}
-
-// Delete deletes the Bucket.
-func (b *BucketHandle) Delete(ctx context.Context) error {
- req := b.c.raw.Buckets.Delete(b.name)
- return req.Context(ctx).Do()
-}
-
-// ACL returns an ACLHandle, which provides access to the bucket's access control list.
-// This controls who can list, create or overwrite the objects in a bucket.
-// This call does not perform any network operations.
-func (c *BucketHandle) ACL() *ACLHandle {
- return c.acl
-}
-
-// DefaultObjectACL returns an ACLHandle, which provides access to the bucket's default object ACLs.
-// These ACLs are applied to newly created objects in this bucket that do not have a defined ACL.
-// This call does not perform any network operations.
-func (c *BucketHandle) DefaultObjectACL() *ACLHandle {
- return c.defaultObjectACL
-}
-
-// Object returns an ObjectHandle, which provides operations on the named object.
-// This call does not perform any network operations.
-//
-// name must consist entirely of valid UTF-8-encoded runes. The full specification
-// for valid object names can be found at:
-// https://cloud.google.com/storage/docs/bucket-naming
-func (b *BucketHandle) Object(name string) *ObjectHandle {
- return &ObjectHandle{
- c: b.c,
- bucket: b.name,
- object: name,
- acl: &ACLHandle{
- c: b.c,
- bucket: b.name,
- object: name,
- },
- }
-}
-
-// TODO(jbd): Add storage.buckets.list.
-// TODO(jbd): Add storage.buckets.update.
-
-// TODO(jbd): Add storage.objects.watch.
-
-// Attrs returns the metadata for the bucket.
-func (b *BucketHandle) Attrs(ctx context.Context) (*BucketAttrs, error) {
- resp, err := b.c.raw.Buckets.Get(b.name).Projection("full").Context(ctx).Do()
- if e, ok := err.(*googleapi.Error); ok && e.Code == http.StatusNotFound {
- return nil, ErrBucketNotExist
- }
- if err != nil {
- return nil, err
- }
- return newBucket(resp), nil
-}
-
-// List lists objects from the bucket. You can specify a query
-// to filter the results. If q is nil, no filtering is applied.
-//
-// Deprecated. Use BucketHandle.Objects instead.
-func (b *BucketHandle) List(ctx context.Context, q *Query) (*ObjectList, error) {
- it := b.Objects(ctx, q)
- attrs, pres, err := it.NextPage()
- if err != nil && err != Done {
- return nil, err
- }
- objects := &ObjectList{
- Results: attrs,
- Prefixes: pres,
- }
- if it.NextPageToken() != "" {
- objects.Next = &it.query
- }
- return objects, nil
-}
-
-func (b *BucketHandle) Objects(ctx context.Context, q *Query) *ObjectIterator {
- it := &ObjectIterator{
- ctx: ctx,
- bucket: b,
- }
- if q != nil {
- it.query = *q
- }
- return it
-}
-
-type ObjectIterator struct {
- ctx context.Context
- bucket *BucketHandle
- query Query
- pageSize int32
- objs []*ObjectAttrs
- prefixes []string
- err error
-}
-
-// Next returns the next result. Its second return value is Done if there are
-// no more results. Once Next returns Done, all subsequent calls will return
-// Done.
-//
-// Internally, Next retrieves results in bulk. You can call SetPageSize as a
-// performance hint to affect how many results are retrieved in a single RPC.
-//
-// SetPageToken should not be called when using Next.
-//
-// Next and NextPage should not be used with the same iterator.
-//
-// If Query.Delimiter is non-empty, Next returns an error. Use NextPage when using delimiters.
-func (it *ObjectIterator) Next() (*ObjectAttrs, error) {
- if it.query.Delimiter != "" {
- return nil, errors.New("cannot use ObjectIterator.Next with a delimiter")
- }
- for len(it.objs) == 0 { // "for", not "if", to handle empty pages
- if it.err != nil {
- return nil, it.err
- }
- it.nextPage()
- if it.err != nil {
- it.objs = nil
- return nil, it.err
- }
- if it.query.Cursor == "" {
- it.err = Done
- }
- }
- o := it.objs[0]
- it.objs = it.objs[1:]
- return o, nil
-}
-
-const DefaultPageSize = 1000
-
-// NextPage returns the next page of results, both objects (as *ObjectAttrs)
-// and prefixes. Prefixes will be nil if query.Delimiter is empty.
-//
-// NextPage will return exactly the number of results (the total of objects and
-// prefixes) specified by the last call to SetPageSize, unless there are not
-// enough results available. If no page size was specified, it uses
-// DefaultPageSize.
-//
-// NextPage may return a second return value of Done along with the last page
-// of results.
-//
-// After NextPage returns Done, all subsequent calls to NextPage will return
-// (nil, Done).
-//
-// Next and NextPage should not be used with the same iterator.
-func (it *ObjectIterator) NextPage() (objs []*ObjectAttrs, prefixes []string, err error) {
- defer it.SetPageSize(it.pageSize) // restore value at entry
- if it.pageSize <= 0 {
- it.pageSize = DefaultPageSize
- }
- for len(objs)+len(prefixes) < int(it.pageSize) {
- it.pageSize -= int32(len(objs) + len(prefixes))
- it.nextPage()
- if it.err != nil {
- return nil, nil, it.err
- }
- objs = append(objs, it.objs...)
- prefixes = append(prefixes, it.prefixes...)
- if it.query.Cursor == "" {
- it.err = Done
- return objs, prefixes, it.err
- }
- }
- return objs, prefixes, it.err
-}
-
-// nextPage gets the next page of results by making a single call to the underlying method.
-// It sets it.objs, it.prefixes, it.query.Cursor, and it.err. It never sets it.err to Done.
-func (it *ObjectIterator) nextPage() {
- if it.err != nil {
- return
- }
- req := it.bucket.c.raw.Objects.List(it.bucket.name)
- req.Projection("full")
- req.Delimiter(it.query.Delimiter)
- req.Prefix(it.query.Prefix)
- req.Versions(it.query.Versions)
- req.PageToken(it.query.Cursor)
- if it.pageSize > 0 {
- req.MaxResults(int64(it.pageSize))
- }
- resp, err := req.Context(it.ctx).Do()
- if err != nil {
- it.err = err
- return
- }
- it.query.Cursor = resp.NextPageToken
- it.objs = nil
- for _, item := range resp.Items {
- it.objs = append(it.objs, newObject(item))
- }
- it.prefixes = resp.Prefixes
-}
-
-// SetPageSize sets the page size for all subsequent calls to NextPage.
-// NextPage will return exactly this many items if they are present.
-func (it *ObjectIterator) SetPageSize(pageSize int32) {
- it.pageSize = pageSize
-}
-
-// SetPageToken sets the page token for the next call to NextPage, to resume
-// the iteration from a previous point.
-func (it *ObjectIterator) SetPageToken(t string) {
- it.query.Cursor = t
-}
-
-// NextPageToken returns a page token that can be used with SetPageToken to
-// resume iteration from the next page. It returns the empty string if there
-// are no more pages. For an example, see SetPageToken.
-func (it *ObjectIterator) NextPageToken() string {
- return it.query.Cursor
-}
-
-// SignedURLOptions allows you to restrict the access to the signed URL.
-type SignedURLOptions struct {
- // GoogleAccessID represents the authorizer of the signed URL generation.
- // It is typically the Google service account client email address from
- // the Google Developers Console in the form of "xxx@developer.gserviceaccount.com".
- // Required.
- GoogleAccessID string
-
- // PrivateKey is the Google service account private key. It is obtainable
- // from the Google Developers Console.
- // At https://console.developers.google.com/project/<your-project-id>/apiui/credential,
- // create a service account client ID or reuse one of your existing service account
- // credentials. Click on the "Generate new P12 key" to generate and download
- // a new private key. Once you download the P12 file, use the following command
- // to convert it into a PEM file.
- //
- // $ openssl pkcs12 -in key.p12 -passin pass:notasecret -out key.pem -nodes
- //
- // Provide the contents of the PEM file as a byte slice.
- // Exactly one of PrivateKey or SignBytes must be non-nil.
- PrivateKey []byte
-
- // SignBytes is a function for implementing custom signing.
- // If your application is running on Google App Engine, you can use appengine's internal signing function:
- // ctx := appengine.NewContext(request)
- // acc, _ := appengine.ServiceAccount(ctx)
- // url, err := SignedURL("bucket", "object", &SignedURLOptions{
- // GoogleAccessID: acc,
- // SignBytes: func(b []byte) ([]byte, error) {
- // _, signedBytes, err := appengine.SignBytes(ctx, b)
- // return signedBytes, err
- // },
- // // etc.
- // })
- //
- // Exactly one of PrivateKey or SignBytes must be non-nil.
- SignBytes func([]byte) ([]byte, error)
-
- // Method is the HTTP method to be used with the signed URL.
- // Signed URLs can be used with GET, HEAD, PUT, and DELETE requests.
- // Required.
- Method string
-
- // Expires is the expiration time on the signed URL. It must be
- // a datetime in the future.
- // Required.
- Expires time.Time
-
- // ContentType is the content type header the client must provide
- // to use the generated signed URL.
- // Optional.
- ContentType string
-
- // Headers is a list of extention headers the client must provide
- // in order to use the generated signed URL.
- // Optional.
- Headers []string
-
- // MD5 is the base64 encoded MD5 checksum of the file.
- // If provided, the client should provide the exact value on the request
- // header in order to use the signed URL.
- // Optional.
- MD5 []byte
-}
-
-// SignedURL returns a URL for the specified object. Signed URLs allow
-// the users access to a restricted resource for a limited time without having a
-// Google account or signing in. For more information about the signed
-// URLs, see https://cloud.google.com/storage/docs/accesscontrol#Signed-URLs.
-func SignedURL(bucket, name string, opts *SignedURLOptions) (string, error) {
- if opts == nil {
- return "", errors.New("storage: missing required SignedURLOptions")
- }
- if opts.GoogleAccessID == "" {
- return "", errors.New("storage: missing required GoogleAccessID")
- }
- if (opts.PrivateKey == nil) == (opts.SignBytes == nil) {
- return "", errors.New("storage: exactly one of PrivateKey or SignedBytes must be set")
- }
- if opts.Method == "" {
- return "", errors.New("storage: missing required method option")
- }
- if opts.Expires.IsZero() {
- return "", errors.New("storage: missing required expires option")
- }
-
- signBytes := opts.SignBytes
- if opts.PrivateKey != nil {
- key, err := parseKey(opts.PrivateKey)
- if err != nil {
- return "", err
- }
- signBytes = func(b []byte) ([]byte, error) {
- sum := sha256.Sum256(b)
- return rsa.SignPKCS1v15(
- rand.Reader,
- key,
- crypto.SHA256,
- sum[:],
- )
- }
- } else {
- signBytes = opts.SignBytes
- }
-
- u := &url.URL{
- Path: fmt.Sprintf("/%s/%s", bucket, name),
- }
-
- buf := &bytes.Buffer{}
- fmt.Fprintf(buf, "%s\n", opts.Method)
- fmt.Fprintf(buf, "%s\n", opts.MD5)
- fmt.Fprintf(buf, "%s\n", opts.ContentType)
- fmt.Fprintf(buf, "%d\n", opts.Expires.Unix())
- fmt.Fprintf(buf, "%s", strings.Join(opts.Headers, "\n"))
- fmt.Fprintf(buf, "%s", u.String())
-
- b, err := signBytes(buf.Bytes())
- if err != nil {
- return "", err
- }
- encoded := base64.StdEncoding.EncodeToString(b)
- u.Scheme = "https"
- u.Host = "storage.googleapis.com"
- q := u.Query()
- q.Set("GoogleAccessId", opts.GoogleAccessID)
- q.Set("Expires", fmt.Sprintf("%d", opts.Expires.Unix()))
- q.Set("Signature", string(encoded))
- u.RawQuery = q.Encode()
- return u.String(), nil
-}
-
-// ObjectHandle provides operations on an object in a Google Cloud Storage bucket.
-// Use BucketHandle.Object to get a handle.
-type ObjectHandle struct {
- c *Client
- bucket string
- object string
-
- acl *ACLHandle
- conds []Condition
-}
-
-// ACL provides access to the object's access control list.
-// This controls who can read and write this object.
-// This call does not perform any network operations.
-func (o *ObjectHandle) ACL() *ACLHandle {
- return o.acl
-}
-
-// WithConditions returns a copy of o using the provided conditions.
-func (o *ObjectHandle) WithConditions(conds ...Condition) *ObjectHandle {
- o2 := *o
- o2.conds = conds
- return &o2
-}
-
-// Attrs returns meta information about the object.
-// ErrObjectNotExist will be returned if the object is not found.
-func (o *ObjectHandle) Attrs(ctx context.Context) (*ObjectAttrs, error) {
- if !utf8.ValidString(o.object) {
- return nil, fmt.Errorf("storage: object name %q is not valid UTF-8", o.object)
- }
- call := o.c.raw.Objects.Get(o.bucket, o.object).Projection("full").Context(ctx)
- if err := applyConds("Attrs", o.conds, call); err != nil {
- return nil, err
- }
- obj, err := call.Do()
- if e, ok := err.(*googleapi.Error); ok && e.Code == http.StatusNotFound {
- return nil, ErrObjectNotExist
- }
- if err != nil {
- return nil, err
- }
- return newObject(obj), nil
-}
-
-// Update updates an object with the provided attributes.
-// All zero-value attributes are ignored.
-// ErrObjectNotExist will be returned if the object is not found.
-func (o *ObjectHandle) Update(ctx context.Context, attrs ObjectAttrs) (*ObjectAttrs, error) {
- if !utf8.ValidString(o.object) {
- return nil, fmt.Errorf("storage: object name %q is not valid UTF-8", o.object)
- }
- call := o.c.raw.Objects.Patch(o.bucket, o.object, attrs.toRawObject(o.bucket)).Projection("full").Context(ctx)
- if err := applyConds("Update", o.conds, call); err != nil {
- return nil, err
- }
- obj, err := call.Do()
- if e, ok := err.(*googleapi.Error); ok && e.Code == http.StatusNotFound {
- return nil, ErrObjectNotExist
- }
- if err != nil {
- return nil, err
- }
- return newObject(obj), nil
-}
-
-// Delete deletes the single specified object.
-func (o *ObjectHandle) Delete(ctx context.Context) error {
- if !utf8.ValidString(o.object) {
- return fmt.Errorf("storage: object name %q is not valid UTF-8", o.object)
- }
- call := o.c.raw.Objects.Delete(o.bucket, o.object).Context(ctx)
- if err := applyConds("Delete", o.conds, call); err != nil {
- return err
- }
- err := call.Do()
- switch e := err.(type) {
- case nil:
- return nil
- case *googleapi.Error:
- if e.Code == http.StatusNotFound {
- return ErrObjectNotExist
- }
- }
- return err
-}
-
-// CopyTo copies the object to the given dst.
-// The copied object's attributes are overwritten by attrs if non-nil.
-func (o *ObjectHandle) CopyTo(ctx context.Context, dst *ObjectHandle, attrs *ObjectAttrs) (*ObjectAttrs, error) {
- // TODO(djd): move bucket/object name validation to a single helper func.
- if o.bucket == "" || dst.bucket == "" {
- return nil, errors.New("storage: the source and destination bucket names must both be non-empty")
- }
- if o.object == "" || dst.object == "" {
- return nil, errors.New("storage: the source and destination object names must both be non-empty")
- }
- if !utf8.ValidString(o.object) {
- return nil, fmt.Errorf("storage: object name %q is not valid UTF-8", o.object)
- }
- if !utf8.ValidString(dst.object) {
- return nil, fmt.Errorf("storage: dst name %q is not valid UTF-8", dst.object)
- }
- var rawObject *raw.Object
- if attrs != nil {
- attrs.Name = dst.object
- if attrs.ContentType == "" {
- return nil, errors.New("storage: attrs.ContentType must be non-empty")
- }
- rawObject = attrs.toRawObject(dst.bucket)
- }
- call := o.c.raw.Objects.Copy(o.bucket, o.object, dst.bucket, dst.object, rawObject).Projection("full").Context(ctx)
- if err := applyConds("CopyTo destination", dst.conds, call); err != nil {
- return nil, err
- }
- if err := applyConds("CopyTo source", toSourceConds(o.conds), call); err != nil {
- return nil, err
- }
- obj, err := call.Do()
- if err != nil {
- return nil, err
- }
- return newObject(obj), nil
-}
-
-// NewReader creates a new Reader to read the contents of the
-// object.
-// ErrObjectNotExist will be returned if the object is not found.
-func (o *ObjectHandle) NewReader(ctx context.Context) (*Reader, error) {
- return o.NewRangeReader(ctx, 0, -1)
-}
-
-// NewRangeReader reads part of an object, reading at most length bytes
-// starting at the given offset. If length is negative, the object is read
-// until the end.
-func (o *ObjectHandle) NewRangeReader(ctx context.Context, offset, length int64) (*Reader, error) {
- if !utf8.ValidString(o.object) {
- return nil, fmt.Errorf("storage: object name %q is not valid UTF-8", o.object)
- }
- if offset < 0 {
- return nil, fmt.Errorf("storage: invalid offset %d < 0", offset)
- }
- u := &url.URL{
- Scheme: "https",
- Host: "storage.googleapis.com",
- Path: fmt.Sprintf("/%s/%s", o.bucket, o.object),
- }
- verb := "GET"
- if length == 0 {
- verb = "HEAD"
- }
- req, err := http.NewRequest(verb, u.String(), nil)
- if err != nil {
- return nil, err
- }
- if err := applyConds("NewReader", o.conds, objectsGetCall{req}); err != nil {
- return nil, err
- }
- if length < 0 && offset > 0 {
- req.Header.Set("Range", fmt.Sprintf("bytes=%d-", offset))
- } else if length > 0 {
- req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", offset, offset+length-1))
- }
- res, err := o.c.hc.Do(req)
- if err != nil {
- return nil, err
- }
- if res.StatusCode == http.StatusNotFound {
- res.Body.Close()
- return nil, ErrObjectNotExist
- }
- if res.StatusCode < 200 || res.StatusCode > 299 {
- body, _ := ioutil.ReadAll(res.Body)
- res.Body.Close()
- return nil, &googleapi.Error{
- Code: res.StatusCode,
- Header: res.Header,
- Body: string(body),
- }
- }
- if offset > 0 && length != 0 && res.StatusCode != http.StatusPartialContent {
- res.Body.Close()
- return nil, errors.New("storage: partial request not satisfied")
- }
- clHeader := res.Header.Get("X-Goog-Stored-Content-Length")
- cl, err := strconv.ParseInt(clHeader, 10, 64)
- if err != nil {
- return nil, fmt.Errorf("storage: can't parse content length %q: %v", clHeader, err)
- }
- remain := res.ContentLength
- body := res.Body
- if length == 0 {
- remain = 0
- body.Close()
- body = emptyBody
- }
- return &Reader{
- body: body,
- size: cl,
- remain: remain,
- contentType: res.Header.Get("Content-Type"),
- }, nil
-}
-
-var emptyBody = ioutil.NopCloser(strings.NewReader(""))
-
-// NewWriter returns a storage Writer that writes to the GCS object
-// associated with this ObjectHandle.
-//
-// A new object will be created if an object with this name already exists.
-// Otherwise any previous object with the same name will be replaced.
-// The object will not be available (and any previous object will remain)
-// until Close has been called.
-//
-// Attributes can be set on the object by modifying the returned Writer's
-// ObjectAttrs field before the first call to Write. If no ContentType
-// attribute is specified, the content type will be automatically sniffed
-// using net/http.DetectContentType.
-//
-// It is the caller's responsibility to call Close when writing is done.
-func (o *ObjectHandle) NewWriter(ctx context.Context) *Writer {
- return &Writer{
- ctx: ctx,
- o: o,
- donec: make(chan struct{}),
- ObjectAttrs: ObjectAttrs{Name: o.object},
- }
-}
-
-// parseKey converts the binary contents of a private key file
-// to an *rsa.PrivateKey. It detects whether the private key is in a
-// PEM container or not. If so, it extracts the the private key
-// from PEM container before conversion. It only supports PEM
-// containers with no passphrase.
-func parseKey(key []byte) (*rsa.PrivateKey, error) {
- if block, _ := pem.Decode(key); block != nil {
- key = block.Bytes
- }
- parsedKey, err := x509.ParsePKCS8PrivateKey(key)
- if err != nil {
- parsedKey, err = x509.ParsePKCS1PrivateKey(key)
- if err != nil {
- return nil, err
- }
- }
- parsed, ok := parsedKey.(*rsa.PrivateKey)
- if !ok {
- return nil, errors.New("oauth2: private key is invalid")
- }
- return parsed, nil
-}
-
-// BucketAttrs represents the metadata for a Google Cloud Storage bucket.
-type BucketAttrs struct {
- // Name is the name of the bucket.
- Name string
-
- // ACL is the list of access control rules on the bucket.
- ACL []ACLRule
-
- // DefaultObjectACL is the list of access controls to
- // apply to new objects when no object ACL is provided.
- DefaultObjectACL []ACLRule
-
- // Location is the location of the bucket. It defaults to "US".
- Location string
-
- // MetaGeneration is the metadata generation of the bucket.
- MetaGeneration int64
-
- // StorageClass is the storage class of the bucket. This defines
- // how objects in the bucket are stored and determines the SLA
- // and the cost of storage. Typical values are "STANDARD" and
- // "DURABLE_REDUCED_AVAILABILITY". Defaults to "STANDARD".
- StorageClass string
-
- // Created is the creation time of the bucket.
- Created time.Time
-}
-
-func newBucket(b *raw.Bucket) *BucketAttrs {
- if b == nil {
- return nil
- }
- bucket := &BucketAttrs{
- Name: b.Name,
- Location: b.Location,
- MetaGeneration: b.Metageneration,
- StorageClass: b.StorageClass,
- Created: convertTime(b.TimeCreated),
- }
- acl := make([]ACLRule, len(b.Acl))
- for i, rule := range b.Acl {
- acl[i] = ACLRule{
- Entity: ACLEntity(rule.Entity),
- Role: ACLRole(rule.Role),
- }
- }
- bucket.ACL = acl
- objACL := make([]ACLRule, len(b.DefaultObjectAcl))
- for i, rule := range b.DefaultObjectAcl {
- objACL[i] = ACLRule{
- Entity: ACLEntity(rule.Entity),
- Role: ACLRole(rule.Role),
- }
- }
- bucket.DefaultObjectACL = objACL
- return bucket
-}
-
-func toRawObjectACL(oldACL []ACLRule) []*raw.ObjectAccessControl {
- var acl []*raw.ObjectAccessControl
- if len(oldACL) > 0 {
- acl = make([]*raw.ObjectAccessControl, len(oldACL))
- for i, rule := range oldACL {
- acl[i] = &raw.ObjectAccessControl{
- Entity: string(rule.Entity),
- Role: string(rule.Role),
- }
- }
- }
- return acl
-}
-
-// toRawBucket copies the editable attribute from b to the raw library's Bucket type.
-func (b *BucketAttrs) toRawBucket() *raw.Bucket {
- var acl []*raw.BucketAccessControl
- if len(b.ACL) > 0 {
- acl = make([]*raw.BucketAccessControl, len(b.ACL))
- for i, rule := range b.ACL {
- acl[i] = &raw.BucketAccessControl{
- Entity: string(rule.Entity),
- Role: string(rule.Role),
- }
- }
- }
- dACL := toRawObjectACL(b.DefaultObjectACL)
- return &raw.Bucket{
- Name: b.Name,
- DefaultObjectAcl: dACL,
- Location: b.Location,
- StorageClass: b.StorageClass,
- Acl: acl,
- }
-}
-
-// toRawObject copies the editable attributes from o to the raw library's Object type.
-func (o ObjectAttrs) toRawObject(bucket string) *raw.Object {
- acl := toRawObjectACL(o.ACL)
- return &raw.Object{
- Bucket: bucket,
- Name: o.Name,
- ContentType: o.ContentType,
- ContentEncoding: o.ContentEncoding,
- ContentLanguage: o.ContentLanguage,
- CacheControl: o.CacheControl,
- ContentDisposition: o.ContentDisposition,
- Acl: acl,
- Metadata: o.Metadata,
- }
-}
-
-// ObjectAttrs represents the metadata for a Google Cloud Storage (GCS) object.
-type ObjectAttrs struct {
- // Bucket is the name of the bucket containing this GCS object.
- // This field is read-only.
- Bucket string
-
- // Name is the name of the object within the bucket.
- // This field is read-only.
- Name string
-
- // ContentType is the MIME type of the object's content.
- ContentType string
-
- // ContentLanguage is the content language of the object's content.
- ContentLanguage string
-
- // CacheControl is the Cache-Control header to be sent in the response
- // headers when serving the object data.
- CacheControl string
-
- // ACL is the list of access control rules for the object.
- ACL []ACLRule
-
- // Owner is the owner of the object. This field is read-only.
- //
- // If non-zero, it is in the form of "user-<userId>".
- Owner string
-
- // Size is the length of the object's content. This field is read-only.
- Size int64
-
- // ContentEncoding is the encoding of the object's content.
- ContentEncoding string
-
- // ContentDisposition is the optional Content-Disposition header of the object
- // sent in the response headers.
- ContentDisposition string
-
- // MD5 is the MD5 hash of the object's content. This field is read-only.
- MD5 []byte
-
- // CRC32C is the CRC32 checksum of the object's content using
- // the Castagnoli93 polynomial. This field is read-only.
- CRC32C uint32
-
- // MediaLink is an URL to the object's content. This field is read-only.
- MediaLink string
-
- // Metadata represents user-provided metadata, in key/value pairs.
- // It can be nil if no metadata is provided.
- Metadata map[string]string
-
- // Generation is the generation number of the object's content.
- // This field is read-only.
- Generation int64
-
- // MetaGeneration is the version of the metadata for this
- // object at this generation. This field is used for preconditions
- // and for detecting changes in metadata. A metageneration number
- // is only meaningful in the context of a particular generation
- // of a particular object. This field is read-only.
- MetaGeneration int64
-
- // StorageClass is the storage class of the bucket.
- // This value defines how objects in the bucket are stored and
- // determines the SLA and the cost of storage. Typical values are
- // "STANDARD" and "DURABLE_REDUCED_AVAILABILITY".
- // It defaults to "STANDARD". This field is read-only.
- StorageClass string
-
- // Created is the time the object was created. This field is read-only.
- Created time.Time
-
- // Deleted is the time the object was deleted.
- // If not deleted, it is the zero value. This field is read-only.
- Deleted time.Time
-
- // Updated is the creation or modification time of the object.
- // For buckets with versioning enabled, changing an object's
- // metadata does not change this property. This field is read-only.
- Updated time.Time
-}
-
-// convertTime converts a time in RFC3339 format to time.Time.
-// If any error occurs in parsing, the zero-value time.Time is silently returned.
-func convertTime(t string) time.Time {
- var r time.Time
- if t != "" {
- r, _ = time.Parse(time.RFC3339, t)
- }
- return r
-}
-
-func newObject(o *raw.Object) *ObjectAttrs {
- if o == nil {
- return nil
- }
- acl := make([]ACLRule, len(o.Acl))
- for i, rule := range o.Acl {
- acl[i] = ACLRule{
- Entity: ACLEntity(rule.Entity),
- Role: ACLRole(rule.Role),
- }
- }
- owner := ""
- if o.Owner != nil {
- owner = o.Owner.Entity
- }
- md5, _ := base64.StdEncoding.DecodeString(o.Md5Hash)
- var crc32c uint32
- d, err := base64.StdEncoding.DecodeString(o.Crc32c)
- if err == nil && len(d) == 4 {
- crc32c = uint32(d[0])<<24 + uint32(d[1])<<16 + uint32(d[2])<<8 + uint32(d[3])
- }
- return &ObjectAttrs{
- Bucket: o.Bucket,
- Name: o.Name,
- ContentType: o.ContentType,
- ContentLanguage: o.ContentLanguage,
- CacheControl: o.CacheControl,
- ACL: acl,
- Owner: owner,
- ContentEncoding: o.ContentEncoding,
- Size: int64(o.Size),
- MD5: md5,
- CRC32C: crc32c,
- MediaLink: o.MediaLink,
- Metadata: o.Metadata,
- Generation: o.Generation,
- MetaGeneration: o.Metageneration,
- StorageClass: o.StorageClass,
- Created: convertTime(o.TimeCreated),
- Deleted: convertTime(o.TimeDeleted),
- Updated: convertTime(o.Updated),
- }
-}
-
-// Query represents a query to filter objects from a bucket.
-type Query struct {
- // Delimiter returns results in a directory-like fashion.
- // Results will contain only objects whose names, aside from the
- // prefix, do not contain delimiter. Objects whose names,
- // aside from the prefix, contain delimiter will have their name,
- // truncated after the delimiter, returned in prefixes.
- // Duplicate prefixes are omitted.
- // Optional.
- Delimiter string
-
- // Prefix is the prefix filter to query objects
- // whose names begin with this prefix.
- // Optional.
- Prefix string
-
- // Versions indicates whether multiple versions of the same
- // object will be included in the results.
- Versions bool
-
- // Cursor is a previously-returned page token
- // representing part of the larger set of results to view.
- // Optional.
- Cursor string
-
- // MaxResults is the maximum number of items plus prefixes
- // to return. As duplicate prefixes are omitted,
- // fewer total results may be returned than requested.
- // The default page limit is used if it is negative or zero.
- //
- // Deprecated. Use ObjectIterator.SetPageSize.
- MaxResults int
-}
-
-// ObjectList represents a list of objects returned from a bucket List call.
-type ObjectList struct {
- // Results represent a list of object results.
- Results []*ObjectAttrs
-
- // Next is the continuation query to retrieve more
- // results with the same filtering criteria. If there
- // are no more results to retrieve, it is nil.
- Next *Query
-
- // Prefixes represents prefixes of objects
- // matching-but-not-listed up to and including
- // the requested delimiter.
- Prefixes []string
-}
-
-// contentTyper implements ContentTyper to enable an
-// io.ReadCloser to specify its MIME type.
-type contentTyper struct {
- io.Reader
- t string
-}
-
-func (c *contentTyper) ContentType() string {
- return c.t
-}
-
-// A Condition constrains methods to act on specific generations of
-// resources.
-//
-// Not all conditions or combinations of conditions are applicable to
-// all methods.
-type Condition interface {
- // method is the high-level ObjectHandle method name, for
- // error messages. call is the call object to modify.
- modifyCall(method string, call interface{}) error
-}
-
-// applyConds modifies the provided call using the conditions in conds.
-// call is something that quacks like a *raw.WhateverCall.
-func applyConds(method string, conds []Condition, call interface{}) error {
- for _, cond := range conds {
- if err := cond.modifyCall(method, call); err != nil {
- return err
- }
- }
- return nil
-}
-
-// toSourceConds returns a slice of Conditions derived from Conds that instead
-// function on the equivalent Source methods of a call.
-func toSourceConds(conds []Condition) []Condition {
- out := make([]Condition, 0, len(conds))
- for _, c := range conds {
- switch c := c.(type) {
- case genCond:
- var m string
- if strings.HasPrefix(c.method, "If") {
- m = "IfSource" + c.method[2:]
- } else {
- m = "Source" + c.method
- }
- out = append(out, genCond{method: m, val: c.val})
- default:
- // NOTE(djd): If the message from unsupportedCond becomes
- // confusing, we'll need to find a way for Conditions to
- // identify themselves.
- out = append(out, unsupportedCond{})
- }
- }
- return out
-}
-
-func Generation(gen int64) Condition { return genCond{"Generation", gen} }
-func IfGenerationMatch(gen int64) Condition { return genCond{"IfGenerationMatch", gen} }
-func IfGenerationNotMatch(gen int64) Condition { return genCond{"IfGenerationNotMatch", gen} }
-func IfMetaGenerationMatch(gen int64) Condition { return genCond{"IfMetagenerationMatch", gen} }
-func IfMetaGenerationNotMatch(gen int64) Condition { return genCond{"IfMetagenerationNotMatch", gen} }
-
-type genCond struct {
- method string
- val int64
-}
-
-func (g genCond) modifyCall(srcMethod string, call interface{}) error {
- rv := reflect.ValueOf(call)
- meth := rv.MethodByName(g.method)
- if !meth.IsValid() {
- return fmt.Errorf("%s: condition %s not supported", srcMethod, g.method)
- }
- meth.Call([]reflect.Value{reflect.ValueOf(g.val)})
- return nil
-}
-
-type unsupportedCond struct{}
-
-func (unsupportedCond) modifyCall(srcMethod string, call interface{}) error {
- return fmt.Errorf("%s: condition not supported", srcMethod)
-}
-
-func appendParam(req *http.Request, k, v string) {
- sep := ""
- if req.URL.RawQuery != "" {
- sep = "&"
- }
- req.URL.RawQuery += sep + url.QueryEscape(k) + "=" + url.QueryEscape(v)
-}
-
-// objectsGetCall wraps an *http.Request for an object fetch call, but adds the methods
-// that modifyCall searches for by name. (the same names as the raw, auto-generated API)
-type objectsGetCall struct{ req *http.Request }
-
-func (c objectsGetCall) Generation(gen int64) {
- appendParam(c.req, "generation", fmt.Sprint(gen))
-}
-func (c objectsGetCall) IfGenerationMatch(gen int64) {
- appendParam(c.req, "ifGenerationMatch", fmt.Sprint(gen))
-}
-func (c objectsGetCall) IfGenerationNotMatch(gen int64) {
- appendParam(c.req, "ifGenerationNotMatch", fmt.Sprint(gen))
-}
-func (c objectsGetCall) IfMetagenerationMatch(gen int64) {
- appendParam(c.req, "ifMetagenerationMatch", fmt.Sprint(gen))
-}
-func (c objectsGetCall) IfMetagenerationNotMatch(gen int64) {
- appendParam(c.req, "ifMetagenerationNotMatch", fmt.Sprint(gen))
-}
diff --git a/vendor/google.golang.org/cloud/storage/writer.go b/vendor/google.golang.org/cloud/storage/writer.go
deleted file mode 100644
index 60937c0..0000000
--- a/vendor/google.golang.org/cloud/storage/writer.go
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package storage
-
-import (
- "fmt"
- "io"
- "unicode/utf8"
-
- "golang.org/x/net/context"
- "google.golang.org/api/googleapi"
- raw "google.golang.org/api/storage/v1"
-)
-
-// A Writer writes a Cloud Storage object.
-type Writer struct {
- // ObjectAttrs are optional attributes to set on the object. Any attributes
- // must be initialized before the first Write call. Nil or zero-valued
- // attributes are ignored.
- ObjectAttrs
-
- ctx context.Context
- o *ObjectHandle
-
- opened bool
- pw *io.PipeWriter
-
- donec chan struct{} // closed after err and obj are set.
- err error
- obj *ObjectAttrs
-}
-
-func (w *Writer) open() error {
- attrs := w.ObjectAttrs
- // Check the developer didn't change the object Name (this is unfortunate, but
- // we don't want to store an object under the wrong name).
- if attrs.Name != w.o.object {
- return fmt.Errorf("storage: Writer.Name %q does not match object name %q", attrs.Name, w.o.object)
- }
- if !utf8.ValidString(attrs.Name) {
- return fmt.Errorf("storage: object name %q is not valid UTF-8", attrs.Name)
- }
- pr, pw := io.Pipe()
- w.pw = pw
- w.opened = true
-
- var mediaOpts []googleapi.MediaOption
- if c := attrs.ContentType; c != "" {
- mediaOpts = append(mediaOpts, googleapi.ContentType(c))
- }
-
- go func() {
- defer close(w.donec)
-
- call := w.o.c.raw.Objects.Insert(w.o.bucket, attrs.toRawObject(w.o.bucket)).
- Media(pr, mediaOpts...).
- Projection("full").
- Context(w.ctx)
-
- var resp *raw.Object
- err := applyConds("NewWriter", w.o.conds, call)
- if err == nil {
- resp, err = call.Do()
- }
- if err != nil {
- w.err = err
- pr.CloseWithError(w.err)
- return
- }
- w.obj = newObject(resp)
- }()
- return nil
-}
-
-// Write appends to w.
-func (w *Writer) Write(p []byte) (n int, err error) {
- if w.err != nil {
- return 0, w.err
- }
- if !w.opened {
- if err := w.open(); err != nil {
- return 0, err
- }
- }
- return w.pw.Write(p)
-}
-
-// Close completes the write operation and flushes any buffered data.
-// If Close doesn't return an error, metadata about the written object
-// can be retrieved by calling Object.
-func (w *Writer) Close() error {
- if !w.opened {
- if err := w.open(); err != nil {
- return err
- }
- }
- if err := w.pw.Close(); err != nil {
- return err
- }
- <-w.donec
- return w.err
-}
-
-// CloseWithError aborts the write operation with the provided error.
-// CloseWithError always returns nil.
-func (w *Writer) CloseWithError(err error) error {
- if !w.opened {
- return nil
- }
- return w.pw.CloseWithError(err)
-}
-
-// ObjectAttrs returns metadata about a successfully-written object.
-// It's only valid to call it after Close returns nil.
-func (w *Writer) Attrs() *ObjectAttrs {
- return w.obj
-}
diff --git a/vendor/google.golang.org/grpc/balancer.go b/vendor/google.golang.org/grpc/balancer.go
index 419e214..e217a20 100644
--- a/vendor/google.golang.org/grpc/balancer.go
+++ b/vendor/google.golang.org/grpc/balancer.go
@@ -38,6 +38,7 @@ import (
"sync"
"golang.org/x/net/context"
+ "google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/naming"
)
@@ -52,6 +53,14 @@ type Address struct {
Metadata interface{}
}
+// BalancerConfig specifies the configurations for Balancer.
+type BalancerConfig struct {
+ // DialCreds is the transport credential the Balancer implementation can
+ // use to dial to a remote load balancer server. The Balancer implementations
+ // can ignore this if it does not need to talk to another party securely.
+ DialCreds credentials.TransportCredentials
+}
+
// BalancerGetOptions configures a Get call.
// This is the EXPERIMENTAL API and may be changed or extended in the future.
type BalancerGetOptions struct {
@@ -66,11 +75,11 @@ type Balancer interface {
// Start does the initialization work to bootstrap a Balancer. For example,
// this function may start the name resolution and watch the updates. It will
// be called when dialing.
- Start(target string) error
+ Start(target string, config BalancerConfig) error
// Up informs the Balancer that gRPC has a connection to the server at
// addr. It returns down which is called once the connection to addr gets
// lost or closed.
- // TODO: It is not clear how to construct and take advantage the meaningful error
+ // TODO: It is not clear how to construct and take advantage of the meaningful error
// parameter for down. Need realistic demands to guide.
Up(addr Address) (down func(error))
// Get gets the address of a server for the RPC corresponding to ctx.
@@ -205,7 +214,12 @@ func (rr *roundRobin) watchAddrUpdates() error {
return nil
}
-func (rr *roundRobin) Start(target string) error {
+func (rr *roundRobin) Start(target string, config BalancerConfig) error {
+ rr.mu.Lock()
+ defer rr.mu.Unlock()
+ if rr.done {
+ return ErrClientConnClosing
+ }
if rr.r == nil {
// If there is no name resolver installed, it is not needed to
// do name resolution. In this case, target is added into rr.addrs
diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go
index a257f01..11dce44 100644
--- a/vendor/google.golang.org/grpc/clientconn.go
+++ b/vendor/google.golang.org/grpc/clientconn.go
@@ -270,31 +270,47 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
if cc.dopts.bs == nil {
cc.dopts.bs = DefaultBackoffConfig
}
-
- var (
- ok bool
- addrs []Address
- )
- if cc.dopts.balancer == nil {
- // Connect to target directly if balancer is nil.
- addrs = append(addrs, Address{Addr: target})
+ creds := cc.dopts.copts.TransportCredentials
+ if creds != nil && creds.Info().ServerName != "" {
+ cc.authority = creds.Info().ServerName
} else {
- if err := cc.dopts.balancer.Start(target); err != nil {
- return nil, err
+ colonPos := strings.LastIndex(target, ":")
+ if colonPos == -1 {
+ colonPos = len(target)
}
- ch := cc.dopts.balancer.Notify()
- if ch == nil {
- // There is no name resolver installed.
+ cc.authority = target[:colonPos]
+ }
+ var ok bool
+ waitC := make(chan error, 1)
+ go func() {
+ var addrs []Address
+ if cc.dopts.balancer == nil {
+ // Connect to target directly if balancer is nil.
addrs = append(addrs, Address{Addr: target})
} else {
- addrs, ok = <-ch
- if !ok || len(addrs) == 0 {
- return nil, errNoAddr
+ var credsClone credentials.TransportCredentials
+ if creds != nil {
+ credsClone = creds.Clone()
+ }
+ config := BalancerConfig{
+ DialCreds: credsClone,
+ }
+ if err := cc.dopts.balancer.Start(target, config); err != nil {
+ waitC <- err
+ return
+ }
+ ch := cc.dopts.balancer.Notify()
+ if ch == nil {
+ // There is no name resolver installed.
+ addrs = append(addrs, Address{Addr: target})
+ } else {
+ addrs, ok = <-ch
+ if !ok || len(addrs) == 0 {
+ waitC <- errNoAddr
+ return
+ }
}
}
- }
- waitC := make(chan error, 1)
- go func() {
for _, a := range addrs {
if err := cc.resetAddrConn(a, false, nil); err != nil {
waitC <- err
@@ -322,11 +338,6 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
if ok {
go cc.lbWatcher()
}
- colonPos := strings.LastIndex(target, ":")
- if colonPos == -1 {
- colonPos = len(target)
- }
- cc.authority = target[:colonPos]
return cc, nil
}
@@ -680,7 +691,7 @@ func (ac *addrConn) resetTransport(closeTransport bool) error {
if e, ok := err.(transport.ConnectionError); ok && !e.Temporary() {
return err
}
- grpclog.Printf("grpc: addrConn.resetTransport failed to create client transport: %v; Reconnecting to %q", err, ac.addr)
+ grpclog.Printf("grpc: addrConn.resetTransport failed to create client transport: %v; Reconnecting to %v", err, ac.addr)
ac.mu.Lock()
if ac.state == Shutdown {
// ac.tearDown(...) has been invoked.
diff --git a/vendor/google.golang.org/grpc/credentials/credentials.go b/vendor/google.golang.org/grpc/credentials/credentials.go
index 13be457..5555ef0 100644
--- a/vendor/google.golang.org/grpc/credentials/credentials.go
+++ b/vendor/google.golang.org/grpc/credentials/credentials.go
@@ -72,7 +72,7 @@ type PerRPCCredentials interface {
}
// ProtocolInfo provides information regarding the gRPC wire protocol version,
-// security protocol, security protocol version in use, etc.
+// security protocol, security protocol version in use, server name, etc.
type ProtocolInfo struct {
// ProtocolVersion is the gRPC wire protocol version.
ProtocolVersion string
@@ -80,6 +80,8 @@ type ProtocolInfo struct {
SecurityProtocol string
// SecurityVersion is the security protocol version.
SecurityVersion string
+ // ServerName is the user-configured server name.
+ ServerName string
}
// AuthInfo defines the common interface for the auth information the users are interested in.
@@ -107,6 +109,12 @@ type TransportCredentials interface {
ServerHandshake(net.Conn) (net.Conn, AuthInfo, error)
// Info provides the ProtocolInfo of this TransportCredentials.
Info() ProtocolInfo
+ // Clone makes a copy of this TransportCredentials.
+ Clone() TransportCredentials
+ // OverrideServerName overrides the server name used to verify the hostname on the returned certificates from the server.
+ // gRPC internals also use it to override the virtual hosting name if it is set.
+ // It must be called before dialing. Currently, this is only used by grpclb.
+ OverrideServerName(string) error
}
// TLSInfo contains the auth information for a TLS authenticated connection.
@@ -130,19 +138,10 @@ func (c tlsCreds) Info() ProtocolInfo {
return ProtocolInfo{
SecurityProtocol: "tls",
SecurityVersion: "1.2",
+ ServerName: c.config.ServerName,
}
}
-// GetRequestMetadata returns nil, nil since TLS credentials does not have
-// metadata.
-func (c *tlsCreds) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
- return nil, nil
-}
-
-func (c *tlsCreds) RequireTransportSecurity() bool {
- return true
-}
-
func (c *tlsCreds) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (_ net.Conn, _ AuthInfo, err error) {
// use local cfg to avoid clobbering ServerName if using multiple endpoints
cfg := cloneTLSConfig(c.config)
@@ -179,6 +178,15 @@ func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error)
return conn, TLSInfo{conn.ConnectionState()}, nil
}
+func (c *tlsCreds) Clone() TransportCredentials {
+ return NewTLS(c.config)
+}
+
+func (c *tlsCreds) OverrideServerName(serverNameOverride string) error {
+ c.config.ServerName = serverNameOverride
+ return nil
+}
+
// NewTLS uses c to construct a TransportCredentials based on TLS.
func NewTLS(c *tls.Config) TransportCredentials {
tc := &tlsCreds{cloneTLSConfig(c)}
@@ -187,12 +195,16 @@ func NewTLS(c *tls.Config) TransportCredentials {
}
// NewClientTLSFromCert constructs a TLS from the input certificate for client.
-func NewClientTLSFromCert(cp *x509.CertPool, serverName string) TransportCredentials {
- return NewTLS(&tls.Config{ServerName: serverName, RootCAs: cp})
+// serverNameOverride is for testing only. If set to a non empty string,
+// it will override the virtual host name of authority (e.g. :authority header field) in requests.
+func NewClientTLSFromCert(cp *x509.CertPool, serverNameOverride string) TransportCredentials {
+ return NewTLS(&tls.Config{ServerName: serverNameOverride, RootCAs: cp})
}
// NewClientTLSFromFile constructs a TLS from the input certificate file for client.
-func NewClientTLSFromFile(certFile, serverName string) (TransportCredentials, error) {
+// serverNameOverride is for testing only. If set to a non empty string,
+// it will override the virtual host name of authority (e.g. :authority header field) in requests.
+func NewClientTLSFromFile(certFile, serverNameOverride string) (TransportCredentials, error) {
b, err := ioutil.ReadFile(certFile)
if err != nil {
return nil, err
@@ -201,7 +213,7 @@ func NewClientTLSFromFile(certFile, serverName string) (TransportCredentials, er
if !cp.AppendCertsFromPEM(b) {
return nil, fmt.Errorf("credentials: failed to append certificates")
}
- return NewTLS(&tls.Config{ServerName: serverName, RootCAs: cp}), nil
+ return NewTLS(&tls.Config{ServerName: serverNameOverride, RootCAs: cp}), nil
}
// NewServerTLSFromCert constructs a TLS from the input certificate for server.
diff --git a/vendor/google.golang.org/grpc/metadata/metadata.go b/vendor/google.golang.org/grpc/metadata/metadata.go
index 954c0f7..3c0ca7a 100644
--- a/vendor/google.golang.org/grpc/metadata/metadata.go
+++ b/vendor/google.golang.org/grpc/metadata/metadata.go
@@ -117,10 +117,17 @@ func (md MD) Len() int {
// Copy returns a copy of md.
func (md MD) Copy() MD {
+ return Join(md)
+}
+
+// Join joins any number of MDs into a single MD.
+// The order of values for each key is determined by the order in which
+// the MDs containing those values are presented to Join.
+func Join(mds ...MD) MD {
out := MD{}
- for k, v := range md {
- for _, i := range v {
- out[k] = append(out[k], i)
+ for _, md := range mds {
+ for k, v := range md {
+ out[k] = append(out[k], v...)
}
}
return out
diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go
index 2524dd2..debbd79 100644
--- a/vendor/google.golang.org/grpc/server.go
+++ b/vendor/google.golang.org/grpc/server.go
@@ -873,25 +873,28 @@ func SendHeader(ctx context.Context, md metadata.MD) error {
}
stream, ok := transport.StreamFromContext(ctx)
if !ok {
- return fmt.Errorf("grpc: failed to fetch the stream from the context %v", ctx)
+ return Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx)
}
t := stream.ServerTransport()
if t == nil {
grpclog.Fatalf("grpc: SendHeader: %v has no ServerTransport to send header metadata.", stream)
}
- return t.WriteHeader(stream, md)
+ if err := t.WriteHeader(stream, md); err != nil {
+ return toRPCErr(err)
+ }
+ return nil
}
// SetTrailer sets the trailer metadata that will be sent when an RPC returns.
-// It may be called at most once from a unary RPC handler. The ctx is the RPC
-// handler's Context or one derived from it.
+// When called more than once, all the provided metadata will be merged.
+// The ctx is the RPC handler's Context or one derived from it.
func SetTrailer(ctx context.Context, md metadata.MD) error {
if md.Len() == 0 {
return nil
}
stream, ok := transport.StreamFromContext(ctx)
if !ok {
- return fmt.Errorf("grpc: failed to fetch the stream from the context %v", ctx)
+ return Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx)
}
return stream.SetTrailer(md)
}
diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go
index e1b4759..68d777b 100644
--- a/vendor/google.golang.org/grpc/stream.go
+++ b/vendor/google.golang.org/grpc/stream.go
@@ -414,8 +414,8 @@ type ServerStream interface {
// after SendProto. It fails if called multiple times or if
// called after SendProto.
SendHeader(metadata.MD) error
- // SetTrailer sets the trailer metadata which will be sent with the
- // RPC status.
+ // SetTrailer sets the trailer metadata which will be sent with the RPC status.
+ // When called more than once, all the provided metadata will be merged.
SetTrailer(metadata.MD)
Stream
}
diff --git a/vendor/google.golang.org/grpc/transport/http2_client.go b/vendor/google.golang.org/grpc/transport/http2_client.go
index 4892faa..3c18554 100644
--- a/vendor/google.golang.org/grpc/transport/http2_client.go
+++ b/vendor/google.golang.org/grpc/transport/http2_client.go
@@ -252,8 +252,10 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream {
s.windowHandler = func(n int) {
t.updateWindow(s, uint32(n))
}
- // Make a stream be able to cancel the pending operations by itself.
- s.ctx, s.cancel = context.WithCancel(ctx)
+ // The client side stream context should have exactly the same life cycle with the user provided context.
+ // That means, s.ctx should be read-only. And s.ctx is done iff ctx is done.
+ // So we use the original context here instead of creating a copy.
+ s.ctx = ctx
s.dec = &recvBufferReader{
ctx: s.ctx,
goAway: s.goAway,
@@ -265,16 +267,6 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream {
// NewStream creates a stream and register it into the transport as "active"
// streams.
func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Stream, err error) {
- // Record the timeout value on the context.
- var timeout time.Duration
- if dl, ok := ctx.Deadline(); ok {
- timeout = dl.Sub(time.Now())
- }
- select {
- case <-ctx.Done():
- return nil, ContextErr(ctx.Err())
- default:
- }
pr := &peer.Peer{
Addr: t.conn.RemoteAddr(),
}
@@ -381,9 +373,12 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
if callHdr.SendCompress != "" {
t.hEnc.WriteField(hpack.HeaderField{Name: "grpc-encoding", Value: callHdr.SendCompress})
}
- if timeout > 0 {
+ if dl, ok := ctx.Deadline(); ok {
+ // Send out timeout regardless its value. The server can detect timeout context by itself.
+ timeout := dl.Sub(time.Now())
t.hEnc.WriteField(hpack.HeaderField{Name: "grpc-timeout", Value: encodeTimeout(timeout)})
}
+
for k, v := range authData {
// Capital header names are illegal in HTTP/2.
k = strings.ToLower(k)
@@ -852,6 +847,12 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
state.processHeaderField(hf)
}
if state.err != nil {
+ s.mu.Lock()
+ if !s.headerDone {
+ close(s.headerChan)
+ s.headerDone = true
+ }
+ s.mu.Unlock()
s.write(recvMsg{err: state.err})
// Something wrong. Stops reading even when there is remaining.
return
diff --git a/vendor/google.golang.org/grpc/transport/http_util.go b/vendor/google.golang.org/grpc/transport/http_util.go
index b024594..a3c68d4 100644
--- a/vendor/google.golang.org/grpc/transport/http_util.go
+++ b/vendor/google.golang.org/grpc/transport/http_util.go
@@ -253,6 +253,9 @@ func div(d, r time.Duration) int64 {
// TODO(zhaoq): It is the simplistic and not bandwidth efficient. Improve it.
func encodeTimeout(t time.Duration) string {
+ if t <= 0 {
+ return "0n"
+ }
if d := div(t, time.Nanosecond); d <= maxTimeoutValue {
return strconv.FormatInt(d, 10) + "n"
}
@@ -349,7 +352,7 @@ func decodeGrpcMessageUnchecked(msg string) string {
for i := 0; i < lenMsg; i++ {
c := msg[i]
if c == percentByte && i+2 < lenMsg {
- parsed, err := strconv.ParseInt(msg[i+1:i+3], 16, 8)
+ parsed, err := strconv.ParseUint(msg[i+1:i+3], 16, 8)
if err != nil {
buf.WriteByte(c)
} else {
diff --git a/vendor/google.golang.org/grpc/transport/transport.go b/vendor/google.golang.org/grpc/transport/transport.go
index f4d8daf..3d6b6a6 100644
--- a/vendor/google.golang.org/grpc/transport/transport.go
+++ b/vendor/google.golang.org/grpc/transport/transport.go
@@ -39,7 +39,6 @@ package transport // import "google.golang.org/grpc/transport"
import (
"bytes"
- "errors"
"fmt"
"io"
"net"
@@ -169,7 +168,8 @@ type Stream struct {
// nil for client side Stream.
st ServerTransport
// ctx is the associated context of the stream.
- ctx context.Context
+ ctx context.Context
+ // cancel is always nil for client side Stream.
cancel context.CancelFunc
// done is closed when the final status arrives.
done chan struct{}
@@ -286,19 +286,12 @@ func (s *Stream) StatusDesc() string {
return s.statusDesc
}
-// ErrIllegalTrailerSet indicates that the trailer has already been set or it
-// is too late to do so.
-var ErrIllegalTrailerSet = errors.New("transport: trailer has been set")
-
// SetTrailer sets the trailer metadata which will be sent with the RPC status
-// by the server. This can only be called at most once. Server side only.
+// by the server. This can be called multiple times. Server side only.
func (s *Stream) SetTrailer(md metadata.MD) error {
s.mu.Lock()
defer s.mu.Unlock()
- if s.trailer != nil {
- return ErrIllegalTrailerSet
- }
- s.trailer = md.Copy()
+ s.trailer = metadata.Join(s.trailer, md)
return nil
}