workspace

package
v0.0.106 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package workspace manages a registry of GitHub repositories and a local clone cache. The registry maps owner/repo identifiers to locally managed bare clones, providing the foundation for klausctl-managed workspaces that don't rely on users' personal checkouts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureCached

func EnsureCached(reposDir, owner, repo string, noFetch bool) (string, error)

EnsureCached ensures a bare clone of the repository exists at reposDir/owner/repo/. If the clone does not exist it is created with `git clone --no-checkout`. If it exists and noFetch is false, origin is fetched to update remote refs. The returned path is the cache directory.

func FetchAll

func FetchAll(reposDir string) error

FetchAll walks reposDir and fetches origin for every cached repository.

func FetchRepo

func FetchRepo(reposDir, owner, repo string) error

FetchRepo runs `git fetch origin` in the cached clone at reposDir/owner/repo/.

func IsAllowed

func IsAllowed(cfg *WorkspaceConfig, owner, repo string) bool

IsAllowed reports whether the given owner/repo is permitted by the workspace config. A repo is allowed if its owner appears in the Organizations list or the full "owner/repo" appears in the Repos list.

func IsRepoIdentifier

func IsRepoIdentifier(workspace string) bool

IsRepoIdentifier reports whether workspace looks like an owner/repo identifier rather than a filesystem path. A repo identifier does NOT start with '/', '~', or '.' and contains exactly one '/'.

func Save

func Save(path string, cfg *WorkspaceConfig) error

Save writes a WorkspaceConfig to the given path, creating parent directories as needed.

Types

type CachedRepo

type CachedRepo struct {
	Owner      string
	Repo       string
	Identifier string // "owner/repo"
}

CachedRepo describes a locally cached repository clone.

func ListCached

func ListCached(reposDir string) ([]CachedRepo, error)

ListCached walks reposDir looking for <owner>/<repo>/ directories that contain a .git directory, and returns them as CachedRepo entries.

type RepoEntry

type RepoEntry struct {
	Name string `yaml:"name"` // owner/repo format
}

RepoEntry represents a single repository in the workspace registry.

type WorkspaceConfig

type WorkspaceConfig struct {
	Organizations []string    `yaml:"organizations,omitempty"`
	Repos         []RepoEntry `yaml:"repos,omitempty"`
}

WorkspaceConfig holds the workspace registry configuration, serialized as workspaces.yaml. Organizations grant access to all repos under an owner; Repos grants access to individual repositories.

func Load

func Load(path string) (*WorkspaceConfig, error)

Load reads a WorkspaceConfig from the given path. If the file does not exist, an empty config is returned without error.

Jump to

Keyboard shortcuts

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