Merge branch 'master' into 10081-cwl-run-same-job
[arvados.git] / sdk / go / arvadosclient / arvadosclient.go
index aeb81f9317e871c81156ba759b163f9aeeb5f08e..e3cbfcf13effab33a5c53e12e6b1a9e4e03b18ac 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