From e7aa0bb4c04e9fca75fe396579f4d29ac92d9617 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Wed, 21 Sep 2016 11:09:04 -0400 Subject: [PATCH 1/1] 9955: 9950: Add shim for using an arvados.Client to configure an arvadosclient.ArvadosClient. --- sdk/go/arvadosclient/arvadosclient.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sdk/go/arvadosclient/arvadosclient.go b/sdk/go/arvadosclient/arvadosclient.go index aeb81f9317..2582671ac2 100644 --- a/sdk/go/arvadosclient/arvadosclient.go +++ b/sdk/go/arvadosclient/arvadosclient.go @@ -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 -- 2.30.2