// NewEnvironProvider returns a new EnvironProvider for Azure.
342903
func NewEnvironProvider(config ProviderConfig) (*azureEnvironProvider, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Annotate(err, "validating environ provider configuration")
	}
	return &azureEnvironProvider{
		environProviderCredentials: environProviderCredentials{
			servicePrincipalCreator: config.ServicePrincipalCreator,
			azureCLI:                config.AzureCLI,
		},
		config: config,
	}, nil
}
886652
func NewDNSProvider() (*DNSProvider, error) {
	config := NewDefaultConfig()

	endpoint, err := url.Parse(env.GetOrDefaultString("EASYDNS_ENDPOINT", defaultEndpoint))
	if err != nil {
		return nil, fmt.Errorf("easydns: %v", err)
	}
	config.Endpoint = endpoint

	values, err := env.Get("EASYDNS_TOKEN", "EASYDNS_KEY")
	if err != nil {
		return nil, fmt.Errorf("easydns: %v", err)
	}

	config.Token = values["EASYDNS_TOKEN"]
	config.Key = values["EASYDNS_KEY"]

	return NewDNSProviderConfig(config)
}
1179669
func NewAzureCloudConfig(c *cli.Context) cloudconfigs.CloudConfigProvider {
	provider := &azureCloudConfig{
		Context: c,
	}
	return provider
}
1032843
func NewDNSProvider() (*DNSProvider, error) {
	values, err := env.Get("OVH_ENDPOINT", "OVH_APPLICATION_KEY", "OVH_APPLICATION_SECRET", "OVH_CONSUMER_KEY")
	if err != nil {
		return nil, fmt.Errorf("ovh: %v", err)
	}

	config := NewDefaultConfig()
	config.APIEndpoint = values["OVH_ENDPOINT"]
	config.ApplicationKey = values["OVH_APPLICATION_KEY"]
	config.ApplicationSecret = values["OVH_APPLICATION_SECRET"]
	config.ConsumerKey = values["OVH_CONSUMER_KEY"]

	return NewDNSProviderConfig(config)
}
728276
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config.SecretKey == "" || config.AccessKey == "" || config.DoServiceCode == "" {
		return nil, fmt.Errorf("iij: credentials missing")
	}

	return &DNSProvider{
		api:    doapi.NewAPI(config.AccessKey, config.SecretKey),
		config: config,
	}, nil
}
350661
func NewOracleEnviron(p *EnvironProvider, args environs.OpenParams, client EnvironAPI, c clock.Clock) (env *OracleEnviron, err error) {
	if client == nil {
		return nil, errors.NotFoundf("oracle client")
	}
	if p == nil {
		return nil, errors.NotFoundf("environ proivder")
	}
	env = &OracleEnviron{
		p:      p,
		spec:   args.Cloud,
		cfg:    args.Config,
		mutex:  &sync.Mutex{},
		client: client,
		clock:  c,
	}
	env.namespace, err = instance.NewNamespace(env.cfg.UUID())
	if err != nil {
		return nil, errors.Trace(err)
	}
	env.Firewaller = oraclenet.NewFirewall(env, client, c)
	env.Networking = oraclenet.NewEnviron(client, env)

	source := rand.NewSource(env.clock.Now().UTC().UnixNano())
	r := rand.New(source)
	env.rand = r

	return env, nil
}
1213030
func NewDNSProvider() (*DNSProvider, error) {
	values, err := env.Get("EXEC_PATH")
	if err != nil {
		return nil, fmt.Errorf("exec: %v", err)
	}

	config := NewDefaultConfig()
	config.Program = values["EXEC_PATH"]
	config.Mode = os.Getenv("EXEC_MODE")

	return NewDNSProviderConfig(config)
}
219037
func NewAuthorizerFromEnvironment() (autorest.Authorizer, error) {
	settings, err := GetSettingsFromEnvironment()
	if err != nil {
		return nil, err
	}
	return settings.GetAuthorizer()
}
971563
func NewProvider() Provider {
	dbProvider := leveldbhelper.NewProvider(&leveldbhelper.Conf{DBPath: getInternalBookkeeperPath()})
	return &provider{dbProvider: dbProvider}
}
560731
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("ns1: the configuration of the DNS provider is nil")
	}

	if config.APIKey == "" {
		return nil, fmt.Errorf("ns1: credentials missing")
	}

	client := rest.NewClient(config.HTTPClient, rest.SetAPIKey(config.APIKey))

	return &DNSProvider{client: client, config: config}, nil
}
837361
func NewEnvironment(root, configRoot, workspace, sshKeyName string, metadata datasource.Metadata) *Environment {
	firstNonNull := func(ip net.IP, env string) string {
		if ip == nil {
			return env
		}
		return ip.String()
	}
	substitutions := map[string]string{
		"$public_ipv4":  firstNonNull(metadata.PublicIPv4, os.Getenv("COREOS_PUBLIC_IPV4")),
		"$private_ipv4": firstNonNull(metadata.PrivateIPv4, os.Getenv("COREOS_PRIVATE_IPV4")),
		"$public_ipv6":  firstNonNull(metadata.PublicIPv6, os.Getenv("COREOS_PUBLIC_IPV6")),
		"$private_ipv6": firstNonNull(metadata.PrivateIPv6, os.Getenv("COREOS_PRIVATE_IPV6")),
	}
	return &Environment{root, configRoot, workspace, sshKeyName, substitutions}
}
452808
func NewDNSProvider() (*DNSProvider, error) {
	values, err := env.Get("NAMECOM_USERNAME", "NAMECOM_API_TOKEN")
	if err != nil {
		return nil, fmt.Errorf("namedotcom: %v", err)
	}

	config := NewDefaultConfig()
	config.Username = values["NAMECOM_USERNAME"]
	config.APIToken = values["NAMECOM_API_TOKEN"]
	config.Server = env.GetOrFile("NAMECOM_SERVER")

	return NewDNSProviderConfig(config)
}
1259107
func NewProvider(ctx context.Context, issuer string) (*Provider, error) {
	wellKnown := strings.TrimSuffix(issuer, "/") + "/.well-known/openid-configuration"
	resp, err := contextClient(ctx).Get(wellKnown)
	if err != nil {
		return nil, err
	}
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("%s: %s", resp.Status, body)
	}
	defer resp.Body.Close()
	var p Provider
	if err := json.Unmarshal(body, &p); err != nil {
		return nil, fmt.Errorf("oidc: failed to decode provider discovery object: %v", err)
	}
	p.rawClaims = body
	if p.Issuer != issuer {
		return nil, fmt.Errorf("oidc: issuer did not match the issuer returned by provider, expected %q got %q", issuer, p.Issuer)
	}
	return &p, nil
}
287958
func (env *environ) newContainer(
	ctx context.ProviderCallContext,
	args environs.StartInstanceParams,
	arch string,
) (*lxd.Container, error) {
	// Note: other providers have the ImageMetadata already read for them
	// and passed in as args.ImageMetadata. However, lxd provider doesn't
	// use datatype: image-ids, it uses datatype: image-download, and we
	// don't have a registered cloud/region.
	imageSources, err := env.getImageSources()
	if err != nil {
		return nil, errors.Trace(err)
	}

	// Keep track of StatusCallback output so we may clean up later.
	// This is implemented here, close to where the StatusCallback calls
	// are made, instead of at a higher level in the package, so as not to
	// assume that all providers will have the same need to be implemented
	// in the same way.
	longestMsg := 0
	statusCallback := func(currentStatus status.Status, msg string, data map[string]interface{}) error {
		if args.StatusCallback != nil {
			args.StatusCallback(currentStatus, msg, nil)
		}
		if len(msg) > longestMsg {
			longestMsg = len(msg)
		}
		return nil
	}
	cleanupCallback := func() {
		if args.CleanupCallback != nil {
			args.CleanupCallback(strings.Repeat(" ", longestMsg))
		}
	}
	defer cleanupCallback()

	target, err := env.getTargetServer(ctx, args)
	if err != nil {
		return nil, errors.Trace(err)
	}

	image, err := target.FindImage(args.InstanceConfig.Series, arch, imageSources, true, statusCallback)
	if err != nil {
		return nil, errors.Trace(err)
	}
	cleanupCallback() // Clean out any long line of completed download status

	cSpec, err := env.getContainerSpec(image, target.ServerVersion(), args)
	if err != nil {
		return nil, errors.Trace(err)
	}

	statusCallback(status.Allocating, "Creating container", nil)
	container, err := target.CreateContainerFromSpec(cSpec)
	if err != nil {
		return nil, errors.Trace(err)
	}
	statusCallback(status.Running, "Container started", nil)
	return container, nil
}
1085073
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("gandi: the configuration of the DNS provider is nil")
	}

	if config.APIKey == "" {
		return nil, fmt.Errorf("gandi: no API Key given")
	}

	if config.BaseURL == "" {
		config.BaseURL = defaultBaseURL
	}

	return &DNSProvider{
		config:              config,
		inProgressFQDNs:     make(map[string]inProgressInfo),
		inProgressAuthZones: make(map[string]struct{}),
		findZoneByFqdn:      dns01.FindZoneByFqdn,
	}, nil
}
1224419
func NewProvider(fs filesystem.Filespace, helpersPath, layoutPath, viewPath, extension string, funcs template.FuncMap) *Provider {
	return &Provider{
		fs:          fs,
		layoutPath:  layoutPath,
		helpersPath: helpersPath,
		viewPath:    viewPath,
		extension:   extension,
		layouts:     map[string]*template.Template{},
		views:       map[string]*template.Template{},
		funcs:       funcs,
	}
}
121781
func (e *Environ) StorageProvider(t storage.ProviderType) (storage.Provider, error) {
	if t == ociStorageProviderType {
		return &storageProvider{
			env: e,
			api: e.Storage,
		}, nil
	}

	return nil, errors.NotFoundf("storage provider %q", t)
}