config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckConfigPermissions

func CheckConfigPermissions(path string) ([]string, []error)

CheckConfigPermissions 检查配置文件是否具有安全权限

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath 返回默认配置文件路径

func ResolveS3Provider added in v0.2.0

func ResolveS3Provider(provider string) string

Types

type Config

type Config struct {
	Mounts  []MountEntry   `yaml:"mounts" mapstructure:"mounts"`
	Include []string       `yaml:"include,omitempty" mapstructure:"include"`
	Sorting *SortingConfig `yaml:"sorting,omitempty" mapstructure:"sorting"`
	Daemon  *DaemonConfig  `yaml:"daemon,omitempty" mapstructure:"daemon"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig 从指定路径或默认路径载入配置

func (*Config) FindByName

func (c *Config) FindByName(name string) (*MountEntry, bool)

FindByName 按名称查找挂载条目

func (*Config) GetMountEntryNames

func (c *Config) GetMountEntryNames() []string

GetMountEntryNames 返回所有挂载条目名称

func (*Config) Normalize

func (c *Config) Normalize() error

Normalize 应用默认值并解析路径

func (*Config) SetMountStatus

func (c *Config) SetMountStatus(name string, isMounted bool)

SetMountStatus 更新条目的挂载状态

type ConfigError

type ConfigError struct {
	Path string
	Err  error
}

ConfigError 配置加载或验证错误

func (*ConfigError) Error

func (e *ConfigError) Error() string

func (*ConfigError) Unwrap

func (e *ConfigError) Unwrap() error

type DaemonConfig

type DaemonConfig struct {
	LogTarget  string `yaml:"log_target,omitempty" mapstructure:"log_target"`
	LogFile    string `yaml:"log_file,omitempty" mapstructure:"log_file"`
	SocketPath string `yaml:"socket_path,omitempty" mapstructure:"socket_path"`
}

func (*DaemonConfig) GetLogTarget

func (d *DaemonConfig) GetLogTarget() string

func (*DaemonConfig) Normalize

func (d *DaemonConfig) Normalize() error

func (*DaemonConfig) Validate

func (d *DaemonConfig) Validate() error

type MountEntry

type MountEntry struct {
	Name         string `yaml:"name" mapstructure:"name" validate:"required"`
	Type         string `yaml:"type" mapstructure:"type" validate:"required"`
	MountDirPath string `yaml:"mount_dir_path" mapstructure:"mount_dir_path" validate:"required"`

	SMB    *SMBConfig    `yaml:"smb,omitempty" mapstructure:"smb"`
	SSHFS  *SSHFSConfig  `yaml:"sshfs,omitempty" mapstructure:"sshfs"`
	WebDAV *WebDAVConfig `yaml:"webdav,omitempty" mapstructure:"webdav"`
	S3     *S3Config     `yaml:"s3,omitempty" mapstructure:"s3"`

	SSHTunnel *SSHTunnelConfig `yaml:"ssh_tunnel,omitempty" mapstructure:"ssh_tunnel"`

	Options   map[string]interface{} `yaml:"options,omitempty" mapstructure:"options"`
	IsMounted bool                   `yaml:"-" mapstructure:"-"`
}

MountEntry 单个挂载配置(支持多种协议)

func (*MountEntry) EnsureMountDir

func (m *MountEntry) EnsureMountDir() error

EnsureMountDir 如果挂载目录的父目录不存在则创建

func (*MountEntry) GetMountPath

func (m *MountEntry) GetMountPath() string

func (*MountEntry) HasPassword

func (m *MountEntry) HasPassword() bool

func (*MountEntry) Normalize

func (m *MountEntry) Normalize() error

Normalize 解析单个条目的挂载路径

func (*MountEntry) ValidateDriverConfig

func (m *MountEntry) ValidateDriverConfig() error

ValidateDriverConfig 根据 type 字段检查对应的配置块是否存在

type S3Config added in v0.2.0

type S3Config struct {
	Provider        string `yaml:"provider" mapstructure:"provider" validate:"required"`
	Bucket          string `yaml:"bucket" mapstructure:"bucket" validate:"required"`
	Path            string `yaml:"path,omitempty" mapstructure:"path"`
	Region          string `yaml:"region,omitempty" mapstructure:"region"`
	Endpoint        string `yaml:"endpoint,omitempty" mapstructure:"endpoint"`
	AccessKeyID     string `yaml:"access_key_id,omitempty" mapstructure:"access_key_id"`
	SecretAccessKey string `yaml:"secret_access_key,omitempty" mapstructure:"secret_access_key"`
	SessionToken    string `yaml:"session_token,omitempty" mapstructure:"session_token"`
	EnvAuth         bool   `yaml:"env_auth,omitempty" mapstructure:"env_auth"`
	ForcePathStyle  *bool  `yaml:"force_path_style,omitempty" mapstructure:"force_path_style"`
}

type SMBConfig

type SMBConfig struct {
	Addr      string `yaml:"addr" mapstructure:"addr" validate:"required"`
	Port      int    `yaml:"port,omitempty" mapstructure:"port" validate:"omitempty,min=1,max=65535"`
	ShareName string `yaml:"share_name" mapstructure:"share_name" validate:"required"`
	Username  string `yaml:"username" mapstructure:"username" validate:"required"`
	Password  string `yaml:"password,omitempty" mapstructure:"password"`
}

SMBConfig SMB/CIFS配置

func (*SMBConfig) GetPort

func (s *SMBConfig) GetPort() int

type SSHFSConfig

type SSHFSConfig struct {
	Host       string `yaml:"host" mapstructure:"host" validate:"required"`
	RemotePath string `yaml:"remote_path" mapstructure:"remote_path" validate:"required"`
}

SSHFSConfig SSHFS配置

type SSHTunnelConfig

type SSHTunnelConfig struct {
	Host string `yaml:"host" mapstructure:"host" validate:"required"`
}

type SortingConfig

type SortingConfig struct {
	By StringOrSlice `yaml:"by" mapstructure:"by"`
}

type StringOrSlice

type StringOrSlice []string

func (*StringOrSlice) UnmarshalYAML

func (s *StringOrSlice) UnmarshalYAML(value *yaml.Node) error

type WebDAVConfig

type WebDAVConfig struct {
	URL      string `yaml:"url" mapstructure:"url" validate:"required,url"`
	Username string `yaml:"username,omitempty" mapstructure:"username"`
	Password string `yaml:"password,omitempty" mapstructure:"password"`
	Path     string `yaml:"path,omitempty" mapstructure:"path"`
}

Jump to

Keyboard shortcuts

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