Documentation
¶
Overview ¶
Package zcontext is used to store the context information for the application.
Index ¶
Constants ¶
const ( KeyContext = "context" // Workspace lives at the top level (sibling to context), mirroring its // role as an outer scope: a workspace switch invalidates the inner // project / environment / service context. KeyWorkspace = "workspace" KeyWorkspaceID = KeyWorkspace + ".id" KeyWorkspaceName = KeyWorkspace + ".name" KeyWorkspaceKind = KeyWorkspace + ".kind" KeyProject = KeyContext + ".project" KeyProjectID = KeyProject + ".id" KeyProjectName = KeyProject + ".name" KeyEnvironment = KeyContext + ".environment" KeyEnvironmentID = KeyEnvironment + ".id" KeyEnvironmentName = KeyEnvironment + ".name" KeyService = KeyContext + ".service" KeyServiceID = KeyService + ".id" KeyServiceName = KeyService + ".name" )
Keys for context
const WorkspaceKindTeam = "team"
WorkspaceKindTeam marks a workspace as a Zeabur team. The empty string is "personal" — the user's own resources, the default when the CLI has never been switched to a team.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface {
// GetWorkspace returns the persisted workspace. Always non-nil; check
// IsPersonal() / IsTeam() to branch. Personal is the zero value.
GetWorkspace() *Workspace
// SetWorkspace persists the workspace; passing nil is equivalent to
// ClearWorkspace().
SetWorkspace(workspace *Workspace)
// ClearWorkspace returns to personal — the default zero state.
ClearWorkspace()
GetProject() BasicInfo
SetProject(project BasicInfo)
ClearProject()
GetEnvironment() BasicInfo
SetEnvironment(environment BasicInfo)
ClearEnvironment()
GetService() BasicInfo
SetService(service BasicInfo)
ClearService()
// ClearAll clears the inner project / environment / service context but
// leaves the workspace intact. Use ClearWorkspace() to go back to personal,
// which on its own does not touch the inner context — switching commands
// orchestrate that explicitly so they can report what was cleared.
ClearAll()
}
Context represents the current context of the CLI, including the current workspace (personal or team), and the pinned project / environment / service inside that workspace.
func NewEphemeralContext ¶ added in v0.18.0
NewEphemeralContext returns a new in-memory Context whose GetWorkspace() reports the supplied workspace. Pass `nil` for personal (or when no override is active and the caller really wants a blank scratch context — uncommon).
func NewViperContext ¶
NewViperContext creates a new Context based on viper
type Workspace ¶ added in v0.18.0
type Workspace struct {
// ID is the team's MongoDB ObjectID hex string. Empty for personal.
ID string
// Name is the team's display name. Empty for personal.
Name string
// Kind is "team" for team workspaces, empty for personal.
Kind string
}
Workspace identifies which owner the CLI is currently acting against for directory-level commands (project list, project create, deploy with no linked project). Other commands address resources by their own ID and stay workspace-independent.
func (*Workspace) IsPersonal ¶ added in v0.18.0
IsPersonal reports whether the workspace addresses the caller's own resources (no team scope). The zero value is personal.