//Create a CcaClient with a custom URL that accepts insecure connections
976356
func NewInsecureCcaClientWithURL(apiURL string, apiKey string) *CcaClient {
	apiClient := api.NewInsecureApiClient(apiURL, apiKey)
	return NewCcaClientWithApiClient(apiClient)
}
757751
func newRPCClient(c *Client) (*RPCClient, error) {
	// Connect to the client
	conn, err := net.Dial(c.address.Network(), c.address.String())
	if err != nil {
		return nil, err
	}
	if tcpConn, ok := conn.(*net.TCPConn); ok {
		// Make sure to set keep alive so that the connection doesn't die
		tcpConn.SetKeepAlive(true)
	}

	if c.config.TLSConfig != nil {
		conn = tls.Client(conn, c.config.TLSConfig)
	}

	// Create the actual RPC client
	result, err := NewRPCClient(conn, c.config.Plugins)
	if err != nil {
		conn.Close()
		return nil, err
	}

	// Begin the stream syncing so that stdin, out, err work properly
	err = result.SyncStreams(
		c.config.SyncStdout,
		c.config.SyncStderr)
	if err != nil {
		result.Close()
		return nil, err
	}

	return result, nil
}
186299
func NewMetricsClient(caCertificatePath string, iamConfigPath string) (*http.Client, error) {
	client := &http.Client{}
	tr, err := getTransport(caCertificatePath)
	if err != nil {
		return client, err
	}
	client.Transport = tr

	if len(iamConfigPath) != 0 {
		rt, err := transport.NewRoundTripper(
			client.Transport,
			transport.OptionReadIAMConfig(iamConfigPath))
		if err != nil {
			log.Fatal(err)
		}
		client.Transport = rt
	}

	return client, nil
}
1057673
func NewRawKVClient(pdAddrs []string, security config.Security) (*RawKVClient, error) {
	pdCli, err := pd.NewClient(pdAddrs, pd.SecurityOption{
		CAPath:   security.ClusterSSLCA,
		CertPath: security.ClusterSSLCert,
		KeyPath:  security.ClusterSSLKey,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return &RawKVClient{
		clusterID:   pdCli.GetClusterID(context.TODO()),
		regionCache: NewRegionCache(pdCli),
		pdClient:    pdCli,
		rpcClient:   newRPCClient(security),
	}, nil
}
229060
func ConfigToClient(config interface{}) (Client, error) {
	switch cfg := config.(type) {
	case NodeConfig:
		return CreateNodeClient(cfg)
	case ClusterConfig:
		return CreateClusterClient(cfg)
	case SentinelConfig:
		return CreateSentinelClient(cfg)
	case nil:
		return nil, fmt.Errorf("Configuration cannot be nil")
	}
	return nil, fmt.Errorf("Unknown configuration type %T", config)
}
357123
func newOrcClient() (*orcClient, error) {
	if *orcAddr == "" {
		// Orchestrator integration is disabled.
		return nil, nil
	}
	apiRoot, err := url.Parse(*orcAddr)
	if err != nil {
		return nil, vterrors.Wrapf(err, "can't parse -orc_api_url flag value (%v)", *orcAddr)
	}
	return &orcClient{
		apiRoot:    apiRoot,
		httpClient: &http.Client{Timeout: *orcTimeout},
	}, nil
}
109907
func newReconnectRPCClient(serverAddr, serviceEndpoint string) *ReconnectRPCClient {
	return &ReconnectRPCClient{
		serverAddr:      serverAddr,
		serviceEndpoint: serviceEndpoint,
	}
}
424706
func CreateHTTPTransport(caBundle *x509.CertPool, hostname string) *http.Transport {
	return &http.Transport{TLSClientConfig: &tls.Config{
		ServerName: hostname,
		RootCAs:    caBundle,
	}}
}
1195473
func NewAccessClient(c context.Context) (*AccessClient, error) {
	settings := GetSettings(c)
	if settings.Buildbucket.GetHost() == "" {
		return nil, errors.Reason("no buildbucket host found").Err()
	}
	t, err := auth.GetRPCTransport(c, auth.AsUser)
	if err != nil {
		return nil, errors.Annotate(err, "getting RPC Transport").Err()
	}
	return &AccessClient{
		AccessClient: bbAccess.NewClient(settings.Buildbucket.Host, &http.Client{Transport: t}),
		Host:         settings.Buildbucket.Host,
	}, nil
}
423231
func NewRPCClient(storePath, certsDir string) libmachine.API {
	c := libmachine.NewClient(storePath, certsDir)
	c.SSHClientType = ssh.Native
	return c
}
614259
func (c *Client) initHTTPClient() {
	tr := &http.Transport{
		Dial: c.dial,
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
	}
	c.httpClient = &http.Client{Transport: tr}
}
1311098
func appURL(acdClient argocdclient.Client, appName string) string {
	var scheme string
	opts := acdClient.ClientOptions()
	server := opts.ServerAddr
	if opts.PlainText {
		scheme = "http"
	} else {
		scheme = "https"
		if strings.HasSuffix(opts.ServerAddr, ":443") {
			server = server[0 : len(server)-4]
		}
	}
	return fmt.Sprintf("%s://%s/applications/%s", scheme, server, appName)
}
1123320
func (b *Broker) CreateAcls(request *CreateAclsRequest) (*CreateAclsResponse, error) {
	response := new(CreateAclsResponse)

	err := b.sendAndReceive(request, response)
	if err != nil {
		return nil, err
	}

	return response, nil
}
249982
func NewCustomisedURL(clientKey, secret, callbackURL, authURL, tokenURL, userAPIEndpoint string, scopes ...string) *Provider {
	p := &Provider{
		ClientKey:       clientKey,
		Secret:          secret,
		CallbackURL:     callbackURL,
		UserAPIEndpoint: userAPIEndpoint,
		Config: &oauth2.Config{
			ClientID:     clientKey,
			ClientSecret: secret,
			RedirectURL:  callbackURL,
			Endpoint: oauth2.Endpoint{
				AuthURL:  authURL,
				TokenURL: tokenURL,
			},
			Scopes: scopes,
		},
		providerName: "influxcloud",
	}
	return p
}
740973
func ConfigToClient(cfg *Config) (*api.Config, error) {
	clientCfg := api.DefaultConfig()
	if cfg.Address != "" {
		clientCfg.Address = cfg.Address
	}
	return clientCfg, nil
}
496662
func newKvClient(machine string, p connectionParams) (*api.Config, *api.Client, error) {
	config := api.DefaultConfig()
	config.HttpClient = http.DefaultClient
	config.Address = machine
	config.Scheme = "http"
	config.Token = p.options[kvdb.ACLTokenKey]

	// check if TLS is required
	if p.options[kvdb.TransportScheme] == "https" {
		tlsConfig := &api.TLSConfig{
			CAFile:             p.options[kvdb.CAFileKey],
			CertFile:           p.options[kvdb.CertFileKey],
			KeyFile:            p.options[kvdb.CertKeyFileKey],
			Address:            p.options[kvdb.CAAuthAddress],
			InsecureSkipVerify: strings.ToLower(p.options[kvdb.InsecureSkipVerify]) == "true",
		}

		consulTLSConfig, err := api.SetupTLSConfig(tlsConfig)
		if err != nil {
			logrus.Fatal(err)
		}

		config.Scheme = p.options[kvdb.TransportScheme]
		config.HttpClient = new(http.Client)
		config.HttpClient.Transport = &http.Transport{
			TLSClientConfig: consulTLSConfig,
		}
	}

	client, err := api.NewClient(config)
	if err != nil {
		logrus.Info("consul: failed to get new api client: %v", err)
		return nil, nil, err
	}

	// check health to ensure communication with consul are working
	if _, _, err := client.Health().State(api.HealthAny, nil); err != nil {
		logrus.Errorf("consul: health check failed for %v : %v", machine, err)
		return nil, nil, err
	}

	return config, client, nil
}
995795
func CreateConnectionDefinition(couchDBAddress, username, password string, maxRetries,
	maxRetriesOnStartup int, requestTimeout time.Duration, createGlobalChangesDB bool) (*CouchConnectionDef, error) {

	logger.Debugf("Entering CreateConnectionDefinition()")

	connectURL := &url.URL{
		Host:   couchDBAddress,
		Scheme: "http",
	}

	//parse the constructed URL to verify no errors
	finalURL, err := url.Parse(connectURL.String())
	if err != nil {
		logger.Errorf("URL parse error: %s", err)
		return nil, errors.Wrapf(err, "error parsing connect URL: %s", connectURL)
	}

	logger.Debugf("Created database configuration  URL=[%s]", finalURL.String())
	logger.Debugf("Exiting CreateConnectionDefinition()")

	//return an object containing the connection information
	return &CouchConnectionDef{finalURL.String(), username, password, maxRetries,
		maxRetriesOnStartup, requestTimeout, createGlobalChangesDB}, nil

}