109 lines
3.4 KiB
Text
109 lines
3.4 KiB
Text
|
|
let claim_state_def = std.contract.custom (fun _label => fun value =>
|
||
|
|
let valid = ["requested", "granted", "active", "released", "rejected", "expired"] in
|
||
|
|
if std.array.any (fun x => x == value) valid then 'Ok value
|
||
|
|
else 'Error {
|
||
|
|
message = "Invalid claim state '%{value}'.\nValid values: requested | granted | active | released | rejected | expired"
|
||
|
|
}
|
||
|
|
) in
|
||
|
|
|
||
|
|
let outcome_def = std.contract.custom (fun _label => fun value =>
|
||
|
|
let valid = ["completed", "failed", "cancelled", "timeout"] in
|
||
|
|
if std.array.any (fun x => x == value) valid then 'Ok value
|
||
|
|
else 'Error {
|
||
|
|
message = "Invalid outcome '%{value}'.\nValid values: completed | failed | cancelled | timeout"
|
||
|
|
}
|
||
|
|
) in
|
||
|
|
|
||
|
|
let rejection_reason_def = std.contract.custom (fun _label => fun value =>
|
||
|
|
let valid = ["no_capacity", "no_matching_capabilities", "access_denied", "quota_exceeded", "fleet_unavailable"] in
|
||
|
|
if std.array.any (fun x => x == value) valid then 'Ok value
|
||
|
|
else 'Error {
|
||
|
|
message = "Invalid rejection reason '%{value}'.\nValid values: no_capacity | no_matching_capabilities | access_denied | quota_exceeded | fleet_unavailable"
|
||
|
|
}
|
||
|
|
) in
|
||
|
|
|
||
|
|
let capability_requirement_def = {
|
||
|
|
name | String,
|
||
|
|
version_constraint | String | optional,
|
||
|
|
meta_match | { _ : Dyn } | default = {},
|
||
|
|
} in
|
||
|
|
|
||
|
|
let resource_requirement_def = {
|
||
|
|
cpu_min | Number | optional,
|
||
|
|
memory_gb_min | Number | optional,
|
||
|
|
disk_gb_min | Number | optional,
|
||
|
|
preferred_tier | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let target_endpoint_def = {
|
||
|
|
host | String,
|
||
|
|
ssh_user | String | default = "root",
|
||
|
|
ssh_key_ref | String,
|
||
|
|
buildkit_socket | String | optional,
|
||
|
|
private_ip | String | optional,
|
||
|
|
public_ip | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let capability_advertisement_def = {
|
||
|
|
name | String,
|
||
|
|
version | String | optional,
|
||
|
|
meta | { _ : Dyn } | default = {},
|
||
|
|
} in
|
||
|
|
|
||
|
|
let claim_lifecycle_def = {
|
||
|
|
release_on_complete | Bool | default = true,
|
||
|
|
max_duration_min | Number | default = 60,
|
||
|
|
release_subject | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let claim_request_def = {
|
||
|
|
id | String,
|
||
|
|
requesting_workspace | String,
|
||
|
|
fleet_ref | String,
|
||
|
|
required_capabilities | Array capability_requirement_def,
|
||
|
|
resources | resource_requirement_def | default = {},
|
||
|
|
lifecycle | claim_lifecycle_def | default = {},
|
||
|
|
reason | String | optional,
|
||
|
|
requested_at | String,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let claim_grant_def = {
|
||
|
|
id | String,
|
||
|
|
request_id | String,
|
||
|
|
fleet_ref | String,
|
||
|
|
granted_node_id | String,
|
||
|
|
target | target_endpoint_def,
|
||
|
|
advertised_capabilities | Array capability_advertisement_def,
|
||
|
|
granted_at | String,
|
||
|
|
expires_at | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
let claim_release_def = {
|
||
|
|
id | String,
|
||
|
|
grant_id | String,
|
||
|
|
released_at | String,
|
||
|
|
outcome | outcome_def,
|
||
|
|
metrics | { _ : Dyn } | default = {},
|
||
|
|
} in
|
||
|
|
|
||
|
|
let claim_rejection_def = {
|
||
|
|
id | String,
|
||
|
|
request_id | String,
|
||
|
|
rejected_at | String,
|
||
|
|
reason | rejection_reason_def,
|
||
|
|
message | String | optional,
|
||
|
|
} in
|
||
|
|
|
||
|
|
{
|
||
|
|
ClaimState | not_exported = claim_state_def,
|
||
|
|
CapabilityRequirement | not_exported = capability_requirement_def,
|
||
|
|
CapabilityAdvertisement | not_exported = capability_advertisement_def,
|
||
|
|
ResourceRequirement | not_exported = resource_requirement_def,
|
||
|
|
TargetEndpoint | not_exported = target_endpoint_def,
|
||
|
|
ClaimLifecycle | not_exported = claim_lifecycle_def,
|
||
|
|
ClaimRequest | not_exported = claim_request_def,
|
||
|
|
ClaimGrant | not_exported = claim_grant_def,
|
||
|
|
ClaimRelease | not_exported = claim_release_def,
|
||
|
|
ClaimRejection | not_exported = claim_rejection_def,
|
||
|
|
}
|