const (
ModeReplace = "replace"
ModeFail = "fail"
ModeIsolate = "isolate"
ModeIgnoreDeps = "ignore-dependencies"
ModeIgnoreReqs = "ignore-requirements"
)
Unit start modes.
type ActionArgs struct {
Name string `json:"name"`
Mode string `json:"mode"`
}
ActionArgs are arguments for service running action handlers.
type Config struct {
*provider.Config
}
Config holds all configuration for the provider.
func NewConfig(flagSet *pflag.FlagSet, v *viper.Viper) *Config
NewConfig creates a new instance of Config.
func (c *Config) LoadConfig() error
LoadConfig loads and validates the Systemd provider config
func (c *Config) UnitFilePath(name string) (string, error)
UnitFilePath returns the absolute path of the unit file for a unit.
func (c *Config) Validate() error
Validate returns whether the config is valid, containing necessary values.
type ConfigData struct {
provider.ConfigData
UnitFileDir string `json:"unit_file_dir"`
}
ConfigData defines the structure of the config data (e.g. in the config file)
type CreateArgs struct {
Name string `json:"name"`
UnitOptions []*unit.UnitOption `json:"unit-options"`
Overwrite bool `json:"overwrite"`
}
CreateArgs are arguments for the Create handler.
type CreateResult struct {
UnitModified bool `json:"modified"`
}
CreateResult is the result of a create action.
type DisableArgs struct {
Name string `json:"name"`
Runtime bool `json:"runtime"`
}
DisableArgs are arguments for the disable handler.
type EnableArgs struct {
Name string `json:"name"`
Runtime bool `json:"runtime"`
Force bool `json:"force"`
}
EnableArgs are arguments for the disable handler.
type GetArgs struct {
Name string `json:"name"`
}
GetArgs are args for the Get handler
type GetResult struct {
Unit UnitStatus `json:"unit"`
}
GetResult is the result of the ListUnits handler.
type ListResult struct {
Units []UnitStatus `json:"units"`
}
ListResult is the result of the List handler.
type MockSystemd struct {
Data *MockSystemdData
}
MockSystemd is a mock version of the Systemd provider.
func NewMockSystemd() *MockSystemd
NewMockSystemd creates a new MockSystemd.
func (s *MockSystemd) ClearData()
ClearData clears all data out of the mock provider.
func (s *MockSystemd) Create(req *acomm.Request) (interface{}, *url.URL, error)
Create creates a mock unit file.
func (s *MockSystemd) Disable(req *acomm.Request) (interface{}, *url.URL, error)
Disable disables a mock service.
func (s *MockSystemd) Enable(req *acomm.Request) (interface{}, *url.URL, error)
Enable enables a mock service.
func (s *MockSystemd) Get(req *acomm.Request) (interface{}, *url.URL, error)
Get retrieves a mock service.
func (s *MockSystemd) List(req *acomm.Request) (interface{}, *url.URL, error)
List lists mock services.
func (s *MockSystemd) ManualCreate(args CreateArgs, enable bool)
ManualCreate directly creates a service in the mock data, optionally enabled.
func (s *MockSystemd) ManualEnable(name string)
ManualEnable directly enables a service in the mock data.
func (s *MockSystemd) ManualGet(name string) *UnitStatus
ManualGet directly retrieves a services from the mock data.
func (s *MockSystemd) RegisterTasks(server *provider.Server)
RegisterTasks registers the MockSystemd tasks.
func (s *MockSystemd) Remove(req *acomm.Request) (interface{}, *url.URL, error)
Remove removes a mock unit file.
func (s *MockSystemd) Restart(req *acomm.Request) (interface{}, *url.URL, error)
Restart restarts a mock service.
func (s *MockSystemd) Start(req *acomm.Request) (interface{}, *url.URL, error)
Start starts a mock service.
func (s *MockSystemd) Stop(req *acomm.Request) (interface{}, *url.URL, error)
Stop stops a mock service.
type MockSystemdData struct {
Statuses map[string]UnitStatus
UnitFiles map[string][]*unit.UnitOption
}
MockSystemdData is the in-memory data structure for the MockSystemd.
type RemoveArgs struct {
Name string `json:"name"`
}
RemoveArgs are arguments for the Remove handler.
type Systemd struct {
}
Systemd is a provider of systemd functionality.
func New(config *Config) (*Systemd, error)
New creates a new instance of Systemd.
func (s *Systemd) Create(req *acomm.Request) (interface{}, *url.URL, error)
Create creates or overwrites a unit file.
func (s *Systemd) Disable(req *acomm.Request) (interface{}, *url.URL, error)
Disable disables a service.
func (s *Systemd) Enable(req *acomm.Request) (interface{}, *url.URL, error)
Enable disables a service.
func (s *Systemd) Get(req *acomm.Request) (interface{}, *url.URL, error)
Get retuns a list of unit statuses.
func (s *Systemd) List(req *acomm.Request) (interface{}, *url.URL, error)
List retuns a list of unit statuses.
func (s *Systemd) RegisterTasks(server *provider.Server)
RegisterTasks registers all of Systemd's task handlers with the server.
func (s *Systemd) Remove(req *acomm.Request) (interface{}, *url.URL, error)
Remove deletes a unit file.
func (s *Systemd) Restart(req *acomm.Request) (interface{}, *url.URL, error)
Restart restarts a service.
func (s *Systemd) Start(req *acomm.Request) (interface{}, *url.URL, error)
Start starts an enabled service.
func (s *Systemd) Stop(req *acomm.Request) (interface{}, *url.URL, error)
Stop stops a running service.
type UnitStatus struct {
dbus.UnitStatus
Uptime time.Duration `json:"uptime"`
UnitProperties map[string]interface{} `json:"unitProperties"`
UnitTypeProperties map[string]interface{} `json:"unitTypeProperties"`
}
UnitStatus contains information about a systemd unit.
-- Generated with godocdown