// New constructs a new Driver with the given Aliyun credentials, region, encryption flag, and
// bucketName
427742
func New(params DriverParameters) (*Driver, error) {

	client := oss.NewOSSClient(params.Region, params.Internal, params.AccessKeyID, params.AccessKeySecret, params.Secure)
	client.SetEndpoint(params.Endpoint)
	bucket := client.Bucket(params.Bucket)
	client.SetDebug(false)

	// Validate that the given credentials have at least read permissions in the
	// given bucket scope.
	if _, err := bucket.List(strings.TrimRight(params.RootDirectory, "/"), "", "", 1); err != nil {
		return nil, err
	}

	// TODO(tg123): Currently multipart uploads have no timestamps, so this would be unwise
	// if you initiated a new OSS client while another one is running on the same bucket.

	d := &driver{
		Client:          client,
		Bucket:          bucket,
		ChunkSize:       params.ChunkSize,
		Encrypt:         params.Encrypt,
		RootDirectory:   params.RootDirectory,
		EncryptionKeyID: params.EncryptionKeyID,
	}

	return &Driver{
		baseEmbed: baseEmbed{
			Base: base.Base{
				StorageDriver: d,
			},
		},
	}, nil
}
831823
func New(endpoints []string, ca, cert, key string) (*Client, error) {
	client := Client{Endpoints: endpoints}

	if ca != "" || cert != "" || key != "" {
		tlsInfo := transport.TLSInfo{
			CertFile:      cert,
			KeyFile:       key,
			TrustedCAFile: ca,
		}
		tlsConfig, err := tlsInfo.ClientConfig()
		if err != nil {
			return nil, err
		}
		client.TLS = tlsConfig
	}

	return &client, nil
}
883059
func New(cnf *config.Config) iface.Broker {
	b := &Broker{Broker: common.NewBroker(cnf)}
	if cnf.SQS != nil && cnf.SQS.Client != nil {
		// Use provided *SQS client
		b.service = cnf.SQS.Client
	} else {
		// Initialize a session that the SDK will use to load credentials from the shared credentials file, ~/.aws/credentials.
		// See details on: https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html
		// Also, env AWS_REGION is also required
		b.sess = session.Must(session.NewSessionWithOptions(session.Options{
			SharedConfigState: session.SharedConfigEnable,
		}))
		b.service = awssqs.New(b.sess)
	}

	return b
}
152756
func New(org, team, certpath, keypath string, cfg *config.Config) (g *http.Gatekeeper, err error) {
	api := api.NewClient(cfg)
	http, err := http.NewGatekeeper(org, team, certpath, keypath, cfg, api)
	if err != nil {
		return nil, err
	}

	return http, nil
}
1305213
func New(loader stick.Loader) *stick.Env {
	if loader == nil {
		loader = &stick.StringLoader{}
	}
	env := &stick.Env{
		Loader:    loader,
		Functions: make(map[string]stick.Func),
		Filters:   filter.TwigFilters(),
		Tests:     make(map[string]stick.Test),
		Visitors:  make([]parse.NodeVisitor, 0),
	}
	env.Register(NewAutoEscapeExtension())
	return env
}
129654
func New(providerName string, identityMapper authapi.UserIdentityMapper) authenticator.Password {
	return &alwaysAcceptPasswordAuthenticator{providerName, identityMapper}
}
662449
func New(serviceURL, userAccount string) *CloudAPI {
	URL, err := url.Parse(serviceURL)
	if err != nil {
		panic(err)
	}
	hostname := URL.Host
	if !strings.HasSuffix(hostname, separator) {
		hostname += separator
	}

	var (
		keys          []cloudapi.Key
		machines      []*machine
		snapshots     = map[string][]cloudapi.Snapshot{}
		firewallRules []*cloudapi.FirewallRule
		fabricVLANs   = map[int16]*fabricVLAN{}
	)

	cloudapiService := &CloudAPI{
		keys:          keys,
		packages:      initPackages(),
		images:        initImages(),
		machines:      machines,
		snapshots:     snapshots,
		firewallRules: firewallRules,
		fabricVLANs:   fabricVLANs,
		networks: []cloudapi.Network{
			{Id: "123abc4d-0011-aabb-2233-ccdd4455", Name: "Test-Joyent-Public", Public: true},
			{Id: "456def0a-33ff-7f8e-9a0b-33bb44cc", Name: "Test-Joyent-Private", Public: false},
		},
		ServiceInstance: localservices.ServiceInstance{
			Scheme:      URL.Scheme,
			Hostname:    hostname,
			UserAccount: userAccount,
		},
	}

	return cloudapiService
}
1201032
func New(dbName string, idAlloc autoid.Allocator) (KvEncoder, error) {
	kvEnc := &kvEncoder{}
	mu.Lock()
	defer mu.Unlock()
	if refCount == 0 {
		if err := initGlobal(); err != nil {
			return nil, err
		}
	}
	err := kvEnc.initial(dbName, idAlloc)
	if err != nil {
		return nil, err
	}
	refCount++
	return kvEnc, nil
}
1204394
func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, usingLegacyStats bool) (Interface, error) {
	client, err := winstats.NewPerfCounterClient()
	return &cadvisorClient{
		rootPath:       rootPath,
		winStatsClient: client,
	}, err
}
923451
func New(pg plugingetter.PluginGetter, netConfig *NetworkConfig) (networkallocator.NetworkAllocator, error) {
	na := &cnmNetworkAllocator{
		networks: make(map[string]*network),
		services: make(map[string]struct{}),
		tasks:    make(map[string]struct{}),
		nodes:    make(map[string]map[string]struct{}),
	}

	// There are no driver configurations and notification
	// functions as of now.
	reg, err := drvregistry.New(nil, nil, nil, nil, pg)
	if err != nil {
		return nil, err
	}

	if err := initializeDrivers(reg); err != nil {
		return nil, err
	}

	if err = initIPAMDrivers(reg, netConfig); err != nil {
		return nil, err
	}

	pa, err := newPortAllocator()
	if err != nil {
		return nil, err
	}

	na.portAllocator = pa
	na.drvRegistry = reg
	return na, nil
}
332967
func New(w io.Writer) *ZipArchive {
	return &ZipArchive{
		writer:      w,
		isHasWriter: true,
	}
}
1148701
func New(name string, clusterID string, kv kvdb.Kvdb) (Alert, error) {
	lock.Lock()
	defer lock.Unlock()

	if initFunc, exists := drivers[name]; exists {
		driver, err := initFunc(kv, clusterID)
		if err != nil {
			return nil, err
		}
		instances[name] = driver
		return driver, err
	}
	return nil, ErrNotSupported
}
367179
func (s *MyNewRelic) New(appEnv *cfenv.App) *MyNewRelic {
	serviceName := os.Getenv("NEWRELIC_SERVICE_NAME")
	keyName := os.Getenv("NEWRELIC_KEY_NAME")
	appName := os.Getenv("NEWRELIC_APP_NAME")
	service, err := appEnv.Services.WithName(serviceName)

	if err != nil {
		panic(fmt.Sprintf("new relic service name error: %s", err.Error()))
	}
	s.Key = service.Credentials[keyName].(string)
	s.App = service.Credentials[appName].(string)
	return s
}
1211943
func New(url string) (Driver, error) {
	u, err := neturl.Parse(url)
	if err != nil {
		return nil, err
	}

	d := GetDriver(u.Scheme)
	if d == nil {
		return nil, fmt.Errorf("Driver '%s' not found.", u.Scheme)
	}
	verifyFilenameExtension(u.Scheme, d)
	if err := d.Initialize(url); err != nil {
		return nil, err
	}

	return d, nil
}
177915
func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ManagerSerfCluster, connPoolPinger Pinger) (m *Manager) {
	m = new(Manager)
	m.logger = logger
	m.clusterInfo = clusterInfo       // can't pass *consul.Client: import cycle
	m.connPoolPinger = connPoolPinger // can't pass *consul.ConnPool: import cycle
	m.rebalanceTimer = time.NewTimer(clientRPCMinReuseDuration)
	m.shutdownCh = shutdownCh
	atomic.StoreInt32(&m.offline, 1)

	l := serverList{}
	l.servers = make([]*metadata.Server, 0)
	m.saveServerList(l)
	return m
}
935479
func New(c *Config) (hash.Hash, error) {
	if c == nil {
		c = defaultConfig
	} else {
		if c.Size == 0 {
			// Set default size if it's zero.
			c.Size = Size
		}
		if err := verifyConfig(c); err != nil {
			return nil, err
		}
	}
	d := new(digest)
	d.initialize(c)
	return d, nil
}
746939
func New(s s3iface.S3API, name string) *Bucket {
	return &Bucket{
		S3:   s,
		Name: aws.String(name),
	}
}