aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/google.golang.org/api/internal
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/google.golang.org/api/internal
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/google.golang.org/api/internal')
-rw-r--r--vendor/google.golang.org/api/internal/creds.go45
-rw-r--r--vendor/google.golang.org/api/internal/pool.go61
-rw-r--r--vendor/google.golang.org/api/internal/service-account.json12
-rw-r--r--vendor/google.golang.org/api/internal/settings.go81
4 files changed, 199 insertions, 0 deletions
diff --git a/vendor/google.golang.org/api/internal/creds.go b/vendor/google.golang.org/api/internal/creds.go
new file mode 100644
index 0000000..e5b849b
--- /dev/null
+++ b/vendor/google.golang.org/api/internal/creds.go
@@ -0,0 +1,45 @@
1// Copyright 2017 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package internal
16
17import (
18 "context"
19 "fmt"
20 "io/ioutil"
21
22 "golang.org/x/oauth2/google"
23)
24
25// Creds returns credential information obtained from DialSettings, or if none, then
26// it returns default credential information.
27func Creds(ctx context.Context, ds *DialSettings) (*google.DefaultCredentials, error) {
28 if ds.Credentials != nil {
29 return ds.Credentials, nil
30 }
31 if ds.CredentialsJSON != nil {
32 return google.CredentialsFromJSON(ctx, ds.CredentialsJSON, ds.Scopes...)
33 }
34 if ds.CredentialsFile != "" {
35 data, err := ioutil.ReadFile(ds.CredentialsFile)
36 if err != nil {
37 return nil, fmt.Errorf("cannot read credentials file: %v", err)
38 }
39 return google.CredentialsFromJSON(ctx, data, ds.Scopes...)
40 }
41 if ds.TokenSource != nil {
42 return &google.DefaultCredentials{TokenSource: ds.TokenSource}, nil
43 }
44 return google.FindDefaultCredentials(ctx, ds.Scopes...)
45}
diff --git a/vendor/google.golang.org/api/internal/pool.go b/vendor/google.golang.org/api/internal/pool.go
new file mode 100644
index 0000000..ba40624
--- /dev/null
+++ b/vendor/google.golang.org/api/internal/pool.go
@@ -0,0 +1,61 @@
1// Copyright 2016 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package internal
16
17import (
18 "errors"
19
20 "google.golang.org/grpc/naming"
21)
22
23// PoolResolver provides a fixed list of addresses to load balance between
24// and does not provide further updates.
25type PoolResolver struct {
26 poolSize int
27 dialOpt *DialSettings
28 ch chan []*naming.Update
29}
30
31// NewPoolResolver returns a PoolResolver
32// This is an EXPERIMENTAL API and may be changed or removed in the future.
33func NewPoolResolver(size int, o *DialSettings) *PoolResolver {
34 return &PoolResolver{poolSize: size, dialOpt: o}
35}
36
37// Resolve returns a Watcher for the endpoint defined by the DialSettings
38// provided to NewPoolResolver.
39func (r *PoolResolver) Resolve(target string) (naming.Watcher, error) {
40 if r.dialOpt.Endpoint == "" {
41 return nil, errors.New("No endpoint configured")
42 }
43 addrs := make([]*naming.Update, 0, r.poolSize)
44 for i := 0; i < r.poolSize; i++ {
45 addrs = append(addrs, &naming.Update{Op: naming.Add, Addr: r.dialOpt.Endpoint, Metadata: i})
46 }
47 r.ch = make(chan []*naming.Update, 1)
48 r.ch <- addrs
49 return r, nil
50}
51
52// Next returns a static list of updates on the first call,
53// and blocks indefinitely until Close is called on subsequent calls.
54func (r *PoolResolver) Next() ([]*naming.Update, error) {
55 return <-r.ch, nil
56}
57
58// Close releases resources associated with the pool and causes Next to unblock.
59func (r *PoolResolver) Close() {
60 close(r.ch)
61}
diff --git a/vendor/google.golang.org/api/internal/service-account.json b/vendor/google.golang.org/api/internal/service-account.json
new file mode 100644
index 0000000..2cb54c2
--- /dev/null
+++ b/vendor/google.golang.org/api/internal/service-account.json
@@ -0,0 +1,12 @@
1{
2 "type": "service_account",
3 "project_id": "project_id",
4 "private_key_id": "private_key_id",
5 "private_key": "private_key",
6 "client_email": "xyz@developer.gserviceaccount.com",
7 "client_id": "123",
8 "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9 "token_uri": "https://accounts.google.com/o/oauth2/token",
10 "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11 "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xyz%40developer.gserviceaccount.com"
12}
diff --git a/vendor/google.golang.org/api/internal/settings.go b/vendor/google.golang.org/api/internal/settings.go
new file mode 100644
index 0000000..afabdc4
--- /dev/null
+++ b/vendor/google.golang.org/api/internal/settings.go
@@ -0,0 +1,81 @@
1// Copyright 2017 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Package internal supports the options and transport packages.
16package internal
17
18import (
19 "errors"
20 "net/http"
21
22 "golang.org/x/oauth2"
23 "golang.org/x/oauth2/google"
24 "google.golang.org/grpc"
25)
26
27// DialSettings holds information needed to establish a connection with a
28// Google API service.
29type DialSettings struct {
30 Endpoint string
31 Scopes []string
32 TokenSource oauth2.TokenSource
33 Credentials *google.DefaultCredentials
34 CredentialsFile string // if set, Token Source is ignored.
35 CredentialsJSON []byte
36 UserAgent string
37 APIKey string
38 HTTPClient *http.Client
39 GRPCDialOpts []grpc.DialOption
40 GRPCConn *grpc.ClientConn
41 NoAuth bool
42}
43
44// Validate reports an error if ds is invalid.
45func (ds *DialSettings) Validate() error {
46 hasCreds := ds.APIKey != "" || ds.TokenSource != nil || ds.CredentialsFile != "" || ds.Credentials != nil
47 if ds.NoAuth && hasCreds {
48 return errors.New("options.WithoutAuthentication is incompatible with any option that provides credentials")
49 }
50 // Credentials should not appear with other options.
51 // We currently allow TokenSource and CredentialsFile to coexist.
52 // TODO(jba): make TokenSource & CredentialsFile an error (breaking change).
53 nCreds := 0
54 if ds.Credentials != nil {
55 nCreds++
56 }
57 if ds.CredentialsJSON != nil {
58 nCreds++
59 }
60 if ds.CredentialsFile != "" {
61 nCreds++
62 }
63 if ds.APIKey != "" {
64 nCreds++
65 }
66 if ds.TokenSource != nil {
67 nCreds++
68 }
69 // Accept only one form of credentials, except we allow TokenSource and CredentialsFile for backwards compatibility.
70 if nCreds > 1 && !(nCreds == 2 && ds.TokenSource != nil && ds.CredentialsFile != "") {
71 return errors.New("multiple credential options provided")
72 }
73 if ds.HTTPClient != nil && ds.GRPCConn != nil {
74 return errors.New("WithHTTPClient is incompatible with WithGRPCConn")
75 }
76 if ds.HTTPClient != nil && ds.GRPCDialOpts != nil {
77 return errors.New("WithHTTPClient is incompatible with gRPC dial options")
78 }
79
80 return nil
81}