Unverified Commit 65c84529 authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

Merge pull request #72248 from freehan/revendor

Revendor GCE API Go Client
parents b006342c 0e4ba4b7
......@@ -122,23 +122,23 @@
},
{
"ImportPath": "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud",
"Comment": "1.2.0",
"Rev": "773c7a284e1399960745d0e2c501f577a20d4947"
"Comment": "1.3.0",
"Rev": "f8e99590510076aa1e3ff07df946f05220c50fb4"
},
{
"ImportPath": "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter",
"Comment": "1.2.0",
"Rev": "773c7a284e1399960745d0e2c501f577a20d4947"
"Comment": "1.3.0",
"Rev": "f8e99590510076aa1e3ff07df946f05220c50fb4"
},
{
"ImportPath": "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta",
"Comment": "1.2.0",
"Rev": "773c7a284e1399960745d0e2c501f577a20d4947"
"Comment": "1.3.0",
"Rev": "f8e99590510076aa1e3ff07df946f05220c50fb4"
},
{
"ImportPath": "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock",
"Comment": "1.2.0",
"Rev": "773c7a284e1399960745d0e2c501f577a20d4947"
"Comment": "1.3.0",
"Rev": "f8e99590510076aa1e3ff07df946f05220c50fb4"
},
{
"ImportPath": "github.com/JeffAshton/win_pdh",
......@@ -3751,47 +3751,47 @@
},
{
"ImportPath": "google.golang.org/api/compute/v0.alpha",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/compute/v0.beta",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/compute/v1",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/container/v1",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/gensupport",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/googleapi",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/googleapi/internal/uritemplates",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/logging/v2beta1",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/monitoring/v3",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/pubsub/v1",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/api/tpu/v1",
"Rev": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
"Rev": "583d854617af4d2080b5d2a24d72f7fc5a128ab2"
},
{
"ImportPath": "google.golang.org/genproto/googleapis/rpc/status",
......
......@@ -7,8 +7,6 @@ go_library(
importpath = "google.golang.org/api/compute/v0.alpha",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/gensupport:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,8 +7,6 @@ go_library(
importpath = "google.golang.org/api/compute/v0.beta",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/gensupport:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,8 +7,6 @@ go_library(
importpath = "google.golang.org/api/compute/v1",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/gensupport:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,8 +7,6 @@ go_library(
importpath = "google.golang.org/api/container/v1",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/gensupport:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
......
......@@ -6,12 +6,10 @@ go_library(
"backoff.go",
"buffer.go",
"doc.go",
"go18.go",
"header.go",
"json.go",
"jsonfloat.go",
"media.go",
"not_go18.go",
"params.go",
"resumable.go",
"retry.go",
......@@ -20,11 +18,7 @@ go_library(
importmap = "k8s.io/kubernetes/vendor/google.golang.org/api/gensupport",
importpath = "google.golang.org/api/gensupport",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
deps = ["//vendor/google.golang.org/api/googleapi:go_default_library"],
)
filegroup(
......
......@@ -9,6 +9,8 @@ import (
"time"
)
// BackoffStrategy defines the set of functions that a backoff-er must
// implement.
type BackoffStrategy interface {
// Pause returns the duration of the next pause and true if the operation should be
// retried, or false if no further retries should be attempted.
......@@ -28,6 +30,7 @@ type ExponentialBackoff struct {
n uint
}
// Pause returns the amount of time the caller should wait.
func (eb *ExponentialBackoff) Pause() (time.Duration, bool) {
if eb.total > eb.Max {
return 0, false
......@@ -40,6 +43,8 @@ func (eb *ExponentialBackoff) Pause() (time.Duration, bool) {
return d, true
}
// Reset resets the backoff strategy such that the next Pause call will begin
// counting from the start. It is not safe to call concurrently with Pause.
func (eb *ExponentialBackoff) Reset() {
eb.n = 0
eb.total = 0
......
......@@ -11,7 +11,8 @@ import (
"google.golang.org/api/googleapi"
)
// MediaBuffer buffers data from an io.Reader to support uploading media in retryable chunks.
// MediaBuffer buffers data from an io.Reader to support uploading media in
// retryable chunks. It should be created with NewMediaBuffer.
type MediaBuffer struct {
media io.Reader
......@@ -22,6 +23,7 @@ type MediaBuffer struct {
off int64
}
// NewMediaBuffer initializes a MediaBuffer.
func NewMediaBuffer(media io.Reader, chunkSize int) *MediaBuffer {
return &MediaBuffer{media: media, chunk: make([]byte, 0, chunkSize)}
}
......
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build go1.8
package gensupport
import (
"io"
"net/http"
)
// SetGetBody sets the GetBody field of req to f.
func SetGetBody(req *http.Request, f func() (io.ReadCloser, error)) {
req.GetBody = f
}
// Copyright 2016 Google Inc. All Rights Reserved.
// Copyright 2016 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
......@@ -242,6 +242,7 @@ func NewInfoFromResumableMedia(r io.ReaderAt, size int64, mediaType string) *Med
}
}
// SetProgressUpdater sets the progress updater for the media info.
func (mi *MediaInfo) SetProgressUpdater(pu googleapi.ProgressUpdater) {
if mi != nil {
mi.progressUpdater = pu
......@@ -334,3 +335,8 @@ func (mi *MediaInfo) ResumableUpload(locURI string) *ResumableUpload {
},
}
}
// SetGetBody sets the GetBody field of req to f.
func SetGetBody(req *http.Request, f func() (io.ReadCloser, error)) {
req.GetBody = f
}
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !go1.8
package gensupport
import (
"io"
"net/http"
)
func SetGetBody(req *http.Request, f func() (io.ReadCloser, error)) {}
......@@ -43,6 +43,7 @@ func (u URLParams) Encode() string {
return url.Values(u).Encode()
}
// SetOptions sets the URL params and any additional call options.
func SetOptions(u URLParams, opts ...googleapi.CallOption) {
for _, o := range opts {
u.Set(o.Get())
......
......@@ -5,14 +5,13 @@
package gensupport
import (
"context"
"errors"
"fmt"
"io"
"net/http"
"sync"
"time"
"golang.org/x/net/context"
)
const (
......
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......@@ -15,12 +15,11 @@
package gensupport
import (
"context"
"io"
"net"
"net/http"
"time"
"golang.org/x/net/context"
)
// Retry invokes the given function, retrying it multiple times if the connection failed or
......
......@@ -5,12 +5,10 @@
package gensupport
import (
"context"
"encoding/json"
"errors"
"net/http"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
)
// Hook is the type of a function that is called once before each HTTP request
......@@ -32,7 +30,8 @@ func RegisterHook(h Hook) {
// SendRequest sends a single HTTP request using the given client.
// If ctx is non-nil, it calls all hooks, then sends the request with
// ctxhttp.Do, then calls any functions returned by the hooks in reverse order.
// req.WithContext, then calls any functions returned by the hooks in
// reverse order.
func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) {
// Disallow Accept-Encoding because it interferes with the automatic gzip handling
// done by the default http.Transport. See https://github.com/google/google-api-go-client/issues/219.
......@@ -50,7 +49,7 @@ func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*
}
// Send request.
resp, err := ctxhttp.Do(ctx, client, req)
resp, err := send(ctx, client, req)
// Call returned funcs in reverse order.
for i := len(post) - 1; i >= 0; i-- {
......@@ -61,6 +60,23 @@ func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*
return resp, err
}
func send(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) {
if client == nil {
client = http.DefaultClient
}
resp, err := client.Do(req.WithContext(ctx))
// If we got an error, and the context has been canceled,
// the context's error is probably more useful.
if err != nil {
select {
case <-ctx.Done():
err = ctx.Err()
default:
}
}
return resp, err
}
// DecodeResponse decodes the body of res into target. If there is no body,
// target is unchanged.
func DecodeResponse(target interface{}, res *http.Response) error {
......
......@@ -37,24 +37,28 @@ type SizeReaderAt interface {
// ServerResponse is embedded in each Do response and
// provides the HTTP status code and header sent by the server.
type ServerResponse struct {
// HTTPStatusCode is the server's response status code.
// When using a resource method's Do call, this will always be in the 2xx range.
// HTTPStatusCode is the server's response status code. When using a
// resource method's Do call, this will always be in the 2xx range.
HTTPStatusCode int
// Header contains the response header fields from the server.
Header http.Header
}
const (
// Version defines the gax version being used. This is typically sent
// in an HTTP header to services.
Version = "0.5"
// UserAgent is the header string used to identify this package.
UserAgent = "google-api-go-client/" + Version
// The default chunk size to use for resumable uploads if not specified by the user.
// DefaultUploadChunkSize is the default chunk size to use for resumable
// uploads if not specified by the user.
DefaultUploadChunkSize = 8 * 1024 * 1024
// The minimum chunk size that can be used for resumable uploads. All
// user-specified chunk sizes must be multiple of this value.
// MinUploadChunkSize is the minimum chunk size that can be used for
// resumable uploads. All user-specified chunk sizes must be multiple of
// this value.
MinUploadChunkSize = 256 * 1024
)
......@@ -161,9 +165,13 @@ func CheckMediaResponse(res *http.Response) error {
}
}
// MarshalStyle defines whether to marshal JSON with a {"data": ...} wrapper.
type MarshalStyle bool
// WithDataWrapper marshals JSON with a {"data": ...} wrapper.
var WithDataWrapper = MarshalStyle(true)
// WithoutDataWrapper marshals JSON without a {"data": ...} wrapper.
var WithoutDataWrapper = MarshalStyle(false)
func (wrap MarshalStyle) JSONReader(v interface{}) (io.Reader, error) {
......@@ -212,6 +220,7 @@ func (w countingWriter) Write(p []byte) (int, error) {
// The remaining usable pieces of resumable uploads is exposed in each auto-generated API.
type ProgressUpdater func(current, total int64)
// MediaOption defines the interface for setting media options.
type MediaOption interface {
setOptions(o *MediaOptions)
}
......@@ -268,6 +277,11 @@ func ProcessMediaOptions(opts []MediaOption) *MediaOptions {
return mo
}
// ResolveRelative resolves relatives such as "http://www.golang.org/" and
// "topics/myproject/mytopic" into a single string, such as
// "http://www.golang.org/topics/myproject/mytopic". It strips all parent
// references (e.g. ../..) as well as anything after the host
// (e.g. /bar/gaz gets stripped out of foo.com/bar/gaz).
func ResolveRelative(basestr, relstr string) string {
u, _ := url.Parse(basestr)
afterColonPath := ""
......
......@@ -120,33 +120,33 @@ func quotedList(n int, fn func(dst []byte, i int) []byte) ([]byte, error) {
return dst, nil
}
func (s Int64s) MarshalJSON() ([]byte, error) {
return quotedList(len(s), func(dst []byte, i int) []byte {
return strconv.AppendInt(dst, s[i], 10)
func (q Int64s) MarshalJSON() ([]byte, error) {
return quotedList(len(q), func(dst []byte, i int) []byte {
return strconv.AppendInt(dst, q[i], 10)
})
}
func (s Int32s) MarshalJSON() ([]byte, error) {
return quotedList(len(s), func(dst []byte, i int) []byte {
return strconv.AppendInt(dst, int64(s[i]), 10)
func (q Int32s) MarshalJSON() ([]byte, error) {
return quotedList(len(q), func(dst []byte, i int) []byte {
return strconv.AppendInt(dst, int64(q[i]), 10)
})
}
func (s Uint64s) MarshalJSON() ([]byte, error) {
return quotedList(len(s), func(dst []byte, i int) []byte {
return strconv.AppendUint(dst, s[i], 10)
func (q Uint64s) MarshalJSON() ([]byte, error) {
return quotedList(len(q), func(dst []byte, i int) []byte {
return strconv.AppendUint(dst, q[i], 10)
})
}
func (s Uint32s) MarshalJSON() ([]byte, error) {
return quotedList(len(s), func(dst []byte, i int) []byte {
return strconv.AppendUint(dst, uint64(s[i]), 10)
func (q Uint32s) MarshalJSON() ([]byte, error) {
return quotedList(len(q), func(dst []byte, i int) []byte {
return strconv.AppendUint(dst, uint64(q[i]), 10)
})
}
func (s Float64s) MarshalJSON() ([]byte, error) {
return quotedList(len(s), func(dst []byte, i int) []byte {
return strconv.AppendFloat(dst, s[i], 'g', -1, 64)
func (q Float64s) MarshalJSON() ([]byte, error) {
return quotedList(len(q), func(dst []byte, i int) []byte {
return strconv.AppendFloat(dst, q[i], 'g', -1, 64)
})
}
......
......@@ -7,8 +7,6 @@ go_library(
importpath = "google.golang.org/api/logging/v2beta1",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/gensupport:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
......
......@@ -7,8 +7,6 @@ go_library(
importpath = "google.golang.org/api/monitoring/v3",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/gensupport:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
......
......@@ -7,8 +7,6 @@ go_library(
importpath = "google.golang.org/api/pubsub/v1",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/gensupport:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
......
......@@ -7,8 +7,6 @@ go_library(
importpath = "google.golang.org/api/tpu/v1",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
"//vendor/google.golang.org/api/gensupport:go_default_library",
"//vendor/google.golang.org/api/googleapi:go_default_library",
],
......
......@@ -400,34 +400,6 @@
"https://www.googleapis.com/auth/cloud-platform"
]
},
"reset": {
"description": "Resets a node, which stops and starts the VM.",
"flatPath": "v1/projects/{projectsId}/locations/{locationsId}/nodes/{nodesId}:reset",
"httpMethod": "POST",
"id": "tpu.projects.locations.nodes.reset",
"parameterOrder": [
"name"
],
"parameters": {
"name": {
"description": "The resource name.",
"location": "path",
"pattern": "^projects/[^/]+/locations/[^/]+/nodes/[^/]+$",
"required": true,
"type": "string"
}
},
"path": "v1/{+name}:reset",
"request": {
"$ref": "ResetNodeRequest"
},
"response": {
"$ref": "Operation"
},
"scopes": [
"https://www.googleapis.com/auth/cloud-platform"
]
},
"start": {
"description": "Starts a node.",
"flatPath": "v1/projects/{projectsId}/locations/{locationsId}/nodes/{nodesId}:start",
......@@ -686,7 +658,7 @@
}
}
},
"revision": "20180601",
"revision": "20181010",
"rootUrl": "https://tpu.googleapis.com/",
"schemas": {
"AcceleratorType": {
......@@ -760,6 +732,13 @@
"$ref": "Node"
},
"type": "array"
},
"unreachable": {
"description": "Locations that could not be reached.",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
......@@ -940,7 +919,9 @@
"REPAIRING",
"STOPPED",
"STOPPING",
"STARTING"
"STARTING",
"PREEMPTED",
"TERMINATED"
],
"enumDescriptions": [
"TPU node state is not known/set.",
......@@ -952,7 +933,9 @@
"TPU node is being repaired and may be unusable. Details can be\nfound in the `help_description` field.",
"7 - Reserved. Was SUSPENDED.\nTPU node is stopped.",
"TPU node is currently stopping.",
"TPU node is currently starting."
"TPU node is currently starting.",
"TPU node has been preempted. Only applies to Preemptible TPU Nodes.",
"TPU node has been terminated due to maintenance or has reached the end of\nits life cycle (for preemptible nodes)."
],
"type": "string"
},
......@@ -1046,12 +1029,6 @@
},
"type": "object"
},
"ResetNodeRequest": {
"description": "Request for ResetNode.",
"id": "ResetNodeRequest",
"properties": {},
"type": "object"
},
"SchedulingConfig": {
"id": "SchedulingConfig",
"properties": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment