func (mgr *Manager) BytesDataSource(fileName string, data []byte) *envoy_config_core_v3.DataSource {
	h := base36.EncodeBytes(cryptutil.Hash("filemgr", data))
	ext := filepath.Ext(fileName)
	fileName = fmt.Sprintf("%s-%x%s", fileName[:len(fileName)-len(ext)], h, ext)
	if err := os.MkdirAll(mgr.cfg.cacheDir, 0o700); err != nil {
		log.Error(context.TODO()).Err(err).Msg("filemgr: error creating cache directory, falling back to inline bytes")
		return inlineBytes(data)
	}
	filePath := filepath.Join(mgr.cfg.cacheDir, fileName)
	if _, err := os.Stat(filePath); os.IsNotExist(err) {
		err = ioutil.WriteFile(filePath, data, 0o600)
		if err != nil {
			log.Error(context.TODO()).Err(err).Msg("filemgr: error writing cache file, falling back to inline bytes")
			return inlineBytes(data)
		}
	} else if err != nil {
		log.Error(context.TODO()).Err(err).Msg("filemgr: error reading cache file, falling back to inline bytes")
		return inlineBytes(data)
	}
	return inlineFilename(filePath)
}
BytesDataSource returns an envoy config data source based on bytes.
package filemgr
import (
	"context"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
	"github.com/martinlindhe/base36"
	"github.com/pomerium/pomerium/internal/log"
	"github.com/pomerium/pomerium/pkg/cryptutil"
)
type Manager struct {
	cfg *config
}
func NewManager(options ...Option) *Manager {
	cfg := newConfig(options...)
	return &Manager{
		cfg: cfg,
	}
}