Documentation
¶
Index ¶
- Constants
- Variables
- type Descriptor
- type Interface
- type InterfaceMock
- func (mock *InterfaceMock) Close()
- func (mock *InterfaceMock) CloseCalls() []struct{}
- func (mock *InterfaceMock) Describe(ctx context.Context) (*Descriptor, error)
- func (mock *InterfaceMock) DescribeCalls() []struct{ ... }
- func (mock *InterfaceMock) DisableShutdownInhibit() error
- func (mock *InterfaceMock) DisableShutdownInhibitCalls() []struct{}
- func (mock *InterfaceMock) EnableShutdownInhibit(ctx context.Context, cb func(ctx2 context.Context) error) error
- func (mock *InterfaceMock) EnableShutdownInhibitCalls() []struct{ ... }
- func (mock *InterfaceMock) GetUnitByName(ctx context.Context, unit string) (systemd.UnitStatus, error)
- func (mock *InterfaceMock) GetUnitByNameCalls() []struct{ ... }
- func (mock *InterfaceMock) IsConnected() bool
- func (mock *InterfaceMock) IsConnectedCalls() []struct{}
- func (mock *InterfaceMock) ListUnitsByNames(ctx context.Context, units []string) ([]systemd.UnitStatus, error)
- func (mock *InterfaceMock) ListUnitsByNamesCalls() []struct{ ... }
- func (mock *InterfaceMock) ReconcileSysUpdate(ctx context.Context, hv *v1.Hypervisor) (bool, error)
- func (mock *InterfaceMock) ReconcileSysUpdateCalls() []struct{ ... }
- func (mock *InterfaceMock) ReloadUnit(ctx context.Context, unit string) (int, error)
- func (mock *InterfaceMock) ReloadUnitCalls() []struct{ ... }
- func (mock *InterfaceMock) StartUnit(ctx context.Context, unit string) (int, error)
- func (mock *InterfaceMock) StartUnitCalls() []struct{ ... }
- type SystemdConn
- func (s *SystemdConn) Close()
- func (s *SystemdConn) Describe(ctx context.Context) (*Descriptor, error)
- func (s *SystemdConn) DisableShutdownInhibit() error
- func (s *SystemdConn) EnableShutdownInhibit(ctx context.Context, cb func(context.Context) error) error
- func (s *SystemdConn) GetUnitByName(ctx context.Context, unit string) (systemd.UnitStatus, error)
- func (s *SystemdConn) IsConnected() bool
- func (s *SystemdConn) ListUnitsByNames(ctx context.Context, units []string) ([]systemd.UnitStatus, error)
- func (s *SystemdConn) ReconcileSysUpdate(ctx context.Context, hv *v1.Hypervisor) (bool, error)
- func (s *SystemdConn) ReloadUnit(ctx context.Context, unit string) (int, error)
- func (s *SystemdConn) StartUnit(ctx context.Context, unit string) (int, error)
Constants ¶
const ( ACTIVE = "active" ACTIVATING = "activating" INACTIVE = "inactive" FAILED = "failed" )
Variables ¶
var ErrFailed = errors.New("update has failed")
Functions ¶
This section is empty.
Types ¶
type Descriptor ¶
type Descriptor struct { Hostname string `json:"Hostname,omitempty"` StaticHostname string `json:"StaticHostname,omitempty"` PrettyHostname interface{} `json:"PrettyHostname,omitempty"` DefaultHostname string `json:"DefaultHostname,omitempty"` HostnameSource string `json:"HostnameSource,omitempty"` IconName string `json:"IconName,omitempty"` Chassis string `json:"Chassis,omitempty"` Deployment interface{} `json:"Deployment,omitempty"` Location interface{} `json:"Location,omitempty"` KernelName string `json:"KernelName,omitempty"` KernelRelease string `json:"KernelRelease,omitempty"` KernelVersion string `json:"KernelVersion,omitempty"` OperatingSystemPrettyName string `json:"PrettyName,omitempty"` OperatingSystemCPEName interface{} `json:"OperatingSystemCPEName,omitempty"` OperatingSystemHomeURL string `json:"OperatingSystemHomeURL,omitempty"` OperatingSystemReleaseData []string `json:"OperatingSystemReleaseData,omitempty"` MachineInformationData []interface{} `json:"MachineInformationData,omitempty"` HardwareVendor string `json:"HardwareVendor,omitempty"` HardwareModel string `json:"HardwareModel,omitempty"` HardwareSerial string `json:"HardwareSerial,omitempty"` FirmwareVersion string `json:"FirmwareVersion,omitempty"` FirmwareVendor string `json:"FirmwareVendor,omitempty"` FirmwareDate int64 `json:"FirmwareDate,omitempty"` MachineID string `json:"MachineID,omitempty"` BootID string `json:"BootID,omitempty"` ProductUUID string `json:"ProductUUID,omitempty"` VSockCID interface{} `json:"VSockCID,omitempty"` }
type Interface ¶
type Interface interface { // Close closes the connection to the systemd D-Bus API. Close() // IsConnected returns true if the connection to the systemd D-Bus API is open. IsConnected() bool // ListUnitsByNames returns the status of the units with the given names. ListUnitsByNames(ctx context.Context, units []string) ([]dbus.UnitStatus, error) // GetUnitByName returns the status of the unit with the given name. GetUnitByName(ctx context.Context, unit string) (dbus.UnitStatus, error) // StartUnit starts the unit with the given name. StartUnit(ctx context.Context, unit string) (int, error) // ReloadUnit reloads the unit with the given name. ReloadUnit(ctx context.Context, unit string) (int, error) // ReconcileSysUpdate reconciles orchestrates a systemd-sysupdate via the systemd-sysupdate@.service unit. ReconcileSysUpdate(ctx context.Context, hv *v1.Hypervisor) (bool, error) // EnableShutdownInhibit enables the shutdown inhibition EnableShutdownInhibit(ctx context.Context, cb func(ctx2 context.Context) error) error // DisableShutdownInhibit disables the shutdown inhibition DisableShutdownInhibit() error // Describe returns hostname and related machine metadata Describe(ctx context.Context) (*Descriptor, error) }
type InterfaceMock ¶
type InterfaceMock struct { // CloseFunc mocks the Close method. CloseFunc func() // DescribeFunc mocks the Describe method. DescribeFunc func(ctx context.Context) (*Descriptor, error) // DisableShutdownInhibitFunc mocks the DisableShutdownInhibit method. DisableShutdownInhibitFunc func() error // EnableShutdownInhibitFunc mocks the EnableShutdownInhibit method. EnableShutdownInhibitFunc func(ctx context.Context, cb func(ctx2 context.Context) error) error // GetUnitByNameFunc mocks the GetUnitByName method. GetUnitByNameFunc func(ctx context.Context, unit string) (systemd.UnitStatus, error) // IsConnectedFunc mocks the IsConnected method. IsConnectedFunc func() bool // ListUnitsByNamesFunc mocks the ListUnitsByNames method. ListUnitsByNamesFunc func(ctx context.Context, units []string) ([]systemd.UnitStatus, error) // ReconcileSysUpdateFunc mocks the ReconcileSysUpdate method. ReconcileSysUpdateFunc func(ctx context.Context, hv *v1.Hypervisor) (bool, error) // ReloadUnitFunc mocks the ReloadUnit method. ReloadUnitFunc func(ctx context.Context, unit string) (int, error) // StartUnitFunc mocks the StartUnit method. StartUnitFunc func(ctx context.Context, unit string) (int, error) // contains filtered or unexported fields }
InterfaceMock is a mock implementation of Interface.
func TestSomethingThatUsesInterface(t *testing.T) { // make and configure a mocked Interface mockedInterface := &InterfaceMock{ CloseFunc: func() { panic("mock out the Close method") }, DescribeFunc: func(ctx context.Context) (*Descriptor, error) { panic("mock out the Describe method") }, DisableShutdownInhibitFunc: func() error { panic("mock out the DisableShutdownInhibit method") }, EnableShutdownInhibitFunc: func(ctx context.Context, cb func(ctx2 context.Context) error) error { panic("mock out the EnableShutdownInhibit method") }, GetUnitByNameFunc: func(ctx context.Context, unit string) (systemd.UnitStatus, error) { panic("mock out the GetUnitByName method") }, IsConnectedFunc: func() bool { panic("mock out the IsConnected method") }, ListUnitsByNamesFunc: func(ctx context.Context, units []string) ([]systemd.UnitStatus, error) { panic("mock out the ListUnitsByNames method") }, ReconcileSysUpdateFunc: func(ctx context.Context, hv *v1.Hypervisor) (bool, error) { panic("mock out the ReconcileSysUpdate method") }, ReloadUnitFunc: func(ctx context.Context, unit string) (int, error) { panic("mock out the ReloadUnit method") }, StartUnitFunc: func(ctx context.Context, unit string) (int, error) { panic("mock out the StartUnit method") }, } // use mockedInterface in code that requires Interface // and then make assertions. }
func (*InterfaceMock) CloseCalls ¶
func (mock *InterfaceMock) CloseCalls() []struct { }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedInterface.CloseCalls())
func (*InterfaceMock) Describe ¶
func (mock *InterfaceMock) Describe(ctx context.Context) (*Descriptor, error)
Describe calls DescribeFunc.
func (*InterfaceMock) DescribeCalls ¶
func (mock *InterfaceMock) DescribeCalls() []struct { Ctx context.Context }
DescribeCalls gets all the calls that were made to Describe. Check the length with:
len(mockedInterface.DescribeCalls())
func (*InterfaceMock) DisableShutdownInhibit ¶
func (mock *InterfaceMock) DisableShutdownInhibit() error
DisableShutdownInhibit calls DisableShutdownInhibitFunc.
func (*InterfaceMock) DisableShutdownInhibitCalls ¶
func (mock *InterfaceMock) DisableShutdownInhibitCalls() []struct { }
DisableShutdownInhibitCalls gets all the calls that were made to DisableShutdownInhibit. Check the length with:
len(mockedInterface.DisableShutdownInhibitCalls())
func (*InterfaceMock) EnableShutdownInhibit ¶
func (mock *InterfaceMock) EnableShutdownInhibit(ctx context.Context, cb func(ctx2 context.Context) error) error
EnableShutdownInhibit calls EnableShutdownInhibitFunc.
func (*InterfaceMock) EnableShutdownInhibitCalls ¶
func (mock *InterfaceMock) EnableShutdownInhibitCalls() []struct { Ctx context.Context Cb func(ctx2 context.Context) error }
EnableShutdownInhibitCalls gets all the calls that were made to EnableShutdownInhibit. Check the length with:
len(mockedInterface.EnableShutdownInhibitCalls())
func (*InterfaceMock) GetUnitByName ¶
func (mock *InterfaceMock) GetUnitByName(ctx context.Context, unit string) (systemd.UnitStatus, error)
GetUnitByName calls GetUnitByNameFunc.
func (*InterfaceMock) GetUnitByNameCalls ¶
func (mock *InterfaceMock) GetUnitByNameCalls() []struct { Ctx context.Context Unit string }
GetUnitByNameCalls gets all the calls that were made to GetUnitByName. Check the length with:
len(mockedInterface.GetUnitByNameCalls())
func (*InterfaceMock) IsConnected ¶
func (mock *InterfaceMock) IsConnected() bool
IsConnected calls IsConnectedFunc.
func (*InterfaceMock) IsConnectedCalls ¶
func (mock *InterfaceMock) IsConnectedCalls() []struct { }
IsConnectedCalls gets all the calls that were made to IsConnected. Check the length with:
len(mockedInterface.IsConnectedCalls())
func (*InterfaceMock) ListUnitsByNames ¶
func (mock *InterfaceMock) ListUnitsByNames(ctx context.Context, units []string) ([]systemd.UnitStatus, error)
ListUnitsByNames calls ListUnitsByNamesFunc.
func (*InterfaceMock) ListUnitsByNamesCalls ¶
func (mock *InterfaceMock) ListUnitsByNamesCalls() []struct { Ctx context.Context Units []string }
ListUnitsByNamesCalls gets all the calls that were made to ListUnitsByNames. Check the length with:
len(mockedInterface.ListUnitsByNamesCalls())
func (*InterfaceMock) ReconcileSysUpdate ¶
func (mock *InterfaceMock) ReconcileSysUpdate(ctx context.Context, hv *v1.Hypervisor) (bool, error)
ReconcileSysUpdate calls ReconcileSysUpdateFunc.
func (*InterfaceMock) ReconcileSysUpdateCalls ¶
func (mock *InterfaceMock) ReconcileSysUpdateCalls() []struct { Ctx context.Context Hv *v1.Hypervisor }
ReconcileSysUpdateCalls gets all the calls that were made to ReconcileSysUpdate. Check the length with:
len(mockedInterface.ReconcileSysUpdateCalls())
func (*InterfaceMock) ReloadUnit ¶
ReloadUnit calls ReloadUnitFunc.
func (*InterfaceMock) ReloadUnitCalls ¶
func (mock *InterfaceMock) ReloadUnitCalls() []struct { Ctx context.Context Unit string }
ReloadUnitCalls gets all the calls that were made to ReloadUnit. Check the length with:
len(mockedInterface.ReloadUnitCalls())
func (*InterfaceMock) StartUnitCalls ¶
func (mock *InterfaceMock) StartUnitCalls() []struct { Ctx context.Context Unit string }
StartUnitCalls gets all the calls that were made to StartUnit. Check the length with:
len(mockedInterface.StartUnitCalls())
type SystemdConn ¶
type SystemdConn struct {
// contains filtered or unexported fields
}
func NewSystemd ¶
func NewSystemd(ctx context.Context) (*SystemdConn, error)
func (*SystemdConn) Close ¶
func (s *SystemdConn) Close()
func (*SystemdConn) Describe ¶
func (s *SystemdConn) Describe(ctx context.Context) (*Descriptor, error)
func (*SystemdConn) DisableShutdownInhibit ¶
func (s *SystemdConn) DisableShutdownInhibit() error
DisableShutdownInhibit releases the systemd inhibition lock
func (*SystemdConn) EnableShutdownInhibit ¶
func (s *SystemdConn) EnableShutdownInhibit(ctx context.Context, cb func(context.Context) error) error
EnableShutdownInhibit blocks shutdown by using systemd inhibition lock, and registers a shutdown callback
func (*SystemdConn) GetUnitByName ¶
func (s *SystemdConn) GetUnitByName(ctx context.Context, unit string) (systemd.UnitStatus, error)
func (*SystemdConn) IsConnected ¶
func (s *SystemdConn) IsConnected() bool
func (*SystemdConn) ListUnitsByNames ¶
func (s *SystemdConn) ListUnitsByNames(ctx context.Context, units []string) ([]systemd.UnitStatus, error)
func (*SystemdConn) ReconcileSysUpdate ¶
func (s *SystemdConn) ReconcileSysUpdate(ctx context.Context, hv *v1.Hypervisor) (bool, error)
ReconcileSysUpdate orchestrates a systemd-sysupdate via the systemd-sysupdate@.service unit.