workspace

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package workspace mounts additional gadak profiles under /w/<name>/ and lists them at GET /api/v1/workspaces. Shared by `gadak serve` and the desktop app.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListHandler

func ListHandler() http.HandlerFunc

ListHandler answers GET /api/v1/workspaces with the primary profile first (active:true) and every named profile after. Credentials never appear.

func ProfileExists

func ProfileExists(name string) bool

ProfileExists reports whether name is a directory under profiles/ (disk is the source of truth for workspace mounts).

Types

type Entry

type Entry struct {
	Handler http.Handler
	DB      *store.DB
	Cfg     *config.Config
}

Entry is one opened workspace mirror (handler + DB + config).

type ListEntry

type ListEntry struct {
	Name     string   `json:"name"`
	Site     string   `json:"site,omitempty"`
	Projects []string `json:"projects,omitempty"`
	Active   bool     `json:"active,omitempty"`
	Error    string   `json:"error,omitempty"`
}

ListEntry is one item in GET /api/v1/workspaces. Never carries Token or Email — only site URL and project keys for the picker.

type Registry

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

Registry lazy-opens profile mirrors on first /w/<name>/ request and closes them when the process exits.

func New

func New() *Registry

New returns an empty workspace registry.

func (*Registry) Close

func (r *Registry) Close()

Close closes every opened workspace DB. Safe to call once at shutdown.

func (*Registry) EnsureWatch added in v0.13.0

func (r *Registry) EnsureWatch(name string) bool

EnsureWatch starts this profile's Watch if WatchAll has armed the owner, the profile now has a credential, and no loop is already running. Idempotent.

func (*Registry) EnsureWatches added in v0.13.0

func (r *Registry) EnsureWatches() []string

EnsureWatches is the single "credential appeared" scan: start a Watch for every non-primary profile that now has a credential and does not already have a loop. Returns the names that were started this call.

func (*Registry) Get

func (r *Registry) Get(name string) (*Entry, error)

Get returns a cached workspace entry, opening the profile on first use.

func (*Registry) Handler

func (r *Registry) Handler(spa http.Handler, version string) http.HandlerFunc

Handler routes /w/<name>/… to the named profile's API, config, healthz, or SPA. Invalid names and unknown profiles answer 404. version is reported in healthz (same field as the primary /healthz).

func (*Registry) WatchAll

func (r *Registry) WatchAll(ctx context.Context, primary string, logf func(string)) []string

WatchAll arms the credential-appearance owner and starts a loop for every profile that already has a credential, skipping primary (its caller already watches that one). Returns the profile names that got a loop. Subsequent credentials (onboarding connect, or a later EnsureWatches / rescan) start through the same owner and cannot double-start. Log receives status lines; never pass secrets into it — only profile names are logged from here.

func (*Registry) Watching added in v0.13.0

func (r *Registry) Watching() []string

Watching returns the profile names whose Watch loop has been started. Debug surface for D8 (settings / tests); order is sorted.

Jump to

Keyboard shortcuts

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