config

package
v0.6.0-beta Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FsConfigGroup       = "org.basenana.nanafs.fs"
	FsAPIConfigGroup    = "org.basenana.nanafs.fs.api"
	AuthConfigGroup     = "org.basenana.nanafs.authentication"
	DocConfigGroup      = "org.basenana.nanafs.document"
	PluginConfigGroup   = "org.basenana.nanafs.plugin"
	WorkflowConfigGroup = "org.basenana.nanafs.workflow"
	WebdavConfigGroup   = "org.basenana.nanafs.webdav"
	AdminApiConfigGroup = "org.basenana.nanafs.admin.api"
)
View Source
const (
	MemoryMeta    = "memory"
	SqliteMeta    = "sqlite"
	PostgresMeta  = "postgres"
	S3Storage     = "s3"
	OSSStorage    = "oss"
	MinioStorage  = "minio"
	WebdavStorage = "webdav"
	LocalStorage  = "local"
	MemoryStorage = "memory"

	AESEncryption      = "AES"
	ChaCha20Encryption = "ChaCha20"
)
View Source
const (
	DefaultConfigBase = "nanafs.conf"
)

Variables

View Source
var (
	ErrNotConfigured = fmt.Errorf("no configured")
)
View Source
var FilePath string

Functions

func LocalUserPath

func LocalUserPath() string

func Verify

func Verify(cfg *Bootstrap) error

Types

type Bootstrap

type Bootstrap struct {
	FUSE FUSE `json:"fuse"`

	Meta             Meta       `json:"meta"`
	Storages         []Storage  `json:"storages"`
	GlobalEncryption Encryption `json:"global_encryption"`

	FS     *FS                `json:"fs,omitempty"`
	Friday *fridayconf.Config `json:"friday,omitempty"`

	CacheDir  string `json:"cache_dir,omitempty"`
	CacheSize int    `json:"cache_size,omitempty"`
	Debug     bool   `json:"debug,omitempty"`
}

type CMDB

type CMDB interface {
	GetConfigValue(ctx context.Context, group, name string) (string, error)
	SetConfigValue(ctx context.Context, group, name, value string) error
}

func NewFakeCmdb

func NewFakeCmdb() CMDB

type Encryption

type Encryption struct {
	Enable    bool   `json:"enable"`
	Method    string `json:"method"`
	SecretKey string `json:"secret_key"`
}

type FS

type FS struct {
	Owner     FSOwner `json:"owner,omitempty"`
	Writeback bool    `json:"writeback,omitempty"`
	PageSize  int     `json:"page_size,omitempty"`
}

type FSOwner

type FSOwner struct {
	Uid int64 `json:"uid"`
	Gid int64 `json:"gid"`
}

type FUSE

type FUSE struct {
	Enable       bool     `json:"enable"`
	RootPath     string   `json:"root_path"`
	MountOptions []string `json:"mount_options,omitempty"`
	DisplayName  string   `json:"display_name,omitempty"`
	VerboseLog   bool     `json:"verbose_log,omitempty"`

	EntryTimeout *int `json:"entry_timeout,omitempty"`
	AttrTimeout  *int `json:"attr_timeout,omitempty"`
}

type FsApi

type FsApi struct {
	Enable     bool   `json:"enable"`
	Host       string `json:"host"`
	Port       int    `json:"port"`
	Metrics    bool   `json:"metrics"`
	ServerName string `json:"server_name"`
	CertFile   string `json:"cert_file"`
	KeyFile    string `json:"key_file"`
	CaFile     string `json:"ca_file"`
	CaKeyFile  string `json:"ca_key_file"`
}

type Loader

type Loader interface {
	GetBootstrapConfig() (Bootstrap, error)
	InitCMDB(cmdb CMDB) error
	SetSystemConfig(ctx context.Context, group, name string, value any) error
	GetSystemConfig(ctx context.Context, group, name string) Value
}

func NewConfigLoader

func NewConfigLoader() Loader

func NewFakeConfigLoader

func NewFakeConfigLoader(b Bootstrap) Loader

type Meta

type Meta struct {
	Type string `json:"type"`
	Path string `json:"path,omitempty"`
	DSN  string `json:"dsn,omitempty"`
}

type MinIOConfig

type MinIOConfig struct {
	Endpoint        string `json:"endpoint"`
	AccessKeyID     string `json:"access_key_id"`
	SecretAccessKey string `json:"secret_access_key"`
	BucketName      string `json:"bucket_name"`
	Location        string `json:"location"`
	Token           string `json:"token"`
	UseSSL          bool   `json:"use_ssl"`
}

type OSSConfig

type OSSConfig struct {
	Endpoint        string `json:"endpoint"`
	AccessKeyID     string `json:"access_key_id"`
	AccessKeySecret string `json:"access_key_secret"`
	BucketName      string `json:"bucket_name"`
}

type OverwriteUser

type OverwriteUser struct {
	UID      int64  `json:"uid"`
	GID      int64  `json:"gid"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type S3Config

type S3Config struct {
	AccessKeyID     string `json:"access_key_id"`
	SecretAccessKey string `json:"secret_access_key"`
	Region          string `json:"region"`
	BucketName      string `json:"bucket_name"`
	UsePathStyle    bool   `json:"use_path_style"`
}

type Storage

type Storage struct {
	ID         string               `json:"id"`
	Type       string               `json:"type"`
	LocalDir   string               `json:"local_dir,omitempty"`
	S3         *S3Config            `json:"s3,omitempty"`
	MinIO      *MinIOConfig         `json:"minio,omitempty"`
	OSS        *OSSConfig           `json:"oss,omitempty"`
	Webdav     *WebdavStorageConfig `json:"webdav,omitempty"`
	Encryption *Encryption          `json:"encryption,omitempty"`
}

type Value

type Value struct {
	Group string
	Name  string
	Value string
	Error error

	Expiration *time.Time
}

func (Value) Bool

func (v Value) Bool() (bool, error)

func (Value) Int

func (v Value) Int() (int, error)

func (Value) Int64

func (v Value) Int64() (int64, error)

func (Value) String

func (v Value) String() (string, error)

func (Value) Unmarshal

func (v Value) Unmarshal(data any) error

type Version

type Version struct {
	Major   int    `json:"major"`
	Minor   int    `json:"minor"`
	Patch   int    `json:"patch"`
	Release string `json:"release"`
	Git     string `json:"git"`
}

func VersionInfo

func VersionInfo() Version

func (Version) Version

func (v Version) Version() string

type Webdav

type Webdav struct {
	Enable         bool            `json:"enable"`
	Host           string          `json:"host"`
	Port           int             `json:"port"`
	OverwriteUsers []OverwriteUser `json:"overwrite_users"`
}

type WebdavStorageConfig

type WebdavStorageConfig struct {
	ServerURL string `json:"server_url"`
	Username  string `json:"username"`
	Password  string `json:"password"`
	Insecure  bool   `json:"insecure,omitempty"`
}

Jump to

Keyboard shortcuts

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