X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/43ad590772de48fbc3a6a45654445bab79a0bdc1..15c688d1c4b41232536d0a275dd5c0fdb8879a00:/sdk/go/arvados/client.go diff --git a/sdk/go/arvados/client.go b/sdk/go/arvados/client.go index 787e01ab8f..cbc2ca72f0 100644 --- a/sdk/go/arvados/client.go +++ b/sdk/go/arvados/client.go @@ -69,6 +69,21 @@ var InsecureHTTPClient = &http.Client{ var DefaultSecureClient = &http.Client{ Timeout: 5 * time.Minute} +// NewClientFromConfig creates a new Client that uses the endpoints in +// the given cluster. +// +// AuthToken is left empty for the caller to populate. +func NewClientFromConfig(cluster *Cluster) (*Client, error) { + ctrlURL := cluster.Services.Controller.ExternalURL + if ctrlURL.Host == "" { + return nil, fmt.Errorf("no host in config Services.Controller.ExternalURL: %v", ctrlURL) + } + return &Client{ + APIHost: ctrlURL.Host, + Insecure: cluster.TLS.Insecure, + }, nil +} + // NewClientFromEnv creates a new Client that uses the default HTTP // client with the API endpoint and credentials given by the // ARVADOS_API_* environment variables.