systemd

package
v0.0.0-...-5c345c6 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2016 License: MIT Imports: 13 Imported by: 0

README

systemd

systemd

Usage

const (
	ModeReplace    = "replace"
	ModeFail       = "fail"
	ModeIsolate    = "isolate"
	ModeIgnoreDeps = "ignore-dependencies"
	ModeIgnoreReqs = "ignore-requirements"
)

Unit start modes.

type ActionArgs
type ActionArgs struct {
	Name string `json:"name"`
	Mode string `json:"mode"`
}

ActionArgs are arguments for service running action handlers.

type Config
type Config struct {
	*provider.Config
}

Config holds all configuration for the provider.

func NewConfig
func NewConfig(flagSet *pflag.FlagSet, v *viper.Viper) *Config

NewConfig creates a new instance of Config.

func (*Config) LoadConfig
func (c *Config) LoadConfig() error

LoadConfig loads and validates the Systemd provider config

func (*Config) UnitFilePath
func (c *Config) UnitFilePath(name string) (string, error)

UnitFilePath returns the absolute path of the unit file for a unit.

func (*Config) Validate
func (c *Config) Validate() error

Validate returns whether the config is valid, containing necessary values.

type ConfigData
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
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
type CreateResult struct {
	UnitModified bool `json:"modified"`
}

CreateResult is the result of a create action.

type DisableArgs
type DisableArgs struct {
	Name    string `json:"name"`
	Runtime bool   `json:"runtime"`
}

DisableArgs are arguments for the disable handler.

type EnableArgs
type EnableArgs struct {
	Name    string `json:"name"`
	Runtime bool   `json:"runtime"`
	Force   bool   `json:"force"`
}

EnableArgs are arguments for the disable handler.

type GetArgs
type GetArgs struct {
	Name string `json:"name"`
}

GetArgs are args for the Get handler

type GetResult
type GetResult struct {
	Unit UnitStatus `json:"unit"`
}

GetResult is the result of the ListUnits handler.

type ListResult
type ListResult struct {
	Units []UnitStatus `json:"units"`
}

ListResult is the result of the List handler.

type MockSystemd
type MockSystemd struct {
	Data *MockSystemdData
}

MockSystemd is a mock version of the Systemd provider.

func NewMockSystemd
func NewMockSystemd() *MockSystemd

NewMockSystemd creates a new MockSystemd.

func (*MockSystemd) ClearData
func (s *MockSystemd) ClearData()

ClearData clears all data out of the mock provider.

func (*MockSystemd) Create
func (s *MockSystemd) Create(req *acomm.Request) (interface{}, *url.URL, error)

Create creates a mock unit file.

func (*MockSystemd) Disable
func (s *MockSystemd) Disable(req *acomm.Request) (interface{}, *url.URL, error)

Disable disables a mock service.

func (*MockSystemd) Enable
func (s *MockSystemd) Enable(req *acomm.Request) (interface{}, *url.URL, error)

Enable enables a mock service.

func (*MockSystemd) Get
func (s *MockSystemd) Get(req *acomm.Request) (interface{}, *url.URL, error)

Get retrieves a mock service.

func (*MockSystemd) List
func (s *MockSystemd) List(req *acomm.Request) (interface{}, *url.URL, error)

List lists mock services.

func (*MockSystemd) ManualCreate
func (s *MockSystemd) ManualCreate(args CreateArgs, enable bool)

ManualCreate directly creates a service in the mock data, optionally enabled.

func (*MockSystemd) ManualEnable
func (s *MockSystemd) ManualEnable(name string)

ManualEnable directly enables a service in the mock data.

func (*MockSystemd) ManualGet
func (s *MockSystemd) ManualGet(name string) *UnitStatus

ManualGet directly retrieves a services from the mock data.

func (*MockSystemd) RegisterTasks
func (s *MockSystemd) RegisterTasks(server *provider.Server)

RegisterTasks registers the MockSystemd tasks.

func (*MockSystemd) Remove
func (s *MockSystemd) Remove(req *acomm.Request) (interface{}, *url.URL, error)

Remove removes a mock unit file.

func (*MockSystemd) Restart
func (s *MockSystemd) Restart(req *acomm.Request) (interface{}, *url.URL, error)

Restart restarts a mock service.

func (*MockSystemd) Start
func (s *MockSystemd) Start(req *acomm.Request) (interface{}, *url.URL, error)

Start starts a mock service.

func (*MockSystemd) Stop
func (s *MockSystemd) Stop(req *acomm.Request) (interface{}, *url.URL, error)

Stop stops a mock service.

type MockSystemdData
type MockSystemdData struct {
	Statuses  map[string]UnitStatus
	UnitFiles map[string][]*unit.UnitOption
}

MockSystemdData is the in-memory data structure for the MockSystemd.

type RemoveArgs
type RemoveArgs struct {
	Name string `json:"name"`
}

RemoveArgs are arguments for the Remove handler.

type Systemd
type Systemd struct {
}

Systemd is a provider of systemd functionality.

func New
func New(config *Config) (*Systemd, error)

New creates a new instance of Systemd.

func (*Systemd) Create
func (s *Systemd) Create(req *acomm.Request) (interface{}, *url.URL, error)

Create creates or overwrites a unit file.

func (*Systemd) Disable
func (s *Systemd) Disable(req *acomm.Request) (interface{}, *url.URL, error)

Disable disables a service.

func (*Systemd) Enable
func (s *Systemd) Enable(req *acomm.Request) (interface{}, *url.URL, error)

Enable disables a service.

func (*Systemd) Get
func (s *Systemd) Get(req *acomm.Request) (interface{}, *url.URL, error)

Get retuns a list of unit statuses.

func (*Systemd) List
func (s *Systemd) List(req *acomm.Request) (interface{}, *url.URL, error)

List retuns a list of unit statuses.

func (*Systemd) RegisterTasks
func (s *Systemd) RegisterTasks(server *provider.Server)

RegisterTasks registers all of Systemd's task handlers with the server.

func (*Systemd) Remove
func (s *Systemd) Remove(req *acomm.Request) (interface{}, *url.URL, error)

Remove deletes a unit file.

func (*Systemd) Restart
func (s *Systemd) Restart(req *acomm.Request) (interface{}, *url.URL, error)

Restart restarts a service.

func (*Systemd) Start
func (s *Systemd) Start(req *acomm.Request) (interface{}, *url.URL, error)

Start starts an enabled service.

func (*Systemd) Stop
func (s *Systemd) Stop(req *acomm.Request) (interface{}, *url.URL, error)

Stop stops a running service.

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

Documentation

Index

Constants

View Source
const (
	ModeReplace    = "replace"
	ModeFail       = "fail"
	ModeIsolate    = "isolate"
	ModeIgnoreDeps = "ignore-dependencies"
	ModeIgnoreReqs = "ignore-requirements"
)

Unit start modes.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionArgs

type ActionArgs struct {
	Name string `json:"name"`
	Mode string `json:"mode"`
}

ActionArgs are arguments for service running action handlers.

type Config

type Config struct {
	*provider.Config
}

Config holds all configuration for the provider.

func NewConfig

func NewConfig(flagSet *pflag.FlagSet, v *viper.Viper) *Config

NewConfig creates a new instance of Config.

func (*Config) LoadConfig

func (c *Config) LoadConfig() error

LoadConfig loads and validates the Systemd provider config

func (*Config) UnitFilePath

func (c *Config) UnitFilePath(name string) (string, error)

UnitFilePath returns the absolute path of the unit file for a unit.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns whether the config is valid, containing necessary values.

type ConfigData

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

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

type CreateResult struct {
	UnitModified bool `json:"modified"`
}

CreateResult is the result of a create action.

type DisableArgs

type DisableArgs struct {
	Name    string `json:"name"`
	Runtime bool   `json:"runtime"`
}

DisableArgs are arguments for the disable handler.

type EnableArgs

type EnableArgs struct {
	Name    string `json:"name"`
	Runtime bool   `json:"runtime"`
	Force   bool   `json:"force"`
}

EnableArgs are arguments for the disable handler.

type GetArgs

type GetArgs struct {
	Name string `json:"name"`
}

GetArgs are args for the Get handler

type GetResult

type GetResult struct {
	Unit UnitStatus `json:"unit"`
}

GetResult is the result of the ListUnits handler.

type ListResult

type ListResult struct {
	Units []UnitStatus `json:"units"`
}

ListResult is the result of the List handler.

type MockSystemd

type MockSystemd struct {
	Data *MockSystemdData
}

MockSystemd is a mock version of the Systemd provider.

func NewMockSystemd

func NewMockSystemd() *MockSystemd

NewMockSystemd creates a new MockSystemd.

func (*MockSystemd) ClearData

func (s *MockSystemd) ClearData()

ClearData clears all data out of the mock provider.

func (*MockSystemd) Create

func (s *MockSystemd) Create(req *acomm.Request) (interface{}, *url.URL, error)

Create creates a mock unit file.

func (*MockSystemd) Disable

func (s *MockSystemd) Disable(req *acomm.Request) (interface{}, *url.URL, error)

Disable disables a mock service.

func (*MockSystemd) Enable

func (s *MockSystemd) Enable(req *acomm.Request) (interface{}, *url.URL, error)

Enable enables a mock service.

func (*MockSystemd) Get

func (s *MockSystemd) Get(req *acomm.Request) (interface{}, *url.URL, error)

Get retrieves a mock service.

func (*MockSystemd) List

func (s *MockSystemd) List(req *acomm.Request) (interface{}, *url.URL, error)

List lists mock services.

func (*MockSystemd) ManualCreate

func (s *MockSystemd) ManualCreate(args CreateArgs, enable bool)

ManualCreate directly creates a service in the mock data, optionally enabled.

func (*MockSystemd) ManualEnable

func (s *MockSystemd) ManualEnable(name string)

ManualEnable directly enables a service in the mock data.

func (*MockSystemd) ManualGet

func (s *MockSystemd) ManualGet(name string) *UnitStatus

ManualGet directly retrieves a services from the mock data.

func (*MockSystemd) RegisterTasks

func (s *MockSystemd) RegisterTasks(server *provider.Server)

RegisterTasks registers the MockSystemd tasks.

func (*MockSystemd) Remove

func (s *MockSystemd) Remove(req *acomm.Request) (interface{}, *url.URL, error)

Remove removes a mock unit file.

func (*MockSystemd) Restart

func (s *MockSystemd) Restart(req *acomm.Request) (interface{}, *url.URL, error)

Restart restarts a mock service.

func (*MockSystemd) Start

func (s *MockSystemd) Start(req *acomm.Request) (interface{}, *url.URL, error)

Start starts a mock service.

func (*MockSystemd) Stop

func (s *MockSystemd) Stop(req *acomm.Request) (interface{}, *url.URL, error)

Stop stops a mock service.

type MockSystemdData

type MockSystemdData struct {
	Statuses  map[string]UnitStatus
	UnitFiles map[string][]*unit.UnitOption
}

MockSystemdData is the in-memory data structure for the MockSystemd.

type RemoveArgs

type RemoveArgs struct {
	Name string `json:"name"`
}

RemoveArgs are arguments for the Remove handler.

type Systemd

type Systemd struct {
	// contains filtered or unexported fields
}

Systemd is a provider of systemd functionality.

func New

func New(config *Config) (*Systemd, error)

New creates a new instance of Systemd.

func (*Systemd) Create

func (s *Systemd) Create(req *acomm.Request) (interface{}, *url.URL, error)

Create creates or overwrites a unit file.

func (*Systemd) Disable

func (s *Systemd) Disable(req *acomm.Request) (interface{}, *url.URL, error)

Disable disables a service.

func (*Systemd) Enable

func (s *Systemd) Enable(req *acomm.Request) (interface{}, *url.URL, error)

Enable disables a service.

func (*Systemd) Get

func (s *Systemd) Get(req *acomm.Request) (interface{}, *url.URL, error)

Get retuns a list of unit statuses.

func (*Systemd) List

func (s *Systemd) List(req *acomm.Request) (interface{}, *url.URL, error)

List retuns a list of unit statuses.

func (*Systemd) RegisterTasks

func (s *Systemd) RegisterTasks(server *provider.Server)

RegisterTasks registers all of Systemd's task handlers with the server.

func (*Systemd) Remove

func (s *Systemd) Remove(req *acomm.Request) (interface{}, *url.URL, error)

Remove deletes a unit file.

func (*Systemd) Restart

func (s *Systemd) Restart(req *acomm.Request) (interface{}, *url.URL, error)

Restart restarts a service.

func (*Systemd) Start

func (s *Systemd) Start(req *acomm.Request) (interface{}, *url.URL, error)

Start starts an enabled service.

func (*Systemd) Stop

func (s *Systemd) Stop(req *acomm.Request) (interface{}, *url.URL, error)

Stop stops a running service.

type UnitStatus

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL