config

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidatorLogrusLogLevel            = "logrus_log_level"
	ValidateDBDriver                   = "db_driver"
	ValidatorBookmarkManager           = "bookmark_manager"
	ValidatorTagsManager               = "tags_manager"
	ValidatorDocumentManager           = "document_manager"
	ValidatorDocumentContentManager    = "document_content_manager"
	ValidatorBookmarkRepository        = "bookmark_repository"
	ValidatorTagsRepository            = "tags_repository"
	ValidatorDocumentRepository        = "document_repository"
	ValidatorDocumentContentRepository = "document_content_repository"
	ValidatorHooks                     = "hooks"
	ValidatorHookPoint                 = "hook_point"
	ValidatorHook                      = "hook"
)
View Source
const (
	LogFile         = "log_file"
	ConsoleLogLevel = "console_log_level"
	FileLogLevel    = "file_log_level"
	DB              = "db"
	DB_Driver       = DB + ".driver"
	DB_DataSource   = DB + ".data_source"
	DB_Args         = DB + ".args"
	Backend         = "backend"
)

Variables

View Source
var ConfigValidator = validator.New()

Functions

This section is empty.

Types

type BackendConfig

type BackendConfig struct {
	Bookmarkmanager        BookmarkManagerConfig        `name:"bookmark_manager" mapstructure:"bookmark_manager" validate:"required,bookmark_manager"`
	TagsManager            TagsManagerConfig            `name:"tags_manager" mapstructure:"tags_manager" validate:"required,tags_manager"`
	DocumentManager        DocumentManagerConfig        `name:"document_manager" mapstructure:"document_manager" validate:"required,document_manager"`
	DocumentContentManager DocumentContentManagerConfig `name:"document_content_manager" mapstructure:"document_content_manager" validate:"required,document_content_manager"`
}

type BookmarkManagerConfig

type BookmarkManagerConfig struct {
	Hooks              HooksConfig              `name:"hooks" mapstructure:"hooks"`
	BookmarkRepository BookmarkRepositoryConfig `name:"bookmark_repository" mapstructure:"bookmark_repository" validate:"required,bookmark_repository"`
}

type BookmarkRepositoryConfig

type BookmarkRepositoryConfig struct {
	DB            DBConfig             `name:"db" mapstructure:"db" validate:"required"`
	TagRepository TagsRepositoryConfig `name:"tag_repository" mapstructure:"tag_repository" validate:"required"`
}

type Config

type Config struct {
	LogFile         string        `name:"log_file" mapstructure:"log_file" validate:"required,file"`
	ConsoleLogLevel string        `name:"console_log_level" mapstructure:"console_log_level" validate:"required,logrus_log_level"`
	FileLogLevel    string        `name:"file_log_level" mapstructure:"file_log_level" validate:"required,logrus_log_level"`
	DB              DBConfig      `name:"db" mapstructure:"db" validate:"required"`
	Backend         BackendConfig `name:"backend" mapstructure:"backend" validate:"required"`
}

TODO: Add test to validate that The field name, tag "name" and "mapstructure" match.

type ConfigManager added in v0.6.0

type ConfigManager struct {
	Viper             *viper.Viper
	DBOverride        *sql.DB
	FSOverride        afero.Fs
	PendingLogMessage []message
	Logger            *log.Logger

	PassedConfigPath   string
	ConfigDir          string
	CacheDir           string
	TempDir            string
	ConfigFileBaseName string
	ConfigSearchPaths  []string
}

func NewConfigManager added in v0.6.0

func NewConfigManager(stderr io.Writer, dbOverride *sql.DB, fsOverride afero.Fs) (m *ConfigManager, err error)

func (*ConfigManager) GetDefaultDBConfig added in v0.6.0

func (m *ConfigManager) GetDefaultDBConfig() DBConfig

func (*ConfigManager) GetDefaultSettings added in v0.6.0

func (m *ConfigManager) GetDefaultSettings() map[string]any

func (*ConfigManager) NewBackendFromConfig added in v0.6.0

func (m *ConfigManager) NewBackendFromConfig() (newBackend *backend.Backend, err error)

********************** Set up backend **********************//

func (*ConfigManager) NewBookmarkManagerFromConfig added in v0.6.0

func (m *ConfigManager) NewBookmarkManagerFromConfig(logger *log.Logger, repo repository.BookmarkRepository) (manager libbookmarks.BookmarkManager, err error)

TODO: Implement proper hook parsing ******************** Manager builders ********************//

func (*ConfigManager) NewBookmarkRepositoryFromConfig added in v0.6.0

func (m *ConfigManager) NewBookmarkRepositoryFromConfig(logger *log.Logger, repoDB *sql.DB, tagRepository repository.TagRepository) (repo repository.BookmarkRepository, err error)

******************** Repository builders ********************// TODO: Allow using non-sql repositories.

func (*ConfigManager) NewDBFromConfig added in v0.6.0

func (m *ConfigManager) NewDBFromConfig() (db *sql.DB, err error)

func (*ConfigManager) NewDocumentContentManagerFromConfig added in v0.6.0

func (m *ConfigManager) NewDocumentContentManagerFromConfig(logger *log.Logger, repo repository.DocumentContentRepository) (manager libdocuments.DocumentContentManager, err error)

func (*ConfigManager) NewDocumentContentRepositoryFromConfig added in v0.6.0

func (m *ConfigManager) NewDocumentContentRepositoryFromConfig(logger *log.Logger, fs afero.Fs) (repo repository.DocumentContentRepository, err error)

TODO: Allow non-fs content repositories

func (*ConfigManager) NewDocumentManagerFromConfig added in v0.6.0

func (m *ConfigManager) NewDocumentManagerFromConfig(logger *log.Logger, repo repository.DocumentRepository) (manager libdocuments.DocumentManager, err error)

func (*ConfigManager) NewDocumentRepositoryFromConfig added in v0.6.0

func (m *ConfigManager) NewDocumentRepositoryFromConfig(logger *log.Logger, repoDB *sql.DB, tagRepository repository.TagRepository) (repo repository.DocumentRepository, err error)

func (*ConfigManager) NewTagsManagerFromConfig added in v0.6.0

func (m *ConfigManager) NewTagsManagerFromConfig(logger *log.Logger, repo repository.TagRepository) (manager libtags.TagManager, err error)

func (*ConfigManager) NewTagsRepositoryFromConfig added in v0.6.0

func (m *ConfigManager) NewTagsRepositoryFromConfig(logger *log.Logger, repoDB *sql.DB) (repo repository.TagRepository, err error)

type DBConfig

type DBConfig struct {
	Driver     string   `name:"driver" mapstructure:"driver" validate:"required,db_driver"`
	DataSource string   `name:"data_source" mapstructure:"data_source" validate:"required,file"`
	Args       []string `name:"args" mapstructure:"args"`
}

type DocumentContentManagerConfig

type DocumentContentManagerConfig struct {
	Hooks                     HooksConfig                     `name:"hooks" mapstructure:"hooks"`
	DocumentContentRepository DocumentContentRepositoryConfig `name:"document_content_repository" mapstructure:"document_content_repository" validate:"required,document_content_repository"`
}

type DocumentContentRepositoryConfig

type DocumentContentRepositoryConfig struct {
	DB DBConfig `name:"db" mapstructure:"db" validate:"required"`
}

type DocumentManagerConfig

type DocumentManagerConfig struct {
	Hooks              HooksConfig              `name:"hooks" mapstructure:"hooks"`
	DocumentRepository DocumentRepositoryConfig `name:"document_repository" mapstructure:"document_repository" validate:"required,document_repository"`
}

type DocumentRepositoryConfig

type DocumentRepositoryConfig struct {
	DB            DBConfig             `name:"db" mapstructure:"db" validate:"required"`
	TagRepository TagsRepositoryConfig `name:"tag_repository" mapstructure:"tag_repository" validate:"required"`
}

type HooksConfig

type HooksConfig struct {
	HookPoints map[string][]string `name:"hooks" mapstructure:"hooks" validate:"dive,keys,hook_point,endkeys,dive,hook"`
}

type TagsManagerConfig

type TagsManagerConfig struct {
	Hooks          HooksConfig          `name:"hooks" mapstructure:"hooks"`
	TagsRepository TagsRepositoryConfig `name:"tags_repository" mapstructure:"tags_repository" validate:"required,tags_repository"`
}

type TagsRepositoryConfig

type TagsRepositoryConfig struct {
	DB DBConfig `name:"db" mapstructure:"db" validate:"required"`
}

Jump to

Keyboard shortcuts

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