directory

package
v0.0.0-...-cbe6392 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 30 Imported by: 32

Documentation

Index

Constants

View Source
const (
	GlobalDirKey   = NamespaceID("global")
	NonSaaSDirKey  = NamespaceID("default")
	DatabaseDirKey = NamespaceID("database")
	NamespaceKey   = "namespace"

	LicenseActiveKey = "license_active"
)
View Source
const (
	ConsoleURLSettingKey = "console_url"
)

Variables

View Source
var (
	FileServerExternal       = utils.GetEnvOrDefault("DEEPFENCE_FILE_SERVER_EXTERNAL", "false") == "true"
	FileServerProtocol       string
	FileServerSecure         = utils.GetEnvOrDefault("DEEPFENCE_FILE_SERVER_SECURE", "false") == "true"
	FileServerHost           = utils.GetEnvOrDefault("DEEPFENCE_FILE_SERVER_HOST", "deepfence-file-server")
	FileServerPort           = utils.GetEnvOrDefault("DEEPFENCE_FILE_SERVER_PORT", "9000")
	FileServerRegion         = utils.GetEnvOrDefault("DEEPFENCE_FILE_SERVER_REGION", "")
	FileServerBucket         = utils.GetEnvOrDefault("DEEPFENCE_FILE_SERVER_BUCKET", string(NonSaaSDirKey))
	FileServerDatabaseBucket = utils.GetEnvOrDefault("DEEPFENCE_FILE_SERVER_DB_BUCKET", string(DatabaseDirKey))
)
View Source
var ErrDatabaseConfigNotFound = errors.New("database config not found")
View Source
var ErrExhaustedResources = errors.New("exhausted worker resources")
View Source
var ErrNamespaceNotFound = errors.New("namespace/tenet-id not found")

Functions

func CheckLicenseActive

func CheckLicenseActive(next http.Handler) http.Handler

func ContextWithNameSpace

func ContextWithNameSpace(ctx context.Context, ns NamespaceID) context.Context

func ForEachNamespace

func ForEachNamespace(applyFn func(ctx context.Context) (string, error))

func GetFileServerHost

func GetFileServerHost(ctx context.Context) (string, error)

func GetFileServerURL

func GetFileServerURL(ctx context.Context) (string, error)

func Injector

func Injector(next http.Handler) http.Handler

Injector makes sure the context is filled with the information provided by the JWT.

func IsNonSaaSDeployment

func IsNonSaaSDeployment() bool

func Neo4jClient

func Neo4jClient(ctx context.Context) (neo4j.DriverWithContext, error)

func NewContextWithNameSpace

func NewContextWithNameSpace(ns NamespaceID) context.Context

func NewGlobalContext

func NewGlobalContext() context.Context

func NewSQLConnection

func NewSQLConnection(ctx context.Context) (*sql.DB, error)

func PostgresClient

func PostgresClient(ctx context.Context) (*postgresqlDb.Queries, error)

func RedisClient

func RedisClient(ctx context.Context) (*redis.Client, error)

func WithDatabaseContext

func WithDatabaseContext(ctx context.Context) context.Context

func WithGlobalContext

func WithGlobalContext(ctx context.Context) context.Context

Types

type AlreadyPresentError

type AlreadyPresentError struct {
	Path string
}

func (AlreadyPresentError) Error

func (e AlreadyPresentError) Error() string

type CypherDriver

type CypherDriver struct {
	// contains filtered or unexported fields
}

type DBConfigs

type DBConfigs struct {
	Redis      *RedisConfig
	Neo4j      *Neo4jConfig
	Postgres   *PostgresqlConfig
	FileServer *FileServerConfig
}

func GetDatabaseConfig

func GetDatabaseConfig(ctx context.Context) (*DBConfigs, error)

type FileDeleteError

type FileDeleteError struct {
	Path string
}

func (FileDeleteError) Error

func (e FileDeleteError) Error() string

type FileManager

type FileManager interface {
	ListFiles(ctx context.Context, pathPrefix string, recursive bool, maxKeys int, skipDir bool) []ObjectInfo
	UploadLocalFile(ctx context.Context, filename string, localFilename string, overwrite bool, extra interface{}) (UploadResult, error)
	UploadFile(ctx context.Context, filename string, data []byte, overwrite bool, extra interface{}) (UploadResult, error)
	DeleteFile(ctx context.Context, filename string, addFilePathPrefix bool, extra interface{}) error
	DownloadFile(ctx context.Context, remoteFile string, localFile string, extra interface{}) error
	DownloadFileTo(ctx context.Context, remoteFile string, localFile io.WriteCloser, extra interface{}) error
	DownloadFileContexts(ctx context.Context, remoteFile string, extra interface{}) ([]byte, error)
	ExposeFile(ctx context.Context, filePath string, addFilePathPrefix bool, expires time.Duration, reqParams url.Values, consoleURL string) (string, error)
	CreatePublicUploadURL(ctx context.Context, filePath string, addFilePathPrefix bool, expires time.Duration, reqParams url.Values, consoleURL string) (string, error)
	Client() interface{}
	Bucket() string
	CreatePublicBucket(ctx context.Context, bucket string) error
	CleanNamespace(ctx context.Context) error
}

func FileServerClient

func FileServerClient(ctx context.Context) (FileManager, error)

type FileServerConfig

type FileServerConfig struct {
	Endpoint   string
	Username   string
	Password   string
	BucketName string
	Secure     bool
	Region     string
}

type FileServerFileManager

type FileServerFileManager struct {
	// contains filtered or unexported fields
}

func (*FileServerFileManager) Bucket

func (mfm *FileServerFileManager) Bucket() string

func (*FileServerFileManager) CleanNamespace

func (mfm *FileServerFileManager) CleanNamespace(ctx context.Context) error

func (*FileServerFileManager) Client

func (mfm *FileServerFileManager) Client() interface{}

func (*FileServerFileManager) CreatePublicBucket

func (mfm *FileServerFileManager) CreatePublicBucket(ctx context.Context, bucket string) error

func (*FileServerFileManager) CreatePublicUploadURL

func (mfm *FileServerFileManager) CreatePublicUploadURL(ctx context.Context, filePath string, addFilePathPrefix bool, expires time.Duration, reqParams url.Values, consoleURL string) (string, error)

func (*FileServerFileManager) DeleteFile

func (mfm *FileServerFileManager) DeleteFile(ctx context.Context, filePath string, addFilePathPrefix bool, extra interface{}) error

func (*FileServerFileManager) DownloadFile

func (mfm *FileServerFileManager) DownloadFile(ctx context.Context, remoteFile string, localFile string, extra interface{}) error

func (*FileServerFileManager) DownloadFileContexts

func (mfm *FileServerFileManager) DownloadFileContexts(ctx context.Context, remoteFile string, extra interface{}) ([]byte, error)

func (*FileServerFileManager) DownloadFileTo

func (mfm *FileServerFileManager) DownloadFileTo(ctx context.Context, remoteFile string, writer io.WriteCloser, extra interface{}) error

func (*FileServerFileManager) ExposeFile

func (mfm *FileServerFileManager) ExposeFile(ctx context.Context, filePath string, addFilePathPrefix bool, expires time.Duration, reqParams url.Values, consoleURL string) (string, error)

func (*FileServerFileManager) ListFiles

func (mfm *FileServerFileManager) ListFiles(ctx context.Context, pathPrefix string, recursive bool, maxKeys int, skipDir bool) []ObjectInfo

func (*FileServerFileManager) UploadFile

func (mfm *FileServerFileManager) UploadFile(ctx context.Context,
	filename string, data []byte, overwrite bool, extra interface{}) (UploadResult, error)

func (*FileServerFileManager) UploadLocalFile

func (mfm *FileServerFileManager) UploadLocalFile(ctx context.Context,
	filename string, localFilename string, overwrite bool, extra interface{}) (UploadResult, error)

type NamespaceID

type NamespaceID string

func ExtractNamespace

func ExtractNamespace(ctx context.Context) (NamespaceID, error)

func FetchNamespace

func FetchNamespace(email string) NamespaceID

func GetAllNamespaces

func GetAllNamespaces() []NamespaceID

type Neo4jConfig

type Neo4jConfig struct {
	Endpoint string
	Username string
	Password string
}

type ObjectInfo

type ObjectInfo struct {
	Key          string    `json:"name"`         // Name of the object
	LastModified time.Time `json:"lastModified"` // Date and time the object was last modified.
	Size         int64     `json:"size"`         // Size in bytes of the object.
	ContentType  string    `json:"contentType"`  // A standard MIME type describing the format of the object data.
	Expires      time.Time `json:"expires"`      // The date and time at which the object is no longer able to be cached.
	IsDir        bool      `json:"isDir"`        // Is this object a directory
}

type PathDoesNotExistsError

type PathDoesNotExistsError struct {
	Path string
}

func (PathDoesNotExistsError) Error

func (e PathDoesNotExistsError) Error() string

type PostgresqlConfig

type PostgresqlConfig struct {
	Host     string
	Port     int
	Username string
	Password string
	Database string
	SslMode  string
}

type RedisConfig

type RedisConfig struct {
	Endpoint string
	Password string
	Database int
}

type SettingValue

type SettingValue struct {
	Label       string      `json:"label"`
	Value       interface{} `json:"value"`
	Description string      `json:"description"`
}

type UploadResult

type UploadResult struct {
	Bucket       string
	Key          string
	ETag         string
	Size         int64
	LastModified time.Time
	Location     string
	VersionID    string
}

type WorkEnqueuer

type WorkEnqueuer struct {
	// contains filtered or unexported fields
}

func Worker

func Worker(ctx context.Context) (WorkEnqueuer, error)

func (WorkEnqueuer) DeleteAllArchivedTasks

func (ws WorkEnqueuer) DeleteAllArchivedTasks() (int, []error)

func (WorkEnqueuer) Enqueue

func (ws WorkEnqueuer) Enqueue(taskEnum string, data []byte, opts ...asynq.Option) error

func (WorkEnqueuer) EnqueueUnique

func (ws WorkEnqueuer) EnqueueUnique(taskEnum string, data []byte, opts ...asynq.Option) error

utility func to use when task name is used as task id to ensure unique task is enqueued

func (WorkEnqueuer) Inspector

func (ws WorkEnqueuer) Inspector() *asynq.Inspector

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL