ui/server/src/workspace
The workspace boundary.
Cockpit server, v0.8. Source: ui/server/src/workspace.mjs.
Classes#
WorkspaceError#
Defined in: ui/server/src/workspace.mjs:23
Extends#
Error
Constructors#
Constructor
new WorkspaceError(
status,code,message):WorkspaceError
Defined in: ui/server/src/workspace.mjs:25
Parameters
status
number
code
string
message
string
Returns
Overrides
Error.constructor
Properties#
code
code:
string
Defined in: ui/server/src/workspace.mjs:29
name
name:
string
Defined in: ui/server/src/workspace.mjs:27
Inherited from
Error.name
status
status:
number
Defined in: ui/server/src/workspace.mjs:28
Variables#
MAX_PATH_LENGTH#
constMAX_PATH_LENGTH:4096=4096
Defined in: ui/server/src/workspace.mjs:21
Functions#
contain()#
contain(
root,requested,opts?):string
Defined in: ui/server/src/workspace.mjs:90
Resolve requested to a real path inside root, or throw a WorkspaceError.
Parameters#
root
string
the realpath'd workspace root (from resolveWorkspaceRoot)
requested
unknown
a client-supplied path (absolute, or relative to base)
opts?
base?
string = root
mustBeDir?
boolean = false
mustBeFile?
boolean = false
mustExist?
boolean = true
Returns#
string
the real absolute path (for a not-yet-existing path: real ancestor + the remainder)
containInWorkspace()#
containInWorkspace(
requested,opts):string
Defined in: ui/server/src/workspace.mjs:138
contain() against the process workspace root.
Parameters#
requested
any
opts
any
Returns#
string
containOrNull()#
containOrNull(
root,requested,opts):string
Defined in: ui/server/src/workspace.mjs:108
Non-throwing form of contain: the real path, or null.
Parameters#
root
any
requested
any
opts
any
Returns#
string
isInside()#
isInside(
root,target):boolean
Defined in: ui/server/src/workspace.mjs:34
True when target is root or nested under it. Both must already be real, absolute paths.
Parameters#
root
any
target
any
Returns#
boolean
relativeToWorkspace()#
relativeToWorkspace(
root,target):any
Defined in: ui/server/src/workspace.mjs:118
Workspace-relative display form ("" for the root itself, otherwise "a/b"), always with forward slashes.
Parameters#
root
any
target
any
Returns#
any
resetWorkspaceRootForTests()#
resetWorkspaceRootForTests():
void
Defined in: ui/server/src/workspace.mjs:133
Test seam: forget the cached root so the next workspaceRoot() re-reads the environment.
Returns#
void
resolveWorkspaceRoot()#
resolveWorkspaceRoot(
env?,__namedParameters?):any
Defined in: ui/server/src/workspace.mjs:42
Resolve (and create if missing) the workspace root. Throws a plain Error on a relative or unusable value: the server must refuse to start rather than run with a boundary it cannot establish.
Parameters#
env?
any = process.env
__namedParameters?
home?
any = ...
Returns#
any
workspaceRoot()#
workspaceRoot():
any
Defined in: ui/server/src/workspace.mjs:127
The workspace root for this server process (resolved from the environment on first use).
Returns#
any