projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
16669: Accept OIDC access token in lieu of arvados api token.
[arvados.git]
/
sdk
/
go
/
arvadosclient
/
arvadosclient.go
diff --git
a/sdk/go/arvadosclient/arvadosclient.go
b/sdk/go/arvadosclient/arvadosclient.go
index 4cfda94581518fd9360ebc4f3268e231893797c7..bfcbde2a70632a170734e2664683223f4740d695 100644
(file)
--- a/
sdk/go/arvadosclient/arvadosclient.go
+++ b/
sdk/go/arvadosclient/arvadosclient.go
@@
-1,3
+1,7
@@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
/* Simple Arvados Go SDK for communicating with API server. */
package arvadosclient
/* Simple Arvados Go SDK for communicating with API server. */
package arvadosclient
@@
-20,7
+24,7
@@
import (
"sync"
"time"
"sync"
"time"
- "git.
curoverse.com
/arvados.git/sdk/go/arvados"
+ "git.
arvados.org
/arvados.git/sdk/go/arvados"
)
type StringMatcher func(string) bool
)
type StringMatcher func(string) bool
@@
-66,12
+70,11
@@
func (e APIServerError) Error() string {
e.HttpStatusCode,
e.HttpStatusMessage,
e.ServerAddress)
e.HttpStatusCode,
e.HttpStatusMessage,
e.ServerAddress)
- } else {
- return fmt.Sprintf("arvados API server error: %d: %s returned by %s",
- e.HttpStatusCode,
- e.HttpStatusMessage,
- e.ServerAddress)
}
}
+ return fmt.Sprintf("arvados API server error: %d: %s returned by %s",
+ e.HttpStatusCode,
+ e.HttpStatusMessage,
+ e.ServerAddress)
}
// StringBool tests whether s is suggestive of true. It returns true
}
// StringBool tests whether s is suggestive of true. It returns true
@@
-118,6
+121,9
@@
type ArvadosClient struct {
// Number of retries
Retries int
// Number of retries
Retries int
+
+ // X-Request-Id for outgoing requests
+ RequestID string
}
var CertFiles = []string{
}
var CertFiles = []string{
@@
-166,8
+172,11
@@
func New(c *arvados.Client) (*ArvadosClient, error) {
ApiServer: c.APIHost,
ApiToken: c.AuthToken,
ApiInsecure: c.Insecure,
ApiServer: c.APIHost,
ApiToken: c.AuthToken,
ApiInsecure: c.Insecure,
- Client: &http.Client{Transport: &http.Transport{
- TLSClientConfig: MakeTLSConfig(c.Insecure)}},
+ Client: &http.Client{
+ Timeout: 5 * time.Minute,
+ Transport: &http.Transport{
+ TLSClientConfig: MakeTLSConfig(c.Insecure)},
+ },
External: false,
Retries: 2,
KeepServiceURIs: c.KeepServiceURIs,
External: false,
Retries: 2,
KeepServiceURIs: c.KeepServiceURIs,
@@
-262,6
+271,9
@@
func (c *ArvadosClient) CallRaw(method string, resourceType string, uuid string,
// Add api token header
req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", c.ApiToken))
// Add api token header
req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", c.ApiToken))
+ if c.RequestID != "" {
+ req.Header.Add("X-Request-Id", c.RequestID)
+ }
if c.External {
req.Header.Add("X-External-Client", "1")
}
if c.External {
req.Header.Add("X-External-Client", "1")
}
@@
-407,9
+419,8
@@
func (c *ArvadosClient) Discovery(parameter string) (value interface{}, err erro
value, found = c.DiscoveryDoc[parameter]
if found {
return value, nil
value, found = c.DiscoveryDoc[parameter]
if found {
return value, nil
- } else {
- return value, ErrInvalidArgument
}
}
+ return value, ErrInvalidArgument
}
func (ac *ArvadosClient) httpClient() *http.Client {
}
func (ac *ArvadosClient) httpClient() *http.Client {