power

package
v0.0.0-...-63dd1cf Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package power provides power management operations (reboot, shutdown).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Darwin

type Darwin struct{}

Darwin implements the Provider interface for Darwin (macOS). All methods return ErrUnsupported as power management is not available on macOS.

func NewDarwinProvider

func NewDarwinProvider() *Darwin

NewDarwinProvider factory to create a new Darwin instance.

func (*Darwin) Reboot

func (d *Darwin) Reboot(
	_ context.Context,
	_ Opts,
) (*Result, error)

Reboot returns ErrUnsupported on Darwin.

func (*Darwin) Shutdown

func (d *Darwin) Shutdown(
	_ context.Context,
	_ Opts,
) (*Result, error)

Shutdown returns ErrUnsupported on Darwin.

type Debian

type Debian struct {
	provider.FactsAware
	// contains filtered or unexported fields
}

Debian implements the Provider interface for Debian-family systems.

func NewDebianProvider

func NewDebianProvider(
	logger *slog.Logger,
	execManager exec.Manager,
) *Debian

NewDebianProvider factory to create a new Debian instance.

func (*Debian) Reboot

func (d *Debian) Reboot(
	ctx context.Context,
	opts Opts,
) (*Result, error)

Reboot schedules a system reboot with the specified delay.

func (*Debian) Shutdown

func (d *Debian) Shutdown(
	ctx context.Context,
	opts Opts,
) (*Result, error)

Shutdown schedules a system shutdown with the specified delay.

type Linux

type Linux struct{}

Linux implements the Provider interface for generic Linux. All methods return ErrUnsupported as this is a generic Linux stub.

func NewLinuxProvider

func NewLinuxProvider() *Linux

NewLinuxProvider factory to create a new Linux instance.

func (*Linux) Reboot

func (l *Linux) Reboot(
	_ context.Context,
	_ Opts,
) (*Result, error)

Reboot returns ErrUnsupported on generic Linux.

func (*Linux) Shutdown

func (l *Linux) Shutdown(
	_ context.Context,
	_ Opts,
) (*Result, error)

Shutdown returns ErrUnsupported on generic Linux.

type Opts

type Opts struct {
	Delay   int    `json:"delay,omitempty"`
	Message string `json:"message,omitempty"`
}

Opts represents options for a power management operation.

type Provider

type Provider interface {
	Reboot(ctx context.Context, opts Opts) (*Result, error)
	Shutdown(ctx context.Context, opts Opts) (*Result, error)
}

Provider implements power management operations.

type Result

type Result struct {
	Action  string `json:"action"`
	Delay   int    `json:"delay"`
	Changed bool   `json:"changed"`
	Error   string `json:"error,omitempty"`
}

Result represents the outcome of a power management operation.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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