module

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: GPL-3.0 Imports: 10 Imported by: ? 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

Index

Constants

This section is empty.

Variables

View Source
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-module constructor uses ErrInvalidModule to refuse a half-filled action (e.g. copy with src but no dest).

View Source
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

func MakeErrInvalidModule(in Task) error

Types

type Copy

type Copy struct {
	// contains filtered or unexported fields
}

Copy copies files or directories to remote hosts via SFTP.

func NewCopy

func NewCopy(in Task) (*Copy, error)

NewCopy creates a new Copy module from the given Task. Returns ErrInvalidModule if the copy body, src or dest is missing.

func (Copy) DefaultName

func (m Copy) DefaultName() string

DefaultName returns the default name for copy modules.

func (Copy) Execute

func (m Copy) Execute(r *remote.Remote) (*gtypes.OrderedMap[string, string], error)

Execute uploads the local file or directory to the remote host.

func (Copy) Name

func (m Copy) Name() string

Name returns the module's display name.

func (Copy) Role

func (m Copy) Role() string

Role returns the host role this module targets.

func (*Copy) SetName

func (m *Copy) SetName(name string)

SetName replaces the module's display name.

func (*Copy) SetRole

func (m *Copy) SetRole(role string)

SetRole replaces the target host role.

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 NewLocal

func NewLocal(in Task) (*Local, error)

func (Local) DefaultName

func (m Local) DefaultName() string

func (Local) Execute

func (m Local) Execute(r *remote.Remote) (*gtypes.OrderedMap[string, string], error)

func (Local) Name

func (m Local) Name() string

Name returns the module's display name.

func (Local) Role

func (m Local) Role() string

Role returns the host role this module targets.

func (*Local) SetName

func (m *Local) SetName(name string)

SetName replaces the module's display name.

func (*Local) SetPrefix

func (m *Local) SetPrefix(prefix string)

func (*Local) SetRole

func (m *Local) SetRole(role string)

SetRole replaces the target host role.

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
}

func GetModule

func GetModule(in Task) (Module, error)

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell executes shell commands on remote hosts.

func NewShell

func NewShell(in Task) (*Shell, error)

NewShell creates a new Shell module from the given Task. Returns ErrInvalidModule if Shell field is empty.

func (Shell) DefaultName

func (m Shell) DefaultName() string

DefaultName returns the default name for shell modules.

func (Shell) Execute

func (m Shell) Execute(r *remote.Remote) (*gtypes.OrderedMap[string, string], error)

Execute runs the shell command on the remote host and returns the results.

func (Shell) Name

func (m Shell) Name() string

Name returns the module's display name.

func (Shell) Role

func (m Shell) Role() string

Role returns the host role this module targets.

func (*Shell) SetName

func (m *Shell) SetName(name string)

SetName replaces the module's display name.

func (*Shell) SetRole

func (m *Shell) SetRole(role string)

SetRole replaces the target host role.

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 module kind — mirroring ansible's task module convention. Name should be set so that `minop task` shows a human-readable label; Role defaults to "all".

Jump to

Keyboard shortcuts

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