Documentation
¶
Index ¶
- Constants
- func IsBrowserIDE(ideName string) bool
- func KillBrowserTunnel(contextName, workspaceID string)
- func Open(ctx context.Context, ideName string, ideOptions map[string]config.OptionValue, ...) (string, error)
- func OpenBrowserWhenReachable(ctx context.Context, url string)
- func ParseAddressAndPort(bindAddressOption string, defaultPort int) (string, int, error)
- func TunnelStateFilePath(contextName, workspaceID string) (string, error)
- func WriteTunnelState(contextName, workspaceID string, state TunnelState) error
- type IDELaunchMode
- type IDEParams
- type TunnelState
Constants ¶
const LabelCodeServer = "code-server"
LabelCodeServer is the TunnelState.Label value used for the code-server (coder.com) browser-IDE tunnel.
const LabelVSCodeBrowser = "vscode"
LabelVSCodeBrowser is the TunnelState.Label value used for the openvscode (VS Code Browser) tunnel. Exposed so tests can reference it without duplicating the literal.
const LabelVSCodeWeb = "vscode-web"
LabelVSCodeWeb is the TunnelState.Label value used for the official VS Code (code serve-web) browser-IDE tunnel.
const TunnelLockFileName = "tunnel.lock"
TunnelLockFileName is the filename used to serialize concurrent attempts to start the browser tunnel for a workspace.
const TunnelLogFileName = "tunnel.log"
TunnelLogFileName is the filename used for the detached browser tunnel helper's stdout/stderr log.
const TunnelStateFileName = "tunnel.json"
TunnelStateFileName is the filename used to record the browser tunnel state inside the workspace directory.
Variables ¶
This section is empty.
Functions ¶
func IsBrowserIDE ¶ added in v1.3.1
IsBrowserIDE reports whether the given IDE name uses a browser-based tunnel (openvscode, jupyter, rstudio). These IDEs spawn a detached helper process for the tunnel; the CLI does not block on the IDE session lifetime.
func KillBrowserTunnel ¶ added in v1.3.1
func KillBrowserTunnel(contextName, workspaceID string)
KillBrowserTunnel terminates the detached browser tunnel for a workspace (if any) and removes its state file. Missing state and dead/foreign PIDs are tolerated silently; lock contention is logged at Warn level. Safe to call from any workspace teardown or recreate path.
func Open ¶
func Open( ctx context.Context, ideName string, ideOptions map[string]config.OptionValue, params IDEParams, ) (string, error)
Open dispatches to the correct IDE opener based on ideName. It returns the IDE URL (when meaningful — see per-IDE openers) along with any error.
func OpenBrowserWhenReachable ¶ added in v1.3.1
OpenBrowserWhenReachable polls the target URL's TCP port until it accepts connections, then opens the browser. Exits silently when ctx is cancelled (the caller already gave up — warning would duplicate the underlying error); emits a "didn't come up" warning only when the budget expires.
Exported so the long-lived browser-tunnel helper can own the probe-then- open sequence rather than the short-lived parent CLI.
func ParseAddressAndPort ¶
ParseAddressAndPort parses a bind address option into host address and port. If bindAddressOption is empty, it finds an available port starting from defaultPort.
func TunnelStateFilePath ¶ added in v1.3.1
TunnelStateFilePath returns the path used to store the browser tunnel state file for the given workspace context and workspace ID.
func WriteTunnelState ¶ added in v1.3.1
func WriteTunnelState(contextName, workspaceID string, state TunnelState) error
WriteTunnelState persists the tunnel state for a workspace.
Types ¶
type IDELaunchMode ¶ added in v1.3.1
type IDELaunchMode string
IDELaunchMode controls how the openIDE phase runs.
- LaunchAuto: full launch — start tunnel (for browser IDEs) and open the host browser/app.
- LaunchHeadless: do not open the host browser/app. For browser IDEs (openvscode, jupyter, rstudio) the detached tunnel still spawns. For Fleet the workspace-side URL is logged so the user can open it manually. For other desktop IDEs (VSCode flavors, JetBrains, Zed) the openIDE phase only does the host launch, so headless is functionally equivalent to skip — backend install (where one exists) happens during workspace setup, not here.
- LaunchSkip: short-circuit the openIDE phase entirely.
const ( LaunchAuto IDELaunchMode = "auto" LaunchHeadless IDELaunchMode = "headless" LaunchSkip IDELaunchMode = "skip" )
func (*IDELaunchMode) Set ¶ added in v1.3.1
func (m *IDELaunchMode) Set(v string) error
Set implements pflag.Value. Strict (case-sensitive) parse to match the kubectl/docker convention; returns a descriptive error on bad input.
func (*IDELaunchMode) String ¶ added in v1.3.1
func (m *IDELaunchMode) String() string
String implements pflag.Value.
func (*IDELaunchMode) Type ¶ added in v1.3.1
func (m *IDELaunchMode) Type() string
Type implements pflag.Value.
type IDEParams ¶ added in v1.3.1
type IDEParams struct {
GPGAgentForwarding bool
SSHAuthSockID string
GitSSHSigningKey string
DevsyConfig *config.Config
Client client2.BaseWorkspaceClient
User string
Result *config2.Result
TunnelMode bool
Launch IDELaunchMode
}
IDEParams holds the parameters needed to open an IDE.
type TunnelState ¶ added in v1.3.1
type TunnelState struct {
PID int `json:"pid"`
CreateTime int64 `json:"createTime"`
TargetURL string `json:"targetUrl"`
Label string `json:"label,omitempty"`
}
TunnelState describes a running browser tunnel for a workspace.
CreateTime is the helper process's creation timestamp in milliseconds since epoch. It pairs with PID to detect PID reuse: if the process at PID has a different CreateTime than the recorded value, the helper is gone and a foreign process now occupies that PID.
func ReadTunnelState ¶ added in v1.3.1
func ReadTunnelState(contextName, workspaceID string) (*TunnelState, error)
ReadTunnelState reads and returns the recorded tunnel state for a workspace. Returns (nil, nil) if no state file exists.