Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidModule = errors.New("invalid module fields")
ErrInvalidModule signals that a task declared an action but is missing the per-action required fields (e.g. copy without src). This is the second-line guard: GetModule picks the action, and the per-op constructor uses ErrInvalidModule to refuse a half-filled action (e.g. copy with src but no dest).
var ErrInvalidModuleSpec = errors.New("invalid module spec")
ErrInvalidModuleSpec signals that a task entry does not match any supported module kind, either because no action was declared or because more than one action was declared on the same task.
Functions ¶
func MakeErrInvalidModule ¶
Types ¶
type Copy ¶
type Copy struct {
// contains filtered or unexported fields
}
Copy copies files or directories to remote hosts via SFTP.
func NewCopy ¶
NewCopy creates a new Copy operation from the given Task. Returns ErrInvalidModule if the copy body, src or dest is missing.
func (Copy) DefaultName ¶
DefaultName returns the default name for copy operations.
type CopySpec ¶
type CopySpec struct {
Src string `yaml:"src"`
Dest string `yaml:"dest"`
Backup bool `yaml:"backup"`
}
CopySpec is the nested body of a "copy" task. Src is the local path; Dest is the absolute remote path. When Backup is true, any pre-existing file at Dest is renamed to "Dest.minop_bak" before the upload, mirroring ansible's backup: yes option.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
func (Local) DefaultName ¶
type Module ¶
type Module interface {
// Name and Role identify the module inside the task list and
// determine which host group it targets. SetName / SetRole are
// setters so the YAML loader and other code paths can populate
// them after construction.
Name() string
SetName(name string)
Role() string
SetRole(role string)
// Execute runs the module against a single remote host and
// returns a structured result map for downstream rendering.
Execute(r *remote.Remote) (*gtypes.OrderedMap[string, string], error)
// DefaultName returns the auto-generated label used when the
// task entry has no explicit name in minop.yaml.
DefaultName() string
}
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
Shell executes shell commands on remote hosts.
func NewShell ¶
NewShell creates a new Shell operation from the given Task. Returns ErrInvalidModule if Shell field is empty.
func (Shell) DefaultName ¶
DefaultName returns the default name for shell operations.
type Task ¶
type Task struct {
Name string `yaml:"name"`
Role string `yaml:"role"`
Shell string `yaml:"shell,omitempty"`
Local string `yaml:"local,omitempty"`
Copy *CopySpec `yaml:"copy,omitempty"`
}
Task is the YAML schema for a single task entry in minop.yaml. A task declares exactly one action: a "shell" string, a "local" string, or a nested "copy" object. Which key is present determines the operation type — mirroring ansible's task module convention. Name should be set so that `minop task` shows a human-readable label; Role defaults to "all".