config

package
v0.0.0-...-a7c217f Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 33 Imported by: 51

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

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",
	"$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 Avatars

func Avatars() *avatar.Service

Avatars return the configured initials service.

func CouchClient

func CouchClient() *http.Client

CouchClient returns the http client to use when making requests to a CouchDB cluster.

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 GetFranceConnect

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

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

func GetKeyring

func GetKeyring() keyring.Keyring

GetKeyring returns the configured instance of keyring.Keyring

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 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

func InitSwiftConnection(fs Fs) error

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

func Lock

func Lock() lock.Getter

Lock return the lock getter.

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(t *testing.T)

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 ClouderyAPI

type ClouderyAPI struct {
	URL   string `mapstructure:"url"`
	Token string `mapstructure:"token"`
}

type ClouderyConfig

type ClouderyConfig struct {
	API ClouderyAPI `mapstructure:"api"`
}

ClouderyConfig for [cloudery.ClouderyService].

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
	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{}
	Office         map[string]Office
	Registries     map[string][]*url.URL
	Clouderies     map[string]ClouderyConfig

	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 {
	Client   *http.Client
	Global   CouchDBCluster
	Clusters []CouchDBCluster
}

CouchDB contains the configuration for the CouchDB clusters.

type CouchDBCluster

type CouchDBCluster struct {
	Auth     *url.Userinfo
	URL      *url.URL
	Creation bool
}

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

type FsVersioning struct {
	MaxNumberToKeep            int
	MinDelayBetweenTwoVersions time.Duration
}

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 Move

type Move struct {
	URL string
}

Move contains the configuration for the move wizard

type Notifications

type Notifications struct {
	Development bool

	FCMCredentialsFile string

	AndroidAPIKey string
	FCMServer     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 Office

type Office struct {
	OnlyOfficeURL string
	InboxSecret   string
	OutboxSecret  string
}

Office contains the configuration for collaborative edition of office documents

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 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