@fabrika/provider-zerops 0.9.0-dev.3 → 0.9.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -9
- package/src/api/client.ts +12 -0
- package/src/api/readers.ts +29 -0
- package/src/api/types.ts +52 -0
- package/src/api.ts +2 -0
- package/src/cli.ts +11 -0
- package/src/collaborators.ts +0 -14
- package/src/compile.ts +1 -1
- package/src/control.ts +9 -57
- package/src/execution.ts +63 -185
- package/src/index.ts +2 -0
- package/src/installation/admin.ts +1 -1
- package/src/installation/deploy-options.ts +1 -2
- package/src/installation/deploy.ts +225 -80
- package/src/installation/generated/platform-console-schema.ts +3 -0
- package/src/installation/generated/platform-proxy-manifest.ts +1 -1
- package/src/installation/guide.md +48 -18
- package/src/installation/hosts.ts +1 -7
- package/src/installation/index.ts +13 -16
- package/src/installation/init-options.ts +2 -1
- package/src/installation/install-environment.ts +47 -108
- package/src/installation/install-options.ts +3 -1
- package/src/installation/install-secrets.ts +24 -68
- package/src/installation/install.ts +9 -4
- package/src/installation/sidecar.ts +5 -26
- package/src/installation/topology/setups.ts +15 -4
- package/src/installation/topology/topology.ts +31 -21
- package/src/installation/upgrade-options.ts +2 -2
- package/src/managed-env.ts +1 -174
- package/src/manifest.ts +2 -9
- package/src/namespace/claims.ts +56 -1
- package/src/namespace/errors.ts +1 -1
- package/src/namespace/manifest.ts +6 -19
- package/src/namespace/provisioning.ts +20 -2
- package/src/namespace/proxy-attempt.ts +14 -2
- package/src/namespace/proxy-reads.ts +12 -22
- package/src/namespace/types.ts +2 -0
- package/src/namespace-cli.ts +152 -0
- package/src/plan.ts +1 -6
- package/src/provider.ts +88 -126
- package/src/proxy-manifest-carrier.ts +18 -0
- package/src/types.ts +0 -2
- package/types/src/api/readers.d.ts +148 -10
- package/types/src/api/types.d.ts +49 -0
- package/types/src/api.d.ts +1 -1
- package/types/src/cli.d.ts +3 -0
- package/types/src/collaborators.d.ts +0 -2
- package/types/src/compile.d.ts +1 -1
- package/types/src/control.d.ts +3 -4
- package/types/src/execution.d.ts +5 -17
- package/types/src/index.d.ts +1 -1
- package/types/src/installation/deploy-options.d.ts +1 -1
- package/types/src/installation/deploy.d.ts +40 -0
- package/types/src/installation/generated/platform-proxy-manifest.d.ts +1 -1
- package/types/src/installation/hosts.d.ts +1 -5
- package/types/src/installation/index.d.ts +0 -2
- package/types/src/installation/install-environment.d.ts +11 -18
- package/types/src/installation/install-secrets.d.ts +3 -16
- package/types/src/installation/sidecar.d.ts +0 -2
- package/types/src/installation/topology/installation-schemas.d.ts +84 -84
- package/types/src/installation/topology/setups.d.ts +2 -1
- package/types/src/installation/topology/topology.d.ts +15 -10
- package/types/src/managed-env.d.ts +0 -33
- package/types/src/manifest.d.ts +0 -2
- package/types/src/namespace/claims.d.ts +14 -1
- package/types/src/namespace/codec.d.ts +4 -4
- package/types/src/namespace/errors.d.ts +1 -1
- package/types/src/namespace/proxy-attempt.d.ts +3 -0
- package/types/src/namespace/proxy-reads.d.ts +4 -15
- package/types/src/namespace/types.d.ts +2 -0
- package/types/src/namespace-cli.d.ts +2 -0
- package/types/src/plan.d.ts +2 -3
- package/types/src/provider.d.ts +0 -2
- package/types/src/proxy-manifest-carrier.d.ts +8 -0
- package/types/src/types.d.ts +0 -2
- package/src/installation/mcp.ts +0 -102
- package/src/installation/proxy-manifest.ts +0 -214
- package/src/installation/secrets.ts +0 -78
- package/types/src/installation/mcp.d.ts +0 -18
- package/types/src/installation/proxy-manifest.d.ts +0 -105
- package/types/src/installation/secrets.d.ts +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/provider-zerops",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,14 +44,15 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"zod": "^3.25.76",
|
|
47
|
-
"@fabrika/
|
|
48
|
-
"@fabrika/auth
|
|
49
|
-
"@fabrika/
|
|
50
|
-
"@fabrika/
|
|
51
|
-
"@fabrika/
|
|
52
|
-
"@fabrika/
|
|
53
|
-
"@fabrika/
|
|
54
|
-
"@fabrika/
|
|
47
|
+
"@fabrika/app": "0.9.0-dev.5",
|
|
48
|
+
"@fabrika/auth": "0.9.0-dev.5",
|
|
49
|
+
"@fabrika/auth-core": "0.9.0-dev.5",
|
|
50
|
+
"@fabrika/email": "0.9.0-dev.5",
|
|
51
|
+
"@fabrika/iam-contract": "0.9.0-dev.5",
|
|
52
|
+
"@fabrika/installation-init": "0.9.0-dev.5",
|
|
53
|
+
"@fabrika/operations-contract": "0.9.0-dev.5",
|
|
54
|
+
"@fabrika/provider-contract": "0.9.0-dev.5",
|
|
55
|
+
"@fabrika/proxy-core": "0.9.0-dev.5",
|
|
55
56
|
"yaml": "^2.9.1"
|
|
56
57
|
}
|
|
57
58
|
}
|
package/src/api/client.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { waitForProcess } from './polling'
|
|
|
5
5
|
import {
|
|
6
6
|
appVersionListSchema,
|
|
7
7
|
appVersionSchema,
|
|
8
|
+
backupConfigSchema,
|
|
8
9
|
importResultSchema,
|
|
9
10
|
integrationTokenSchema,
|
|
10
11
|
logAccessSchema,
|
|
@@ -370,6 +371,17 @@ export const createZeropsApi = (options: ZeropsApiOptions): ZeropsApi => {
|
|
|
370
371
|
return readResponse('configure custom autoscaling', processNilSchema, payload).process ?? null
|
|
371
372
|
},
|
|
372
373
|
|
|
374
|
+
getBackupConfig: async ({ serviceId, signal }) =>
|
|
375
|
+
readResponse('list backups', backupConfigSchema, await request('list backups', 'GET', `/service-stack/${serviceId}/backup`, { signal })),
|
|
376
|
+
|
|
377
|
+
configureBackup: async ({ serviceId, backupPeriod, retentionPolicy, signal }) => {
|
|
378
|
+
const payload = await request('configure backup', 'PUT', `/service-stack/${serviceId}/backup-config`, {
|
|
379
|
+
body: { backupPeriod, retentionPolicy },
|
|
380
|
+
signal,
|
|
381
|
+
})
|
|
382
|
+
return readResponse('configure backup', processNilSchema, payload).process ?? null
|
|
383
|
+
},
|
|
384
|
+
|
|
373
385
|
getService: async ({ serviceId, signal }) =>
|
|
374
386
|
readResponse('get service', serviceSchema, await request('get service', 'GET', `/service-stack/${serviceId}`, { signal })),
|
|
375
387
|
|
package/src/api/readers.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { withoutSensitiveContent } from './service-env-response'
|
|
|
3
3
|
import type {
|
|
4
4
|
ZeropsAppVersion,
|
|
5
5
|
ZeropsAppVersionStatus,
|
|
6
|
+
ZeropsBackupConfig,
|
|
7
|
+
ZeropsBackupRetentionPolicy,
|
|
6
8
|
ZeropsImportResult,
|
|
7
9
|
ZeropsIntegrationToken,
|
|
8
10
|
ZeropsLogAccess,
|
|
@@ -170,6 +172,33 @@ export const serviceSchema = z.object({
|
|
|
170
172
|
currentAutoscaling: optional(serviceAutoscalingSchema),
|
|
171
173
|
}).transform(({ activeAppVersion, ...service }): ZeropsService => ({ ...service, activeAppVersionId: activeAppVersion?.id }))
|
|
172
174
|
|
|
175
|
+
const backupCountSchema = z.number().int().nonnegative()
|
|
176
|
+
|
|
177
|
+
/** Strict like the custom autoscaling, for the same reason: it is sent back whole, so no field may read as absent. */
|
|
178
|
+
const backupRetentionPolicySchema = z.object({
|
|
179
|
+
maxTotalFiles: backupCountSchema,
|
|
180
|
+
maxTotalGiB: backupCountSchema,
|
|
181
|
+
// A Go API may serialise an empty list as null; read as the empty list it is.
|
|
182
|
+
protectedTags: z.array(z.string()).nullable().transform((tags) => tags ?? []),
|
|
183
|
+
minDaily: backupCountSchema,
|
|
184
|
+
maxDaily: backupCountSchema,
|
|
185
|
+
minWeekly: backupCountSchema,
|
|
186
|
+
maxWeekly: backupCountSchema,
|
|
187
|
+
minMonthly: backupCountSchema,
|
|
188
|
+
maxMonthly: backupCountSchema,
|
|
189
|
+
}) satisfies z.ZodType<ZeropsBackupRetentionPolicy, z.ZodTypeDef, unknown>
|
|
190
|
+
|
|
191
|
+
/** A service's own retention that does not parse fails the whole read: reading it as absent would send the default over it. */
|
|
192
|
+
export const backupConfigSchema = z.object({
|
|
193
|
+
backupPeriod: z.string(),
|
|
194
|
+
defaultRetentionPolicy: backupRetentionPolicySchema,
|
|
195
|
+
retentionPolicy: backupRetentionPolicySchema.nullish(),
|
|
196
|
+
}).transform(({ backupPeriod, defaultRetentionPolicy, retentionPolicy }): ZeropsBackupConfig => ({
|
|
197
|
+
backupPeriod,
|
|
198
|
+
defaultRetentionPolicy,
|
|
199
|
+
...(retentionPolicy === null || retentionPolicy === undefined ? {} : { retentionPolicy }),
|
|
200
|
+
}))
|
|
201
|
+
|
|
173
202
|
export const projectSchema = z.object({
|
|
174
203
|
id: idSchema,
|
|
175
204
|
name: z.string(),
|
package/src/api/types.ts
CHANGED
|
@@ -196,6 +196,34 @@ export interface ZeropsServiceAutoscaling {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
/**
|
|
200
|
+
* How many backups of a managed service the platform keeps. VERIFIED AS A SHAPE: `OutDtoBackupRetentionPolicy` and
|
|
201
|
+
* `InDtoBodyBackupRetentionPolicy` carry these nine fields, all required. The `min*`/`max*` counts are per backup TAG
|
|
202
|
+
* (`daily`, `weekly`, `monthly`); UNVERIFIED: which tags an hourly automatic backup gets.
|
|
203
|
+
*/
|
|
204
|
+
export interface ZeropsBackupRetentionPolicy {
|
|
205
|
+
maxTotalFiles: number
|
|
206
|
+
maxTotalGiB: number
|
|
207
|
+
/** Backups with one of these tags are never deleted automatically. */
|
|
208
|
+
protectedTags: string[]
|
|
209
|
+
minDaily: number
|
|
210
|
+
maxDaily: number
|
|
211
|
+
minWeekly: number
|
|
212
|
+
maxWeekly: number
|
|
213
|
+
minMonthly: number
|
|
214
|
+
maxMonthly: number
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** A managed service's backup schedule and retention. VERIFIED AS A SHAPE: `ResponseServiceStackBackupFileList`, without its `files`. */
|
|
218
|
+
export interface ZeropsBackupConfig {
|
|
219
|
+
/** UNVERIFIED: the format. Zerops' GUI documentation describes a 5-field cron (`min hour dom mon dow`). */
|
|
220
|
+
backupPeriod: string
|
|
221
|
+
/** What the platform applies to a service with no retention of its own. UNVERIFIED: that it is what applies then. */
|
|
222
|
+
defaultRetentionPolicy: ZeropsBackupRetentionPolicy
|
|
223
|
+
/** The service's own retention; absent when none was set. */
|
|
224
|
+
retentionPolicy?: ZeropsBackupRetentionPolicy
|
|
225
|
+
}
|
|
226
|
+
|
|
199
227
|
/** One service. VERIFIED: `ResponseServiceStack` (narrowed to the fields fabrika reads). */
|
|
200
228
|
export interface ZeropsService {
|
|
201
229
|
id: string
|
|
@@ -506,6 +534,30 @@ export interface ZeropsApi {
|
|
|
506
534
|
*/
|
|
507
535
|
configureCustomAutoscaling(input: { serviceId: string; autoscaling: ZeropsServiceAutoscaling; signal: AbortSignal }): Promise<ZeropsProcess | null>
|
|
508
536
|
|
|
537
|
+
// ── service-stack: backups ────────────────────────────────────────────────────
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* A managed service's backup schedule and retention. VERIFIED AS A SHAPE: `GET /service-stack/{id}/backup`
|
|
541
|
+
* (`ListBackups`), response `ResponseServiceStackBackupFileList`; the backup files it also lists are not read.
|
|
542
|
+
*/
|
|
543
|
+
getBackupConfig(input: { serviceId: string; signal: AbortSignal }): Promise<ZeropsBackupConfig>
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Set a managed service's backup schedule and retention. VERIFIED AS A SHAPE: `PUT /service-stack/{id}/backup-config`
|
|
547
|
+
* (`ConfigureBackup`), body `RequestServiceStackBackupConfig`, response `ResponseProcessNil`. The platform stores the
|
|
548
|
+
* period as the service's `BACKUP_PERIOD` variable and may start a user-data sync, whose process this answers.
|
|
549
|
+
*
|
|
550
|
+
* `retentionPolicy` is required here although the body makes it optional. UNVERIFIED: whether a request without one
|
|
551
|
+
* resets the service's retention; a PUT elsewhere on this API resets every field it leaves out, so the caller sends
|
|
552
|
+
* the retention it read, whole.
|
|
553
|
+
*/
|
|
554
|
+
configureBackup(input: {
|
|
555
|
+
serviceId: string
|
|
556
|
+
backupPeriod: string
|
|
557
|
+
retentionPolicy: ZeropsBackupRetentionPolicy
|
|
558
|
+
signal: AbortSignal
|
|
559
|
+
}): Promise<ZeropsProcess | null>
|
|
560
|
+
|
|
509
561
|
// ── service-stack / project: reading state ────────────────────────────────────
|
|
510
562
|
|
|
511
563
|
/** One service by id. VERIFIED: `GET /service-stack/{id}`. */
|
package/src/api.ts
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
+
import type { AppCli } from '@fabrika/provider-contract/app-cli'
|
|
2
3
|
import { constants } from 'node:fs'
|
|
3
4
|
import { open } from 'node:fs/promises'
|
|
4
5
|
import { resolve } from 'node:path'
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
manifestServiceHostnames,
|
|
13
14
|
ZEROPS_SOURCE_DESCRIPTOR_MAX_BYTES,
|
|
14
15
|
} from './manifest'
|
|
16
|
+
import { zeropsNamespaceCli } from './namespace-cli'
|
|
15
17
|
import type { ZeropsAppConfig } from './types'
|
|
16
18
|
|
|
17
19
|
const USAGE = `Zerops app tools
|
|
@@ -106,6 +108,15 @@ export const runZeropsCli = async (argv: readonly string[]): Promise<void> => {
|
|
|
106
108
|
console.info(`wrote ${output} (${manifestServiceHostnames(manifest).length} service(s))`)
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
/** What `fabrika app build`, `app register` and `fabrika namespace` run for an application on Zerops. */
|
|
112
|
+
export const appCli: AppCli = {
|
|
113
|
+
provider: 'zerops',
|
|
114
|
+
entryRuntime: 'bun',
|
|
115
|
+
build: (argv) => runZeropsCli(['build', ...argv]),
|
|
116
|
+
registrationManifest: buildZeropsManifestText,
|
|
117
|
+
namespaces: zeropsNamespaceCli,
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
if (import.meta.main) {
|
|
110
121
|
await runZeropsCli(process.argv.slice(2)).catch((error: unknown) => {
|
|
111
122
|
console.error(error instanceof Error ? error.message : String(error))
|
package/src/collaborators.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { reconcileSchema } from '@fabrika/auth'
|
|
2
|
-
import type { SchemaReconciler } from '@fabrika/provider-contract'
|
|
3
1
|
import { createZeropsApi, type ZeropsApi } from './api'
|
|
4
2
|
import { type ExposureAlerter, sendExposureAlert } from './exposure'
|
|
5
3
|
import type { ZeropsSourcePort } from './source/port'
|
|
@@ -28,7 +26,6 @@ export interface ZeropsCollaborators {
|
|
|
28
26
|
api: ZeropsApi
|
|
29
27
|
/** Injected by the Zerops control composition; dry runs do not require it. */
|
|
30
28
|
source?: ZeropsSourcePort
|
|
31
|
-
reconcileSchema: SchemaReconciler
|
|
32
29
|
/** Raises the Operations alert for a refused activation; best-effort. */
|
|
33
30
|
alertExposure: ExposureAlerter
|
|
34
31
|
sleep: Sleeper
|
|
@@ -36,19 +33,8 @@ export interface ZeropsCollaborators {
|
|
|
36
33
|
|
|
37
34
|
export type ZeropsCollaboratorFactory = (target: ZeropsRuntimeTarget) => ZeropsCollaborators
|
|
38
35
|
|
|
39
|
-
const defaultReconcileSchema: SchemaReconciler = (input) =>
|
|
40
|
-
reconcileSchema({
|
|
41
|
-
url: input.url,
|
|
42
|
-
app: input.app,
|
|
43
|
-
schema: input.schema,
|
|
44
|
-
...(input.returnOrigins === undefined ? {} : { returnOrigins: input.returnOrigins }),
|
|
45
|
-
adminKey: input.adminKey,
|
|
46
|
-
signal: input.signal,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
36
|
export const defaultZeropsCollaborators: ZeropsCollaboratorFactory = (target) => ({
|
|
50
37
|
api: createZeropsApi({ token: target.accessToken, baseUrl: target.apiBaseUrl }),
|
|
51
|
-
reconcileSchema: defaultReconcileSchema,
|
|
52
38
|
alertExposure: sendExposureAlert,
|
|
53
39
|
sleep: defaultSleep,
|
|
54
40
|
})
|
package/src/compile.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { ZeropsImportProject, ZeropsImportService } from './schema.generate
|
|
|
23
23
|
import type { ZeropsProjectSpec, ZeropsResourceContext, ZeropsServiceSpec, ZeropsSourceTarget } from './types'
|
|
24
24
|
|
|
25
25
|
/** The ONLY value fabrika ever writes for `envIsolation`, at either level. Not a default — an assertion. */
|
|
26
|
-
export const ENV_ISOLATION
|
|
26
|
+
export const ENV_ISOLATION = 'service'
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* The ONLY value fabrika ever writes for `override`, on EVERY service class including managed ones.
|
package/src/control.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { appEnvironmentId } from '@fabrika/auth-core'
|
|
2
1
|
import type {
|
|
3
2
|
ControlProvider,
|
|
4
3
|
JsonValue,
|
|
@@ -17,7 +16,6 @@ import type {
|
|
|
17
16
|
ProviderSourceBinding,
|
|
18
17
|
ProviderSourceResolution,
|
|
19
18
|
ProviderSourceResolutionInput,
|
|
20
|
-
SchemaReconciler,
|
|
21
19
|
} from '@fabrika/provider-contract'
|
|
22
20
|
import { decodeEnvelope, ProviderSecretError } from '@fabrika/provider-contract'
|
|
23
21
|
import { z } from 'zod'
|
|
@@ -32,9 +30,8 @@ import {
|
|
|
32
30
|
} from './api'
|
|
33
31
|
import { defaultSleep, defaultZeropsCollaborators, type Sleeper } from './collaborators'
|
|
34
32
|
import { createdServices, type ExposureAlerter, isObjectStorageType } from './exposure'
|
|
35
|
-
import { assertAuthoredManagedInputs, assertAuthoredManagedName, assertNoFrameworkReference
|
|
33
|
+
import { assertAuthoredManagedInputs, assertAuthoredManagedName, assertNoFrameworkReference } from './managed-env'
|
|
36
34
|
import {
|
|
37
|
-
approvedSchemaOf,
|
|
38
35
|
assertFabrikaManifestCoordinates,
|
|
39
36
|
type FabrikaManifest,
|
|
40
37
|
manifestServiceHostnames,
|
|
@@ -91,11 +88,8 @@ const envelope = <T>(codec: ProviderCodec<T>, value: T): ProviderEnvelope => ({
|
|
|
91
88
|
export interface ZeropsControlProviderOptions {
|
|
92
89
|
readonly accessToken: string
|
|
93
90
|
readonly apiBaseUrl?: string
|
|
94
|
-
readonly propustkaUrl?: string
|
|
95
|
-
readonly adminKey?: string
|
|
96
91
|
readonly api?: ZeropsApi
|
|
97
92
|
readonly source: ZeropsSourcePort
|
|
98
|
-
readonly reconcileSchema?: SchemaReconciler
|
|
99
93
|
readonly alertExposure?: ExposureAlerter
|
|
100
94
|
readonly sleep?: Sleeper
|
|
101
95
|
readonly namespaces?: {
|
|
@@ -103,6 +97,8 @@ export interface ZeropsControlProviderOptions {
|
|
|
103
97
|
readonly proxySource: ZeropsNamespaceProxySource
|
|
104
98
|
readonly iamUrl: string
|
|
105
99
|
readonly iamKey: string
|
|
100
|
+
/** The installation's own project, which no namespace may adopt. */
|
|
101
|
+
readonly installationProjectId?: string
|
|
106
102
|
/** The manifest parsers of the older releases' proxies, which a namespace pinned to an older source may run. */
|
|
107
103
|
readonly olderProxies: OlderProxyReaders
|
|
108
104
|
}
|
|
@@ -227,7 +223,6 @@ export const createZeropsControlProvider = (options: ZeropsControlProviderOption
|
|
|
227
223
|
return {
|
|
228
224
|
api,
|
|
229
225
|
source: options.source,
|
|
230
|
-
reconcileSchema: options.reconcileSchema ?? defaults.reconcileSchema,
|
|
231
226
|
alertExposure: options.alertExposure ?? defaults.alertExposure,
|
|
232
227
|
sleep: options.sleep ?? defaultSleep,
|
|
233
228
|
}
|
|
@@ -261,34 +256,6 @@ export const createZeropsControlProvider = (options: ZeropsControlProviderOption
|
|
|
261
256
|
}
|
|
262
257
|
}
|
|
263
258
|
|
|
264
|
-
const reconcileActiveSchema = async (
|
|
265
|
-
input: { environment: ProviderEnvironment; returnOrigins?: readonly string[] },
|
|
266
|
-
signal: AbortSignal,
|
|
267
|
-
): Promise<void> => {
|
|
268
|
-
const artifact = artifactFor(input.environment)
|
|
269
|
-
const schema = approvedSchemaOf(input.environment)
|
|
270
|
-
if (schema === undefined || options.propustkaUrl === undefined) return
|
|
271
|
-
const placement = resolvedEnvironment(input.environment, { requireReady: false })
|
|
272
|
-
const runtimeTarget: ZeropsRuntimeTarget = {
|
|
273
|
-
projectId: placement.projectId,
|
|
274
|
-
serviceId: placement.target.serviceId,
|
|
275
|
-
accessToken: options.accessToken,
|
|
276
|
-
...(options.apiBaseUrl !== undefined ? { apiBaseUrl: options.apiBaseUrl } : {}),
|
|
277
|
-
propustkaUrl: options.propustkaUrl,
|
|
278
|
-
...(options.adminKey !== undefined ? { adminKey: options.adminKey } : {}),
|
|
279
|
-
}
|
|
280
|
-
const reconcileSchema = options.reconcileSchema ?? defaultZeropsCollaborators(runtimeTarget).reconcileSchema
|
|
281
|
-
signal.throwIfAborted()
|
|
282
|
-
await reconcileSchema({
|
|
283
|
-
url: options.propustkaUrl,
|
|
284
|
-
app: appEnvironmentId(artifact.app.id, artifact.app.env),
|
|
285
|
-
schema,
|
|
286
|
-
...(input.returnOrigins === undefined || input.returnOrigins.length === 0 ? {} : { returnOrigins: input.returnOrigins }),
|
|
287
|
-
adminKey: options.adminKey,
|
|
288
|
-
signal,
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
|
|
292
259
|
const assertVersionCoordinates = (environment: ProviderEnvironment, appVersionId: string, version: ZeropsAppVersion): void => {
|
|
293
260
|
const serviceId = decodeEnvironment(environment).target.serviceId
|
|
294
261
|
if (version.id !== appVersionId || (version.serviceStackId !== undefined && version.serviceStackId !== serviceId)) {
|
|
@@ -346,6 +313,8 @@ export const createZeropsControlProvider = (options: ZeropsControlProviderOption
|
|
|
346
313
|
const controlProvider: ControlProvider = {
|
|
347
314
|
id: 'zerops',
|
|
348
315
|
normalizeRegistration,
|
|
316
|
+
// The deploy reads `zerops.yaml` from the repository, so a workspace may not change it (ADR-0049 D6).
|
|
317
|
+
authoring: { protectedFiles: ['zerops.yaml', 'zerops.yml'] },
|
|
349
318
|
source: { binding: 'connection' },
|
|
350
319
|
/**
|
|
351
320
|
* A Zerops artifact IS the compiled manifest, so the declaration is right here and core can refuse
|
|
@@ -368,8 +337,6 @@ export const createZeropsControlProvider = (options: ZeropsControlProviderOption
|
|
|
368
337
|
deploy: async (input: ProviderDeployInput): Promise<ProviderDeployOutcome> => {
|
|
369
338
|
input.signal.throwIfAborted()
|
|
370
339
|
assertAuthoredManagedInputs({ variableNames: Object.keys(input.vars), secretNames: Object.keys(input.secrets) })
|
|
371
|
-
const handed = parseManagedEnvironment(input.managedEnvironment)
|
|
372
|
-
const managedEnvironment = { ...handed.values, ...handed.familyVariables }
|
|
373
340
|
const binding = privateBinding(input.sourceBinding)
|
|
374
341
|
assertEnvironmentOfApp(input.app, input.environment)
|
|
375
342
|
const placement = resolvedEnvironment(input.environment, { requireReady: true })
|
|
@@ -395,17 +362,14 @@ export const createZeropsControlProvider = (options: ZeropsControlProviderOption
|
|
|
395
362
|
...(placement.target.createdBuckets === undefined ? {} : { createdBuckets: placement.target.createdBuckets }),
|
|
396
363
|
...(source === undefined ? {} : { source }),
|
|
397
364
|
...(options.apiBaseUrl !== undefined ? { apiBaseUrl: options.apiBaseUrl } : {}),
|
|
398
|
-
...(options.propustkaUrl !== undefined ? { propustkaUrl: options.propustkaUrl } : {}),
|
|
399
|
-
...(options.adminKey !== undefined ? { adminKey: options.adminKey } : {}),
|
|
400
365
|
}
|
|
401
366
|
const result = await deployRun({
|
|
402
367
|
appId: input.app.id,
|
|
403
368
|
env: input.environment.env,
|
|
404
369
|
...(input.environment.kind === 'dev' && source !== undefined ? { dev: { head: source.commitSha } } : {}),
|
|
405
|
-
...(input.returnOrigins === undefined ? {} : { returnOrigins: input.returnOrigins }),
|
|
406
370
|
secrets: input.secrets,
|
|
407
371
|
vars: input.vars,
|
|
408
|
-
managedEnvironment,
|
|
372
|
+
managedEnvironment: input.managedEnvironment,
|
|
409
373
|
target: runtimeTarget,
|
|
410
374
|
artifact,
|
|
411
375
|
...(input.environment.access === undefined ? {} : { access: input.environment.access }),
|
|
@@ -438,17 +402,8 @@ export const createZeropsControlProvider = (options: ZeropsControlProviderOption
|
|
|
438
402
|
const version = await getVersion({ appVersionId: checkpoint.appVersionId, signal })
|
|
439
403
|
if (version === null) return { state: 'settled', outcome: 'failed' }
|
|
440
404
|
assertVersionCoordinates(input.environment, checkpoint.appVersionId, version)
|
|
441
|
-
// Cancellation never implies rollback: a version that activated first makes the run a success
|
|
442
|
-
|
|
443
|
-
if (version.status === ZEROPS_ACTIVE) {
|
|
444
|
-
try {
|
|
445
|
-
await reconcileActiveSchema(input, signal)
|
|
446
|
-
} catch {
|
|
447
|
-
signal.throwIfAborted()
|
|
448
|
-
return { state: 'pending' }
|
|
449
|
-
}
|
|
450
|
-
return { state: 'settled', outcome: 'succeeded' }
|
|
451
|
-
}
|
|
405
|
+
// Cancellation never implies rollback: a version that activated first makes the run a success.
|
|
406
|
+
if (version.status === ZEROPS_ACTIVE) return { state: 'settled', outcome: 'succeeded' }
|
|
452
407
|
if (version.status !== undefined && ZEROPS_TERMINAL.has(version.status)) return { state: 'settled', outcome: 'failed' }
|
|
453
408
|
await cancelBuildQuietly(checkpoint.appVersionId, signal)
|
|
454
409
|
// A build request that never landed leaves the version UPLOADING for good; the deadline settles it.
|
|
@@ -485,10 +440,7 @@ export const createZeropsControlProvider = (options: ZeropsControlProviderOption
|
|
|
485
440
|
}
|
|
486
441
|
if (version === null) return { state: 'failed' }
|
|
487
442
|
assertVersionCoordinates(input.environment, checkpoint.appVersionId, version)
|
|
488
|
-
if (version.status === ZEROPS_ACTIVE) {
|
|
489
|
-
await reconcileActiveSchema(input, signal)
|
|
490
|
-
return { state: 'succeeded' }
|
|
491
|
-
}
|
|
443
|
+
if (version.status === ZEROPS_ACTIVE) return { state: 'succeeded' }
|
|
492
444
|
if (version.status !== undefined && ZEROPS_TERMINAL.has(version.status)) return { state: 'failed' }
|
|
493
445
|
if (pastDeadline(input.startedAtMs)) {
|
|
494
446
|
await cancelBuildQuietly(checkpoint.appVersionId, signal)
|