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 // All confirms an app-wide deploy of a multi-service app.
51 All bool `json:"all,omitempty"`
52}
53
54// AppServiceResultDTO is one service's terminal deployment result.
55type AppServiceResultDTO struct {
56 Result string `json:"result"`
57 EffectiveRevision string `json:"effective_revision"`
58 Before string `json:"before,omitempty"`
59 After string `json:"after,omitempty"`
60 RestartUnsafe bool `json:"restart_unsafe"`
61 Error string `json:"error,omitempty"`
62}
63
64// AppStepDTO is one journaled operation step.
65type AppStepDTO struct {
66 ID string `json:"id"`
67 State string `json:"state"`
68 Detail string `json:"detail,omitempty"`
69 Error string `json:"error,omitempty"`
70 Before string `json:"before,omitempty"`
71 After string `json:"after,omitempty"`
72 // Diagnostics is redacted failure output, populated only for callers
73 // holding the logs read scope.
74 Diagnostics []string `json:"diagnostics,omitempty"`
75}
76
77// AppCleanupWarningDTO records post-publication leftovers.
78type AppCleanupWarningDTO struct {
79 Service string `json:"service"`
80 Leftover string `json:"leftover"`
81 Detail string `json:"detail"`
82}
83
84// AppEffectiveDTO maps services to effective revisions.
85type AppEffectiveDTO struct {
86 Converged bool `json:"converged"`
87 ConvergedRevision string `json:"converged_revision,omitempty"`
88 Services map[string]string `json:"services"`
89}
90
91// AppRetainedDTO lists the resources an app owns and would retain on
92// removal (names and paths, never values).
93type AppRetainedDTO struct {
94 Volumes []string `json:"volumes"`
95 Secrets []string `json:"secrets"`
96 Images []string `json:"images"`
97}
98
99// AppSecretMetadataDTO reports registration metadata without secret values.
100type AppSecretMetadataDTO struct {
101 Service string `json:"service"`
102 Key string `json:"key"`
103 Name string `json:"name"`
104 Source string `json:"source"`
105 Presence string `json:"presence"`
106}
107
108// AppStatusRunning is the wire status of an operation whose effects are
109// still executing in the background. A terminal operation reports its
110// persisted outcome as the status instead.
111const AppStatusRunning = "running"
112
113// AppDeployResponse reports deploy outcome with terminal results.
114// Effective and Retained are filled from current app state when the app
115// still exists; they are omitted when it does not.
116type AppDeployResponse struct {
117 Op string `json:"op"`
118 App string `json:"app"`
119 Revision string `json:"revision"`
120 Status string `json:"status"`
121 Outcome string `json:"outcome"`
122 Services map[string]AppServiceResultDTO `json:"services"`
123 Steps []AppStepDTO `json:"steps"`
124 CleanupWarnings []AppCleanupWarningDTO `json:"cleanup_warnings,omitempty"`
125 Effective *AppEffectiveDTO `json:"effective,omitempty"`
126 Retained *AppRetainedDTO `json:"retained,omitempty"`
127}
128
129// AppDesiredDTO summarizes desired state.
130type AppDesiredDTO struct {
131 Revision string `json:"revision,omitempty"`
132 Status string `json:"status,omitempty"`
133 // Pending reports desired state ACTIVE has not reached yet.
134 Pending bool `json:"pending"`
135}
136
137// AppActiveServiceDTO is one effective service for inspection.
138type AppActiveServiceDTO struct {
139 EffectiveRevision string `json:"effective_revision"`
140 Digest string `json:"digest,omitempty"`
141 Container string `json:"container,omitempty"`
142 RestartUnsafe bool `json:"restart_unsafe"`
143}
144
145// AppActiveDTO carries per-service effective state.
146type AppActiveDTO struct {
147 Converged bool `json:"converged"`
148 ConvergedRevision string `json:"converged_revision,omitempty"`
149 Services map[string]AppActiveServiceDTO `json:"services"`
150}
151
152// AppIntentDTO carries durable stopped/running intent.
153type AppIntentDTO struct {
154 Stopped bool `json:"stopped"`
155}
156
157// AppLastOpDTO references the latest operation.
158type AppLastOpDTO struct {
159 Op string `json:"op"`
160 Kind string `json:"kind,omitempty"`
161 Outcome string `json:"outcome,omitempty"`
162 StartedAt time.Time `json:"started_at,omitzero"`
163}
164
165// AppShowResponse inspects desired + active + intent + ownership + op ref.
166type AppShowResponse struct {
167 App string `json:"app"`
168 Desired AppDesiredDTO `json:"desired"`
169 Active AppActiveDTO `json:"active"`
170 Intent AppIntentDTO `json:"intent"`
171 Retained AppRetainedDTO `json:"retained"`
172 LastOp *AppLastOpDTO `json:"last_op,omitempty"`
173}
174
175// AppSummaryDTO is one row of the app list.
176type AppSummaryDTO struct {
177 App string `json:"app"`
178 Desired string `json:"desired,omitempty"`
179 DesiredStatus string `json:"desired_status,omitempty"`
180 Active string `json:"active,omitempty"`
181 Converged bool `json:"converged"`
182 Pending bool `json:"pending"`
183 Stopped bool `json:"stopped"`
184 LastOutcome string `json:"last_outcome,omitempty"`
185}
186
187// AppDiffResponse reports normalized desired-vs-active diff.
188type AppDiffResponse struct {
189 App string `json:"app"`
190 Diff AppDiffSection `json:"diff"`
191}
192
193// AppSecretSetRequest writes secret values (names pre-registered).
194type AppSecretSetRequest struct {
195 Service string `json:"service"`
196 Secrets map[string]string `json:"secrets"`
197}
198
199// AppSecretDeleteRequest removes one secret value.
200type AppSecretDeleteRequest struct {
201 Service string `json:"service"`
202 Key string `json:"key"`
203}