1package dto
2
3import "time"
4
5// App admin DTOs use stable wire-facing field names.
6// No secret values exist in any shape here: secret references carry
7// paths and env keys only. The versioned error envelope is a deliberate
8// change from ErrorResponse for app mutations; clients accept both
9// during the mixed-version window.
10
11// AppError is the v3 app-mutation error envelope. Its stable fields are
12// error/message/cause/hint.
13// `logs` never appears on mutations. Clients accept the legacy
14// single-field ErrorResponse during the mixed-version window.
15type AppError struct {
16 Error string `json:"error"`
17 Message string `json:"message,omitempty"`
18 Cause string `json:"cause,omitempty"`
19 Hint string `json:"hint,omitempty"`
20}
21
22// AppDiffSection carries normalized added/removed/changed paths.
23type AppDiffSection struct {
24 Added []string `json:"added"`
25 Removed []string `json:"removed"`
26 Changed []string `json:"changed"`
27}
28
29// AppApplyRequest asks the daemon to validate and persist desired state.
30type AppApplyRequest struct {
31 ManifestTOML string `json:"manifest_toml"`
32 DryRun bool `json:"dry_run,omitempty"`
33}
34
35// AppApplyResponse reports persistence success separately from deploy.
36type AppApplyResponse struct {
37 App string `json:"app"`
38 FormerRevision string `json:"former_revision,omitempty"`
39 ResultingRevision string `json:"resulting_revision,omitempty"`
40 Pending bool `json:"pending"`
41 Noop bool `json:"noop,omitempty"`
42 Diff AppDiffSection `json:"diff"`
43 Intent string `json:"intent,omitempty"`
44}
45
46// AppDeployRequest activates a captured revision.
47type AppDeployRequest struct {
48 Revision string `json:"revision,omitempty"`
49 Service string `json:"service,omitempty"`
50}
51
52// AppServiceResultDTO is one service's terminal deployment result.
53type AppServiceResultDTO struct {
54 Result string `json:"result"`
55 EffectiveRevision string `json:"effective_revision"`
56 Before string `json:"before,omitempty"`
57 After string `json:"after,omitempty"`
58 RestartUnsafe bool `json:"restart_unsafe"`
59 Error string `json:"error,omitempty"`
60}
61
62// AppStepDTO is one journaled operation step.
63type AppStepDTO struct {
64 ID string `json:"id"`
65 State string `json:"state"`
66 Detail string `json:"detail,omitempty"`
67 Error string `json:"error,omitempty"`
68 Before string `json:"before,omitempty"`
69 After string `json:"after,omitempty"`
70 // Diagnostics is redacted failure output, populated only for callers
71 // holding the logs read scope.
72 Diagnostics []string `json:"diagnostics,omitempty"`
73}
74
75// AppCleanupWarningDTO records post-publication leftovers.
76type AppCleanupWarningDTO struct {
77 Service string `json:"service"`
78 Leftover string `json:"leftover"`
79 Detail string `json:"detail"`
80}
81
82// AppEffectiveDTO maps services to effective revisions.
83type AppEffectiveDTO struct {
84 Converged bool `json:"converged"`
85 ConvergedRevision string `json:"converged_revision,omitempty"`
86 Services map[string]string `json:"services"`
87}
88
89// AppRetainedDTO lists the resources an app owns and would retain on
90// removal (names and paths, never values).
91type AppRetainedDTO struct {
92 Volumes []string `json:"volumes"`
93 Secrets []string `json:"secrets"`
94 Images []string `json:"images"`
95}
96
97// AppSecretMetadataDTO reports registration metadata without secret values.
98type AppSecretMetadataDTO struct {
99 Service string `json:"service"`
100 Key string `json:"key"`
101 Name string `json:"name"`
102 Source string `json:"source"`
103 Presence string `json:"presence"`
104}
105
106// AppStatusRunning is the wire status of an operation whose effects are
107// still executing in the background. A terminal operation reports its
108// persisted outcome as the status instead.
109const AppStatusRunning = "running"
110
111// AppDeployResponse reports deploy outcome with terminal results.
112// Effective and Retained are filled from current app state when the app
113// still exists; they are omitted when it does not.
114type AppDeployResponse struct {
115 Op string `json:"op"`
116 App string `json:"app"`
117 Revision string `json:"revision"`
118 Status string `json:"status"`
119 Outcome string `json:"outcome"`
120 Services map[string]AppServiceResultDTO `json:"services"`
121 Steps []AppStepDTO `json:"steps"`
122 CleanupWarnings []AppCleanupWarningDTO `json:"cleanup_warnings,omitempty"`
123 Effective *AppEffectiveDTO `json:"effective,omitempty"`
124 Retained *AppRetainedDTO `json:"retained,omitempty"`
125}
126
127// AppDesiredDTO summarizes desired state.
128type AppDesiredDTO struct {
129 Revision string `json:"revision,omitempty"`
130 Status string `json:"status,omitempty"`
131 // Pending reports desired state ACTIVE has not reached yet.
132 Pending bool `json:"pending"`
133}
134
135// AppActiveServiceDTO is one effective service for inspection.
136type AppActiveServiceDTO struct {
137 EffectiveRevision string `json:"effective_revision"`
138 Digest string `json:"digest,omitempty"`
139 Container string `json:"container,omitempty"`
140 RestartUnsafe bool `json:"restart_unsafe"`
141}
142
143// AppActiveDTO carries per-service effective state.
144type AppActiveDTO struct {
145 Converged bool `json:"converged"`
146 ConvergedRevision string `json:"converged_revision,omitempty"`
147 Services map[string]AppActiveServiceDTO `json:"services"`
148}
149
150// AppIntentDTO carries durable stopped/running intent.
151type AppIntentDTO struct {
152 Stopped bool `json:"stopped"`
153}
154
155// AppLastOpDTO references the latest operation.
156type AppLastOpDTO struct {
157 Op string `json:"op"`
158 Kind string `json:"kind,omitempty"`
159 Outcome string `json:"outcome,omitempty"`
160 StartedAt time.Time `json:"started_at,omitzero"`
161}
162
163// AppShowResponse inspects desired + active + intent + ownership + op ref.
164type AppShowResponse struct {
165 App string `json:"app"`
166 Desired AppDesiredDTO `json:"desired"`
167 Active AppActiveDTO `json:"active"`
168 Intent AppIntentDTO `json:"intent"`
169 Retained AppRetainedDTO `json:"retained"`
170 LastOp *AppLastOpDTO `json:"last_op,omitempty"`
171}
172
173// AppSummaryDTO is one row of the app list.
174type AppSummaryDTO struct {
175 App string `json:"app"`
176 Desired string `json:"desired,omitempty"`
177 DesiredStatus string `json:"desired_status,omitempty"`
178 Active string `json:"active,omitempty"`
179 Converged bool `json:"converged"`
180 Pending bool `json:"pending"`
181 Stopped bool `json:"stopped"`
182 LastOutcome string `json:"last_outcome,omitempty"`
183}
184
185// AppDiffResponse reports normalized desired-vs-active diff.
186type AppDiffResponse struct {
187 App string `json:"app"`
188 Diff AppDiffSection `json:"diff"`
189}
190
191// AppSecretSetRequest writes secret values (names pre-registered).
192type AppSecretSetRequest struct {
193 Service string `json:"service"`
194 Secrets map[string]string `json:"secrets"`
195}
196
197// AppSecretDeleteRequest removes one secret value.
198type AppSecretDeleteRequest struct {
199 Service string `json:"service"`
200 Key string `json:"key"`
201}