Documentation
¶
Overview ¶
Package config is where the configuration from the configuration files, the command line parameters, and the environment variables is used to fill some structs, and initializes connections (to Swift for example).
Index ¶
- Constants
- Variables
- func AdminServerAddr() string
- func Avatars() *avatar.Service
- func CouchClient() *http.Client
- func FindConfigFile(name string) (string, error)
- func FsURL() *url.URL
- func GetCommonSettings() map[string]CommonSettings
- func GetFranceConnect(contextName string) (map[string]interface{}, bool)
- func GetKeyring() keyring.Keyring
- func GetOIDC(contextName string) (map[string]interface{}, bool)
- func GetPublicOIDC(contextName string) (map[string]interface{}, bool)
- func GetPublicOIDCContext(contextName string) string
- func GetRateLimiter() *limits.RateLimiter
- func GetRedis(v *viper.Viper, mainOpt *redis.UniversalOptions, key, ptr string) (redis.UniversalClient, error)
- func GetSwiftConnection() *swift.Connection
- func InitDefaultSwiftConnection() error
- func InitSwiftConnection(fs Fs) error
- func Lock() lock.Getter
- func PDF() *pdf.Service
- func PasswordResetInterval() time.Duration
- func ServerAddr() string
- func Setup(cfgFile string) (err error)
- func SplitCozyHost(host string) (instanceHost, appSlug, siblings string)
- func UseTestFile(t *testing.T)
- func UseViper(v *viper.Viper) error
- type AntivirusContextConfig
- type AntivirusNotificationsConfig
- type ClouderyAPI
- type ClouderyConfig
- type CommonSettings
- type Config
- type CouchDB
- type CouchDBCluster
- type DeprecatedApp
- type DeprecatedAppsCfg
- type Flagship
- type Fs
- type FsVersioning
- type Jobs
- type Konnectors
- type Move
- type Notifications
- type Office
- type RAGServer
- type RabbitExchange
- type RabbitMQ
- type RabbitMQNode
- type RabbitMQTLS
- type RabbitQueue
- type SMS
- type SharingConfig
- type SharingNotificationsConfig
- type SubdomainType
- type Worker
Constants ¶
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" )
const DefaultInstanceContext = "default"
DefaultInstanceContext is the default context name for an instance
const Filename = "cozy"
Filename is the default configuration filename that cozy search for
Variables ¶
var Paths = []string{
".",
".cozy",
"$HOME/.cozy",
"$HOME/.config/cozy",
"$XDG_CONFIG_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 CouchClient ¶
CouchClient returns the http client to use when making requests to a CouchDB cluster.
func FindConfigFile ¶
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 GetCommonSettings ¶
func GetCommonSettings() map[string]CommonSettings
GetCommonSettings returns the CommonSettings configuration
func GetFranceConnect ¶
GetFranceConnect returns the FranceConnect config for the given context (with a boolean to say if FranceConnect is enabled).
func GetKeyring ¶
GetKeyring returns the configured instance of keyring.Keyring
func GetOIDC ¶
GetOIDC returns the OIDC config for the given context (with a boolean to say if OIDC is enabled).
func GetPublicOIDC ¶
GetPublicOIDC returns the public Twake OIDC configuration from the configured context If contextName is empty, it uses the default context
func GetPublicOIDCContext ¶
GetPublicOIDCContext returns the context name for public OIDC from the specific context or falls back to the default context if not set
func GetRateLimiter ¶
func GetRateLimiter() *limits.RateLimiter
GetRateLimiter return the setup rate limiter.
func GetRedis ¶
func GetRedis(v *viper.Viper, mainOpt *redis.UniversalOptions, key, ptr string) (redis.UniversalClient, error)
GetRedis returns a redis.UniversalClient for the given db.
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 ¶
InitSwiftConnection initialize the global swift handler connection. This is not a thread-safe method.
func PasswordResetInterval ¶
PasswordResetInterval returns the minimal delay between two password reset
func SplitCozyHost ¶
SplitCozyHost returns a splitted host domain taking into account the subdomains configuration mode used.
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.
Types ¶
type AntivirusContextConfig ¶
type AntivirusContextConfig struct {
// Enabled enables or disables antivirus scanning for this context
Enabled bool `json:"enabled" mapstructure:"enabled"`
// Address is the ClamAV daemon TCP address (e.g., "localhost:3310")
Address string `json:"address,omitempty" mapstructure:"address"`
// Timeout is the maximum time to wait for a scan to complete
Timeout time.Duration `json:"timeout,omitempty" mapstructure:"timeout"`
// MaxFileSize is the maximum file size to scan (larger files are skipped)
MaxFileSize int64 `json:"max_file_size,omitempty" mapstructure:"max_file_size"`
// OnInfected defines the action when an infected file is detected: "warn" or "block".
OnInfected string `json:"on_infected,omitempty" mapstructure:"on_infected"`
Notifications AntivirusNotificationsConfig `json:"notifications,omitempty" mapstructure:"notifications"`
Actions map[string][]string `json:"actions,omitempty" mapstructure:"actions"`
}
AntivirusContextConfig contains the antivirus settings for a context.
func GetAntivirusConfig ¶
func GetAntivirusConfig(contextName string) *AntivirusContextConfig
GetAntivirusConfig returns the antivirus configuration for a given context.
type AntivirusNotificationsConfig ¶
type AntivirusNotificationsConfig struct {
EmailOnInfected bool `json:"email_on_infected" mapstructure:"email_on_infected"`
}
AntivirusNotificationsConfig contains notification settings for antivirus.
type ClouderyAPI ¶
type ClouderyConfig ¶
type ClouderyConfig struct {
API ClouderyAPI `mapstructure:"api"`
}
ClouderyConfig for [cloudery.ClouderyService].
type CommonSettings ¶
CommonSettings contains the configuration for common settings for a context
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
GeoDB string
PasswordResetInterval time.Duration
RemoteAssets map[string]string
DeprecatedApps DeprecatedAppsCfg
AuthorizedForConfirm []string
Avatars *avatar.Service
PDF *pdf.Service
Fs Fs
Keyring keyring.Keyring
CouchDB CouchDB
Jobs Jobs
Konnectors Konnectors
Mail *gomail.DialerOptions
MailPerContext map[string]interface{}
CampaignMail *gomail.DialerOptions
CampaignMailPerContext map[string]interface{}
Move Move
Notifications Notifications
Flagship Flagship
Lock lock.Getter
Limiter *limits.RateLimiter
SessionStorage redis.UniversalClient
DownloadStorage redis.UniversalClient
OauthStateStorage redis.UniversalClient
Realtime redis.UniversalClient
CacheStorage cache.Cache
Contexts map[string]interface{}
Authentication map[string]interface{}
RAGServers map[string]RAGServer
CommonSettings map[string]CommonSettings
Office map[string]Office
Registries map[string][]*url.URL
Clouderies map[string]ClouderyConfig
RabbitMQ RabbitMQ
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
type CouchDB ¶
type CouchDB struct {
Client *http.Client
Global CouchDBCluster
Clusters []CouchDBCluster
}
CouchDB contains the configuration for the CouchDB clusters.
type CouchDBCluster ¶
CouchDBCluster contains the configuration values for a cluster of CouchDB.
func CouchCluster ¶
func CouchCluster(n int) CouchDBCluster
CouchCluster returns the CouchDB configuration for the given cluster.
type DeprecatedApp ¶
type DeprecatedApp struct {
// SoftwareID found inside the oauth client.
SoftwareID string `mapstructure:"software_id"`
// Name as printed to the user.
Name string `mapstructure:"name"`
StoreURLs map[string]string `mapstructure:"store_urls"`
}
DeprecatedApp describes a list deprecated app and the links used to replace them.
type DeprecatedAppsCfg ¶
type DeprecatedAppsCfg struct {
Apps []DeprecatedApp `mapstructure:"apps"`
}
DeprecatedAppsCfg describes the config used to setup github.com/cozy/cozy-stack/web/auth.DeprecatedAppList.
XXX: Move this struct next to github.com/cozy/cozy-stack/web/auth.DeprecatedAppList once the circling dependency issue is fixed.
type Flagship ¶
type Flagship struct {
Contexts map[string]interface{}
APKPackageNames []string
APKCertificateDigests []string
PlayIntegrityDecryptionKeys []string
PlayIntegrityVerificationKeys []string
AppleAppIDs []string
}
Flagship contains the configuration for the flagship app.
type Fs ¶
type Fs struct {
Auth *url.Userinfo
URL *url.URL
Transport http.RoundTripper
DefaultLayout int
CanQueryInfo bool
AutoCleanTrashedAfter map[string]string
Versioning FsVersioning
Contexts map[string]interface{}
}
Fs contains the configuration values of the file-system
type FsVersioning ¶
FsVersioning contains the configuration for the versioning of files
type Jobs ¶
type Jobs struct {
Client redis.UniversalClient
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 Notifications ¶
type Notifications struct {
Development bool
FCMCredentialsFile string
IOSCertificateKeyPath string
IOSCertificatePassword string
IOSKeyID string
IOSTeamID string
HuaweiGetTokenURL string
HuaweiSendMessagesURL string
Contexts map[string]SMS
}
Notifications contains the configuration for the mobile push-notification center, for Android and iOS
type RabbitExchange ¶
type RabbitExchange struct {
Name string `mapstructure:"name" yaml:"name"` // e.g. "user-common-settings" or "user-password-updates"
Kind string `mapstructure:"kind" yaml:"kind"` // "topic", "direct", etc.
Durable bool `mapstructure:"durable" yaml:"durable"` // whether exchange is durable
DeclareExchange bool `mapstructure:"declare_exchange" yaml:"declare_exchange"` // whether declare exchange on start up
DLXName string `mapstructure:"dlx_name" yaml:"dlx_name"` // DLX name
DLQName string `mapstructure:"dlq_name" yaml:"dlq_name"` // DLQ name
Queues []RabbitQueue `mapstructure:"queues" yaml:"queues"` // list of queues
}
type RabbitMQ ¶
type RabbitMQ struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Nodes map[string]RabbitMQNode `mapstructure:"nodes" yaml:"nodes"`
Exchanges []RabbitExchange `mapstructure:"exchanges" yaml:"exchanges"`
}
RabbitMQ contains configuration for the RabbitMQ consumers.
type RabbitMQNode ¶
type RabbitMQNode struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
URL string `mapstructure:"url" yaml:"url"`
TLS RabbitMQTLS `mapstructure:"tls" yaml:"tls"`
}
RabbitMQNode defines the configuration for the connection with a RabbitMQ node.
type RabbitMQTLS ¶
type RabbitMQTLS struct {
RootCAFile string `mapstructure:"root_ca" yaml:"root_ca"`
InsecureSkipValidation bool `mapstructure:"insecure_skip_validation" yaml:"insecure_skip_validation"`
ServerName string `mapstructure:"server_name" yaml:"server_name"`
}
RabbitMQTLS defines TLS settings for the RabbitMQ connection.
type RabbitQueue ¶
type RabbitQueue struct {
Name string `mapstructure:"name" yaml:"name"` // e.g. "user-settings-queue"
Bindings []string `mapstructure:"bindings" yaml:"bindings"` // routing keys to bind
Prefetch int `mapstructure:"prefetch" yaml:"prefetch"` // per-consumer QoS (optional override)
DeliveryLimit int `mapstructure:"delivery_limit" yaml:"delivery_limit"` // x-delivery-limit (for quorum)
Declare bool `mapstructure:"declare" yaml:"declare"` // whether declare queue on start up
DeclareDLX bool `mapstructure:"declare_dlx" yaml:"declare_dlx"` // whether declare DLX on start up
DeclareDLQ bool `mapstructure:"declare_dlq" yaml:"declare_dlq"` // whether declare DLQ on start up
DLXName string `mapstructure:"dlx_name" yaml:"dlx_name"` // optional per-queue DLX name (overrides exchange)
DLQName string `mapstructure:"dlq_name" yaml:"dlq_name"` // optional per-queue DLQ name (overrides exchange)
DLRoutingKey string `mapstructure:"dl_routing_key" yaml:"dl_routing_key"` // optional dead-letter routing key override
}
type SharingConfig ¶
type SharingConfig struct {
AutoAcceptTrusted bool `mapstructure:"auto_accept_trusted"`
AutoAcceptTrustedContacts bool `mapstructure:"auto_accept_trusted_contacts"`
TrustedDomains []string `mapstructure:"trusted_domains"`
}
SharingConfig contains sharing trust settings for a specific context.
func GetSharingConfig ¶
func GetSharingConfig(contextName string) SharingConfig
GetSharingConfig returns the sharing configuration for a given context. It reads from contexts.<contextName>.sharing and falls back to contexts.default.sharing if the specific context doesn't have sharing configuration.
type SharingNotificationsConfig ¶
type SharingNotificationsConfig struct {
Enabled bool `mapstructure:"enabled"`
}
SharingNotificationsConfig contains settings for sharing file change notifications.
func GetSharingNotificationsConfig ¶
func GetSharingNotificationsConfig(contextName string) SharingNotificationsConfig
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 )