142 lines
4.5 KiB
Text
142 lines
4.5 KiB
Text
|
|
let lifecycle_mode_def = std.contract.custom (fun _label => fun value =>
|
||
|
|
let valid = ["persistent", "ephemeral", "rotating", "cold_storage"] in
|
||
|
|
if std.array.any (fun x => x == value) valid then 'Ok value
|
||
|
|
else 'Error {
|
||
|
|
message = "Invalid lifecycle_mode '%{value}'.\nValid values: persistent | ephemeral | rotating | cold_storage"
|
||
|
|
}
|
||
|
|
) in
|
||
|
|
|
||
|
|
let fleet_node_state_def = std.contract.custom (fun _label => fun value =>
|
||
|
|
let valid = ["provisioning", "idle", "claimed", "rescaling", "draining", "offline"] in
|
||
|
|
if std.array.any (fun x => x == value) valid then 'Ok value
|
||
|
|
else 'Error {
|
||
|
|
message = "Invalid node state '%{value}'.\nValid values: provisioning | idle | claimed | rescaling | draining | offline"
|
||
|
|
}
|
||
|
|
) in
|
||
|
|
|
||
|
|
let provider_kind_def = std.contract.custom (fun _label => fun value =>
|
||
|
|
let valid = ["hcloud", "proxmox", "docker_local"] in
|
||
|
|
if std.array.any (fun x => x == value) valid then 'Ok value
|
||
|
|
else 'Error {
|
||
|
|
message = "Invalid provider.kind '%{value}'.\nValid values: hcloud | proxmox | docker_local"
|
||
|
|
}
|
||
|
|
) in
|
||
|
|
|
||
|
|
let arbitration_def = std.contract.custom (fun _label => fun value =>
|
||
|
|
let valid = ["fifo", "fifo_per_workspace", "priority"] in
|
||
|
|
if std.array.any (fun x => x == value) valid then 'Ok value
|
||
|
|
else 'Error {
|
||
|
|
message = "Invalid arbitration '%{value}'.\nValid values: fifo | fifo_per_workspace | priority"
|
||
|
|
}
|
||
|
|
) in
|
||
|
|
|
||
|
|
let network_method_def = std.contract.custom (fun _label => fun value =>
|
||
|
|
let valid = ["private_network", "wireguard", "public"] in
|
||
|
|
if std.array.any (fun x => x == value) valid then 'Ok value
|
||
|
|
else 'Error {
|
||
|
|
message = "Invalid network method '%{value}'.\nValid values: private_network | wireguard | public"
|
||
|
|
}
|
||
|
|
) in
|
||
|
|
|
||
|
|
let provider_ref_def = {
|
||
|
|
kind | provider_kind_def,
|
||
|
|
account_ref | String,
|
||
|
|
project_hint | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let capacity_spec_def = {
|
||
|
|
min_nodes | Number,
|
||
|
|
max_nodes | Number,
|
||
|
|
idle_tier | String,
|
||
|
|
scale_tiers | Array String,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let tier_pin_def = {
|
||
|
|
tier | String,
|
||
|
|
expires_at | String | optional,
|
||
|
|
reason | String | optional,
|
||
|
|
applied_by | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let lifecycle_policy_def = {
|
||
|
|
mode | lifecycle_mode_def,
|
||
|
|
idle_after_min | Number | default = 30,
|
||
|
|
destroy_after_idle_h | Number | optional,
|
||
|
|
max_lifetime_h | Number | optional,
|
||
|
|
tier_pin | tier_pin_def | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let access_policy_def = {
|
||
|
|
claims_accepted_from | Array String,
|
||
|
|
max_concurrent_claims_per_workspace | { _ : Number } | default = {},
|
||
|
|
priority_order | Array String | optional,
|
||
|
|
arbitration | arbitration_def | default = "fifo_per_workspace",
|
||
|
|
} in
|
||
|
|
|
||
|
|
let network_route_def = {
|
||
|
|
workspace | String,
|
||
|
|
method | network_method_def,
|
||
|
|
network_ref | String | optional,
|
||
|
|
config_ref | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let fleet_network_def = {
|
||
|
|
fleet_subnet | String,
|
||
|
|
reachable_from | Array network_route_def,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let node_capability_def = {
|
||
|
|
name | String,
|
||
|
|
version | String | optional,
|
||
|
|
meta | { _ : Dyn } | default = {},
|
||
|
|
} in
|
||
|
|
|
||
|
|
let registry_ref_def = {
|
||
|
|
name | String,
|
||
|
|
endpoint | String,
|
||
|
|
creds_ref | String,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let fleet_node_def = {
|
||
|
|
id | String,
|
||
|
|
role | String,
|
||
|
|
capabilities | Array node_capability_def,
|
||
|
|
registries | Array registry_ref_def | default = [],
|
||
|
|
current_state | fleet_node_state_def | default = "provisioning",
|
||
|
|
current_tier | String | optional,
|
||
|
|
provider_server_id | String | optional,
|
||
|
|
last_heartbeat_at | String | optional,
|
||
|
|
current_claim_id | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let fleet_def = {
|
||
|
|
id | String,
|
||
|
|
host_workspace | String,
|
||
|
|
purpose | String,
|
||
|
|
payer | String,
|
||
|
|
provider | provider_ref_def,
|
||
|
|
capacity | capacity_spec_def,
|
||
|
|
access_policy | access_policy_def,
|
||
|
|
lifecycle_policy | lifecycle_policy_def,
|
||
|
|
network | fleet_network_def,
|
||
|
|
nodes | Array fleet_node_def | default = [],
|
||
|
|
} in
|
||
|
|
|
||
|
|
{
|
||
|
|
LifecycleMode | not_exported = lifecycle_mode_def,
|
||
|
|
FleetNodeState | not_exported = fleet_node_state_def,
|
||
|
|
ProviderKind | not_exported = provider_kind_def,
|
||
|
|
ArbitrationStrategy | not_exported = arbitration_def,
|
||
|
|
NetworkMethod | not_exported = network_method_def,
|
||
|
|
ProviderRef | not_exported = provider_ref_def,
|
||
|
|
CapacitySpec | not_exported = capacity_spec_def,
|
||
|
|
TierPin | not_exported = tier_pin_def,
|
||
|
|
LifecyclePolicy | not_exported = lifecycle_policy_def,
|
||
|
|
AccessPolicy | not_exported = access_policy_def,
|
||
|
|
NetworkRoute | not_exported = network_route_def,
|
||
|
|
FleetNetwork | not_exported = fleet_network_def,
|
||
|
|
NodeCapability | not_exported = node_capability_def,
|
||
|
|
FleetNode | not_exported = fleet_node_def,
|
||
|
|
Fleet | not_exported = fleet_def,
|
||
|
|
}
|