Documentation ¶
Overview ¶
Package config provides a simple config management implementation based on JSON files.
Index ¶
- Constants
- Variables
- func AllowedServiceCmd(s string) bool
- func ClearKeyring(a *Authority) error
- func ControlAppService(cmd ServiceCmd) error
- func GetAppService(runner func()) (service.Service, error)
- func GetHttpAddress() (string, error)
- func GetHttpProtocol() string
- func ProcessName(name string) string
- func RunningAsService() bool
- func Save() error
- func ServiceInstalled() bool
- func SetMacService(s bool)
- func Status() (service.Status, error)
- func SyncClientDataDir() string
- func Watch() chan interface{}
- func WriteToFile(config *Global) error
- type AuthChange
- type Authority
- type Debugging
- type Global
- func (g *Global) CreateAuthority(a *Authority) error
- func (g *Global) CreateTask(t *Task) error
- func (g *Global) Items() (items []string)
- func (g *Global) PublicAuthorities() []*Authority
- func (g *Global) RemoveAuthority(a *Authority) error
- func (g *Global) RemoveTask(task *Task) error
- func (g *Global) UpdateAuthority(a *Authority, isRefresh bool) error
- func (g *Global) UpdateGlobals(logs *Logs, updates *Updates, debugging *Debugging, service *Service) error
- func (g *Global) UpdateTask(task *Task) error
- func (g *Global) UpdateTaskPaused(taskUuid string, paused bool) error
- type Logs
- type RefreshStatus
- type Service
- type ServiceCmd
- type ServiceProgram
- type ShortcutInstaller
- type ShortcutOptions
- type Task
- type TaskChange
- type Updates
Constants ¶
const ( UpdateDefaultChannel = "stable" UpdateDefaultServerUrl = "https://updatecells.pydio.com/" UpdateDefaultPublicKey = "" /* 424-byte string literal not displayed */ )
Variables ¶
Functions ¶
func AllowedServiceCmd ¶
AllowedServiceCmd returns a list of acceptable commands for ControlAppService function.
func ClearKeyring ¶ added in v0.9.0
ClearKeyring removes tokens from local keychain, if they are present
func ControlAppService ¶
func ControlAppService(cmd ServiceCmd) error
ControlAppService sends a command to the service.
func GetAppService ¶
GetAppService returns a usable kardianos Service.
func GetHttpAddress ¶
GetHttpAddress tries to bind to an available port between 3636 and 3666 and returns the first port available. This range of port is important for the OAuth2 authentication mechanism as the associated redirect_uris are automatically registered inside the server.
func GetHttpProtocol ¶
func GetHttpProtocol() string
GetHttpProtocol returns the protocol to use for binding. Currently only http is supported.
func ProcessName ¶
ProcessName computes the actual path to current process.
func RunningAsService ¶
func RunningAsService() bool
NotRunningAsService overrides service.Interactive() function by additionally checking if service is really installed, as on MacOS the .app is launched by "launchd" just like the service.
func ServiceInstalled ¶
func ServiceInstalled() bool
ServiceInstalled checks if background service is installed.
func SetMacService ¶
func SetMacService(s bool)
func SyncClientDataDir ¶
func SyncClientDataDir() string
SyncClientDataDir finds the user directory where to store all application data
func WriteToFile ¶
WriteToFile stores a Global config JSON-encoded.
Types ¶
type AuthChange ¶
AuthChange is an event emitted when an Authority is updated.
type Authority ¶
type Authority struct { Id string `json:"id"` URI string `json:"uri"` InsecureSkipVerify bool `json:"insecureSkipVerify"` ServerLabel string `json:"serverLabel"` Username string `json:"username"` LoginDate time.Time `json:"loginDate"` RefreshDate time.Time `json:"refreshDate"` TokenStatus string `json:"token_status,omitempty"` // Kept for backward compat RefreshStatus *RefreshStatus `json:"refreshStatus,omitempty"` TasksCount int `json:"tasksCount"` IdToken string `json:"id_token"` AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ExpiresAt int `json:"expires_at"` }
Authority represent an active account where user has logged in using the OpenID Connect workflow.
func AuthFromKeyring ¶ added in v0.9.0
AuthFromKeyring tries to find tokens inside local keychain and feed the conf with them
func AuthToKeyring ¶ added in v0.9.0
AuthToKeyring tries to store tokens in local keychain and remove them from the conf
func (*Authority) AfterLoad ¶ added in v0.9.0
func (a *Authority) AfterLoad()
AfterLoad tries to read tokens from keyring and replace them in the Authority
func (*Authority) BeforeSave ¶ added in v0.9.0
BeforeSave tries to save tokens in keyring and returns a copy of the Authority without tokens
func (*Authority) LoadInfo ¶
func (a *Authority) LoadInfo()
LoadInfo performs a REST query to the server to read the application title, and parses the JWT unsafely to just get a display name for the current user.
type Debugging ¶
type Debugging struct {
ShowPanels bool
}
Debugging is a simple section for showing/hiding special debug panels.
type Global ¶
type Global struct { Tasks []*Task Authorities []*Authority Logs *Logs Updates *Updates Debugging *Debugging Service *Service // contains filtered or unexported fields }
Global is the main struct representing configs.
func Default ¶
func Default() *Global
Default provides a usable config object. It is loaded from a JSON file.
func LoadFromFile ¶
LoadFromFile loads a Global config from a JSON file.
func (*Global) CreateAuthority ¶
CreateAuthority creates or updates an Authority in the config and emits an AuthChange event.
func (*Global) CreateTask ¶
CreateTask adds a Task to the config and emits a TaskChange event "create".
func (*Global) Items ¶
Items provides a readable list of labels representing sync tasks stored in config.
func (*Global) PublicAuthorities ¶
PublicAuthorities returns the list of Authorities without any sensitive information, and counts the number of active sync tasks on each.
func (*Global) RemoveAuthority ¶
RemoveAuthority removes an authority from the config and emits an AuthChange event.
func (*Global) RemoveTask ¶
RemoveTask removes a Task from the config and emits a TaskChange event "remove".
func (*Global) UpdateAuthority ¶
UpdateAuthority updates an Authority in the config and emits an AuthChange event.
func (*Global) UpdateGlobals ¶
func (g *Global) UpdateGlobals(logs *Logs, updates *Updates, debugging *Debugging, service *Service) error
UpdateGlobals updates various sections of config (each parameter can be nil).
func (*Global) UpdateTask ¶
UpdateTask updates a Task inside the config and emits a TaskChange event "update".
type RefreshStatus ¶ added in v0.9.2
type Service ¶
type Service struct {
AutoStart bool
}
Service is a simple section for enabling/disabling shortcuts or service (depending on OS).
type ServiceCmd ¶
type ServiceCmd string
const ServiceCmdInstall ServiceCmd = "install"
const ServiceCmdRestart ServiceCmd = "restart"
const ServiceCmdStart ServiceCmd = "start"
const ServiceCmdStop ServiceCmd = "stop"
const ServiceCmdUninstall ServiceCmd = "uninstall"
type ServiceProgram ¶
type ServiceProgram struct {
// contains filtered or unexported fields
}
type ShortcutInstaller ¶
type ShortcutInstaller interface { Install(options ShortcutOptions) error Uninstall() error IsInstalled() bool }
ShortcutInstaller provides tools for installing / removing os-shortcuts for automatic startup.
func GetOSShortcutInstaller ¶
func GetOSShortcutInstaller() ShortcutInstaller
type ShortcutOptions ¶
ShortcutOptions defines where to create shortcuts.
type Task ¶
type Task struct { Uuid string Label string LeftURI string RightURI string Direction string SelectiveRoots []string Realtime bool RealtimePaused bool LoopInterval string HardInterval string }
Tasks represents a sync task configuration.
type TaskChange ¶
TaskChange is an event sent when something changes inside the configs tasks.