config

package
v0.0.0-...-4b98c26 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SchemeFile is the URL scheme used to configure a file filesystem.
	SchemeFile = "file"
	// SchemeMem is the URL scheme used to configure an in-memory filesystem.
	SchemeMem = "mem"
	// SchemeSwift is the URL scheme used to configure a swift filesystem.
	SchemeSwift = "swift"
	// SchemeSwiftSecure is the URL scheme used to configure the swift filesystem
	// in secure mode (HTTPS).
	SchemeSwiftSecure = "swift+https"
)
View Source
const DefaultInstanceContext = "default"

DefaultInstanceContext is the default context name for an instance

View Source
const Filename = "cozy"

Filename is the default configuration filename that cozy search for

Variables

View Source
var Paths = []string{
	".",
	".cozy",
	"$HOME/.cozy",
	"/etc/cozy",
}

Paths is the list of directories used to search for a configuration file

Functions

func AdminServerAddr

func AdminServerAddr() string

AdminServerAddr returns the address on which the administration is listening

func CouchURL

func CouchURL() *url.URL

CouchURL returns the CouchDB string url

func FindConfigFile

func FindConfigFile(name string) (string, error)

FindConfigFile search in the Paths directories for the file with the given name. It returns an error if it cannot find it or if an error occurs while searching.

func FsURL

func FsURL() *url.URL

FsURL returns a copy of the filesystem URL

func GetOIDC

func GetOIDC(contextName string) (map[string]interface{}, bool)

GetOIDC returns the OIDC config for the given context (with a boolean to say if OIDC is enabled).

func GetSwiftConnection

func GetSwiftConnection() *swift.Connection

GetSwiftConnection returns a swift.Connection pointer created from the actual configuration.

func InitDefaultSwiftConnection

func InitDefaultSwiftConnection() error

InitDefaultSwiftConnection initializes the default swift handler.

func InitSwiftConnection

func InitSwiftConnection(fs Fs) error

InitSwiftConnection initialize the global swift handler connection. This is not a thread-safe method.

func MakeVault

func MakeVault(c *Config) error

MakeVault initializes the global vault.

func Normalize

func Normalize(input map[string]interface{}) map[string]interface{}

Normalize can be used on a config loaded from a Yaml file so that it can encoded as JSON. Go doesn't want to encode map[interface{}]interface{} to JSON, so we need to do some tricks to have a type that is accepted by Go.

func PasswordResetInterval

func PasswordResetInterval() time.Duration

PasswordResetInterval returns the minimal delay between two password reset

func ServerAddr

func ServerAddr() string

ServerAddr returns the address on which the stack is run

func Setup

func Setup(cfgFile string) (err error)

Setup Viper to read the environment and the optional config file

func SplitCozyHost

func SplitCozyHost(host string) (instanceHost, appSlug, siblings string)

SplitCozyHost returns a splitted host domain taking into account the subdomains configuration mode used.

func UseTestFile

func UseTestFile()

UseTestFile can be used in a test file to inject a configuration from a cozy.test.* file. If it can not find this file in your $HOME/.cozy directory it will use the default one.

func UseViper

func UseViper(v *viper.Viper) error

UseViper sets the configured instance of Config

Types

type Config

type Config struct {
	Host string
	Port int

	AdminHost           string
	AdminPort           int
	AdminSecretFileName string

	Assets                string
	Doctypes              string
	Subdomains            SubdomainType
	AlertAddr             string
	NoReplyAddr           string
	NoReplyName           string
	ReplyTo               string
	Hooks                 string
	GeoDB                 string
	PasswordResetInterval time.Duration

	CredentialsEncryptorKey string
	CredentialsDecryptorKey string

	RemoteAssets map[string]string

	Fs             Fs
	CouchDB        CouchDB
	Jobs           Jobs
	Konnectors     Konnectors
	Mail           *gomail.DialerOptions
	MailPerContext map[string]interface{}
	Matomo         Matomo
	Move           Move
	Notifications  Notifications
	Logger         logger.Options

	Lock                RedisConfig
	SessionStorage      RedisConfig
	DownloadStorage     RedisConfig
	OauthStateStorage   RedisConfig
	RateLimitingStorage RedisConfig
	Realtime            RedisConfig

	CacheStorage cache.Cache

	Contexts       map[string]interface{}
	Authentication map[string]interface{}
	Office         map[string]Office
	Registries     map[string][]*url.URL
	Clouderies     map[string]interface{}

	RemoteAllowCustomPort bool

	CSPDisabled   bool
	CSPAllowList  map[string]string
	CSPPerContext map[string]map[string]string

	AssetsPollingDisabled bool
	AssetsPollingInterval time.Duration
}

Config contains the configuration values of the application

func GetConfig

func GetConfig() *Config

GetConfig returns the configured instance of Config

type CouchDB

type CouchDB struct {
	Auth   *url.Userinfo
	URL    *url.URL
	Client *http.Client
}

CouchDB contains the configuration values of the database

type Fs

type Fs struct {
	Auth                  *url.Userinfo
	URL                   *url.URL
	Transport             http.RoundTripper
	DefaultLayout         int
	CanQueryInfo          bool
	AutoCleanTrashedAfter map[string]string
	Versioning            FsVersioning
}

Fs contains the configuration values of the file-system

type FsVersioning

type FsVersioning struct {
	MaxNumberToKeep            int
	MinDelayBetweenTwoVersions time.Duration
}

FsVersioning contains the configuration for the versioning of files

type Jobs

type Jobs struct {
	RedisConfig
	NoWorkers             bool
	AllowList             bool
	Workers               []Worker
	ImageMagickConvertCmd string
	// XXX for retro-compatibility
	NbWorkers             int
	DefaultDurationToKeep string
}

Jobs contains the configuration values for the jobs and triggers synchronization

type Konnectors

type Konnectors struct {
	Cmd string
}

Konnectors contains the configuration values for the konnectors

type Matomo

type Matomo struct {
	URL             string
	SiteID          int
	OnboardingAppID int
}

Matomo contains the configuration for the JS tracking

type Move

type Move struct {
	URL string
}

Move contains the configuration for the move wizard

type Notifications

type Notifications struct {
	Development bool

	AndroidAPIKey string
	FCMServer     string

	IOSCertificateKeyPath  string
	IOSCertificatePassword string
	IOSKeyID               string
	IOSTeamID              string

	Contexts map[string]SMS
}

Notifications contains the configuration for the mobile push-notification center, for Android and iOS

type Office

type Office struct {
	OnlyOfficeURL string
	InboxSecret   string
	OutboxSecret  string
}

Office contains the configuration for collaborative edition of office documents

type RedisConfig

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

RedisConfig contains the configuration values for a redis system

func GetRedisConfig

func GetRedisConfig(v *viper.Viper, mainOpt *redis.UniversalOptions, key, ptr string) (conf RedisConfig, err error)

GetRedisConfig returns a

func NewRedisConfig

func NewRedisConfig(u string) (conf RedisConfig, err error)

NewRedisConfig creates a redis configuration and its associated client.

func (*RedisConfig) Client

func (rc *RedisConfig) Client() redis.UniversalClient

Client returns the redis.Client for a RedisConfig

type SMS

type SMS struct {
	Provider string
	URL      string
	Token    string
}

SMS contains the configuration to send notifications by SMS.

type SubdomainType

type SubdomainType int

SubdomainType specify how subdomains are structured.

const (
	// FlatSubdomains is the value for apps subdomains like
	// https://<user>-<app>.<domain>/
	FlatSubdomains SubdomainType = iota + 1
	// NestedSubdomains is the value for apps subdomains like
	// https://<app>.<user>.<domain>/ (used by default)
	NestedSubdomains
)

type Vault

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

Vault contains security keys used for various encryption or signing of critical assets.

func GetVault

func GetVault() *Vault

GetVault returns the configured instance of Vault

func (*Vault) CredentialsDecryptorKey

func (v *Vault) CredentialsDecryptorKey() *keymgmt.NACLKey

CredentialsDecryptorKey returns the key used to decrypt credentials values, stored in accounts.

func (*Vault) CredentialsEncryptorKey

func (v *Vault) CredentialsEncryptorKey() *keymgmt.NACLKey

CredentialsEncryptorKey returns the key used to encrypt credentials values, stored in accounts.

type Worker

type Worker struct {
	WorkerType   string
	Concurrency  *int
	MaxExecCount *int
	Timeout      *time.Duration
}

Worker contains the configuration fields for a specific worker type.

Jump to

Keyboard shortcuts

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