492 lines
14 KiB
Go
492 lines
14 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
type RunJobProgressReport struct {
|
|
Percent int
|
|
Phase string
|
|
Message string
|
|
}
|
|
|
|
type RunJobAssignment struct {
|
|
JobID string
|
|
ServerInstanceID string
|
|
RunEndpointID string
|
|
Capability string
|
|
TargetKey string
|
|
InputRef string
|
|
IdempotencyKey string
|
|
State JobState
|
|
Progress RunJobProgressReport
|
|
ResultRef string
|
|
ExecutionInput JobExecutionInput
|
|
LeaseToken string
|
|
Attempt int
|
|
FencingToken uint64
|
|
MaxAttempts int
|
|
AckDeadlineAt time.Time
|
|
LeaseExpiresAt time.Time
|
|
NextAttemptAt time.Time
|
|
ProgressSequence uint64
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type RunJobClaim struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
Capabilities []string
|
|
Capacity RunCapacity
|
|
WaitSeconds int
|
|
}
|
|
|
|
type RunJobClaimResult struct {
|
|
Accepted bool
|
|
RunEndpointID string
|
|
HasJob bool
|
|
Job *RunJobAssignment
|
|
NextPollSeconds int
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type RunJobAck struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
Message string
|
|
}
|
|
|
|
type RunJobAckResult struct {
|
|
Accepted bool
|
|
Job RunJobAssignment
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type RunJobProgress struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
Progress RunJobProgressReport
|
|
Sequence uint64
|
|
}
|
|
|
|
type RunJobProgressResult struct {
|
|
Accepted bool
|
|
Job RunJobAssignment
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type RunJobResult struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
State JobState
|
|
Progress RunJobProgressReport
|
|
ResultRef string
|
|
Message string
|
|
ErrorCode string
|
|
Retryable bool
|
|
ExecutionResult JobExecutionResult
|
|
}
|
|
|
|
type RunJobResultResult struct {
|
|
Accepted bool
|
|
Job RunJobAssignment
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type DistributionBuildInputRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type DistributionBuildInput struct {
|
|
JobID string
|
|
ComponentKind DistributionComponentKind
|
|
ServerInstanceID string
|
|
PluginID string
|
|
RunEndpointID string
|
|
ProfileKey string
|
|
TargetOS string
|
|
TargetArch string
|
|
TargetRelease string
|
|
PlatformURL string
|
|
PackageFormat string
|
|
RepositoryURL string
|
|
SourceRevision string
|
|
ArtifactID string
|
|
OutputFilename string
|
|
SecretRef string
|
|
KeyGeneration int
|
|
AuthKey string
|
|
WorkspaceSeed string
|
|
AutonomousLifecycle *RunAutonomousLifecyclePlan
|
|
}
|
|
|
|
type RunAutonomousLifecyclePlan struct {
|
|
SchemaVersion string `json:"schemaVersion"`
|
|
ServerInstanceID string `json:"serverInstanceId"`
|
|
PluginID string `json:"pluginId"`
|
|
PluginVersion string `json:"pluginVersion"`
|
|
RunEndpointID string `json:"runEndpointId"`
|
|
ProfileKey string `json:"profileKey,omitempty"`
|
|
TargetOS string `json:"targetOs"`
|
|
TargetArch string `json:"targetArch"`
|
|
TargetRelease string `json:"targetRelease"`
|
|
DeploymentRevision int `json:"deploymentRevision,omitempty"`
|
|
Bootstrap *RunAutonomousLifecycleAction `json:"bootstrap,omitempty"`
|
|
Actions []RunAutonomousLifecycleAction `json:"actions,omitempty"`
|
|
DependencyProbes []RunAutonomousDependencyProbe `json:"dependencyProbes,omitempty"`
|
|
InstallPlans []RunAutonomousInstallPlan `json:"installPlans,omitempty"`
|
|
LogSources []RunAutonomousLogSource `json:"logSources,omitempty"`
|
|
DLLExtensions []RunAutonomousDLLExtension `json:"dllExtensions,omitempty"`
|
|
RuntimeBindings map[string]string `json:"runtimeBindings,omitempty"`
|
|
Deployment *RunAutonomousDeployment `json:"deployment,omitempty"`
|
|
}
|
|
|
|
type RunAutonomousLifecycleAction struct {
|
|
Action ServerLifecycleAction `json:"action"`
|
|
Operation string `json:"operation"`
|
|
Capability string `json:"capability"`
|
|
TargetKey string `json:"targetKey"`
|
|
}
|
|
|
|
type RunAutonomousDependencyProbe struct {
|
|
Key string `json:"key"`
|
|
Kind string `json:"kind"`
|
|
TargetKey string `json:"targetKey"`
|
|
Required bool `json:"required,omitempty"`
|
|
MinimumVersion string `json:"minimumVersion,omitempty"`
|
|
Platforms []string `json:"platforms,omitempty"`
|
|
}
|
|
|
|
type RunAutonomousInstallPlan struct {
|
|
Key string `json:"key"`
|
|
Title string `json:"title,omitempty"`
|
|
Platforms []string `json:"platforms,omitempty"`
|
|
Steps []RunAutonomousInstallStep `json:"steps,omitempty"`
|
|
}
|
|
|
|
type RunAutonomousInstallStep struct {
|
|
Type string `json:"type"`
|
|
TargetKey string `json:"targetKey"`
|
|
PackageManager string `json:"packageManager,omitempty"`
|
|
PackageName string `json:"packageName,omitempty"`
|
|
Version string `json:"version,omitempty"`
|
|
DownloadRef string `json:"downloadRef,omitempty"`
|
|
Checksum string `json:"checksum,omitempty"`
|
|
}
|
|
|
|
type RunAutonomousLogSource struct {
|
|
Key string `json:"key"`
|
|
Kind string `json:"kind"`
|
|
TargetKey string `json:"targetKey"`
|
|
StreamKey string `json:"streamKey,omitempty"`
|
|
CursorKind string `json:"cursorKind,omitempty"`
|
|
RetentionDays int `json:"retentionDays,omitempty"`
|
|
}
|
|
|
|
type RunAutonomousDLLExtension struct {
|
|
Key string `json:"key"`
|
|
Version string `json:"version"`
|
|
ReleaseURL string `json:"releaseUrl"`
|
|
Checksum string `json:"checksum"`
|
|
SizeBytes int64 `json:"sizeBytes,omitempty"`
|
|
TargetKey string `json:"targetKey"`
|
|
ModKey string `json:"modKey"`
|
|
DLLRef string `json:"dllRef"`
|
|
SCUMExecutableChecksum string `json:"scumExecutableChecksum,omitempty"`
|
|
UE4SSABI string `json:"ue4ssAbi,omitempty"`
|
|
RCONPort int `json:"rconPort,omitempty"`
|
|
}
|
|
|
|
type RunAutonomousDeployment struct {
|
|
SchemaVersion string `json:"schemaVersion"`
|
|
Mode ServerDeploymentMode `json:"mode"`
|
|
ProfileKey string `json:"profileKey,omitempty"`
|
|
RuntimeBindings map[string]string `json:"runtimeBindings,omitempty"`
|
|
CreateInputs map[string]string `json:"createInputs,omitempty"`
|
|
ServerRoot string `json:"serverRoot,omitempty"`
|
|
WorkingDirectory string `json:"workingDirectory,omitempty"`
|
|
InstallCommand string `json:"installCommand,omitempty"`
|
|
StartCommand string `json:"startCommand,omitempty"`
|
|
StopCommand string `json:"stopCommand,omitempty"`
|
|
StatusCommand string `json:"statusCommand,omitempty"`
|
|
Shell ServerCommandShell `json:"shell,omitempty"`
|
|
Revision int `json:"revision,omitempty"`
|
|
}
|
|
|
|
type DependencyExecutionInputRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type DependencyExecutionInput struct {
|
|
JobID string
|
|
ServerInstanceID string
|
|
RunEndpointID string
|
|
PluginID string
|
|
PluginVersion string
|
|
ProfileKey string
|
|
TargetOS string
|
|
TargetArch string
|
|
PlanDigest string
|
|
Probe RuntimeDependencyProbe
|
|
Plan RuntimeInstallPlan
|
|
Bindings map[string]string
|
|
}
|
|
|
|
type SourceRCONExecutionInputRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
// SourceRCONExecutionInput is sent only to the active signed Run lease. Its
|
|
// Command value must never be persisted in a Job, assignment, or journal.
|
|
type SourceRCONExecutionInput struct {
|
|
JobID string
|
|
ServerInstanceID string
|
|
RunEndpointID string
|
|
Command string
|
|
}
|
|
|
|
type RunUpdateInputRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type RunUpdateInput struct {
|
|
JobID string
|
|
ServerInstanceID string
|
|
RunEndpointID string
|
|
ArtifactID string
|
|
Checksum string
|
|
SizeBytes int64
|
|
TargetOS string
|
|
TargetArch string
|
|
PackageFormat string
|
|
ExecutableName string
|
|
TargetRelease string
|
|
ChunkSizeBytes int
|
|
}
|
|
|
|
type RunUpdateChunkRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
Offset int64
|
|
Length int
|
|
}
|
|
|
|
type RunUpdateChunk struct {
|
|
JobID string
|
|
ArtifactID string
|
|
Offset int64
|
|
TotalBytes int64
|
|
Checksum string
|
|
Payload []byte
|
|
Complete bool
|
|
}
|
|
|
|
type RunUpdateHealthReport struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
Outcome string
|
|
Version string
|
|
}
|
|
|
|
type RunUpdateHealthResult struct {
|
|
Accepted bool
|
|
JobID string
|
|
Phase RunUpdatePhase
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type DependencyExecutionEvidence struct {
|
|
ProbeKey string `json:"probeKey"`
|
|
PlanKey string `json:"planKey,omitempty"`
|
|
PlanDigest string `json:"planDigest"`
|
|
State string `json:"state"`
|
|
Evidence string `json:"evidence,omitempty"`
|
|
CompletedSteps int `json:"completedSteps,omitempty"`
|
|
}
|
|
|
|
type RunUpdateExecutionEvidence struct {
|
|
TargetRelease string `json:"targetRelease"`
|
|
Phase string `json:"phase"`
|
|
}
|
|
|
|
type RunJobCancelRequest struct {
|
|
JobID string
|
|
Reason string
|
|
}
|
|
|
|
type RunJobCancelRequestResult struct {
|
|
Accepted bool
|
|
JobID string
|
|
Reason string
|
|
RequestedAt time.Time
|
|
CompletedAt time.Time
|
|
State JobState
|
|
}
|
|
|
|
type RunJobCancelPoll struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type RunJobCancelPollResult struct {
|
|
Accepted bool
|
|
RunEndpointID string
|
|
HasCancel bool
|
|
JobID string
|
|
Reason string
|
|
RequestedAt time.Time
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type RunJobReconcileEntry struct {
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type RunJobReconcile struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
ActiveJobs []RunJobReconcileEntry
|
|
}
|
|
|
|
type RunJobReconcileResult struct {
|
|
Accepted bool
|
|
RunEndpointID string
|
|
ConfirmedJobs []RunJobAssignment
|
|
DiscardJobIDs []string
|
|
ServerTime time.Time
|
|
}
|
|
|
|
func CopyRunJobAssignment(assignment RunJobAssignment) RunJobAssignment {
|
|
assignment.ExecutionInput.Inputs = CopyStringMap(assignment.ExecutionInput.Inputs)
|
|
assignment.ExecutionInput.LogSource = CopyRuntimeLogSourcePtr(assignment.ExecutionInput.LogSource)
|
|
assignment.ExecutionInput.LogSources = CopyRuntimeLogSources(assignment.ExecutionInput.LogSources)
|
|
assignment.ExecutionInput.DLLExtensions = append([]RuntimeDLLExtensionPlan(nil), assignment.ExecutionInput.DLLExtensions...)
|
|
assignment.ExecutionInput.SourceRCON = CopyRuntimeSourceRCONPlan(assignment.ExecutionInput.SourceRCON)
|
|
return assignment
|
|
}
|
|
|
|
func CopyRunJobAssignmentPtr(assignment *RunJobAssignment) *RunJobAssignment {
|
|
if assignment == nil {
|
|
return nil
|
|
}
|
|
copy := CopyRunJobAssignment(*assignment)
|
|
return ©
|
|
}
|
|
|
|
func CopyRunJobClaim(claim RunJobClaim) RunJobClaim {
|
|
claim.Capabilities = CopyStringSlice(claim.Capabilities)
|
|
return claim
|
|
}
|
|
|
|
func CopyRunJobClaimResult(result RunJobClaimResult) RunJobClaimResult {
|
|
result.Job = CopyRunJobAssignmentPtr(result.Job)
|
|
return result
|
|
}
|
|
|
|
func CopyRunJobReconcile(reconcile RunJobReconcile) RunJobReconcile {
|
|
if reconcile.ActiveJobs != nil {
|
|
reconcile.ActiveJobs = append([]RunJobReconcileEntry(nil), reconcile.ActiveJobs...)
|
|
}
|
|
return reconcile
|
|
}
|
|
|
|
func CopyRunJobReconcileResult(result RunJobReconcileResult) RunJobReconcileResult {
|
|
result.ConfirmedJobs = CopyRunJobAssignments(result.ConfirmedJobs)
|
|
result.DiscardJobIDs = CopyStringSlice(result.DiscardJobIDs)
|
|
return result
|
|
}
|
|
|
|
func CopyRunJobAssignments(assignments []RunJobAssignment) []RunJobAssignment {
|
|
if assignments == nil {
|
|
return nil
|
|
}
|
|
out := make([]RunJobAssignment, len(assignments))
|
|
for index, assignment := range assignments {
|
|
out[index] = CopyRunJobAssignment(assignment)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func CopyDependencyExecutionInput(input DependencyExecutionInput) DependencyExecutionInput {
|
|
input.Probe.Platforms = CopyStringSlice(input.Probe.Platforms)
|
|
input.Plan.Platforms = CopyStringSlice(input.Plan.Platforms)
|
|
input.Plan.Steps = append([]RuntimeInstallStep(nil), input.Plan.Steps...)
|
|
input.Bindings = CopyStringMap(input.Bindings)
|
|
return input
|
|
}
|
|
|
|
func CopyRunAutonomousLifecyclePlanPtr(plan *RunAutonomousLifecyclePlan) *RunAutonomousLifecyclePlan {
|
|
if plan == nil {
|
|
return nil
|
|
}
|
|
copy := *plan
|
|
if plan.Bootstrap != nil {
|
|
bootstrap := *plan.Bootstrap
|
|
copy.Bootstrap = &bootstrap
|
|
}
|
|
copy.Actions = append([]RunAutonomousLifecycleAction(nil), plan.Actions...)
|
|
copy.DependencyProbes = append([]RunAutonomousDependencyProbe(nil), plan.DependencyProbes...)
|
|
for i := range copy.DependencyProbes {
|
|
copy.DependencyProbes[i].Platforms = CopyStringSlice(plan.DependencyProbes[i].Platforms)
|
|
}
|
|
copy.InstallPlans = append([]RunAutonomousInstallPlan(nil), plan.InstallPlans...)
|
|
for i := range copy.InstallPlans {
|
|
copy.InstallPlans[i].Platforms = CopyStringSlice(plan.InstallPlans[i].Platforms)
|
|
copy.InstallPlans[i].Steps = append([]RunAutonomousInstallStep(nil), plan.InstallPlans[i].Steps...)
|
|
}
|
|
copy.LogSources = append([]RunAutonomousLogSource(nil), plan.LogSources...)
|
|
copy.DLLExtensions = append([]RunAutonomousDLLExtension(nil), plan.DLLExtensions...)
|
|
copy.RuntimeBindings = CopyStringMap(plan.RuntimeBindings)
|
|
if plan.Deployment != nil {
|
|
deployment := *plan.Deployment
|
|
deployment.RuntimeBindings = CopyStringMap(plan.Deployment.RuntimeBindings)
|
|
deployment.CreateInputs = CopyStringMap(plan.Deployment.CreateInputs)
|
|
copy.Deployment = &deployment
|
|
}
|
|
return ©
|
|
}
|
|
|
|
func CopySourceRCONExecutionInput(input SourceRCONExecutionInput) SourceRCONExecutionInput {
|
|
return input
|
|
}
|
|
|
|
func CopyRunUpdateChunk(chunk RunUpdateChunk) RunUpdateChunk {
|
|
chunk.Payload = append([]byte(nil), chunk.Payload...)
|
|
return chunk
|
|
}
|