slotresource

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckoutNewBranch added in v0.6.0

func CheckoutNewBranch(exec dal.Executor, dir, branch string) error

CheckoutNewBranch creates and checks out a new branch in the given directory.

func CommitsBehind added in v0.6.0

func CommitsBehind(exec dal.Executor, repoDir, branch, baseBranch string) (int, error)

CommitsBehind returns how many commits branch is behind baseBranch.

func CopyRepo added in v0.6.0

func CopyRepo(fs dal.FileSystem, exec dal.Executor, src, dst string) error

CopyRepo copies the source directory to dst using cp -r. Returns an error if dst already exists.

func CurrentBranch added in v0.6.0

func CurrentBranch(exec dal.Executor, dir string) (string, error)

CurrentBranch returns the current branch name of the repository at dir.

func FetchAndRebase added in v0.6.0

func FetchAndRebase(exec dal.Executor, dir, baseBranch string) error

FetchAndRebase fetches the latest base branch and rebases the current branch onto it. If rebase conflicts, it aborts and returns an error.

func FindRepoRoot added in v0.6.0

func FindRepoRoot(fs dal.FileSystem, dir string) (string, error)

FindRepoRoot walks up from dir looking for a .git directory or file.

func IsDirty added in v0.6.0

func IsDirty(exec dal.Executor, dir string) (bool, error)

IsDirty returns true if the working tree has uncommitted changes.

func SlotNameFromPath added in v0.6.0

func SlotNameFromPath(path, prefix string) (string, error)

SlotNameFromPath extracts a slot name from a directory name given the prefix. For a dir named "<prefix>-<name>", returns "<name>".

func ValidateSlotName added in v0.6.0

func ValidateSlotName(name string) error

ValidateSlotName checks whether name is a valid slot name. Names must match ^[a-z][a-z0-9-]*$ and must not be empty or whitespace.

Types

type GitError added in v0.6.0

type GitError struct {
	Args   []string
	Output string
	Err    error
}

GitError wraps a failed git command with its arguments and output.

func (*GitError) Error added in v0.6.0

func (e *GitError) Error() string

func (*GitError) Unwrap added in v0.6.0

func (e *GitError) Unwrap() error

type SlotConfig added in v0.6.0

type SlotConfig struct {
	BaseBranch string `yaml:"base_branch"`
	CopyPrefix string `yaml:"copy_prefix"`
}

SlotConfig represents the parsed .agentops/slot.yaml configuration.

func LoadSlotConfig added in v0.6.0

func LoadSlotConfig(fs dal.FileSystem, agentopsDir string, repoRoot string) (*SlotConfig, error)

LoadSlotConfig reads and parses .agentops/slot.yaml. If the file does not exist, sensible defaults are returned. The repoRoot is used to derive the default copy prefix from the repository directory name.

func (*SlotConfig) CopyPath added in v0.6.0

func (c *SlotConfig) CopyPath(parentDir, name string) string

CopyPath computes the path for a copy-based slot directory. Copies are placed as siblings to the source repo: <parentDir>/<prefix>-<name>.

type SlotResource

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

SlotResource implements Resource, Deleter, Syncer, Doctor, and Pruner for copy-based slots.

func New

func New(fs dal.FileSystem, exec dal.Executor) *SlotResource

New creates a SlotResource with the given filesystem and executor.

func (*SlotResource) Create

func (s *SlotResource) Create(ctx *agentops.AppContext, slug string, opts map[string]string) (*resource.Record, error)

Create validates the name, copies the repo, and checks out a new branch.

func (*SlotResource) Delete

func (s *SlotResource) Delete(ctx *agentops.AppContext, id string) error

Delete removes a slot copy after checking for uncommitted changes.

func (*SlotResource) Doctor added in v0.6.0

Doctor runs health checks on all active slot copies.

func (*SlotResource) Get

Get returns a single slot by name.

func (*SlotResource) List

func (s *SlotResource) List(ctx *agentops.AppContext, filter resource.Filter) ([]resource.Record, error)

List returns all slots for the project by scanning sibling directories.

func (*SlotResource) Prune added in v0.6.0

func (s *SlotResource) Prune(ctx *agentops.AppContext, confirm bool) ([]resource.PruneResult, error)

Prune removes clean stale copies. Dry-run by default (confirm=false).

func (*SlotResource) Schema

func (s *SlotResource) Schema() resource.ResourceSchema

Schema returns the resource schema for slots.

func (*SlotResource) Sync

func (s *SlotResource) Sync(ctx *agentops.AppContext, id string) error

Sync rebases the slot branch onto origin/<base_branch>.

Jump to

Keyboard shortcuts

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