github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/service/systemd/interface.go (about) 1 // Copyright 2020 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package systemd 5 6 import ( 7 "os" 8 9 "github.com/coreos/go-systemd/v22/dbus" 10 ) 11 12 // DBusAPI describes all the systemd API methods needed by juju. 13 type DBusAPI interface { 14 Close() 15 ListUnits() ([]dbus.UnitStatus, error) 16 StartUnit(string, string, chan<- string) (int, error) 17 StopUnit(string, string, chan<- string) (int, error) 18 LinkUnitFiles([]string, bool, bool) ([]dbus.LinkUnitFileChange, error) 19 EnableUnitFiles([]string, bool, bool) (bool, []dbus.EnableUnitFileChange, error) 20 DisableUnitFiles([]string, bool) ([]dbus.DisableUnitFileChange, error) 21 GetUnitProperties(string) (map[string]interface{}, error) 22 GetUnitTypeProperties(string, string) (map[string]interface{}, error) 23 Reload() error 24 } 25 26 // FileSystemOps describes file-system operations required to install 27 // and remove a service. 28 type FileSystemOps interface { 29 Remove(name string) error 30 RemoveAll(name string) error 31 WriteFile(fileName string, data []byte, perm os.FileMode) error 32 }