systemd

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArtifactPathToUnitName added in v0.24.7

func ArtifactPathToUnitName(artifactPath string) string

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

func IsConnectionError(err error) bool

IsConnectionError checks if an error is a ConnectionError.

func IsError added in v0.21.0

func IsError(err error) bool

IsError checks if an error is a systemd Error.

func IsUnitNotFoundError added in v0.21.0

func IsUnitNotFoundError(err error) bool

IsUnitNotFoundError checks if an error is a UnitNotFoundError.

Types

type BaseUnit

type BaseUnit struct {
	Name string
	Type string
}

BaseUnit provides common implementation for all systemd units.

func NewBaseUnit

func NewBaseUnit(name, unitType string) *BaseUnit

NewBaseUnit creates a new BaseUnit with the given name and type.

func (*BaseUnit) GetServiceName

func (u *BaseUnit) GetServiceName() string

GetServiceName returns the full systemd service name based on unit type.

func (*BaseUnit) GetUnitName

func (u *BaseUnit) GetUnitName() string

GetUnitName returns the name of the unit.

func (*BaseUnit) GetUnitType

func (u *BaseUnit) GetUnitType() string

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.

func (*DBusConnection) StartUnit added in v0.21.0

func (d *DBusConnection) StartUnit(ctx context.Context, unitName, mode string) (chan string, error)

StartUnit starts a systemd unit.

func (*DBusConnection) StopUnit added in v0.21.0

func (d *DBusConnection) StopUnit(ctx context.Context, unitName, mode string) (chan string, error)

StopUnit stops 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.

func NewError added in v0.21.0

func NewError(operation, unitName, unitType string, cause error) *Error

NewError creates a new Error with the given details.

func (*Error) Error added in v0.21.0

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Unwrap added in v0.21.0

func (e *Error) Unwrap() error

Unwrap returns the underlying error for error unwrapping.

type FileSystemChecker added in v0.24.7

type FileSystemChecker interface {
	Stat(path string) (bool, error)
}

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.

func (*ManagedUnit) Stop added in v0.21.0

func (u *ManagedUnit) Stop() error

Stop stops 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.

func (*MockConnection) StartUnit added in v0.21.0

func (m *MockConnection) StartUnit(ctx context.Context, unitName, mode string) (chan string, error)

StartUnit starts a systemd unit.

func (*MockConnection) StopUnit added in v0.21.0

func (m *MockConnection) StopUnit(ctx context.Context, unitName, mode string) (chan string, error)

StopUnit stops 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

type MockContextProvider struct {
	GetContextFunc func() context.Context
	Ctx            context.Context
}

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

type MockTextCaser struct {
	TitleFunc func(text string) string
}

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

func (m *MockUnit) GetServiceName() string

GetServiceName returns the full systemd service name.

func (*MockUnit) GetStatus added in v0.21.0

func (m *MockUnit) GetStatus() (string, error)

GetStatus returns the current status of the unit.

func (*MockUnit) GetUnitName added in v0.21.0

func (m *MockUnit) GetUnitName() string

GetUnitName returns the name of the unit.

func (*MockUnit) GetUnitType added in v0.21.0

func (m *MockUnit) GetUnitType() string

GetUnitType returns the type of the unit.

func (*MockUnit) ResetFailed added in v0.21.0

func (m *MockUnit) ResetFailed() error

ResetFailed resets the failed state of the unit.

func (*MockUnit) Restart added in v0.21.0

func (m *MockUnit) Restart() error

Restart restarts the unit.

func (*MockUnit) Show added in v0.21.0

func (m *MockUnit) Show() error

Show displays the unit configuration and status.

func (*MockUnit) Start added in v0.21.0

func (m *MockUnit) Start() error

Start starts the unit.

func (*MockUnit) Stop added in v0.21.0

func (m *MockUnit) Stop() error

Stop stops 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

type OrchestrationResult struct {
	Success bool
	Errors  map[string]error
}

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 TextCaser added in v0.21.0

type TextCaser interface {
	// Title converts text to title case.
	Title(text string) string
}

TextCaser provides text casing operations.

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

type UnitChange struct {
	Name string
	Type string
}

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

type UnitNotFoundError struct {
	UnitName string
	UnitType string
}

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.

Jump to

Keyboard shortcuts

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