Documentation
¶
Overview ¶
Package systemd provides systemd unit management operations.
Package systemd provides systemd unit management operations.
Package systemd provides legacy unit operations that are now deprecated. This file contains old method implementations that should be migrated to use dependency injection.
Index ¶
- func ArtifactPathToUnitName(artifactPath string) string
- func CheckGeneratorBinaryExists(generatorPath string, fs FileSystemChecker, logger log.Logger) (bool, error)
- func CheckUnitLoaded(ctx context.Context, unitName string, factory ConnectionFactory, userMode bool, ...) (bool, error)
- func FormatDiagnosticIssue(issue DiagnosticIssue) string
- func IsConnectionError(err error) bool
- func IsError(err error) bool
- func IsUnitNotFoundError(err error) bool
- type BaseUnit
- type Connection
- type ConnectionError
- type ConnectionFactory
- type ContextProvider
- type DBusConnection
- func (d *DBusConnection) Close() error
- func (d *DBusConnection) GetUnitProperties(ctx context.Context, unitName string) (map[string]interface{}, error)
- func (d *DBusConnection) GetUnitProperty(ctx context.Context, unitName, propertyName string) (*dbus.Property, error)
- func (d *DBusConnection) Reload(ctx context.Context) error
- func (d *DBusConnection) ResetFailedUnit(ctx context.Context, unitName string) error
- func (d *DBusConnection) RestartUnit(ctx context.Context, unitName, mode string) (chan string, error)
- func (d *DBusConnection) StartUnit(ctx context.Context, unitName, mode string) (chan string, error)
- func (d *DBusConnection) StopUnit(ctx context.Context, unitName, mode string) (chan string, error)
- type DefaultConnectionFactory
- type DefaultContextProvider
- type DefaultFactory
- type DefaultOrchestrator
- type DefaultTextCaser
- type DefaultUnitManager
- func (m *DefaultUnitManager) GetStatus(unitName, unitType string) (string, error)
- func (m *DefaultUnitManager) GetUnit(name, unitType string) Unit
- func (m *DefaultUnitManager) GetUnitFailureDetails(unitName string) string
- func (m *DefaultUnitManager) ReloadSystemd() error
- func (m *DefaultUnitManager) ResetFailed(unitName, unitType string) error
- func (m *DefaultUnitManager) Restart(unitName, unitType string) error
- func (m *DefaultUnitManager) Show(unitName, unitType string) error
- func (m *DefaultUnitManager) Start(unitName, unitType string) error
- func (m *DefaultUnitManager) Stop(unitName, unitType string) error
- type DiagnosticIssue
- type Error
- type FileSystemChecker
- type ManagedUnit
- type MockConnection
- func (m *MockConnection) Close() error
- func (m *MockConnection) GetUnitProperties(ctx context.Context, unitName string) (map[string]interface{}, error)
- func (m *MockConnection) GetUnitProperty(ctx context.Context, unitName, propertyName string) (*dbus.Property, error)
- func (m *MockConnection) Reload(ctx context.Context) error
- func (m *MockConnection) ResetFailedUnit(ctx context.Context, unitName string) error
- func (m *MockConnection) RestartUnit(ctx context.Context, unitName, mode string) (chan string, error)
- func (m *MockConnection) StartUnit(ctx context.Context, unitName, mode string) (chan string, error)
- func (m *MockConnection) StopUnit(ctx context.Context, unitName, mode string) (chan string, error)
- type MockConnectionFactory
- type MockContextProvider
- type MockOrchestrator
- type MockTextCaser
- type MockUnit
- func (m *MockUnit) GetServiceName() string
- func (m *MockUnit) GetStatus() (string, error)
- func (m *MockUnit) GetUnitName() string
- func (m *MockUnit) GetUnitType() string
- func (m *MockUnit) ResetFailed() error
- func (m *MockUnit) Restart() error
- func (m *MockUnit) Show() error
- func (m *MockUnit) Start() error
- func (m *MockUnit) Stop() error
- type MockUnitManager
- func (m *MockUnitManager) GetStatus(unitName, unitType string) (string, error)
- func (m *MockUnitManager) GetUnit(name, unitType string) Unit
- func (m *MockUnitManager) GetUnitFailureDetails(unitName string) string
- func (m *MockUnitManager) ReloadSystemd() error
- func (m *MockUnitManager) ResetFailed(unitName, unitType string) error
- func (m *MockUnitManager) Restart(unitName, unitType string) error
- func (m *MockUnitManager) Show(unitName, unitType string) error
- func (m *MockUnitManager) Start(unitName, unitType string) error
- func (m *MockUnitManager) Stop(unitName, unitType string) error
- type OrchestrationResult
- type Orchestrator
- type TextCaser
- type Unit
- type UnitChange
- type UnitManager
- type UnitNotFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArtifactPathToUnitName ¶ added in v0.24.7
ArtifactPathToUnitName converts a Quadlet artifact path to the expected systemd unit name. Examples:
- /etc/containers/systemd/test.container → test.service
- /etc/containers/systemd/mynet.network → mynet-network.service
- /etc/containers/systemd/myvol.volume → myvol-volume.service
func CheckGeneratorBinaryExists ¶ added in v0.24.7
func CheckGeneratorBinaryExists(generatorPath string, fs FileSystemChecker, logger log.Logger) (bool, error)
CheckGeneratorBinaryExists verifies that the Quadlet generator binary is installed.
func CheckUnitLoaded ¶ added in v0.24.7
func CheckUnitLoaded(ctx context.Context, unitName string, factory ConnectionFactory, userMode bool, logger log.Logger) (bool, error)
CheckUnitLoaded verifies that a systemd unit is loaded.
func FormatDiagnosticIssue ¶ added in v0.24.7
func FormatDiagnosticIssue(issue DiagnosticIssue) string
FormatDiagnosticIssue formats a diagnostic issue for display.
func IsConnectionError ¶ added in v0.21.0
IsConnectionError checks if an error is a ConnectionError.
func IsUnitNotFoundError ¶ added in v0.21.0
IsUnitNotFoundError checks if an error is a UnitNotFoundError.
Types ¶
type BaseUnit ¶
BaseUnit provides common implementation for all systemd units.
func NewBaseUnit ¶
NewBaseUnit creates a new BaseUnit with the given name and type.
func (*BaseUnit) GetServiceName ¶
GetServiceName returns the full systemd service name based on unit type.
func (*BaseUnit) GetUnitName ¶
GetUnitName returns the name of the unit.
func (*BaseUnit) GetUnitType ¶
GetUnitType returns the type of the unit.
type Connection ¶ added in v0.21.0
type Connection interface {
// GetUnitProperty gets a property of a systemd unit.
GetUnitProperty(ctx context.Context, unitName, propertyName string) (*dbus.Property, error)
// GetUnitProperties gets all properties of a systemd unit.
GetUnitProperties(ctx context.Context, unitName string) (map[string]interface{}, error)
// StartUnit starts a systemd unit.
StartUnit(ctx context.Context, unitName, mode string) (chan string, error)
// StopUnit stops a systemd unit.
StopUnit(ctx context.Context, unitName, mode string) (chan string, error)
// RestartUnit restarts a systemd unit.
RestartUnit(ctx context.Context, unitName, mode string) (chan string, error)
// ResetFailedUnit resets the failed state of a unit.
ResetFailedUnit(ctx context.Context, unitName string) error
// Reload reloads systemd configuration.
Reload(ctx context.Context) error
// Close closes the connection.
Close() error
}
Connection wraps systemd D-Bus operations for testability.
type ConnectionError ¶ added in v0.21.0
type ConnectionError struct {
UserMode bool // Whether this was a user or system connection attempt
Cause error // The underlying error
}
ConnectionError represents an error connecting to systemd.
func NewConnectionError ¶ added in v0.21.0
func NewConnectionError(userMode bool, cause error) *ConnectionError
NewConnectionError creates a new ConnectionError.
func (*ConnectionError) Error ¶ added in v0.21.0
func (e *ConnectionError) Error() string
Error implements the error interface.
func (*ConnectionError) Unwrap ¶ added in v0.21.0
func (e *ConnectionError) Unwrap() error
Unwrap returns the underlying error for error unwrapping.
type ConnectionFactory ¶ added in v0.21.0
type ConnectionFactory interface {
// NewConnection creates a new systemd connection based on configuration.
NewConnection(ctx context.Context, userMode bool) (Connection, error)
}
ConnectionFactory creates Connection instances.
type ContextProvider ¶ added in v0.21.0
type ContextProvider interface {
// GetContext returns a context for systemd operations.
GetContext() context.Context
}
ContextProvider provides context for systemd operations.
type DBusConnection ¶ added in v0.21.0
type DBusConnection struct {
// contains filtered or unexported fields
}
DBusConnection implements Connection interface wrapping systemd D-Bus operations.
func NewDBusConnection ¶ added in v0.21.0
func NewDBusConnection(conn *dbus.Conn) *DBusConnection
NewDBusConnection creates a new D-Bus connection wrapper.
func (*DBusConnection) Close ¶ added in v0.21.0
func (d *DBusConnection) Close() error
Close closes the D-Bus connection.
func (*DBusConnection) GetUnitProperties ¶ added in v0.21.0
func (d *DBusConnection) GetUnitProperties(ctx context.Context, unitName string) (map[string]interface{}, error)
GetUnitProperties gets all properties of a systemd unit.
func (*DBusConnection) GetUnitProperty ¶ added in v0.21.0
func (d *DBusConnection) GetUnitProperty(ctx context.Context, unitName, propertyName string) (*dbus.Property, error)
GetUnitProperty gets a property of a systemd unit.
func (*DBusConnection) Reload ¶ added in v0.21.0
func (d *DBusConnection) Reload(ctx context.Context) error
Reload reloads systemd configuration.
func (*DBusConnection) ResetFailedUnit ¶ added in v0.21.0
func (d *DBusConnection) ResetFailedUnit(ctx context.Context, unitName string) error
ResetFailedUnit resets the failed state of a unit.
func (*DBusConnection) RestartUnit ¶ added in v0.21.0
func (d *DBusConnection) RestartUnit(ctx context.Context, unitName, mode string) (chan string, error)
RestartUnit restarts a systemd unit.
type DefaultConnectionFactory ¶ added in v0.21.0
type DefaultConnectionFactory struct {
// contains filtered or unexported fields
}
DefaultConnectionFactory implements ConnectionFactory interface.
func NewConnectionFactory ¶ added in v0.21.0
func NewConnectionFactory(logger log.Logger) *DefaultConnectionFactory
NewConnectionFactory creates a new connection factory with injected logger.
func (*DefaultConnectionFactory) NewConnection ¶ added in v0.21.0
func (f *DefaultConnectionFactory) NewConnection(ctx context.Context, userMode bool) (Connection, error)
NewConnection creates a new systemd connection based on configuration.
type DefaultContextProvider ¶ added in v0.21.0
type DefaultContextProvider struct {
// contains filtered or unexported fields
}
DefaultContextProvider implements ContextProvider interface.
func NewDefaultContextProvider ¶ added in v0.21.0
func NewDefaultContextProvider() *DefaultContextProvider
NewDefaultContextProvider creates a new default context provider.
func (*DefaultContextProvider) GetContext ¶ added in v0.21.0
func (p *DefaultContextProvider) GetContext() context.Context
GetContext returns a context for systemd operations.
type DefaultFactory ¶ added in v0.21.0
type DefaultFactory struct {
// contains filtered or unexported fields
}
DefaultFactory provides default implementations of all systemd interfaces.
func NewDefaultFactory ¶ added in v0.21.0
func NewDefaultFactory(configProvider config.Provider, logger log.Logger) *DefaultFactory
NewDefaultFactory creates a new default factory with all default implementations.
func (*DefaultFactory) GetConnectionFactory ¶ added in v0.21.0
func (f *DefaultFactory) GetConnectionFactory() ConnectionFactory
GetConnectionFactory returns the connection factory.
func (*DefaultFactory) GetContextProvider ¶ added in v0.21.0
func (f *DefaultFactory) GetContextProvider() ContextProvider
GetContextProvider returns the context provider.
func (*DefaultFactory) GetOrchestrator ¶ added in v0.21.0
func (f *DefaultFactory) GetOrchestrator() Orchestrator
GetOrchestrator returns the orchestrator.
func (*DefaultFactory) GetTextCaser ¶ added in v0.21.0
func (f *DefaultFactory) GetTextCaser() TextCaser
GetTextCaser returns the text caser.
func (*DefaultFactory) GetUnitManager ¶ added in v0.21.0
func (f *DefaultFactory) GetUnitManager() UnitManager
GetUnitManager returns the unit manager.
type DefaultOrchestrator ¶ added in v0.21.0
type DefaultOrchestrator struct {
// contains filtered or unexported fields
}
DefaultOrchestrator implements Orchestrator interface.
func NewDefaultOrchestrator ¶ added in v0.21.0
func NewDefaultOrchestrator(unitManager UnitManager, connectionFactory ConnectionFactory, configProvider config.Provider, logger log.Logger) *DefaultOrchestrator
NewDefaultOrchestrator creates a new default orchestrator.
func (*DefaultOrchestrator) RestartChangedUnits ¶ added in v0.21.0
func (o *DefaultOrchestrator) RestartChangedUnits(changedUnits []UnitChange, projectDependencyGraphs map[string]*dependency.ServiceDependencyGraph) error
RestartChangedUnits restarts all changed units in dependency-aware order.
func (*DefaultOrchestrator) StartUnitDependencyAware ¶ added in v0.21.0
func (o *DefaultOrchestrator) StartUnitDependencyAware(unitName, unitType string, dependencyGraph *dependency.ServiceDependencyGraph) error
StartUnitDependencyAware starts or restarts a unit with dependency awareness.
type DefaultTextCaser ¶ added in v0.21.0
type DefaultTextCaser struct {
// contains filtered or unexported fields
}
DefaultTextCaser implements TextCaser interface.
func NewDefaultTextCaser ¶ added in v0.21.0
func NewDefaultTextCaser() *DefaultTextCaser
NewDefaultTextCaser creates a new default text caser.
func (*DefaultTextCaser) Title ¶ added in v0.21.0
func (c *DefaultTextCaser) Title(text string) string
Title converts text to title case.
type DefaultUnitManager ¶ added in v0.21.0
type DefaultUnitManager struct {
// contains filtered or unexported fields
}
DefaultUnitManager implements UnitManager interface.
func NewDefaultUnitManager ¶ added in v0.21.0
func NewDefaultUnitManager(connectionFactory ConnectionFactory, contextProvider ContextProvider, textCaser TextCaser, configProvider config.Provider, logger log.Logger, runner execx.Runner) *DefaultUnitManager
NewDefaultUnitManager creates a new default unit manager.
func (*DefaultUnitManager) GetStatus ¶ added in v0.21.0
func (m *DefaultUnitManager) GetStatus(unitName, unitType string) (string, error)
GetStatus returns the current status of a unit.
func (*DefaultUnitManager) GetUnit ¶ added in v0.21.0
func (m *DefaultUnitManager) GetUnit(name, unitType string) Unit
GetUnit creates a Unit interface for the given name and type.
func (*DefaultUnitManager) GetUnitFailureDetails ¶ added in v0.21.0
func (m *DefaultUnitManager) GetUnitFailureDetails(unitName string) string
GetUnitFailureDetails gets detailed failure information for a unit.
func (*DefaultUnitManager) ReloadSystemd ¶ added in v0.21.0
func (m *DefaultUnitManager) ReloadSystemd() error
ReloadSystemd reloads systemd configuration.
func (*DefaultUnitManager) ResetFailed ¶ added in v0.21.0
func (m *DefaultUnitManager) ResetFailed(unitName, unitType string) error
ResetFailed resets the failed state of a unit.
func (*DefaultUnitManager) Restart ¶ added in v0.21.0
func (m *DefaultUnitManager) Restart(unitName, unitType string) error
Restart restarts a unit.
func (*DefaultUnitManager) Show ¶ added in v0.21.0
func (m *DefaultUnitManager) Show(unitName, unitType string) error
Show displays unit configuration and status.
func (*DefaultUnitManager) Start ¶ added in v0.21.0
func (m *DefaultUnitManager) Start(unitName, unitType string) error
Start starts a unit.
func (*DefaultUnitManager) Stop ¶ added in v0.21.0
func (m *DefaultUnitManager) Stop(unitName, unitType string) error
Stop stops a unit.
type DiagnosticIssue ¶ added in v0.24.7
type DiagnosticIssue struct {
Type string // Type of issue: "generator_missing", "unit_not_generated", etc.
Message string // Human-readable description
Suggestions []string // Actionable recommendations
}
DiagnosticIssue represents a detected problem with the Quadlet generator.
func DiagnoseGeneratorIssues ¶ added in v0.24.7
func DiagnoseGeneratorIssues( ctx context.Context, generatorPath string, artifacts []string, fs FileSystemChecker, factory ConnectionFactory, userMode bool, logger log.Logger, ) []DiagnosticIssue
DiagnoseGeneratorIssues performs comprehensive diagnostics to identify why units may not be available.
type Error ¶ added in v0.21.0
type Error struct {
Operation string // The operation that failed (Start, Stop, Restart, etc.)
UnitName string // The name of the unit
UnitType string // The type of the unit
Cause error // The underlying error
}
Error represents an error from systemd operations.
type FileSystemChecker ¶ added in v0.24.7
FileSystemChecker provides file system operations for diagnostics.
type ManagedUnit ¶ added in v0.21.0
type ManagedUnit struct {
*BaseUnit
// contains filtered or unexported fields
}
ManagedUnit wraps BaseUnit with injected dependencies for testing.
func NewManagedUnit ¶ added in v0.21.0
func NewManagedUnit(name, unitType string, connectionFactory ConnectionFactory, contextProvider ContextProvider, textCaser TextCaser, configProvider config.Provider, logger log.Logger) *ManagedUnit
NewManagedUnit creates a new managed unit with injected dependencies.
func (*ManagedUnit) GetStatus ¶ added in v0.21.0
func (u *ManagedUnit) GetStatus() (string, error)
GetStatus returns the current status of the unit.
func (*ManagedUnit) ResetFailed ¶ added in v0.21.0
func (u *ManagedUnit) ResetFailed() error
ResetFailed resets the failed state of the unit.
func (*ManagedUnit) Restart ¶ added in v0.21.0
func (u *ManagedUnit) Restart() error
Restart restarts the unit.
func (*ManagedUnit) Show ¶ added in v0.21.0
func (u *ManagedUnit) Show() error
Show displays the unit configuration and status.
func (*ManagedUnit) Start ¶ added in v0.21.0
func (u *ManagedUnit) Start() error
Start starts the unit.
type MockConnection ¶ added in v0.21.0
type MockConnection struct {
GetUnitPropertyFunc func(ctx context.Context, unitName, propertyName string) (*dbus.Property, error)
GetUnitPropertiesFunc func(ctx context.Context, unitName string) (map[string]interface{}, error)
StartUnitFunc func(ctx context.Context, unitName, mode string) (chan string, error)
StopUnitFunc func(ctx context.Context, unitName, mode string) (chan string, error)
RestartUnitFunc func(ctx context.Context, unitName, mode string) (chan string, error)
ResetFailedUnitFunc func(ctx context.Context, unitName string) error
ReloadFunc func(ctx context.Context) error
CloseFunc func() error
}
MockConnection implements Connection interface for testing.
func (*MockConnection) Close ¶ added in v0.21.0
func (m *MockConnection) Close() error
Close closes the connection.
func (*MockConnection) GetUnitProperties ¶ added in v0.21.0
func (m *MockConnection) GetUnitProperties(ctx context.Context, unitName string) (map[string]interface{}, error)
GetUnitProperties gets all properties of a systemd unit.
func (*MockConnection) GetUnitProperty ¶ added in v0.21.0
func (m *MockConnection) GetUnitProperty(ctx context.Context, unitName, propertyName string) (*dbus.Property, error)
GetUnitProperty gets a property of a systemd unit.
func (*MockConnection) Reload ¶ added in v0.21.0
func (m *MockConnection) Reload(ctx context.Context) error
Reload reloads systemd configuration.
func (*MockConnection) ResetFailedUnit ¶ added in v0.21.0
func (m *MockConnection) ResetFailedUnit(ctx context.Context, unitName string) error
ResetFailedUnit resets the failed state of a unit.
func (*MockConnection) RestartUnit ¶ added in v0.21.0
func (m *MockConnection) RestartUnit(ctx context.Context, unitName, mode string) (chan string, error)
RestartUnit restarts a systemd unit.
type MockConnectionFactory ¶ added in v0.21.0
type MockConnectionFactory struct {
NewConnectionFunc func(ctx context.Context, userMode bool) (Connection, error)
Connection Connection
}
MockConnectionFactory implements ConnectionFactory interface for testing.
func (*MockConnectionFactory) NewConnection ¶ added in v0.21.0
func (m *MockConnectionFactory) NewConnection(ctx context.Context, userMode bool) (Connection, error)
NewConnection creates a new systemd connection based on configuration.
type MockContextProvider ¶ added in v0.21.0
MockContextProvider implements ContextProvider interface for testing.
func (*MockContextProvider) GetContext ¶ added in v0.21.0
func (m *MockContextProvider) GetContext() context.Context
GetContext returns a context for systemd operations.
type MockOrchestrator ¶ added in v0.21.0
type MockOrchestrator struct {
StartUnitDependencyAwareFunc func(unitName, unitType string, dependencyGraph *dependency.ServiceDependencyGraph) error
RestartChangedUnitsFunc func(changedUnits []UnitChange, projectDependencyGraphs map[string]*dependency.ServiceDependencyGraph) error
}
MockOrchestrator implements Orchestrator interface for testing.
func (*MockOrchestrator) RestartChangedUnits ¶ added in v0.21.0
func (m *MockOrchestrator) RestartChangedUnits(changedUnits []UnitChange, projectDependencyGraphs map[string]*dependency.ServiceDependencyGraph) error
RestartChangedUnits restarts all changed units in dependency-aware order.
func (*MockOrchestrator) StartUnitDependencyAware ¶ added in v0.21.0
func (m *MockOrchestrator) StartUnitDependencyAware(unitName, unitType string, dependencyGraph *dependency.ServiceDependencyGraph) error
StartUnitDependencyAware starts or restarts a unit with dependency awareness.
type MockTextCaser ¶ added in v0.21.0
MockTextCaser implements TextCaser interface for testing.
func (*MockTextCaser) Title ¶ added in v0.21.0
func (m *MockTextCaser) Title(text string) string
Title converts text to title case.
type MockUnit ¶ added in v0.21.0
type MockUnit struct {
GetServiceNameFunc func() string
GetUnitTypeFunc func() string
GetUnitNameFunc func() string
GetStatusFunc func() (string, error)
StartFunc func() error
StopFunc func() error
RestartFunc func() error
ShowFunc func() error
ResetFailedFunc func() error
}
MockUnit implements Unit interface for testing.
func (*MockUnit) GetServiceName ¶ added in v0.21.0
GetServiceName returns the full systemd service name.
func (*MockUnit) GetUnitName ¶ added in v0.21.0
GetUnitName returns the name of the unit.
func (*MockUnit) GetUnitType ¶ added in v0.21.0
GetUnitType returns the type of the unit.
func (*MockUnit) ResetFailed ¶ added in v0.21.0
ResetFailed resets the failed state of the unit.
type MockUnitManager ¶ added in v0.21.0
type MockUnitManager struct {
GetUnitFunc func(name, unitType string) Unit
GetStatusFunc func(unitName, unitType string) (string, error)
StartFunc func(unitName, unitType string) error
StopFunc func(unitName, unitType string) error
RestartFunc func(unitName, unitType string) error
ShowFunc func(unitName, unitType string) error
ResetFailedFunc func(unitName, unitType string) error
ReloadSystemdFunc func() error
GetUnitFailureDetailsFunc func(unitName string) string
}
MockUnitManager implements UnitManager interface for testing.
func (*MockUnitManager) GetStatus ¶ added in v0.21.0
func (m *MockUnitManager) GetStatus(unitName, unitType string) (string, error)
GetStatus returns the current status of a unit.
func (*MockUnitManager) GetUnit ¶ added in v0.21.0
func (m *MockUnitManager) GetUnit(name, unitType string) Unit
GetUnit creates a Unit interface for the given name and type.
func (*MockUnitManager) GetUnitFailureDetails ¶ added in v0.21.0
func (m *MockUnitManager) GetUnitFailureDetails(unitName string) string
GetUnitFailureDetails gets detailed failure information for a unit.
func (*MockUnitManager) ReloadSystemd ¶ added in v0.21.0
func (m *MockUnitManager) ReloadSystemd() error
ReloadSystemd reloads systemd configuration.
func (*MockUnitManager) ResetFailed ¶ added in v0.21.0
func (m *MockUnitManager) ResetFailed(unitName, unitType string) error
ResetFailed resets the failed state of a unit.
func (*MockUnitManager) Restart ¶ added in v0.21.0
func (m *MockUnitManager) Restart(unitName, unitType string) error
Restart restarts a unit.
func (*MockUnitManager) Show ¶ added in v0.21.0
func (m *MockUnitManager) Show(unitName, unitType string) error
Show displays unit configuration and status.
func (*MockUnitManager) Start ¶ added in v0.21.0
func (m *MockUnitManager) Start(unitName, unitType string) error
Start starts a unit.
func (*MockUnitManager) Stop ¶ added in v0.21.0
func (m *MockUnitManager) Stop(unitName, unitType string) error
Stop stops a unit.
type OrchestrationResult ¶
OrchestrationResult represents the result of an orchestration operation.
type Orchestrator ¶ added in v0.21.0
type Orchestrator interface {
// StartUnitDependencyAware starts or restarts a unit with dependency awareness.
StartUnitDependencyAware(unitName, unitType string, dependencyGraph *dependency.ServiceDependencyGraph) error
// RestartChangedUnits restarts all changed units in dependency-aware order.
RestartChangedUnits(changedUnits []UnitChange, projectDependencyGraphs map[string]*dependency.ServiceDependencyGraph) error
}
Orchestrator handles dependency-aware unit management.
type Unit ¶
type Unit interface {
// GetServiceName returns the full systemd service name
GetServiceName() string
// GetUnitType returns the type of the unit (container, volume, network, etc.)
GetUnitType() string
// GetUnitName returns the name of the unit
GetUnitName() string
// GetStatus returns the current status of the unit
GetStatus() (string, error)
// Start starts the unit
Start() error
// Stop stops the unit
Stop() error
// Restart restarts the unit
Restart() error
// Show displays the unit configuration and status
Show() error
// ResetFailed resets the failed state of the unit
ResetFailed() error
}
Unit defines the interface for managing systemd units.
type UnitChange ¶
UnitChange represents a unit that has changed and needs to be restarted.
type UnitManager ¶ added in v0.21.0
type UnitManager interface {
// GetUnit creates a Unit interface for the given name and type.
GetUnit(name, unitType string) Unit
// GetStatus returns the current status of a unit.
GetStatus(unitName, unitType string) (string, error)
// Start starts a unit.
Start(unitName, unitType string) error
// Stop stops a unit.
Stop(unitName, unitType string) error
// Restart restarts a unit.
Restart(unitName, unitType string) error
// Show displays unit configuration and status.
Show(unitName, unitType string) error
// ResetFailed resets the failed state of a unit.
ResetFailed(unitName, unitType string) error
// ReloadSystemd reloads systemd configuration.
ReloadSystemd() error
// GetUnitFailureDetails gets detailed failure information for a unit.
GetUnitFailureDetails(unitName string) string
}
UnitManager manages systemd units and their operations.
type UnitNotFoundError ¶ added in v0.21.0
UnitNotFoundError represents an error when a unit cannot be found.
func NewUnitNotFoundError ¶ added in v0.21.0
func NewUnitNotFoundError(unitName, unitType string) *UnitNotFoundError
NewUnitNotFoundError creates a new UnitNotFoundError.
func (*UnitNotFoundError) Error ¶ added in v0.21.0
func (e *UnitNotFoundError) Error() string
Error implements the error interface.