Documentation
¶
Index ¶
- func CheckoutNewBranch(exec dal.Executor, dir, branch string) error
- func CommitsBehind(exec dal.Executor, repoDir, branch, baseBranch string) (int, error)
- func CopyRepo(fs dal.FileSystem, exec dal.Executor, src, dst string) error
- func CurrentBranch(exec dal.Executor, dir string) (string, error)
- func FetchAndRebase(exec dal.Executor, dir, baseBranch string) error
- func FindRepoRoot(fs dal.FileSystem, dir string) (string, error)
- func IsDirty(exec dal.Executor, dir string) (bool, error)
- func SlotNameFromPath(path, prefix string) (string, error)
- func ValidateSlotName(name string) error
- type GitError
- type SlotConfig
- type SlotResource
- func (s *SlotResource) Create(ctx *agentops.AppContext, slug string, opts map[string]string) (*resource.Record, error)
- func (s *SlotResource) Delete(ctx *agentops.AppContext, id string) error
- func (s *SlotResource) Doctor(ctx *agentops.AppContext) ([]resource.DoctorCheck, error)
- func (s *SlotResource) Get(ctx *agentops.AppContext, id string) (*resource.Record, error)
- func (s *SlotResource) List(ctx *agentops.AppContext, filter resource.Filter) ([]resource.Record, error)
- func (s *SlotResource) Prune(ctx *agentops.AppContext, confirm bool) ([]resource.PruneResult, error)
- func (s *SlotResource) Schema() resource.ResourceSchema
- func (s *SlotResource) Sync(ctx *agentops.AppContext, id string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckoutNewBranch ¶ added in v0.6.0
CheckoutNewBranch creates and checks out a new branch in the given directory.
func CommitsBehind ¶ added in v0.6.0
CommitsBehind returns how many commits branch is behind baseBranch.
func CopyRepo ¶ added in v0.6.0
CopyRepo copies the source directory to dst using cp -r. Returns an error if dst already exists.
func CurrentBranch ¶ added in v0.6.0
CurrentBranch returns the current branch name of the repository at dir.
func FetchAndRebase ¶ added in v0.6.0
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 SlotNameFromPath ¶ added in v0.6.0
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
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 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
func (s *SlotResource) Doctor(ctx *agentops.AppContext) ([]resource.DoctorCheck, error)
Doctor runs health checks on all active slot copies.
func (*SlotResource) Get ¶
func (s *SlotResource) Get(ctx *agentops.AppContext, id string) (*resource.Record, error)
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>.