9955: 9950: Add shim for using an arvados.Client to configure an arvadosclient.Arvado...
authorTom Clegg <tom@curoverse.com>
Wed, 21 Sep 2016 15:09:04 +0000 (11:09 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 21 Sep 2016 15:09:04 +0000 (11:09 -0400)
sdk/go/arvadosclient/arvadosclient.go

index aeb81f9317e871c81156ba759b163f9aeeb5f08e..2582671ac2f246b571b6745c9ea89d253f243599 100644 (file)
@@ -15,6 +15,8 @@ import (
        "regexp"
        "strings"
        "time"
+
+       "git.curoverse.com/arvados.git/sdk/go/arvados"
 )
 
 type StringMatcher func(string) bool
@@ -101,6 +103,24 @@ type ArvadosClient struct {
        Retries int
 }
 
+// New returns an ArvadosClient using the given arvados.Client
+// configuration. This is useful for callers who load arvados.Client
+// fields from configuration files but still need to use the
+// arvadosclient.ArvadosClient package.
+func New(c *arvados.Client) (*ArvadosClient, error) {
+       return &ArvadosClient{
+               Scheme: "https",
+               ApiServer: c.APIHost,
+               ApiToken: c.AuthToken,
+               ApiInsecure: c.Insecure,
+               Client: &http.Client{Transport: &http.Transport{
+                       TLSClientConfig: &tls.Config{InsecureSkipVerify: c.Insecure}}},
+               External: false,
+               Retries: 2,
+               lastClosedIdlesAt: time.Now(),
+       }, nil
+}
+
 // MakeArvadosClient creates a new ArvadosClient using the standard
 // environment variables ARVADOS_API_HOST, ARVADOS_API_TOKEN,
 // ARVADOS_API_HOST_INSECURE, ARVADOS_EXTERNAL_CLIENT, and