@fabrika/provider-cloudflare 0.9.0-dev.12 → 0.9.0-dev.14
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 +11 -11
- package/src/checkout.ts +2 -0
- package/src/cli.ts +3 -2
- package/src/command.ts +41 -8
- package/src/control.ts +1 -0
- package/src/installation/init-options.ts +13 -58
- package/src/installation/templates/README.md +1 -1
- package/src/provider.ts +31 -6
- package/src/runner-protocol.ts +7 -0
- package/types/src/command.d.ts +10 -1
- package/types/src/runner-protocol.d.ts +10 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/provider-cloudflare",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"zod": "^3.25.76",
|
|
46
|
-
"@fabrika/app": "0.9.0-dev.
|
|
47
|
-
"@fabrika/auth": "0.9.0-dev.
|
|
48
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
49
|
-
"@fabrika/check": "0.9.0-dev.
|
|
50
|
-
"@fabrika/email": "0.9.0-dev.
|
|
51
|
-
"@fabrika/iam-contract": "0.9.0-dev.
|
|
52
|
-
"@fabrika/installation-init": "0.9.0-dev.
|
|
53
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
54
|
-
"@fabrika/provider-contract": "0.9.0-dev.
|
|
46
|
+
"@fabrika/app": "0.9.0-dev.14",
|
|
47
|
+
"@fabrika/auth": "0.9.0-dev.14",
|
|
48
|
+
"@fabrika/auth-core": "0.9.0-dev.14",
|
|
49
|
+
"@fabrika/check": "0.9.0-dev.14",
|
|
50
|
+
"@fabrika/email": "0.9.0-dev.14",
|
|
51
|
+
"@fabrika/iam-contract": "0.9.0-dev.14",
|
|
52
|
+
"@fabrika/installation-init": "0.9.0-dev.14",
|
|
53
|
+
"@fabrika/proxy-core": "0.9.0-dev.14",
|
|
54
|
+
"@fabrika/provider-contract": "0.9.0-dev.14",
|
|
55
55
|
"ignore": "^5.3.2",
|
|
56
|
-
"oblaka-iac": "^0.0.
|
|
56
|
+
"oblaka-iac": "^0.0.22"
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/checkout.ts
CHANGED
|
@@ -36,6 +36,8 @@ export const runnerWorkerGraph = (value: unknown, path: readonly unknown[] = [])
|
|
|
36
36
|
const bindings: Record<string, Binding> = {}
|
|
37
37
|
for (const [key, binding] of Object.entries(typeof authored === 'object' && authored !== null ? authored : {})) {
|
|
38
38
|
const resolved: unknown = binding
|
|
39
|
+
// oblaka skips these entries, so the rebuilt graph leaves them out.
|
|
40
|
+
if (resolved === false || resolved === null || resolved === undefined) continue
|
|
39
41
|
if (isWorkerResource(resolved)) bindings[key] = runnerWorkerGraph(resolved, [...path, value])
|
|
40
42
|
else if (isBinding(resolved)) bindings[key] = resolved
|
|
41
43
|
else throw new Error(`cloudflare: Worker \`${name}\` binding \`${key}\` is not an oblaka binding`)
|
package/src/cli.ts
CHANGED
|
@@ -14,11 +14,12 @@ Usage:
|
|
|
14
14
|
Options:
|
|
15
15
|
--env=<env> Target environment.
|
|
16
16
|
--config=<path> App config path (default: ./fabrika.config.ts).
|
|
17
|
-
--managed-var=<name> Platform-owned environment name; repeatable.
|
|
17
|
+
--managed-var=<name> Platform-owned environment name; repeatable. Its value is read like a declared secret.
|
|
18
18
|
--dry-run Plan only; do not mutate remote resources.
|
|
19
19
|
-h, --help Show this help.
|
|
20
20
|
|
|
21
|
-
Credentials
|
|
21
|
+
Credentials are read only from the environment. Declared secrets and vars are read from the file
|
|
22
|
+
FABRIKA_DEPLOY_VALUES_FILE names when it is set (a runner sets it), and from the environment otherwise.
|
|
22
23
|
`
|
|
23
24
|
|
|
24
25
|
const die = (message: string): never => {
|
package/src/command.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
applicationObjectsSchema,
|
|
10
10
|
APPROVED_ACCESS_FILE_ENV,
|
|
11
11
|
CROSS_ORIGINS_ENV,
|
|
12
|
+
DEPLOY_VALUES_FILE_ENV,
|
|
12
13
|
INSTALLATION_APPS_ENV,
|
|
13
14
|
OPERATIONS_ORIGIN_ENV,
|
|
14
15
|
type RunnerApprovedAccess,
|
|
@@ -23,10 +24,13 @@ const requiredEnvironmentValue = (name: string): string => {
|
|
|
23
24
|
return value
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
/** Where the executor looks up an application-authored name: the runner's values file, or the environment outside a runner. */
|
|
28
|
+
export type DeployValueLookup = (name: string) => string | undefined
|
|
29
|
+
|
|
30
|
+
const declaredValues = (names: readonly string[] | undefined, lookup: DeployValueLookup): Record<string, string> => {
|
|
27
31
|
const values: Record<string, string> = {}
|
|
28
32
|
for (const name of names ?? []) {
|
|
29
|
-
const value =
|
|
33
|
+
const value = lookup(name)
|
|
30
34
|
if (value !== undefined && value !== '') {
|
|
31
35
|
values[name] = value
|
|
32
36
|
}
|
|
@@ -36,10 +40,12 @@ const declaredValues = (names: readonly string[] | undefined): Record<string, st
|
|
|
36
40
|
|
|
37
41
|
const environmentValue = (name: string): string | undefined => process.env[name]
|
|
38
42
|
|
|
39
|
-
const requiredValues = (names: readonly string[] | undefined): Record<string, string> => {
|
|
43
|
+
const requiredValues = (names: readonly string[] | undefined, lookup: DeployValueLookup): Record<string, string> => {
|
|
40
44
|
const values: Record<string, string> = {}
|
|
41
45
|
for (const name of names ?? []) {
|
|
42
|
-
|
|
46
|
+
const value = lookup(name)
|
|
47
|
+
if (value === undefined || value === '') throw new Error(`Missing ${name} value`)
|
|
48
|
+
values[name] = value
|
|
43
49
|
}
|
|
44
50
|
return values
|
|
45
51
|
}
|
|
@@ -131,6 +137,32 @@ export const readApprovedAccess = async (path: string | undefined): Promise<Runn
|
|
|
131
137
|
return access.data
|
|
132
138
|
}
|
|
133
139
|
|
|
140
|
+
/**
|
|
141
|
+
* The lookup for application-authored names. A runner names its values file in `FABRIKA_DEPLOY_VALUES_FILE`, and then
|
|
142
|
+
* every secret, var and managed value comes from that file alone, never from the process environment; a deploy outside a
|
|
143
|
+
* runner reads them from the environment. A file that is unreadable or malformed fails the deploy. Values never reach
|
|
144
|
+
* an error message.
|
|
145
|
+
*/
|
|
146
|
+
export const readDeployValues = async (path: string | undefined): Promise<DeployValueLookup> => {
|
|
147
|
+
if (path === undefined || path === '') return environmentValue
|
|
148
|
+
let decoded: unknown
|
|
149
|
+
try {
|
|
150
|
+
decoded = JSON.parse(await readFile(path, 'utf8'))
|
|
151
|
+
} catch {
|
|
152
|
+
throw new Error(`${DEPLOY_VALUES_FILE_ENV} does not name a readable JSON file`)
|
|
153
|
+
}
|
|
154
|
+
if (typeof decoded !== 'object' || decoded === null || Array.isArray(decoded)) {
|
|
155
|
+
throw new Error(`${DEPLOY_VALUES_FILE_ENV} does not hold an object of names to values`)
|
|
156
|
+
}
|
|
157
|
+
// A Map, so a name such as `__proto__` stays a name.
|
|
158
|
+
const values = new Map<string, string>()
|
|
159
|
+
for (const [name, value] of Object.entries(decoded)) {
|
|
160
|
+
if (typeof value !== 'string') throw new Error(`${DEPLOY_VALUES_FILE_ENV} does not hold an object of names to values`)
|
|
161
|
+
values.set(name, value)
|
|
162
|
+
}
|
|
163
|
+
return (name) => values.get(name)
|
|
164
|
+
}
|
|
165
|
+
|
|
134
166
|
/** The approved access as the deployer takes it: the contract Control read at the commit, and its application's digest. */
|
|
135
167
|
const approvedRun = (access: RunnerApprovedAccess | undefined): { readonly approved?: RunnerApprovedAccess } =>
|
|
136
168
|
access === undefined ? {} : { approved: access }
|
|
@@ -159,11 +191,12 @@ export interface CloudflareCommandDeployOptions {
|
|
|
159
191
|
readonly log?: (line: string) => void
|
|
160
192
|
}
|
|
161
193
|
|
|
162
|
-
/** Deploy one config with the account credentials, declared secrets and vars
|
|
194
|
+
/** Deploy one config with the account credentials from the environment, and declared secrets and vars from `readDeployValues`. */
|
|
163
195
|
export const deployCloudflareConfig = async (options: CloudflareCommandDeployOptions): Promise<CloudflareDeployResult> => {
|
|
164
196
|
const cwd = options.cwd ?? process.cwd()
|
|
165
197
|
// Before the config runs: loading it executes the checkout's code.
|
|
166
198
|
const approved = approvedRun(await readApprovedAccess(environmentValue(APPROVED_ACCESS_FILE_ENV)))
|
|
199
|
+
const authored = await readDeployValues(environmentValue(DEPLOY_VALUES_FILE_ENV))
|
|
167
200
|
const loaded = await loadCloudflareCommandConfig(options.configPath ?? './fabrika.config.ts', cwd)
|
|
168
201
|
const deploy = createCloudflareDeployer({
|
|
169
202
|
accountId: requiredEnvironmentValue('CLOUDFLARE_ACCOUNT_ID'),
|
|
@@ -190,10 +223,10 @@ export const deployCloudflareConfig = async (options: CloudflareCommandDeployOpt
|
|
|
190
223
|
cwd: loaded.cwd,
|
|
191
224
|
configPath: loaded.absolutePath,
|
|
192
225
|
...(options.stateNamespace === undefined ? {} : { stateNamespace: options.stateNamespace }),
|
|
193
|
-
secrets: declaredValues(loaded.config.pipeline?.secrets),
|
|
194
|
-
vars: declaredValues(loaded.config.pipeline?.vars),
|
|
226
|
+
secrets: declaredValues(loaded.config.pipeline?.secrets, authored),
|
|
227
|
+
vars: declaredValues(loaded.config.pipeline?.vars, authored),
|
|
195
228
|
// The runner hands what Control handed its job; parsed here, where it enters the executor.
|
|
196
|
-
managedEnvironment: parseManagedEnvironment(requiredValues(options.managedVarNames)),
|
|
229
|
+
managedEnvironment: parseManagedEnvironment(requiredValues(options.managedVarNames, authored)),
|
|
197
230
|
dryRun: options.dryRun ?? false,
|
|
198
231
|
signal: options.signal ?? new AbortController().signal,
|
|
199
232
|
log: options.log ?? ((line) => console.log(line)),
|
package/src/control.ts
CHANGED
|
@@ -387,6 +387,7 @@ export const createCloudflareControlProvider = (options: CloudflareControlOption
|
|
|
387
387
|
dataOperations: (access) => servesOps(applicationRelease(access)) && servesDataOperations(applicationRelease(access)),
|
|
388
388
|
normalizeRegistration,
|
|
389
389
|
applicationRoot: (source) => checkoutRelativeDirectory(source.workerDir),
|
|
390
|
+
applicationDialect: 'sqlite',
|
|
390
391
|
source: { binding: 'connection' },
|
|
391
392
|
resolveSource: async (input) => {
|
|
392
393
|
input.signal.throwIfAborted()
|
|
@@ -8,13 +8,21 @@
|
|
|
8
8
|
|
|
9
9
|
import { builtinEmailProviders } from '@fabrika/email/providers'
|
|
10
10
|
import {
|
|
11
|
+
checkedOidcIssuer,
|
|
11
12
|
CHECKOUT_FLAG,
|
|
12
13
|
type CommandEnv,
|
|
13
14
|
EMAIL_FLAGS,
|
|
14
15
|
type InstallationEmail,
|
|
16
|
+
OIDC_CLIENT_ID_FLAG,
|
|
17
|
+
OIDC_CLIENT_ID_INPUT,
|
|
18
|
+
OIDC_CLIENT_SECRET_INPUT,
|
|
19
|
+
OIDC_ISSUER_FLAG,
|
|
20
|
+
OIDC_ISSUER_INPUT,
|
|
21
|
+
readAuthMethods,
|
|
15
22
|
readEnv,
|
|
16
23
|
readFlag,
|
|
17
24
|
readInstallationEmail,
|
|
25
|
+
refuseFlags,
|
|
18
26
|
requiredSetting,
|
|
19
27
|
setting,
|
|
20
28
|
shellWord,
|
|
@@ -83,8 +91,6 @@ const FLAGS = [
|
|
|
83
91
|
|
|
84
92
|
const REPO_PATTERN = /^[^/\s]+\/[^/\s]+$/
|
|
85
93
|
|
|
86
|
-
const AUTH_METHODS = ['oidc', 'password'] as const
|
|
87
|
-
|
|
88
94
|
const assertKnownArguments = (argv: readonly string[]): void => {
|
|
89
95
|
for (const arg of argv) {
|
|
90
96
|
if (arg === UNATTENDED_FLAG || !arg.startsWith('-')) {
|
|
@@ -162,60 +168,9 @@ const parseList = (raw: string | undefined, flag: string, variable: string): str
|
|
|
162
168
|
return parsed.data.map((item) => item.trim()).filter((item) => item !== '')
|
|
163
169
|
}
|
|
164
170
|
|
|
165
|
-
const parseBoolean = (value: string, name: string): boolean => {
|
|
166
|
-
if (value === 'true') return true
|
|
167
|
-
if (value === 'false') return false
|
|
168
|
-
throw new Error(`${name} must be true or false`)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
interface AuthMethods {
|
|
172
|
-
readonly oidcEnabled: boolean
|
|
173
|
-
readonly passwordEnabled: boolean
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/** `--auth-methods`, or the pair of switches the Environment carries. */
|
|
177
|
-
const readAuthMethods = (argv: readonly string[], env: CommandEnv): AuthMethods => {
|
|
178
|
-
const flag = readFlag(argv, '--auth-methods')
|
|
179
|
-
if (flag !== undefined) {
|
|
180
|
-
const methods = flag.split(',').map((item) => item.trim())
|
|
181
|
-
const unknown = methods.find((method) => !AUTH_METHODS.some((known) => known === method))
|
|
182
|
-
if (unknown !== undefined || methods.length > AUTH_METHODS.length) {
|
|
183
|
-
throw new Error(`--auth-methods takes oidc, password, or oidc,password — not \`${flag}\``)
|
|
184
|
-
}
|
|
185
|
-
return { oidcEnabled: methods.includes('oidc'), passwordEnabled: methods.includes('password') }
|
|
186
|
-
}
|
|
187
|
-
const oidc = readEnv(env, 'FABRIKA_IAM_OIDC_ENABLED')
|
|
188
|
-
const password = readEnv(env, 'FABRIKA_IAM_PASSWORD_ENABLED')
|
|
189
|
-
if (oidc === undefined && password === undefined) {
|
|
190
|
-
throw new Error('--auth-methods=<oidc|password|oidc,password> or FABRIKA_IAM_OIDC_ENABLED + FABRIKA_IAM_PASSWORD_ENABLED is required')
|
|
191
|
-
}
|
|
192
|
-
if (oidc === undefined || password === undefined) {
|
|
193
|
-
throw new Error('FABRIKA_IAM_OIDC_ENABLED and FABRIKA_IAM_PASSWORD_ENABLED must be configured together')
|
|
194
|
-
}
|
|
195
|
-
const methods = {
|
|
196
|
-
oidcEnabled: parseBoolean(oidc, 'FABRIKA_IAM_OIDC_ENABLED'),
|
|
197
|
-
passwordEnabled: parseBoolean(password, 'FABRIKA_IAM_PASSWORD_ENABLED'),
|
|
198
|
-
}
|
|
199
|
-
if (!methods.oidcEnabled && !methods.passwordEnabled) {
|
|
200
|
-
throw new Error('At least one IAM authentication method must be enabled')
|
|
201
|
-
}
|
|
202
|
-
return methods
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/** A flag that only means something under a selection the run did not make is refused, not ignored. */
|
|
206
|
-
const refuseFlags = (argv: readonly string[], flags: readonly string[], why: string): void => {
|
|
207
|
-
const given = flags.find((flag) => readFlag(argv, flag) !== undefined)
|
|
208
|
-
if (given !== undefined) {
|
|
209
|
-
throw new Error(`${given} was given, but ${why}`)
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
171
|
const readOidc = (argv: readonly string[], env: CommandEnv): OidcInput => {
|
|
214
|
-
const issuer = setting(argv, env,
|
|
215
|
-
|
|
216
|
-
throw new Error(`--oidc-issuer / FABRIKA_IAM_OIDC_ISSUER is not a URL: \`${issuer}\``)
|
|
217
|
-
}
|
|
218
|
-
const clientId = setting(argv, env, '--oidc-client-id', 'FABRIKA_IAM_OIDC_CLIENT_ID') ?? PLACEHOLDER_OIDC_CLIENT_ID
|
|
172
|
+
const issuer = checkedOidcIssuer(setting(argv, env, OIDC_ISSUER_FLAG, OIDC_ISSUER_INPUT) ?? DEFAULT_OIDC_ISSUER)
|
|
173
|
+
const clientId = setting(argv, env, OIDC_CLIENT_ID_FLAG, OIDC_CLIENT_ID_INPUT) ?? PLACEHOLDER_OIDC_CLIENT_ID
|
|
219
174
|
const humanEmailDomains = parseList(
|
|
220
175
|
setting(argv, env, '--human-email-domains', 'FABRIKA_IAM_HUMAN_EMAIL_DOMAINS'),
|
|
221
176
|
'--human-email-domains',
|
|
@@ -225,14 +180,14 @@ const readOidc = (argv: readonly string[], env: CommandEnv): OidcInput => {
|
|
|
225
180
|
return {
|
|
226
181
|
issuer,
|
|
227
182
|
clientId,
|
|
228
|
-
clientSecret: readEnv(env,
|
|
183
|
+
clientSecret: readEnv(env, OIDC_CLIENT_SECRET_INPUT) ?? PLACEHOLDER_OIDC_CLIENT_SECRET,
|
|
229
184
|
humanEmailDomains,
|
|
230
185
|
}
|
|
231
186
|
}
|
|
232
|
-
const clientSecret = credential(env,
|
|
187
|
+
const clientSecret = credential(env, OIDC_CLIENT_SECRET_INPUT, `the OIDC client secret for client ${clientId}`)
|
|
233
188
|
if (clientSecret === PLACEHOLDER_OIDC_CLIENT_SECRET) {
|
|
234
189
|
throw new Error(
|
|
235
|
-
|
|
190
|
+
`${OIDC_CLIENT_SECRET_INPUT} still holds the placeholder secret, but client ${clientId} is a real one. `
|
|
236
191
|
+ 'Set the real secret in the environment',
|
|
237
192
|
)
|
|
238
193
|
}
|
|
@@ -50,7 +50,7 @@ the Environment with its secrets and variables, and triggers the workflow. The r
|
|
|
50
50
|
runner container image into the account.
|
|
51
51
|
|
|
52
52
|
Public repositories deploy without a GitHub App. To deploy private repositories, connect GitHub from the
|
|
53
|
-
control plane at **Settings → Source**: each connection is an organization
|
|
53
|
+
control plane at **Settings → Source**: each connection is a GitHub App owned by an organization or a personal account, whose key
|
|
54
54
|
Control keeps in its encrypted vault, never in this Environment.
|
|
55
55
|
|
|
56
56
|
To close the escape hatch once IAM grants you admin, set the `{{ACCOUNT}}` Environment variable
|
package/src/provider.ts
CHANGED
|
@@ -64,6 +64,23 @@ const CANCELLED = 'deploy cancelled'
|
|
|
64
64
|
/** Every credential the platform hands the executor. The checkout's own build step must inherit none of them. */
|
|
65
65
|
const PLATFORM_CREDENTIAL_NAMES: readonly string[] = ['CLOUDFLARE_API_TOKEN', 'CLOUDFLARE_ACCOUNT_ID', 'FABRIKA_IAM_PROVISIONING_KEY']
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* What the checkout's build step gets of the run's values, over what it inherits: the secrets and vars the checkout's
|
|
69
|
+
* config declares and the managed environment, as the runner once handed them through the executor's environment. An
|
|
70
|
+
* undeclared name a secret's author chose never reaches it, and no value replaces a platform credential name.
|
|
71
|
+
*/
|
|
72
|
+
const buildEnvironment = (run: CloudflareDeployRun): Record<string, string> => {
|
|
73
|
+
const env: Record<string, string> = {}
|
|
74
|
+
for (const [name, value] of Object.entries(run.secrets)) env[name] = value
|
|
75
|
+
for (const [name, value] of Object.entries(run.vars)) env[name] = value
|
|
76
|
+
for (const name of Object.keys(run.managedEnvironment)) {
|
|
77
|
+
const value = managedValue(run.managedEnvironment, name)
|
|
78
|
+
if (value !== null) env[name] = value
|
|
79
|
+
}
|
|
80
|
+
for (const name of PLATFORM_CREDENTIAL_NAMES) delete env[name]
|
|
81
|
+
return env
|
|
82
|
+
}
|
|
83
|
+
|
|
67
84
|
const workerDir = (config: CloudflareAppConfig, cwd: string): string => resolve(cwd, config.pipeline?.workerDir ?? '.')
|
|
68
85
|
|
|
69
86
|
/** The KV namespace oblaka keeps deploy state in. One definition, so the check and the call cannot drift. */
|
|
@@ -226,8 +243,9 @@ const isWithin = (root: string, dir: string): boolean => {
|
|
|
226
243
|
}
|
|
227
244
|
|
|
228
245
|
/**
|
|
229
|
-
* The executor
|
|
230
|
-
* failed output reaches the log: it inherits nothing and gets only
|
|
246
|
+
* The executor holds the platform credentials in its environment and the run's application and managed secrets in
|
|
247
|
+
* memory, and the CLI is checkout code whose failed output reaches the log: it inherits nothing and gets only
|
|
248
|
+
* `ENTRY_BUILD_VARIABLES`.
|
|
231
249
|
*/
|
|
232
250
|
const entryBuildEnvironment = (): { readonly env: Record<string, string>; readonly omitEnv: readonly string[] } => {
|
|
233
251
|
const env: Record<string, string> = {}
|
|
@@ -311,8 +329,8 @@ const connectorBindings = (contract: ContractArtifact | null): Readonly<Record<s
|
|
|
311
329
|
const withIamIdentity = (authored: Worker, iamAppId: string): Worker => {
|
|
312
330
|
const application = applicationWorker(authored)
|
|
313
331
|
const declared = application.options.bindings?.['IAM']
|
|
314
|
-
// A resource under the name is no IAM binding; oblaka provisions it, and the bounds check whatever it emits.
|
|
315
|
-
if (declared
|
|
332
|
+
// A skipped binding or a resource under the name is no IAM binding; oblaka provisions it, and the bounds check whatever it emits.
|
|
333
|
+
if (!declared || 'getId' in declared) return authored
|
|
316
334
|
const configured = new Worker({
|
|
317
335
|
...application.options,
|
|
318
336
|
bindings: { ...application.options.bindings, IAM: new IamApplicationReference(iamAppId, 'application', declared) },
|
|
@@ -370,7 +388,7 @@ const assertContractSchema = (schema: AppSchema | null, contract: ContractArtifa
|
|
|
370
388
|
* `ops` adds Control's ops row to the table.
|
|
371
389
|
*/
|
|
372
390
|
const platformProxied = (authored: Worker, served: ServedContract, run: ApplicationTarget, ops: boolean): Worker => {
|
|
373
|
-
if (authored.options.bindings?.['APP']
|
|
391
|
+
if (authored.options.bindings?.['APP']) {
|
|
374
392
|
throw new Error(
|
|
375
393
|
`cloudflare: \`resources\` returns the Worker \`${authored.options.name}\` binding \`APP\`, a proxy of its own; return the application Worker, and the platform builds the proxy Worker from its contract`,
|
|
376
394
|
)
|
|
@@ -552,7 +570,14 @@ const runStep = async (spec: CloudflareStep, env: StepEnv): Promise<void> => {
|
|
|
552
570
|
run.log(` [dry-run] would run build: \`${build}\` in ${dir}`)
|
|
553
571
|
} else if (build !== undefined) {
|
|
554
572
|
assertRunning(signal)
|
|
555
|
-
const result = await cf.runCommand({
|
|
573
|
+
const result = await cf.runCommand({
|
|
574
|
+
command: 'sh',
|
|
575
|
+
args: ['-c', build],
|
|
576
|
+
cwd: dir,
|
|
577
|
+
env: buildEnvironment(run),
|
|
578
|
+
omitEnv: PLATFORM_CREDENTIAL_NAMES,
|
|
579
|
+
signal,
|
|
580
|
+
})
|
|
556
581
|
if (result.exitCode !== 0) throw commandError(`build (\`${build}\`)`, result)
|
|
557
582
|
}
|
|
558
583
|
if (env.entryBuild !== null) await buildEntry(env.entryBuild, run, cf)
|
package/src/runner-protocol.ts
CHANGED
|
@@ -88,6 +88,13 @@ export const runnerApprovedAccessSchema = z.object({
|
|
|
88
88
|
/** Where the runner leaves the job's `RunnerApprovedAccess` as JSON for the executor — beside the checkout, never inside it. */
|
|
89
89
|
export const APPROVED_ACCESS_FILE_ENV = 'FABRIKA_APPROVED_ACCESS_FILE'
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Where the runner leaves the job's secrets, vars and managed environment as one JSON object of names to values, beside
|
|
93
|
+
* the checkout and never inside it. Those names are the application's own, so they never enter the executor's process
|
|
94
|
+
* environment: there a name could steer the runtime that holds the account credential, or replace the credential.
|
|
95
|
+
*/
|
|
96
|
+
export const DEPLOY_VALUES_FILE_ENV = 'FABRIKA_DEPLOY_VALUES_FILE'
|
|
97
|
+
|
|
91
98
|
/** The terminal and in-progress status polled from the container, and persisted by the runner Worker once terminal. */
|
|
92
99
|
export const runnerStatusSchema = z.object({
|
|
93
100
|
runId: z.string(),
|
package/types/src/command.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { type AppEnvironment, type ApplicationObjects } from '@fabrika/auth-core
|
|
|
2
2
|
import type { CloudflareAppConfig } from './authoring';
|
|
3
3
|
import { type CloudflareDeployResult, type PlatformIamTarget } from './provider';
|
|
4
4
|
import { type RunnerApprovedAccess } from './runner-protocol';
|
|
5
|
+
/** Where the executor looks up an application-authored name: the runner's values file, or the environment outside a runner. */
|
|
6
|
+
export type DeployValueLookup = (name: string) => string | undefined;
|
|
5
7
|
/**
|
|
6
8
|
* Decode `FABRIKA_IAM_RETURN_ORIGINS`, the comma-separated set the installation's workflow hands the
|
|
7
9
|
* platform's own deploy (ADR-0022). Undefined for an absent or empty value, so a deploy with nothing to
|
|
@@ -30,6 +32,13 @@ export declare const parseInstallationApps: (raw: string | undefined) => readonl
|
|
|
30
32
|
* rather than falling back to the checkout.
|
|
31
33
|
*/
|
|
32
34
|
export declare const readApprovedAccess: (path: string | undefined) => Promise<RunnerApprovedAccess | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* The lookup for application-authored names. A runner names its values file in `FABRIKA_DEPLOY_VALUES_FILE`, and then
|
|
37
|
+
* every secret, var and managed value comes from that file alone, never from the process environment; a deploy outside a
|
|
38
|
+
* runner reads them from the environment. A file that is unreadable or malformed fails the deploy. Values never reach
|
|
39
|
+
* an error message.
|
|
40
|
+
*/
|
|
41
|
+
export declare const readDeployValues: (path: string | undefined) => Promise<DeployValueLookup>;
|
|
33
42
|
export interface LoadedCloudflareCommandConfig {
|
|
34
43
|
readonly config: CloudflareAppConfig;
|
|
35
44
|
readonly absolutePath: string;
|
|
@@ -50,5 +59,5 @@ export interface CloudflareCommandDeployOptions {
|
|
|
50
59
|
readonly signal?: AbortSignal;
|
|
51
60
|
readonly log?: (line: string) => void;
|
|
52
61
|
}
|
|
53
|
-
/** Deploy one config with the account credentials, declared secrets and vars
|
|
62
|
+
/** Deploy one config with the account credentials from the environment, and declared secrets and vars from `readDeployValues`. */
|
|
54
63
|
export declare const deployCloudflareConfig: (options: CloudflareCommandDeployOptions) => Promise<CloudflareDeployResult>;
|
|
@@ -86,6 +86,12 @@ export declare const runnerApprovedAccessSchema: z.ZodEffects<z.ZodObject<{
|
|
|
86
86
|
}>;
|
|
87
87
|
/** Where the runner leaves the job's `RunnerApprovedAccess` as JSON for the executor — beside the checkout, never inside it. */
|
|
88
88
|
export declare const APPROVED_ACCESS_FILE_ENV = "FABRIKA_APPROVED_ACCESS_FILE";
|
|
89
|
+
/**
|
|
90
|
+
* Where the runner leaves the job's secrets, vars and managed environment as one JSON object of names to values, beside
|
|
91
|
+
* the checkout and never inside it. Those names are the application's own, so they never enter the executor's process
|
|
92
|
+
* environment: there a name could steer the runtime that holds the account credential, or replace the credential.
|
|
93
|
+
*/
|
|
94
|
+
export declare const DEPLOY_VALUES_FILE_ENV = "FABRIKA_DEPLOY_VALUES_FILE";
|
|
89
95
|
/** The terminal and in-progress status polled from the container, and persisted by the runner Worker once terminal. */
|
|
90
96
|
export declare const runnerStatusSchema: z.ZodObject<{
|
|
91
97
|
runId: z.ZodString;
|
|
@@ -108,26 +114,26 @@ export declare const runnerStatusSchema: z.ZodObject<{
|
|
|
108
114
|
startedAt: z.ZodNumber;
|
|
109
115
|
finishedAt: z.ZodOptional<z.ZodNumber>;
|
|
110
116
|
}, "strip", z.ZodTypeAny, {
|
|
111
|
-
state: "
|
|
117
|
+
state: "pending" | "succeeded" | "failed" | "cloning" | "installing" | "deploying";
|
|
112
118
|
runId: string;
|
|
113
119
|
startedAt: number;
|
|
114
120
|
error?: string | undefined;
|
|
115
121
|
dryRun?: boolean | undefined;
|
|
116
122
|
exitCode?: number | undefined;
|
|
117
|
-
artifactState?: "
|
|
123
|
+
artifactState?: "complete" | "incomplete" | "not_applicable" | undefined;
|
|
118
124
|
iamReconcile?: {
|
|
119
125
|
app: string;
|
|
120
126
|
schemaJson: string;
|
|
121
127
|
} | undefined;
|
|
122
128
|
finishedAt?: number | undefined;
|
|
123
129
|
}, {
|
|
124
|
-
state: "
|
|
130
|
+
state: "pending" | "succeeded" | "failed" | "cloning" | "installing" | "deploying";
|
|
125
131
|
runId: string;
|
|
126
132
|
startedAt: number;
|
|
127
133
|
error?: string | undefined;
|
|
128
134
|
dryRun?: boolean | undefined;
|
|
129
135
|
exitCode?: number | undefined;
|
|
130
|
-
artifactState?: "
|
|
136
|
+
artifactState?: "complete" | "incomplete" | "not_applicable" | undefined;
|
|
131
137
|
iamReconcile?: {
|
|
132
138
|
app: string;
|
|
133
139
|
schemaJson: string;
|