Documentation
¶
Index ¶
- func IsRootless() bool
- func IsSELinuxAvailable() bool
- func IsSELinuxEnabled() bool
- func RemoveNetworks(projectName string) error
- func RemoveVolumes(projectName string) error
- func StateFileExists() bool
- func ValidatePodmanVersion() error
- type PodmanResource
- type ProjectState
- type ResourceInfo
- type StateManager
- func (sm *StateManager) GetProject(name string) (ProjectState, bool)
- func (sm *StateManager) GetStateFilePath() string
- func (sm *StateManager) ListProjects() []ProjectState
- func (sm *StateManager) RegisterProject(project ProjectState) error
- func (sm *StateManager) Save() error
- func (sm *StateManager) SetProject(name string, state ProjectState)
- func (sm *StateManager) UnregisterProject(projectName string) error
- type StateStore
- type SystemdClient
- type SystemdManager
- func (s *SystemdManager) Close() error
- func (s *SystemdManager) GetInvocationID(unitName string) (string, error)
- func (s *SystemdManager) ListAllUnits() ([]dbus.UnitStatus, error)
- func (s *SystemdManager) ListUnitsByNames(unitNames []string) ([]dbus.UnitStatus, error)
- func (s *SystemdManager) ReloadDaemon(filePaths ...string) error
- func (s *SystemdManager) RestartUnit(unitName string) error
- func (s *SystemdManager) StartUnit(unitName string) error
- func (s *SystemdManager) StopUnit(unitName string) error
- func (s *SystemdManager) WaitForUnit(unitName string, timeout time.Duration) error
- type TargetDirResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRootless ¶
func IsRootless() bool
IsRootless returns true if the current process is running as a non-root user.
func IsSELinuxAvailable ¶ added in v0.3.0
func IsSELinuxAvailable() bool
func IsSELinuxEnabled ¶ added in v0.3.0
func IsSELinuxEnabled() bool
func RemoveNetworks ¶
RemoveNetworks removes all Podman networks with label com.comquad.managed=true and com.comquad.project=<projectName>.
func RemoveVolumes ¶
RemoveVolumes removes all Podman volumes with label com.comquad.managed=true and com.comquad.project=<projectName>.
func StateFileExists ¶ added in v0.1.5
func StateFileExists() bool
StateFileExists returns true if the comquad state file already exists on disk.
func ValidatePodmanVersion ¶ added in v0.1.5
func ValidatePodmanVersion() error
ValidatePodmanVersion checks that podman meets the minimum required version (4.8.0). Returns nil if the version is sufficient, or an error describing the shortfall.
Types ¶
type PodmanResource ¶
type PodmanResource struct {
Name string
ProjectName string
Type string // "container", "network", "volume"
}
PodmanResource represents a discovered Podman resource with its project label
type ProjectState ¶
type ProjectState struct {
ProjectName string `json:"project_name"`
SourcePath string `json:"source_path"`
Files []string `json:"files"` // List of generated quadlet files
Resources *ResourceInfo `json:"resources,omitempty"` // Podman resources discovered via labels
}
ProjectState represents the state of a single managed project
type ResourceInfo ¶
type ResourceInfo struct {
Containers []string `json:"containers"`
Networks []string `json:"networks"`
Volumes []string `json:"volumes"`
Images []string `json:"images"`
Builds []string `json:"builds"`
}
ResourceInfo tracks Podman resources for a managed project
type StateManager ¶
type StateManager struct {
StateFilePath string
Projects map[string]ProjectState
// contains filtered or unexported fields
}
StateManager manages the persistence of project states in a JSON file
func NewStateManager ¶
func NewStateManager() (*StateManager, error)
NewStateManager initializes a new state manager with a default path
func RegenerateState ¶
func RegenerateState() (*StateManager, error)
RegenerateState scans Podman for managed resources and reconstructs the state file.
func (*StateManager) GetProject ¶
func (sm *StateManager) GetProject(name string) (ProjectState, bool)
GetProject returns the state for the named project and whether it exists. This satisfies the StateStore interface without exposing the raw Projects map.
func (*StateManager) GetStateFilePath ¶
func (sm *StateManager) GetStateFilePath() string
GetStateFilePath returns the path of the state file on disk.
func (*StateManager) ListProjects ¶
func (sm *StateManager) ListProjects() []ProjectState
func (*StateManager) RegisterProject ¶
func (sm *StateManager) RegisterProject(project ProjectState) error
func (*StateManager) Save ¶
func (sm *StateManager) Save() error
func (*StateManager) SetProject ¶
func (sm *StateManager) SetProject(name string, state ProjectState)
SetProject directly sets a project in the state without saving. This is used by RegenerateState to batch-populate the map before a single Save.
func (*StateManager) UnregisterProject ¶
func (sm *StateManager) UnregisterProject(projectName string) error
type StateStore ¶
type StateStore interface {
GetProject(name string) (ProjectState, bool)
GetStateFilePath() string
ListProjects() []ProjectState
RegisterProject(project ProjectState) error
UnregisterProject(projectName string) error
Save() error
}
StateStore is the subset of StateManager used by the orchestrator. GetProject replaces direct map access so the interface is satisfiable.
type SystemdClient ¶
type SystemdClient interface {
Close() error
ReloadDaemon(filePaths ...string) error
WaitForUnit(unitName string, timeout time.Duration) error
StartUnit(unitName string) error
StopUnit(unitName string) error
RestartUnit(unitName string) error
ListUnitsByNames(unitNames []string) ([]dbus.UnitStatus, error)
ListAllUnits() ([]dbus.UnitStatus, error)
GetInvocationID(unitName string) (string, error)
}
SystemdClient is the subset of SystemdManager used by the orchestrator. Using an interface here allows tests to inject a fake without a live D-Bus.
type SystemdManager ¶
type SystemdManager struct {
// contains filtered or unexported fields
}
SystemdManager handles direct communication with the systemd D-Bus
func NewSystemdManager ¶
func NewSystemdManager() (*SystemdManager, error)
NewSystemdManager initializes a new connection to the systemd bus. Uses the user bus for rootless (non-root) and system bus for root.
func (*SystemdManager) Close ¶
func (s *SystemdManager) Close() error
Close closes the D-Bus connection
func (*SystemdManager) GetInvocationID ¶
func (s *SystemdManager) GetInvocationID(unitName string) (string, error)
GetInvocationID returns the invocation ID of a specific unit as raw hex. Returns empty string if the unit is not found or has no invocation ID.
func (*SystemdManager) ListAllUnits ¶
func (s *SystemdManager) ListAllUnits() ([]dbus.UnitStatus, error)
ListAllUnits returns all units known to systemd.
func (*SystemdManager) ListUnitsByNames ¶
func (s *SystemdManager) ListUnitsByNames(unitNames []string) ([]dbus.UnitStatus, error)
ListUnitsByNames returns the current state of the specified units.
func (*SystemdManager) ReloadDaemon ¶
func (s *SystemdManager) ReloadDaemon(filePaths ...string) error
ReloadDaemon triggers a systemd daemon-reload and waits for quadlet generators to produce units for the given file paths.
func (*SystemdManager) RestartUnit ¶
func (s *SystemdManager) RestartUnit(unitName string) error
RestartUnit restarts a specific systemd unit and waits for the job to complete. Unlike StartUnit, this always tears down and recreates the unit even if already active.
func (*SystemdManager) StartUnit ¶
func (s *SystemdManager) StartUnit(unitName string) error
StartUnit starts a specific systemd unit and waits for the job to complete. Returns an error if the unit fails to start or the job does not complete with "done".
func (*SystemdManager) StopUnit ¶
func (s *SystemdManager) StopUnit(unitName string) error
StopUnit stops a specific systemd unit and waits for the job to complete. Returns an error if the unit fails to stop or the job does not complete with "done".
func (*SystemdManager) WaitForUnit ¶
func (s *SystemdManager) WaitForUnit(unitName string, timeout time.Duration) error
WaitForUnit polls systemd until the unit is known or timeout is reached. This is needed because the quadlet generator runs asynchronously after daemon-reload.
type TargetDirResolver ¶
type TargetDirResolver struct{}
TargetDirResolver determines the correct Systemd directory based on UID
func NewTargetDirResolver ¶
func NewTargetDirResolver() *TargetDirResolver
NewTargetDirResolver creates a new resolver
func (*TargetDirResolver) GetSystemdPath ¶
func (r *TargetDirResolver) GetSystemdPath() (string, error)
GetSystemdPath returns either /etc/containers/systemd or ~/.config/containers/systemd