executor

package
v0.0.0-...-8198c06 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDockerInfo

func GetDockerInfo() (string, error)

GetDockerInfo returns Docker system information

func IsDockerAvailable

func IsDockerAvailable() bool

IsDockerAvailable checks if Docker is available

Types

type DockerRunner

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

DockerRunner executes commands in Docker containers

func NewDockerRunner

func NewDockerRunner() (*DockerRunner, error)

NewDockerRunner creates a new Docker runner

func (*DockerRunner) Close

func (dr *DockerRunner) Close() error

Close closes the Docker client

func (*DockerRunner) RunInSandbox

func (dr *DockerRunner) RunInSandbox(cmd string, opts SandboxOptions) (*SandboxResult, error)

RunInSandbox executes a command in an isolated Docker container

type FileUndoStrategy

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

FileUndoStrategy handles file operation undos

func (*FileUndoStrategy) CanUndo

func (s *FileUndoStrategy) CanUndo(command string) bool

func (*FileUndoStrategy) CreateBackup

func (s *FileUndoStrategy) CreateBackup(command string, affectedPaths []string) (*UndoRecord, error)

func (*FileUndoStrategy) Undo

func (s *FileUndoStrategy) Undo(record *UndoRecord) error

type GitUndoStrategy

type GitUndoStrategy struct{}

GitUndoStrategy handles git operation undos

func (*GitUndoStrategy) CanUndo

func (s *GitUndoStrategy) CanUndo(command string) bool

func (*GitUndoStrategy) CreateBackup

func (s *GitUndoStrategy) CreateBackup(command string, affectedPaths []string) (*UndoRecord, error)

func (*GitUndoStrategy) Undo

func (s *GitUndoStrategy) Undo(record *UndoRecord) error

type KubectlUndoStrategy

type KubectlUndoStrategy struct{}

KubectlUndoStrategy handles kubectl operation undos

func (*KubectlUndoStrategy) CanUndo

func (s *KubectlUndoStrategy) CanUndo(command string) bool

func (*KubectlUndoStrategy) CreateBackup

func (s *KubectlUndoStrategy) CreateBackup(command string, affectedPaths []string) (*UndoRecord, error)

func (*KubectlUndoStrategy) Undo

func (s *KubectlUndoStrategy) Undo(record *UndoRecord) error

type Mount

type Mount struct {
	Source   string
	Target   string
	ReadOnly bool
}

Mount represents a volume mount

type SandboxOptions

type SandboxOptions struct {
	WorkingDir    string        // Working directory inside container
	Mounts        []Mount       // Volume mounts
	NetworkAccess bool          // Enable network access
	CPULimit      float64       // CPU limit (cores, e.g., 0.5)
	MemoryLimit   int64         // Memory limit in bytes
	PidsLimit     int64         // Max number of processes
	Timeout       time.Duration // Execution timeout
	Image         string        // Docker image to use
	ReadOnly      bool          // Mount filesystem as read-only
}

SandboxOptions configures sandbox execution

type SandboxResult

type SandboxResult struct {
	Stdout    []byte
	Stderr    []byte
	ExitCode  int
	SandboxID string
	StartTime time.Time
	EndTime   time.Time
	Error     error
}

SandboxResult contains execution results

type SnapshotMetadata

type SnapshotMetadata struct {
	Type          string // "git" or "filesystem"
	Location      string // Branch name or backup directory
	Timestamp     time.Time
	AffectedPaths []string
	Reversible    bool
	RestoreCmd    string // Command to restore the snapshot
}

SnapshotMetadata contains information about a pre-run snapshot

type Snapshotter

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

Snapshotter creates pre-run snapshots for undo capability

func NewSnapshotter

func NewSnapshotter() *Snapshotter

NewSnapshotter creates a new snapshotter

func (*Snapshotter) CleanupOldSnapshots

func (s *Snapshotter) CleanupOldSnapshots(maxAge time.Duration) error

CleanupOldSnapshots removes snapshots older than the specified duration

func (*Snapshotter) CreateSnapshot

func (s *Snapshotter) CreateSnapshot(workingDir string, affectedPaths []string) (*SnapshotMetadata, error)

CreateSnapshot creates a snapshot based on the working directory

func (*Snapshotter) RestoreSnapshot

func (s *Snapshotter) RestoreSnapshot(metadata *SnapshotMetadata, workingDir string) error

RestoreSnapshot restores a snapshot

type UndoEngine

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

UndoEngine manages undo/rollback functionality

func NewUndoEngine

func NewUndoEngine(backupDir string) *UndoEngine

NewUndoEngine creates a new undo engine

func (*UndoEngine) CreateUndo

func (ue *UndoEngine) CreateUndo(command string, affectedPaths []string) (*UndoRecord, error)

CreateUndo creates an undo record for a command

func (*UndoEngine) Undo

func (ue *UndoEngine) Undo(record *UndoRecord) error

Undo performs an undo operation

type UndoRecord

type UndoRecord struct {
	ID             string
	Command        string
	UndoCommand    string
	BackupLocation string
	BackupSize     int64
	CanUndo        bool
	Strategy       string
	AffectedPaths  []string
	CreatedAt      time.Time
	ExpiresAt      time.Time
}

UndoRecord represents an undoable operation

type UndoStrategy

type UndoStrategy interface {
	CanUndo(command string) bool
	CreateBackup(command string, affectedPaths []string) (*UndoRecord, error)
	Undo(record *UndoRecord) error
}

UndoStrategy defines how to undo a specific type of command

Jump to

Keyboard shortcuts

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