Documentation
¶
Overview ¶
Package session contains client-side primitives for treating a labeled Workspace as a paddock-tui session: list/create/end/watch and template-default annotations.
A "session" is just a Workspace with the SessionLabel set to "true". All cluster-side state introduced by paddock-tui lives in three keys: one label and two annotations.
Index ¶
- Constants
- func DefaultTemplate(ws *paddockv1alpha1.Workspace) string
- func End(ctx context.Context, c client.Client, ns, name string) error
- func IsSession(ws *paddockv1alpha1.Workspace) bool
- func LastTemplate(ws *paddockv1alpha1.Workspace) string
- func Watch(ctx context.Context, c client.Client, ns string, interval time.Duration) (<-chan Event, error)
- type CreateOptions
- type Event
- type EventType
- type Session
- type TemplateInfo
Constants ¶
const ( // SessionLabel marks a Workspace as a paddock-tui session. SessionLabel = "paddock.dev/session" // SessionLabelTrue is the value set on the SessionLabel for sessions. SessionLabelTrue = "true" // DefaultTemplateAnnotation records the HarnessTemplate the session // was created against. Used as a fallback when LastTemplate is unset. DefaultTemplateAnnotation = "paddock.dev/session-default-template" // LastTemplateAnnotation records the last HarnessTemplate actually // used by a HarnessRun in this session. The TUI updates this on // every prompt submission and on the `template` palette command. // Falls back to DefaultTemplate when missing. LastTemplateAnnotation = "paddock.dev/session-last-template" )
const DescriptionAnnotation = "paddock.dev/description"
DescriptionAnnotation lets template authors surface a one-line blurb in paddock-tui's picker. Optional; image is the fallback.
Variables ¶
This section is empty.
Functions ¶
func DefaultTemplate ¶
func DefaultTemplate(ws *paddockv1alpha1.Workspace) string
DefaultTemplate returns the session's default template annotation (empty string when unset).
func End ¶
End deletes a session-labeled Workspace. Refuses to delete a Workspace that isn't a session — paddock-tui only manages its own labeled workspaces.
func IsSession ¶
func IsSession(ws *paddockv1alpha1.Workspace) bool
IsSession reports whether a Workspace carries the session label.
func LastTemplate ¶
func LastTemplate(ws *paddockv1alpha1.Workspace) string
LastTemplate returns the session's last-used template annotation, falling back to DefaultTemplate when LastTemplate is unset.
func Watch ¶
func Watch(ctx context.Context, c client.Client, ns string, interval time.Duration) (<-chan Event, error)
Watch polls List(ns) at the given interval and emits Add/Update/ Delete events on the returned channel. The channel closes when ctx is done. We poll rather than use a controller-runtime informer so the client side stays small and dependency-light. interval=0 falls back to one second.
Types ¶
type CreateOptions ¶
type CreateOptions struct {
Namespace string
Name string
Template string // HarnessTemplate name; recorded as default + last template.
StorageSize resource.Quantity // PVC size; required.
SeedRepoURL string // optional; if set, becomes spec.seed.repos[0].URL.
SeedBranch string // optional.
}
CreateOptions parameterises Create. Name is required; Namespace is resolved from the kubeconfig at command time and threaded through.
type Session ¶
type Session struct {
Name string
Namespace string
DefaultTemplate string
LastTemplate string
Phase paddockv1alpha1.WorkspacePhase
ActiveRunRef string
TotalRuns int32
LastActivity time.Time
CreationTime time.Time
ResourceVersion string
}
Session is a TUI-shaped projection of a labeled Workspace. It carries only what the TUI needs and is safe to copy across goroutines.
func Create ¶
Create creates a new session-labeled Workspace and returns its Session projection. Does not wait for the Workspace controller to finish seeding — callers that need that should watch separately.
func FromWorkspace ¶
func FromWorkspace(ws *paddockv1alpha1.Workspace) Session
FromWorkspace converts a Workspace to its Session projection.
type TemplateInfo ¶
type TemplateInfo struct {
Name string
Kind string // "HarnessTemplate" or "ClusterHarnessTemplate"
Description string
}
TemplateInfo is a flattened view of a HarnessTemplate suited for the new-session modal.
func ListTemplates ¶
ListTemplates returns namespaced HarnessTemplates plus all ClusterHarnessTemplates. Sorted by Name. ClusterHarnessTemplate errors are tolerated (RBAC may forbid list at cluster scope).