494 lines
20 KiB
Go
494 lines
20 KiB
Go
package dto
|
|
|
|
import (
|
|
"time"
|
|
|
|
"browser.local/platform/domain"
|
|
)
|
|
|
|
type RunDistributionGenerateRequest struct {
|
|
TargetOS string `json:"targetOs"`
|
|
TargetArch string `json:"targetArch"`
|
|
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"`
|
|
IdempotencyKey string `json:"idempotencyKey,omitempty"`
|
|
}
|
|
|
|
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"`
|
|
}
|
|
|
|
type LogBackfillRequest struct {
|
|
SourceKey string `json:"sourceKey"`
|
|
CheckpointRef string `json:"checkpointRef,omitempty"`
|
|
Limit int `json:"limit,omitempty"`
|
|
IdempotencyKey string `json:"idempotencyKey,omitempty"`
|
|
}
|
|
|
|
type ClientManagerDownloadRequest struct {
|
|
ProfileKey string `json:"profileKey,omitempty"`
|
|
}
|
|
|
|
type ClientManagerBuildRequest struct {
|
|
ProfileKey string `json:"profileKey"`
|
|
TargetOS string `json:"targetOs"`
|
|
TargetArch string `json:"targetArch"`
|
|
RepositoryURL string `json:"repositoryUrl"`
|
|
SourceRevision string `json:"sourceRevision,omitempty"`
|
|
IdempotencyKey string `json:"idempotencyKey,omitempty"`
|
|
}
|
|
|
|
type ComponentKeyResetRequest struct {
|
|
ComponentKind string `json:"componentKind"`
|
|
ComponentKey string `json:"componentKey,omitempty"`
|
|
}
|
|
|
|
type ComponentKeyResponse struct {
|
|
ID string `json:"id"`
|
|
ServerInstanceID string `json:"serverInstanceId"`
|
|
ComponentKind string `json:"componentKind"`
|
|
ComponentKey string `json:"componentKey,omitempty"`
|
|
SecretRef string `json:"secretRef"`
|
|
Fingerprint string `json:"fingerprint"`
|
|
Generation int `json:"generation"`
|
|
Status string `json:"status"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
ResetAt time.Time `json:"resetAt,omitempty"`
|
|
}
|
|
|
|
type ServerRuntimeActionResponse struct {
|
|
Key string `json:"key"`
|
|
Label string `json:"label"`
|
|
Available bool `json:"available"`
|
|
Reason string `json:"reason,omitempty"`
|
|
}
|
|
|
|
type ServerRuntimeActionsResponse struct {
|
|
ServerInstanceID string `json:"serverInstanceId"`
|
|
PluginID string `json:"pluginId"`
|
|
RunEndpointID string `json:"runEndpointId"`
|
|
RunStatus string `json:"runStatus"`
|
|
Actions []ServerRuntimeActionResponse `json:"actions"`
|
|
}
|
|
|
|
type RunDistributionResponse struct {
|
|
ID string `json:"id"`
|
|
ServerInstanceID string `json:"serverInstanceId"`
|
|
PluginID string `json:"pluginId"`
|
|
RunEndpointID string `json:"runEndpointId"`
|
|
TargetOS string `json:"targetOs"`
|
|
TargetArch string `json:"targetArch"`
|
|
PackageFormat string `json:"packageFormat"`
|
|
BuildJobID string `json:"buildJobId"`
|
|
ArtifactID string `json:"artifactId"`
|
|
Checksum string `json:"checksum"`
|
|
KeyGeneration int `json:"keyGeneration"`
|
|
SecretRef string `json:"secretRef"`
|
|
Status string `json:"status"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
type ClientManagerDistributionResponse 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"`
|
|
SourceRevision string `json:"sourceRevision"`
|
|
BuildJobID string `json:"buildJobId"`
|
|
ArtifactID string `json:"artifactId"`
|
|
Checksum string `json:"checksum"`
|
|
KeyGeneration int `json:"keyGeneration"`
|
|
SecretRef string `json:"secretRef"`
|
|
Status string `json:"status"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
type DependencyStatusResponse struct {
|
|
ID string `json:"id"`
|
|
ServerInstanceID string `json:"serverInstanceId"`
|
|
PluginID string `json:"pluginId"`
|
|
ProbeKey string `json:"probeKey"`
|
|
TargetOS string `json:"targetOs"`
|
|
TargetArch string `json:"targetArch"`
|
|
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"`
|
|
SourceRevision string `json:"sourceRevision"`
|
|
ArtifactID string `json:"artifactId,omitempty"`
|
|
Checksum string `json:"checksum,omitempty"`
|
|
KeyGeneration int `json:"keyGeneration,omitempty"`
|
|
LogsRef string `json:"logsRef,omitempty"`
|
|
Status string `json:"status"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
type RunUpdateJobResponse struct {
|
|
ID string `json:"id"`
|
|
ServerInstanceID string `json:"serverInstanceId"`
|
|
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,
|
|
TargetOS: request.TargetOS,
|
|
TargetArch: request.TargetArch,
|
|
IdempotencyKey: request.IdempotencyKey,
|
|
}
|
|
}
|
|
|
|
func (request RunUpdateRequest) ToDomain(serverInstanceID string) domain.RunUpdateRequest {
|
|
return domain.RunUpdateRequest{
|
|
ServerInstanceID: serverInstanceID,
|
|
ArtifactID: request.ArtifactID,
|
|
Checksum: request.Checksum,
|
|
IdempotencyKey: request.IdempotencyKey,
|
|
}
|
|
}
|
|
|
|
func (request DependencyJobRequest) ToDomain(serverInstanceID string, install bool) domain.DependencyJobRequest {
|
|
return domain.DependencyJobRequest{
|
|
ServerInstanceID: serverInstanceID,
|
|
ProbeKey: request.ProbeKey,
|
|
InstallPlanKey: request.InstallPlanKey,
|
|
PlanDigest: request.PlanDigest,
|
|
TargetOS: request.TargetOS,
|
|
TargetArch: request.TargetArch,
|
|
IdempotencyKey: request.IdempotencyKey,
|
|
Install: install,
|
|
}
|
|
}
|
|
|
|
func (request LogBackfillRequest) ToDomain(serverInstanceID string) domain.LogBackfillRequest {
|
|
return domain.LogBackfillRequest{
|
|
ServerInstanceID: serverInstanceID,
|
|
SourceKey: request.SourceKey,
|
|
CheckpointRef: request.CheckpointRef,
|
|
Limit: request.Limit,
|
|
IdempotencyKey: request.IdempotencyKey,
|
|
}
|
|
}
|
|
|
|
func (request ClientManagerBuildRequest) ToDomain(serverInstanceID string) domain.ClientManagerBuildRequest {
|
|
return domain.ClientManagerBuildRequest{
|
|
ServerInstanceID: serverInstanceID,
|
|
ProfileKey: request.ProfileKey,
|
|
TargetOS: request.TargetOS,
|
|
TargetArch: request.TargetArch,
|
|
RepositoryURL: request.RepositoryURL,
|
|
SourceRevision: request.SourceRevision,
|
|
IdempotencyKey: request.IdempotencyKey,
|
|
}
|
|
}
|
|
|
|
func (request ComponentKeyResetRequest) ToDomain(serverInstanceID string) domain.ComponentKeyResetRequest {
|
|
return domain.ComponentKeyResetRequest{
|
|
ServerInstanceID: serverInstanceID,
|
|
ComponentKind: domain.DistributionComponentKind(request.ComponentKind),
|
|
ComponentKey: request.ComponentKey,
|
|
}
|
|
}
|
|
|
|
func ComponentKeyFromDomain(key domain.EncryptedComponentKey) ComponentKeyResponse {
|
|
return ComponentKeyResponse{
|
|
ID: key.ID,
|
|
ServerInstanceID: key.ServerInstanceID,
|
|
ComponentKind: string(key.ComponentKind),
|
|
ComponentKey: key.ComponentKey,
|
|
SecretRef: key.SecretRef,
|
|
Fingerprint: key.Fingerprint,
|
|
Generation: key.Generation,
|
|
Status: string(key.Status),
|
|
CreatedAt: key.CreatedAt,
|
|
UpdatedAt: key.UpdatedAt,
|
|
ResetAt: key.ResetAt,
|
|
}
|
|
}
|
|
|
|
func ServerRuntimeActionsFromDomain(actions domain.ServerRuntimeActions) ServerRuntimeActionsResponse {
|
|
actions = domain.CopyServerRuntimeActions(actions)
|
|
items := make([]ServerRuntimeActionResponse, len(actions.Actions))
|
|
for i, action := range actions.Actions {
|
|
items[i] = ServerRuntimeActionResponse{Key: action.Key, Label: action.Label, Available: action.Available, Reason: action.Reason}
|
|
}
|
|
return ServerRuntimeActionsResponse{
|
|
ServerInstanceID: actions.ServerInstanceID,
|
|
PluginID: actions.PluginID,
|
|
RunEndpointID: actions.RunEndpointID,
|
|
RunStatus: string(actions.RunStatus),
|
|
Actions: items,
|
|
}
|
|
}
|
|
|
|
func RunDistributionFromDomain(distribution domain.RunDistribution) RunDistributionResponse {
|
|
return RunDistributionResponse{
|
|
ID: distribution.ID,
|
|
ServerInstanceID: distribution.ServerInstanceID,
|
|
PluginID: distribution.PluginID,
|
|
RunEndpointID: distribution.RunEndpointID,
|
|
TargetOS: distribution.TargetOS,
|
|
TargetArch: distribution.TargetArch,
|
|
PackageFormat: distribution.PackageFormat,
|
|
BuildJobID: distribution.BuildJobID,
|
|
ArtifactID: distribution.ArtifactID,
|
|
Checksum: distribution.Checksum,
|
|
KeyGeneration: distribution.KeyGeneration,
|
|
SecretRef: distribution.SecretRef,
|
|
Status: string(distribution.Status),
|
|
CreatedAt: distribution.CreatedAt,
|
|
UpdatedAt: distribution.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func ClientManagerDistributionFromDomain(distribution domain.ClientManagerDistribution) ClientManagerDistributionResponse {
|
|
return ClientManagerDistributionResponse{
|
|
ID: distribution.ID,
|
|
ServerInstanceID: distribution.ServerInstanceID,
|
|
PluginID: distribution.PluginID,
|
|
ProfileKey: distribution.ProfileKey,
|
|
Version: distribution.Version,
|
|
TargetOS: distribution.TargetOS,
|
|
TargetArch: distribution.TargetArch,
|
|
RepositoryURL: distribution.RepositoryURL,
|
|
SourceRevision: distribution.SourceRevision,
|
|
BuildJobID: distribution.BuildJobID,
|
|
ArtifactID: distribution.ArtifactID,
|
|
Checksum: distribution.Checksum,
|
|
KeyGeneration: distribution.KeyGeneration,
|
|
SecretRef: distribution.SecretRef,
|
|
Status: string(distribution.Status),
|
|
CreatedAt: distribution.CreatedAt,
|
|
UpdatedAt: distribution.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func DependencyStatusFromDomain(status domain.DependencyStatus) DependencyStatusResponse {
|
|
return DependencyStatusResponse{
|
|
ID: status.ID,
|
|
ServerInstanceID: status.ServerInstanceID,
|
|
PluginID: status.PluginID,
|
|
ProbeKey: status.ProbeKey,
|
|
TargetOS: status.TargetOS,
|
|
TargetArch: status.TargetArch,
|
|
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,
|
|
SourceRevision: job.SourceRevision,
|
|
ArtifactID: job.ArtifactID,
|
|
Checksum: job.Checksum,
|
|
KeyGeneration: job.KeyGeneration,
|
|
LogsRef: job.LogsRef,
|
|
Status: string(job.Status),
|
|
CreatedAt: job.CreatedAt,
|
|
UpdatedAt: job.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func RunUpdateJobFromDomain(job domain.RunUpdateJob) RunUpdateJobResponse {
|
|
return RunUpdateJobResponse{
|
|
ID: job.ID,
|
|
ServerInstanceID: job.ServerInstanceID,
|
|
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)}
|
|
}
|