mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 01:57:57 +00:00
* test(runtime-environments): pin connect, remove, call readiness, hint and phone relay per host kind * refactor(runtime-environments): dispatch on one exhaustive host-kind classifier * test: avoid type assertions in host-kind characterization fakes * refactor(runtime-environments): keep service-owned connect/remove in one module; tighten characterization tests * style: break, not bare return, in host service ops switches
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import type { OrcadDeploymentLink } from './runtime-environments'
|
|
import type { OrcadWslDeploymentLink } from './wsl-host-deployment-link'
|
|
|
|
/**
|
|
* What kind of host serves a runtime environment. Switch on `kind` (lint requires the switch to be
|
|
* exhaustive), so a new kind fails the build at every switch on it.
|
|
* `network`: reached over the network or an SSH tunnel (paired, SSH access, SSH-managed).
|
|
* `wsl`: a distro on this computer, reached over the wsl.exe bridge.
|
|
*/
|
|
export type RuntimeEnvironmentHost<T> =
|
|
| { kind: 'network'; environment: T }
|
|
| { kind: 'wsl'; environment: T; deployment: OrcadWslDeploymentLink }
|
|
|
|
export function classifyRuntimeEnvironmentHost<
|
|
T extends { orcadDeployment?: OrcadDeploymentLink | null }
|
|
>(environment: T): RuntimeEnvironmentHost<T> {
|
|
const deployment = environment.orcadDeployment
|
|
if (!deployment) {
|
|
return { kind: 'network', environment }
|
|
}
|
|
switch (deployment.kind) {
|
|
// Why undefined: SSH deployment links are persisted without their kind.
|
|
case undefined:
|
|
case 'ssh':
|
|
return { kind: 'network', environment }
|
|
case 'wsl':
|
|
return { kind: 'wsl', environment, deployment }
|
|
}
|
|
}
|