Complete SCUM controlled deployment lifecycle

This commit is contained in:
npc0-hue
2026-07-25 10:13:53 +08:00
parent 6cfd929f7f
commit 15789e15b4
28 changed files with 1349 additions and 123 deletions
+159 -24
View File
@@ -521,11 +521,52 @@ type RuntimeConfigTemplate struct {
OutputRef string
}
// RuntimeServerConfigMapping maps one safe plugin create field to a logical
// game configuration key. Paths and file syntax remain Run-owned.
type RuntimeServerConfigMapping struct {
FieldKey string
ConfigKey string
ValueType string
Required bool
}
type RuntimeServerDiscoveryMarker struct {
Key string
Kind string
TargetKey string
Expected string
Required bool
}
type RuntimeServerVerificationCheck struct {
Key string
Kind string
TargetKey string
Required bool
}
// RuntimeServerDeploymentProfile is a frozen, game-specific deployment
// template. It contains logical references only; Run resolves them locally.
type RuntimeServerDeploymentProfile struct {
Key string
Version string
SupportedTargets []RuntimeTarget
SteamAppID string
ExecutableKey string
InstallRootKey string
ConfigKey string
ConfigFormat string
ConfigMappings []RuntimeServerConfigMapping
DiscoveryMarkers []RuntimeServerDiscoveryMarker
VerificationChecks []RuntimeServerVerificationCheck
}
type GamePluginRuntimeProfiles struct {
Discovery []RuntimeDiscoveryProbe
LifecycleProfiles []RuntimeLifecycleProfile
DependencyProbes []RuntimeDependencyProbe
InstallPlans []RuntimeInstallPlan
ServerDeployments []RuntimeServerDeploymentProfile
LogSources []RuntimeLogSource
LogEvents []RuntimeLogEvent
TransportProfiles []RuntimeTransportProfile
@@ -694,7 +735,24 @@ type ServerInstance struct {
UpdatedAt time.Time
// Deployment stores operator-supplied deployment inputs. Its protected path
// and command values are never included in normal platform read projections.
Deployment ServerDeploymentDefinition
Deployment ServerDeploymentDefinition
DeploymentProjection ServerDeploymentProjection
}
type ServerDeploymentProjection struct {
State string
Operation string
TemplateKey string
TemplateVersion string
PreflightState string
DiscoveryState string
MappingState string
VerificationState string
DiscoveredFacts map[string]string
MappingResults map[string]string
VerificationResults map[string]string
FailureCode string
UpdatedAt time.Time
}
type ServerInstanceUpdate struct {
@@ -803,6 +861,7 @@ type ServerDeploymentView struct {
Shell ServerCommandShell
Revision int
UpdatedAt time.Time
Projection ServerDeploymentProjection
}
type ConfigDiffLine struct {
@@ -914,6 +973,7 @@ const (
// JobCapabilityDeploymentPlan gates Run implementations that understand
// protected deployment definitions, absolute paths, and custom commands.
JobCapabilityDeploymentPlan = "deployment.plan.v1"
JobCapabilitySCUMDeploymentPlan = "deployment.scum.v1"
JobCapabilityDeploymentShellPosix = "deployment.shell.posix-sh"
JobCapabilityDeploymentShellPowerShell = "deployment.shell.powershell"
JobCapabilityDeploymentShellCmd = "deployment.shell.cmd"
@@ -944,33 +1004,64 @@ type JobRetryPolicy struct {
}
type JobExecutionInput struct {
WorkspaceScope string
Content string
ExpectedVersion int
ExpectedChecksum string
MaxReadBytes int
RemoteAdapterKey string
RemoteAdapterKind string
TimeoutSeconds int
WorkspaceScope string
Content string
ExpectedVersion int
ExpectedChecksum string
MaxReadBytes int
RemoteAdapterKey string
RemoteAdapterKind string
TimeoutSeconds int
PluginID string
LifecycleOperation string
TargetVersion string
Inputs map[string]string
DLLExtensions []RuntimeDLLExtensionPlan
SourceRCON *RuntimeSourceRCONPlan
Deployment *ServerDeploymentDefinition
ServerDeploymentPlan *ServerDeploymentPlan
}
type ServerDeploymentPlan struct {
SchemaVersion string
Operation string
PluginID string
LifecycleOperation string
TargetVersion string
Inputs map[string]string
DLLExtensions []RuntimeDLLExtensionPlan
SourceRCON *RuntimeSourceRCONPlan
Deployment *ServerDeploymentDefinition
TemplateKey string
TemplateVersion string
SteamAppID string
ExecutableKey string
InstallRootKey string
ConfigKey string
ConfigFormat string
ConfigMappings []RuntimeServerConfigMapping
DiscoveryMarkers []RuntimeServerDiscoveryMarker
VerificationChecks []RuntimeServerVerificationCheck
}
type ServerDeploymentEvidence struct {
TemplateKey string
TemplateVersion string
PreflightState string
DiscoveryState string
MappingState string
VerificationState string
DiscoveredFacts map[string]string
MappingResults map[string]string
VerificationResults map[string]string
FailureCode string
}
type JobExecutionResult struct {
Kind string
ProcessState string
ExitClassification string
ExitCode int
Version int
Checksum string
SizeBytes int64
AuditSummary string
Content string
Kind string
ProcessState string
ExitClassification string
ExitCode int
Version int
Checksum string
SizeBytes int64
AuditSummary string
Content string
ServerDeploymentEvidence *ServerDeploymentEvidence
}
type Job struct {
@@ -1570,6 +1661,10 @@ func CopyGamePluginRuntimeProfiles(profiles GamePluginRuntimeProfiles) GamePlugi
profiles.InstallPlans[i].Platforms = CopyStringSlice(profiles.InstallPlans[i].Platforms)
profiles.InstallPlans[i].Steps = append([]RuntimeInstallStep(nil), profiles.InstallPlans[i].Steps...)
}
profiles.ServerDeployments = append([]RuntimeServerDeploymentProfile(nil), profiles.ServerDeployments...)
for i := range profiles.ServerDeployments {
profiles.ServerDeployments[i] = CopyRuntimeServerDeploymentProfile(profiles.ServerDeployments[i])
}
profiles.LogSources = append([]RuntimeLogSource(nil), profiles.LogSources...)
profiles.LogEvents = append([]RuntimeLogEvent(nil), profiles.LogEvents...)
profiles.TransportProfiles = append([]RuntimeTransportProfile(nil), profiles.TransportProfiles...)
@@ -1637,9 +1732,47 @@ func CopyPluginBridgeExecuteResponse(response PluginBridgeExecuteResponse) Plugi
func CopyServerInstance(instance ServerInstance) ServerInstance {
instance.AdminUserIDs = CopyStringSlice(instance.AdminUserIDs)
instance.Deployment = CopyServerDeploymentDefinition(instance.Deployment)
instance.DeploymentProjection = CopyServerDeploymentProjection(instance.DeploymentProjection)
return instance
}
func CopyRuntimeServerDeploymentProfile(profile RuntimeServerDeploymentProfile) RuntimeServerDeploymentProfile {
profile.SupportedTargets = append([]RuntimeTarget(nil), profile.SupportedTargets...)
profile.ConfigMappings = append([]RuntimeServerConfigMapping(nil), profile.ConfigMappings...)
profile.DiscoveryMarkers = append([]RuntimeServerDiscoveryMarker(nil), profile.DiscoveryMarkers...)
profile.VerificationChecks = append([]RuntimeServerVerificationCheck(nil), profile.VerificationChecks...)
return profile
}
func CopyServerDeploymentProjection(projection ServerDeploymentProjection) ServerDeploymentProjection {
projection.DiscoveredFacts = CopyStringMap(projection.DiscoveredFacts)
projection.MappingResults = CopyStringMap(projection.MappingResults)
projection.VerificationResults = CopyStringMap(projection.VerificationResults)
return projection
}
func CopyServerDeploymentPlan(plan *ServerDeploymentPlan) *ServerDeploymentPlan {
if plan == nil {
return nil
}
copy := *plan
copy.ConfigMappings = append([]RuntimeServerConfigMapping(nil), plan.ConfigMappings...)
copy.DiscoveryMarkers = append([]RuntimeServerDiscoveryMarker(nil), plan.DiscoveryMarkers...)
copy.VerificationChecks = append([]RuntimeServerVerificationCheck(nil), plan.VerificationChecks...)
return &copy
}
func CopyServerDeploymentEvidence(evidence *ServerDeploymentEvidence) *ServerDeploymentEvidence {
if evidence == nil {
return nil
}
copy := *evidence
copy.DiscoveredFacts = CopyStringMap(evidence.DiscoveredFacts)
copy.MappingResults = CopyStringMap(evidence.MappingResults)
copy.VerificationResults = CopyStringMap(evidence.VerificationResults)
return &copy
}
func CopyServerDeploymentDefinition(definition ServerDeploymentDefinition) ServerDeploymentDefinition {
definition.RuntimeBindings = CopyStringMap(definition.RuntimeBindings)
definition.CreateInputs = CopyStringMap(definition.CreateInputs)
@@ -1713,6 +1846,8 @@ func CopyJob(job Job) Job {
job.ExecutionInput.Inputs = CopyStringMap(job.ExecutionInput.Inputs)
job.ExecutionInput.DLLExtensions = append([]RuntimeDLLExtensionPlan(nil), job.ExecutionInput.DLLExtensions...)
job.ExecutionInput.SourceRCON = CopyRuntimeSourceRCONPlan(job.ExecutionInput.SourceRCON)
job.ExecutionInput.ServerDeploymentPlan = CopyServerDeploymentPlan(job.ExecutionInput.ServerDeploymentPlan)
job.ExecutionResult.ServerDeploymentEvidence = CopyServerDeploymentEvidence(job.ExecutionResult.ServerDeploymentEvidence)
if job.ExecutionInput.Deployment != nil {
copy := CopyServerDeploymentDefinition(*job.ExecutionInput.Deployment)
job.ExecutionInput.Deployment = &copy