labs

package
v0.77.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 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

Overview

Package labs is the registry of the labs on this machine: one entry per cluster name, pointing at the lab directory that holds its agentlab.yaml, certs/ and state/. `configure` and `up` write it; every command that runs against a lab resolves the lab through it (Resolve), so a person no longer has to `cd` into the lab first. The lab's own layout does not move: the registry only points at directories.

Index

Constants

This section is empty.

Variables

View Source
var Dir = func() (string, error) {
	dir, err := os.UserConfigDir()
	if err != nil {
		return "", err
	}
	return filepath.Join(dir, project.Name), nil
}

Dir is the registry's directory: agentlab's own under the user's config directory (~/.config/agentlab on Linux, ~/Library/Application Support/agentlab on macOS), the sibling of the update check's cache. A variable so tests can point it at a temporary directory.

Functions

func Check

func Check(name, dir string) error

Check refuses a name registered to a different, still existing lab directory; it writes nothing. `configure` and the first run call it before they save an agentlab.yaml, so a refused name leaves no file behind.

func Register

func Register(name, dir string) error

Register records dir as the lab of that name, dropping any other name the directory was registered under (a changed clusterName) and the entries whose directory no longer holds a lab. A name registered to another existing lab directory is refused with a *TakenError.

Types

type Lab

type Lab struct {
	Name string
	Dir  string
}

Lab is one registered lab: its cluster name (agentlab.yaml's clusterName, the lab's name everywhere) and its absolute directory.

func List

func List() ([]Lab, error)

List returns the registered labs sorted by name. Entries whose directory or agentlab.yaml is gone are left out — neither offered nor listed — but kept in the file: a read never writes, so a lab whose agentlab.yaml is away for a moment (moved aside, being rewritten) is back once the file is. Register drops the stale entries when it writes.

func Resolve

func Resolve(flag string, create bool, pick Picker) (lab Lab, err error)

Resolve decides which lab directory a command runs against, in one order:

  1. --lab <name> (flag), refused naming the registered labs when unknown;
  2. an agentlab.yaml in the current directory, whatever the registry says;
  3. unless create: the one registered lab, or on a terminal (pick non-nil) the person's choice among several, or off one a refusal naming them and --lab.

dir is "" for the current directory — also when nothing is registered, so the caller's missing-agentlab.yaml path (the first run, or its refusal) stays what it is. create is for the commands that make a lab where they run (`configure`, `up`): in a directory without agentlab.yaml they create one there instead of reaching for another lab.

type Picker

type Picker func(labs []Lab) (Lab, error)

Picker asks which of several labs a command runs against, on a terminal.

type TakenError

type TakenError struct {
	Name  string
	Dir   string // the directory asking for the name
	Other string // the directory the name is registered to
}

TakenError refuses a second lab of a registered name: the two would collide on the kind cluster and its ports.

func (*TakenError) Error

func (e *TakenError) Error() string

Jump to

Keyboard shortcuts

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