operation

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidOperation = errors.New("invalid operation")

ErrInvalidOperation is returned when an operation cannot be created from Input.

Functions

func MakeErrInvalidOperation

func MakeErrInvalidOperation(in Input) error

MakeErrInvalidOperation creates an error combining ErrInvalidOperation with the Input.

Types

type Input

type Input struct {
	Name string `yaml:"name"`
	Role string `yaml:"role"`

	Shell string `yaml:"shell"`

	Copy   string `yaml:"copy"`
	To     string `yaml:"to"`
	Backup bool   `yaml:"backup"`
}

Input defines the YAML input structure for creating operations. It specifies the operation type (shell or copy) and its parameters.

type OpCopy

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

OpCopy copies files or directories to remote hosts via SFTP.

func NewOpCopy

func NewOpCopy(in Input) (*OpCopy, error)

NewOpCopy creates a new OpCopy operation from the given Input. Returns ErrInvalidOperation if the To field is empty.

func (OpCopy) DefaultName added in v0.0.13

func (op OpCopy) DefaultName() string

DefaultName returns the default name for copy operations.

func (OpCopy) Execute

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

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

func (OpCopy) Name

func (op OpCopy) Name() string

Name returns the operation's name.

func (OpCopy) Role

func (op OpCopy) Role() string

Role returns the operation's target role.

func (*OpCopy) SetName

func (op *OpCopy) SetName(name string)

SetName sets the operation's name.

func (*OpCopy) SetRole

func (op *OpCopy) SetRole(role string)

SetRole sets the operation's target role.

type OpShell

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

OpShell executes shell commands on remote hosts.

func NewOpShell

func NewOpShell(in Input) (*OpShell, error)

NewOpShell creates a new OpShell operation from the given Input. Returns ErrInvalidOperation if Shell field is empty.

func (OpShell) DefaultName added in v0.0.13

func (op OpShell) DefaultName() string

DefaultName returns the default name for shell operations.

func (OpShell) Execute

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

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

func (OpShell) Name

func (op OpShell) Name() string

Name returns the operation's name.

func (OpShell) Role

func (op OpShell) Role() string

Role returns the operation's target role.

func (*OpShell) SetName

func (op *OpShell) SetName(name string)

SetName sets the operation's name.

func (*OpShell) SetRole

func (op *OpShell) SetRole(role string)

SetRole sets the operation's target role.

type Operation

type Operation interface {
	Execute(r *remote.Remote) (*gtypes.OrderedMap[string, string], error)
	DefaultName() string
	// contains filtered or unexported methods
}

Operation defines the interface for executable remote operations.

func GetOperation

func GetOperation(in Input) (Operation, error)

GetOperation creates an Operation from the given Input. It returns an error if the Input is invalid or unsupported.

Jump to

Keyboard shortcuts

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