power

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package power is the power behavior: reboot or shut down the host. Each method is an action with the execute permission, power:execute, so the operator role has it and the automation role does not. The host goes down, so no example runs on a live host.

Index

Constants

This section is empty.

Variables

View Source
var Behavior = behavior.Register(behavior.Define(
	"power", "Reboot or shut down the host",
	behavior.Node,
	behavior.API,
	behavior.Area(area.Node),
	behavior.CLI,
	behavior.Platform(behavior.PlatformDebian, newDebian),
	action("reboot", Reboot, "Reboot the host", "-r"),
	action("shutdown", Shutdown, "Shut the host down", "-h"),
))

Behavior is the power definition.

Functions

This section is empty.

Types

type Input

type Input struct {
	Delay   int    `` /* 151-byte string literal not displayed */
	Message string `json:"message,omitempty" validate:"omitempty"                        doc:"A message to the logged-in users first."`
}

Input is when the host goes down, and what its users read first.

type Provider

type Provider interface {
	Reboot(ctx context.Context, in Input) (Result, error)
	Shutdown(ctx context.Context, in Input) (Result, error)
}

Provider reboots or shuts down the host.

type Result

type Result struct {
	Action  string `json:"action"  doc:"reboot or shutdown"`
	Delay   int    `json:"delay"   doc:"Seconds before the host goes down."`
	Changed bool   `json:"changed" doc:"Always true: each run changes the host."`
}

Result is what the host does.

func Reboot

func Reboot(
	ctx context.Context,
	p Provider,
	in Input,
) (Result, error)

Reboot reboots the host after the delay.

func Shutdown

func Shutdown(
	ctx context.Context,
	p Provider,
	in Input,
) (Result, error)

Shutdown shuts the host down after the delay.

Directories

Path Synopsis
Package mocks holds the generated double of the power provider, for the methods' tests.
Package mocks holds the generated double of the power provider, for the methods' tests.

Jump to

Keyboard shortcuts

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