Merge branch '21535-multi-wf-delete'
[arvados.git] / sdk / go / arvadosclient / arvadosclient.go
index 516187c0e6146506b790a0ef8f95dcb7ac11c1f1..1f849ebacec5bdb61038ec72cd09525957ee503f 100644 (file)
@@ -9,21 +9,18 @@ package arvadosclient
 import (
        "bytes"
        "crypto/tls"
-       "crypto/x509"
        "encoding/json"
        "errors"
        "fmt"
        "io"
-       "io/ioutil"
-       "log"
        "net/http"
        "net/url"
-       "os"
        "strings"
        "sync"
        "time"
 
        "git.arvados.org/arvados.git/sdk/go/arvados"
+       "github.com/sirupsen/logrus"
 )
 
 type StringMatcher func(string) bool
@@ -109,6 +106,14 @@ type ArvadosClient struct {
        // available services.
        KeepServiceURIs []string
 
+       // Maximum disk cache size in bytes or percent of total
+       // filesystem size. If zero, use default, currently 10% of
+       // filesystem size.
+       DiskCacheSize arvados.ByteSizeOrPercent
+
+       // Where to write debug logs. May be nil.
+       Logger logrus.FieldLogger
+
        // Discovery document
        DiscoveryDoc Dict
 
@@ -121,40 +126,10 @@ type ArvadosClient struct {
        RequestID string
 }
 
-var CertFiles = []string{
-       "/etc/arvados/ca-certificates.crt",
-       "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
-       "/etc/pki/tls/certs/ca-bundle.crt",   // Fedora/RHEL
-}
-
 // MakeTLSConfig sets up TLS configuration for communicating with
 // Arvados and Keep services.
 func MakeTLSConfig(insecure bool) *tls.Config {
-       tlsconfig := tls.Config{InsecureSkipVerify: insecure}
-
-       if !insecure {
-               // Use the first entry in CertFiles that we can read
-               // certificates from. If none of those work out, use
-               // the Go defaults.
-               certs := x509.NewCertPool()
-               for _, file := range CertFiles {
-                       data, err := ioutil.ReadFile(file)
-                       if err != nil {
-                               if !os.IsNotExist(err) {
-                                       log.Printf("proceeding without loading cert file %q: %s", file, err)
-                               }
-                               continue
-                       }
-                       if !certs.AppendCertsFromPEM(data) {
-                               log.Printf("unable to load any certificates from %v", file)
-                               continue
-                       }
-                       tlsconfig.RootCAs = certs
-                       break
-               }
-       }
-
-       return &tlsconfig
+       return &tls.Config{InsecureSkipVerify: insecure}
 }
 
 // New returns an ArvadosClient using the given arvados.Client
@@ -178,6 +153,8 @@ func New(c *arvados.Client) (*ArvadosClient, error) {
                Client:            hc,
                Retries:           2,
                KeepServiceURIs:   c.KeepServiceURIs,
+               DiskCacheSize:     c.DiskCacheSize,
+               Logger:            c.Logger,
                lastClosedIdlesAt: time.Now(),
        }