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 GetLogsDir() (string, error)
- 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 ¶ added in v0.8.0
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 ¶ added in v0.8.0
func ControlAppService(cmd ServiceCmd) error
ControlAppService sends a command to the service.
func GetAppService ¶ added in v0.8.0
GetAppService returns a usable kardianos Service.
func GetHttpAddress ¶ added in v0.8.0
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 ¶ added in v0.8.0
func GetHttpProtocol() string
GetHttpProtocol returns the protocol to use for binding. Currently only http is supported.
func GetLogsDir ¶ added in v0.9.3
func ProcessName ¶ added in v0.8.0
ProcessName computes the actual path to current process.
func RunningAsService ¶ added in v0.8.0
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 ¶ added in v0.8.0
func ServiceInstalled() bool
ServiceInstalled checks if background service is installed.
func SetMacService ¶ added in v0.8.0
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 ¶ added in v0.8.0
AuthChange is an event emitted when an Authority is updated.
type Authority ¶ added in v0.8.0
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 ¶ added in v0.8.0
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 ¶ added in v0.8.0
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 ¶ added in v0.8.0
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 ¶ added in v0.8.0
PublicAuthorities returns the list of Authorities without any sensitive information, and counts the number of active sync tasks on each.
func (*Global) RemoveAuthority ¶ added in v0.8.0
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 ¶ added in v0.8.0
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 ¶ added in v0.8.0
type Service struct {
AutoStart bool
}
Service is a simple section for enabling/disabling shortcuts or service (depending on OS).
type ServiceCmd ¶ added in v0.8.0
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 ¶ added in v0.8.0
type ServiceProgram struct {
// contains filtered or unexported fields
}
type ShortcutInstaller ¶ added in v0.8.0
type ShortcutInstaller interface { Install(options ShortcutOptions) error Uninstall() error IsInstalled() bool }
ShortcutInstaller provides tools for installing / removing os-shortcuts for automatic startup.
func GetOSShortcutInstaller ¶ added in v0.8.0
func GetOSShortcutInstaller() ShortcutInstaller
type ShortcutOptions ¶ added in v0.8.0
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 }
Task represents a sync task configuration.
type TaskChange ¶
TaskChange is an event sent when something changes inside the configs tasks.