feat: 完整游戏运维功能
This commit is contained in:
@@ -12,6 +12,52 @@ type RunDistributionGenerateRequest struct {
|
||||
IdempotencyKey string `json:"idempotencyKey,omitempty"`
|
||||
}
|
||||
|
||||
type RuntimeBindingUpdateRequest struct {
|
||||
ProfileKey string `json:"profileKey"`
|
||||
Bindings map[string]string `json:"bindings,omitempty"`
|
||||
}
|
||||
|
||||
type RuntimeBindingKeyResponse struct {
|
||||
Key string `json:"key"`
|
||||
Required bool `json:"required"`
|
||||
Configured bool `json:"configured"`
|
||||
Secret bool `json:"secret"`
|
||||
}
|
||||
|
||||
type RuntimeBindingResponse struct {
|
||||
ServerInstanceID string `json:"serverInstanceId"`
|
||||
PluginID string `json:"pluginId"`
|
||||
ProfileKey string `json:"profileKey,omitempty"`
|
||||
Mode string `json:"mode,omitempty"`
|
||||
Configured bool `json:"configured"`
|
||||
Keys []RuntimeBindingKeyResponse `json:"keys"`
|
||||
MissingKeys []string `json:"missingKeys"`
|
||||
Status domain.RuntimeBindingStatus `json:"status"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt,omitempty"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
||||
}
|
||||
|
||||
func (request RuntimeBindingUpdateRequest) ToDomain() domain.RuntimeBindingUpdate {
|
||||
return domain.RuntimeBindingUpdate{ProfileKey: request.ProfileKey, Bindings: domain.CopyStringMap(request.Bindings)}
|
||||
}
|
||||
|
||||
func RuntimeBindingFromDomain(view domain.RuntimeBindingView) RuntimeBindingResponse {
|
||||
view = domain.CopyRuntimeBindingView(view)
|
||||
keys := make([]RuntimeBindingKeyResponse, len(view.Keys))
|
||||
for i, key := range view.Keys {
|
||||
keys[i] = RuntimeBindingKeyResponse{Key: key.Key, Required: key.Required, Configured: key.Configured, Secret: key.Secret}
|
||||
}
|
||||
if keys == nil {
|
||||
keys = []RuntimeBindingKeyResponse{}
|
||||
}
|
||||
missing := view.MissingKeys
|
||||
if missing == nil {
|
||||
missing = []string{}
|
||||
}
|
||||
return RuntimeBindingResponse{ServerInstanceID: view.ServerInstanceID, PluginID: view.PluginID, ProfileKey: view.ProfileKey, Mode: view.Mode, Configured: view.Configured, Keys: keys, MissingKeys: missing, Status: view.Status, Reason: view.Reason, CreatedAt: view.CreatedAt, UpdatedAt: view.UpdatedAt}
|
||||
}
|
||||
|
||||
type RunUpdateRequest struct {
|
||||
ArtifactID string `json:"artifactId"`
|
||||
Checksum string `json:"checksum,omitempty"`
|
||||
@@ -21,6 +67,7 @@ type RunUpdateRequest struct {
|
||||
type DependencyJobRequest struct {
|
||||
ProbeKey string `json:"probeKey"`
|
||||
InstallPlanKey string `json:"installPlanKey,omitempty"`
|
||||
PlanDigest string `json:"planDigest,omitempty"`
|
||||
TargetOS string `json:"targetOs,omitempty"`
|
||||
TargetArch string `json:"targetArch,omitempty"`
|
||||
IdempotencyKey string `json:"idempotencyKey,omitempty"`
|
||||
@@ -103,6 +150,7 @@ type ClientManagerDistributionResponse struct {
|
||||
ServerInstanceID string `json:"serverInstanceId"`
|
||||
PluginID string `json:"pluginId"`
|
||||
ProfileKey string `json:"profileKey"`
|
||||
Version string `json:"version,omitempty"`
|
||||
TargetOS string `json:"targetOs"`
|
||||
TargetArch string `json:"targetArch"`
|
||||
RepositoryURL string `json:"repositoryUrl"`
|
||||
@@ -127,16 +175,62 @@ type DependencyStatusResponse struct {
|
||||
State string `json:"state"`
|
||||
Required bool `json:"required"`
|
||||
InstallPlanKey string `json:"installPlanKey,omitempty"`
|
||||
PlanDigest string `json:"planDigest,omitempty"`
|
||||
JobID string `json:"jobId,omitempty"`
|
||||
Evidence string `json:"evidence,omitempty"`
|
||||
CompletedSteps int `json:"completedSteps,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
CheckedAt time.Time `json:"checkedAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type DependencyProbeResponse struct {
|
||||
Key string `json:"key"`
|
||||
Kind string `json:"kind"`
|
||||
Required bool `json:"required"`
|
||||
MinimumVersion string `json:"minimumVersion,omitempty"`
|
||||
State string `json:"state"`
|
||||
Evidence string `json:"evidence,omitempty"`
|
||||
InstallPlanKey string `json:"installPlanKey,omitempty"`
|
||||
}
|
||||
|
||||
type DependencyPlanStepResponse struct {
|
||||
Type string `json:"type"`
|
||||
TargetKey string `json:"targetKey"`
|
||||
PackageManager string `json:"packageManager,omitempty"`
|
||||
PackageName string `json:"packageName,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
DownloadHost string `json:"downloadHost,omitempty"`
|
||||
SizeBytes int64 `json:"sizeBytes,omitempty"`
|
||||
}
|
||||
|
||||
type DependencyPlanResponse struct {
|
||||
Key string `json:"key"`
|
||||
Title string `json:"title"`
|
||||
TargetOS string `json:"targetOs"`
|
||||
TargetArch string `json:"targetArch"`
|
||||
Digest string `json:"digest"`
|
||||
Steps []DependencyPlanStepResponse `json:"steps"`
|
||||
}
|
||||
|
||||
type DependencyCatalogResponse struct {
|
||||
ServerInstanceID string `json:"serverInstanceId"`
|
||||
PluginID string `json:"pluginId"`
|
||||
PluginVersion string `json:"pluginVersion"`
|
||||
ProfileKey string `json:"profileKey"`
|
||||
TargetOS string `json:"targetOs"`
|
||||
TargetArch string `json:"targetArch"`
|
||||
Probes []DependencyProbeResponse `json:"probes"`
|
||||
Plans []DependencyPlanResponse `json:"plans"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type ClientManagerBuildJobResponse struct {
|
||||
ID string `json:"id"`
|
||||
ServerInstanceID string `json:"serverInstanceId"`
|
||||
PluginID string `json:"pluginId"`
|
||||
ProfileKey string `json:"profileKey"`
|
||||
Version string `json:"version,omitempty"`
|
||||
TargetOS string `json:"targetOs"`
|
||||
TargetArch string `json:"targetArch"`
|
||||
RepositoryURL string `json:"repositoryUrl"`
|
||||
@@ -156,13 +250,25 @@ type RunUpdateJobResponse struct {
|
||||
RunEndpointID string `json:"runEndpointId"`
|
||||
ArtifactID string `json:"artifactId"`
|
||||
Checksum string `json:"checksum"`
|
||||
TargetOS string `json:"targetOs"`
|
||||
TargetArch string `json:"targetArch"`
|
||||
TargetRelease string `json:"targetRelease,omitempty"`
|
||||
PreviousVersion string `json:"previousVersion,omitempty"`
|
||||
JobID string `json:"jobId,omitempty"`
|
||||
IdempotencyKey string `json:"idempotencyKey,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Phase string `json:"phase"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Rollback bool `json:"rollback"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type RunUpdateJobListResponse struct {
|
||||
Items []RunUpdateJobResponse `json:"items"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
func (request RunDistributionGenerateRequest) ToDomain(serverInstanceID string) domain.RunDistributionGenerateRequest {
|
||||
return domain.RunDistributionGenerateRequest{
|
||||
ServerInstanceID: serverInstanceID,
|
||||
@@ -186,6 +292,7 @@ func (request DependencyJobRequest) ToDomain(serverInstanceID string, install bo
|
||||
ServerInstanceID: serverInstanceID,
|
||||
ProbeKey: request.ProbeKey,
|
||||
InstallPlanKey: request.InstallPlanKey,
|
||||
PlanDigest: request.PlanDigest,
|
||||
TargetOS: request.TargetOS,
|
||||
TargetArch: request.TargetArch,
|
||||
IdempotencyKey: request.IdempotencyKey,
|
||||
@@ -280,6 +387,7 @@ func ClientManagerDistributionFromDomain(distribution domain.ClientManagerDistri
|
||||
ServerInstanceID: distribution.ServerInstanceID,
|
||||
PluginID: distribution.PluginID,
|
||||
ProfileKey: distribution.ProfileKey,
|
||||
Version: distribution.Version,
|
||||
TargetOS: distribution.TargetOS,
|
||||
TargetArch: distribution.TargetArch,
|
||||
RepositoryURL: distribution.RepositoryURL,
|
||||
@@ -306,18 +414,40 @@ func DependencyStatusFromDomain(status domain.DependencyStatus) DependencyStatus
|
||||
State: string(status.State),
|
||||
Required: status.Required,
|
||||
InstallPlanKey: status.InstallPlanKey,
|
||||
PlanDigest: status.PlanDigest,
|
||||
JobID: status.JobID,
|
||||
Evidence: status.Evidence,
|
||||
CompletedSteps: status.CompletedSteps,
|
||||
Message: status.Message,
|
||||
CheckedAt: status.CheckedAt,
|
||||
UpdatedAt: status.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func DependencyCatalogFromDomain(catalog domain.DependencyCatalog) DependencyCatalogResponse {
|
||||
catalog = domain.CopyDependencyCatalog(catalog)
|
||||
probes := make([]DependencyProbeResponse, len(catalog.Probes))
|
||||
for i, probe := range catalog.Probes {
|
||||
probes[i] = DependencyProbeResponse{Key: probe.Key, Kind: probe.Kind, Required: probe.Required, MinimumVersion: probe.MinimumVersion, State: string(probe.State), Evidence: probe.Evidence, InstallPlanKey: probe.InstallPlanKey}
|
||||
}
|
||||
plans := make([]DependencyPlanResponse, len(catalog.Plans))
|
||||
for i, plan := range catalog.Plans {
|
||||
steps := make([]DependencyPlanStepResponse, len(plan.Steps))
|
||||
for j, step := range plan.Steps {
|
||||
steps[j] = DependencyPlanStepResponse{Type: step.Type, TargetKey: step.TargetKey, PackageManager: step.PackageManager, PackageName: step.PackageName, Version: step.Version, DownloadHost: step.DownloadHost, SizeBytes: step.SizeBytes}
|
||||
}
|
||||
plans[i] = DependencyPlanResponse{Key: plan.Key, Title: plan.Title, TargetOS: plan.TargetOS, TargetArch: plan.TargetArch, Digest: plan.Digest, Steps: steps}
|
||||
}
|
||||
return DependencyCatalogResponse{ServerInstanceID: catalog.ServerInstanceID, PluginID: catalog.PluginID, PluginVersion: catalog.PluginVersion, ProfileKey: catalog.ProfileKey, TargetOS: catalog.TargetOS, TargetArch: catalog.TargetArch, Probes: probes, Plans: plans, UpdatedAt: catalog.UpdatedAt}
|
||||
}
|
||||
|
||||
func ClientManagerBuildJobFromDomain(job domain.ClientManagerBuildJob) ClientManagerBuildJobResponse {
|
||||
return ClientManagerBuildJobResponse{
|
||||
ID: job.ID,
|
||||
ServerInstanceID: job.ServerInstanceID,
|
||||
PluginID: job.PluginID,
|
||||
ProfileKey: job.ProfileKey,
|
||||
Version: job.Version,
|
||||
TargetOS: job.TargetOS,
|
||||
TargetArch: job.TargetArch,
|
||||
RepositoryURL: job.RepositoryURL,
|
||||
@@ -339,10 +469,25 @@ func RunUpdateJobFromDomain(job domain.RunUpdateJob) RunUpdateJobResponse {
|
||||
RunEndpointID: job.RunEndpointID,
|
||||
ArtifactID: job.ArtifactID,
|
||||
Checksum: job.Checksum,
|
||||
TargetOS: job.TargetOS,
|
||||
TargetArch: job.TargetArch,
|
||||
TargetRelease: job.TargetRelease,
|
||||
PreviousVersion: job.PreviousVersion,
|
||||
JobID: job.JobID,
|
||||
IdempotencyKey: job.IdempotencyKey,
|
||||
Status: string(job.Status),
|
||||
Phase: string(job.Phase),
|
||||
Message: job.Message,
|
||||
Rollback: job.Rollback,
|
||||
CreatedAt: job.CreatedAt,
|
||||
UpdatedAt: job.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func RunUpdateJobListFromDomain(jobs []domain.RunUpdateJob) RunUpdateJobListResponse {
|
||||
items := make([]RunUpdateJobResponse, len(jobs))
|
||||
for i, job := range jobs {
|
||||
items[i] = RunUpdateJobFromDomain(job)
|
||||
}
|
||||
return RunUpdateJobListResponse{Items: items, Count: len(items)}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user