projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '17722-adjust-token-expiry' refs #17722
[arvados.git]
/
sdk
/
go
/
arvados
/
client.go
diff --git
a/sdk/go/arvados/client.go
b/sdk/go/arvados/client.go
index 52c75d5113c2a9399267e90fb8c18c8a5aeeaad7..13bb3bf80de70c11e4567ab69ea56c9c03b28a8f 100644
(file)
--- a/
sdk/go/arvados/client.go
+++ b/
sdk/go/arvados/client.go
@@
-9,6
+9,7
@@
import (
"context"
"crypto/tls"
"encoding/json"
"context"
"crypto/tls"
"encoding/json"
+ "errors"
"fmt"
"io"
"io/ioutil"
"fmt"
"io"
"io/ioutil"
@@
-67,6
+68,10
@@
type Client struct {
dd *DiscoveryDocument
defaultRequestID string
dd *DiscoveryDocument
defaultRequestID string
+
+ // APIHost and AuthToken were loaded from ARVADOS_* env vars
+ // (used to customize "no host/token" error messages)
+ loadedFromEnv bool
}
// InsecureHTTPClient is the default http.Client used by a Client with
}
// InsecureHTTPClient is the default http.Client used by a Client with
@@
-123,6
+128,7
@@
func NewClientFromEnv() *Client {
Insecure: insecure,
KeepServiceURIs: svcs,
Timeout: 5 * time.Minute,
Insecure: insecure,
KeepServiceURIs: svcs,
Timeout: 5 * time.Minute,
+ loadedFromEnv: true,
}
}
}
}
@@
-312,6
+318,12
@@
func (c *Client) RequestAndDecodeContext(ctx context.Context, dst interface{}, m
// Ensure body is closed even if we error out early
defer body.Close()
}
// Ensure body is closed even if we error out early
defer body.Close()
}
+ if c.APIHost == "" {
+ if c.loadedFromEnv {
+ return errors.New("ARVADOS_API_HOST and/or ARVADOS_API_TOKEN environment variables are not set")
+ }
+ return errors.New("arvados.Client cannot perform request: APIHost is not set")
+ }
urlString := c.apiURL(path)
urlValues, err := anythingToValues(params)
if err != nil {
urlString := c.apiURL(path)
urlValues, err := anythingToValues(params)
if err != nil {