// HtdigestFileProvider is a SecretProvider implementation based on
// htdigest-formated files. It will automatically reload htdigest file
// on changes. It panics on syntax errors in htdigest files.
554911
func HtdigestFileProvider(filename string) SecretProvider {
	hf := &HtdigestFile{File: File{Path: filename}}
	hf.Reload = func() { reloadHTDigest(hf) }
	return func(user, realm string) string {
		hf.ReloadIfNeeded()
		hf.mu.RLock()
		defer hf.mu.RUnlock()
		_, exists := hf.Users[realm]
		if !exists {
			return ""
		}
		digest, exists := hf.Users[realm][user]
		if !exists {
			return ""
		}
		return digest
	}
}
52052
func (a *Client) DeleteFilesFileidentifier(params *DeleteFilesFileidentifierParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteFilesFileidentifierNoContent, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewDeleteFilesFileidentifierParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "DeleteFilesFileidentifier",
		Method:             "DELETE",
		PathPattern:        "/files/{fileidentifier}",
		ProducesMediaTypes: []string{"application/json", "application/x-gzip"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &DeleteFilesFileidentifierReader{formats: a.formats},
		AuthInfo:           authInfo,
	})
	if err != nil {
		return nil, err
	}
	return result.(*DeleteFilesFileidentifierNoContent), nil
}
64189
func (c *Context) SaveOAuthProvider(baseURL url.URL, id string, secret string) (*OAuthProvider, error) {
	if id == "" || secret == "" {
		return nil, errors.New("id and secret must not be empty")
	}

	baseURL.Host = strings.ToLower(baseURL.Host)

	provider := OAuthProvider{BaseURL: baseURL, ID: id, Secret: secret, Service: c.ServiceName}
	//TODO: multiply installations on one host are not available
	c.db.C("oauth_providers").UpsertId(provider.internalID(), provider.toBson())

	return &provider, nil
}
514168
func (c *Configuration) InitACMEProvider() (*acmeprovider.Provider, error) {
	if c.ACME != nil {
		if len(c.ACME.Storage) == 0 {
			return nil, errors.New("unable to initialize ACME provider with no storage location for the certificates")
		}
		return &acmeprovider.Provider{
			Configuration: c.ACME,
		}, nil
	}
	return nil, nil
}
610272
func (a *Client) PutFilesFileidentifier(params *PutFilesFileidentifierParams, authInfo runtime.ClientAuthInfoWriter) (*PutFilesFileidentifierCreated, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewPutFilesFileidentifierParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "PutFilesFileidentifier",
		Method:             "PUT",
		PathPattern:        "/files/{fileidentifier}",
		ProducesMediaTypes: []string{"application/json", "application/x-gzip"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &PutFilesFileidentifierReader{formats: a.formats},
		AuthInfo:           authInfo,
	})
	if err != nil {
		return nil, err
	}
	return result.(*PutFilesFileidentifierCreated), nil
}
1196054
func (m *Meta) loadHCLFile(filename string) (hcl.Body, tfdiags.Diagnostics) {
	var diags tfdiags.Diagnostics
	filename = m.normalizePath(filename)

	loader, err := m.initConfigLoader()
	if err != nil {
		diags = diags.Append(err)
		return nil, diags
	}

	body, hclDiags := loader.Parser().LoadHCLFile(filename)
	diags = diags.Append(hclDiags)
	return body, diags
}
870429
func (c *RDPOpener) RDPFileContent() string {
	addr := c.IPAddress
	if c.Port > 0 {
		addr = fmt.Sprintf("%s:%d", c.IPAddress, c.Port)
	}

	template := c.RDPFileTemplate
	if template == "" {
		template = defaultRDPTemplate
	}
	return fmt.Sprintf(template, addr, c.User)
}
934171
func (env *environ) StorageProvider(t storage.ProviderType) (storage.Provider, error) {
	if env.storageSupported() && t == lxdStorageProviderType {
		return &lxdStorageProvider{env}, nil
	}
	return nil, errors.NotFoundf("storage provider %q", t)
}
170839
func (pc *PCCloud) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) {
	return []v1.NodeAddress{}, cloudprovider.NotImplemented
}
307556
func NewTlfEditHistoryFile(folder *Folder) *SpecialReadFile {
	return &SpecialReadFile{
		read: func(ctx context.Context) ([]byte, time.Time, error) {
			return libfs.GetEncodedTlfEditHistory(
				ctx, folder.fs.config, folder.getFolderBranch())
		},
		fs: folder.fs,
	}
}
561235
func (dht *IpfsDHT) FindProviders(ctx context.Context, c cid.Cid) ([]pstore.PeerInfo, error) {
	var providers []pstore.PeerInfo
	for p := range dht.FindProvidersAsync(ctx, c, KValue) {
		providers = append(providers, p)
	}
	return providers, nil
}
436244
func (m *model) RemoteNeedFolderFiles(device protocol.DeviceID, folder string, page, perpage int) ([]db.FileInfoTruncated, error) {
	m.fmut.RLock()
	m.pmut.RLock()
	err := m.checkDeviceFolderConnectedLocked(device, folder)
	rf := m.folderFiles[folder]
	m.pmut.RUnlock()
	m.fmut.RUnlock()
	if err != nil {
		return nil, err
	}

	files := make([]db.FileInfoTruncated, 0, perpage)
	skip := (page - 1) * perpage
	get := perpage
	rf.WithNeedTruncated(device, func(f db.FileIntf) bool {
		if skip > 0 {
			skip--
			return true
		}
		files = append(files, f.(db.FileInfoTruncated))
		get--
		return get > 0
	})

	return files, nil
}
7300
func NewStorageProviderRegistry(reg storage.ProviderRegistry) storage.ProviderRegistry {
	return storage.ChainedProviderRegistry{reg, provider.CommonStorageProviders()}
}
156084
func (k *kubernetesClient) StorageProvider(t storage.ProviderType) (storage.Provider, error) {
	if t == K8s_ProviderType {
		return &storageProvider{k}, nil
	}
	return nil, errors.NotFoundf("storage provider %q", t)
}
756364
func (d *initData) CertificateWriteDir() string {
	if d.dryRun {
		return d.dryRunDir
	}
	return d.certificatesDir
}
1031369
func (ec *Envcfg) buildCertProvider() CertificateProvider {
	provider := ec.GetKey(ec.certProviderKey)
	var params []string
	if i := strings.Index(provider, ":"); i != -1 {
		provider, params = strings.TrimSpace(provider[:i]), strings.Split(provider[i+1:], ":")
	}

	switch provider {
	case "", "auto":
		return &autocert.Manager{
			Prompt:     autocert.AcceptTOS,
			HostPolicy: autocert.HostWhitelist(ec.Host()),
			Cache:      autocert.DirCache(ec.CertPath()),
		}

	case "dns":
		return ec.dnsCertProvider(params)

	case "disk":
		return ec.diskCertProvider(params)

	case "none":
		return nil

	default:
		panic("unknown certificate provider type: " + provider)
	}
}
1271814
func (s *EncryptionEntity) SetProviderId(v string) *EncryptionEntity {
	s.ProviderId = &v
	return s
}