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 ¶
- func EnsureCached(reposDir, owner, repo string, noFetch bool) (string, error)
- func FetchAll(reposDir string) error
- func FetchRepo(reposDir, owner, repo string) error
- func IsAllowed(cfg *WorkspaceConfig, owner, repo string) bool
- func IsRepoIdentifier(workspace string) bool
- func Save(path string, cfg *WorkspaceConfig) error
- type CachedRepo
- type RepoEntry
- type WorkspaceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureCached ¶
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 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 ¶
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 ¶
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.