add support for unsigned manifests to SizedDigests() in Go SDK
[arvados.git] / sdk / go / arvados / client.go
index 3d8fa55757715cd48b97fa1addaa5e2671300dbe..36f4eb52ae298982dfa09ddf82b0cea08c2604f7 100644 (file)
@@ -10,6 +10,7 @@ import (
        "net/http"
        "net/url"
        "os"
+       "strings"
        "time"
 )
 
@@ -22,7 +23,7 @@ import (
 type Client struct {
        // HTTP client used to make requests. If nil,
        // DefaultSecureClient or InsecureHTTPClient will be used.
-       Client *http.Client
+       Client *http.Client `json:"-"`
 
        // Hostname (or host:port) of Arvados API server.
        APIHost string
@@ -33,6 +34,13 @@ type Client struct {
        // Accept unverified certificates. This works only if the
        // Client field is nil: otherwise, it has no effect.
        Insecure bool
+
+       // Override keep service discovery with a list of base
+       // URIs. (Currently there are no Client methods for
+       // discovering keep services so this is just a convenience for
+       // callers who use a Client to initialize an
+       // arvadosclient.ArvadosClient.)
+       KeepServiceURIs []string `json:",omitempty"`
 }
 
 // The default http.Client used by a Client with Insecure==true and
@@ -51,10 +59,15 @@ var DefaultSecureClient = &http.Client{
 // client with the API endpoint and credentials given by the
 // ARVADOS_API_* environment variables.
 func NewClientFromEnv() *Client {
+       var svcs []string
+       if s := os.Getenv("ARVADOS_KEEP_SERVICES"); s != "" {
+               svcs = strings.Split(s, " ")
+       }
        return &Client{
-               APIHost:   os.Getenv("ARVADOS_API_HOST"),
-               AuthToken: os.Getenv("ARVADOS_API_TOKEN"),
-               Insecure:  os.Getenv("ARVADOS_API_HOST_INSECURE") != "",
+               APIHost:         os.Getenv("ARVADOS_API_HOST"),
+               AuthToken:       os.Getenv("ARVADOS_API_TOKEN"),
+               Insecure:        os.Getenv("ARVADOS_API_HOST_INSECURE") != "",
+               KeepServiceURIs: svcs,
        }
 }