@di-framework/cli-plugin-platform 6.2.0 → 6.3.0
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/README.md +10 -0
- package/dist/args.d.ts +8 -0
- package/dist/args.js +73 -28
- package/dist/assets/platform/README.md +68 -19
- package/dist/assets/platform/index.ts.tmpl +1 -1
- package/dist/assets/platform/tsconfig.json +2 -2
- package/dist/assets/sqlite/BUILD-INFO.txt +1 -1
- package/dist/build.js +17 -4
- package/dist/bundle.d.ts +85 -0
- package/dist/bundle.js +608 -0
- package/dist/command.js +85 -3
- package/dist/console/cluster.d.ts +4 -2
- package/dist/console/cluster.js +38 -40
- package/dist/controller/client.d.ts +47 -0
- package/dist/controller/client.js +157 -0
- package/dist/controller/commands.d.ts +48 -0
- package/dist/controller/commands.js +584 -0
- package/dist/controller/credentials.d.ts +63 -0
- package/dist/controller/credentials.js +156 -0
- package/dist/controller/index.d.ts +6 -0
- package/dist/controller/index.js +6 -0
- package/dist/controller/oidc.d.ts +54 -0
- package/dist/controller/oidc.js +121 -0
- package/dist/controller/registry.d.ts +15 -0
- package/dist/controller/registry.js +47 -0
- package/dist/controller/schema.d.ts +157 -0
- package/dist/controller/schema.js +1 -0
- package/dist/controller/sse.d.ts +12 -0
- package/dist/controller/sse.js +61 -0
- package/dist/controller/trust.d.ts +14 -0
- package/dist/controller/trust.js +39 -0
- package/dist/deploy.d.ts +8 -1
- package/dist/deploy.js +89 -2
- package/dist/deps.d.ts +4 -0
- package/dist/destroy.js +26 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/manifest.d.ts +45 -1
- package/dist/manifest.js +197 -4
- package/dist/pglite.d.ts +12 -2
- package/dist/pglite.js +19 -11
- package/dist/publish.d.ts +7 -1
- package/dist/publish.js +33 -1
- package/dist/service.d.ts +34 -0
- package/dist/service.js +156 -145
- package/dist/target.d.ts +7 -1
- package/dist/target.js +19 -0
- package/dist/workload.d.ts +17 -1
- package/dist/workload.js +44 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -768,6 +768,16 @@ ServiceBindings before applying the workload. Successful updates and workload
|
|
|
768
768
|
deletion remove obsolete deployment-owned associations. Shared projections stay
|
|
769
769
|
while other workloads use them.
|
|
770
770
|
|
|
771
|
+
`wasmcloud:postgres@0.2.0` has no transaction handle, and a `serviceName` binding
|
|
772
|
+
is a named import served from a connection pool with no connection affinity:
|
|
773
|
+
`BEGIN` sent as one call does not cover the next. Do not wrap the binding with
|
|
774
|
+
`createSqlDatabase`, which sends `BEGIN` and `COMMIT` as separate calls and leaves
|
|
775
|
+
a poisoned pool connection that fails subsequent overlapping requests. Statements
|
|
776
|
+
execute as independent transactions and row locks last one statement; keep atomic
|
|
777
|
+
work in single statements (conditional `UPDATE … RETURNING`, data-modifying CTEs)
|
|
778
|
+
or `query-batch` scripts, and use an autocommit adapter such as `identity-server`'s
|
|
779
|
+
(`apps/guest/src/database.ts`, `pg.ts`) or `@di-framework/repo/postgres`.
|
|
780
|
+
|
|
771
781
|
See [PostgreSQL storage, deletion, and recovery](../di-framework-platform/README.md#dedicated-postgresql-upcoming-release).
|
|
772
782
|
|
|
773
783
|
### Blobstore services
|
package/dist/args.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { DeployEnvironment } from './manifest.js';
|
|
1
2
|
export type AppCommandOptions = {
|
|
2
3
|
name?: string;
|
|
3
4
|
target?: string;
|
|
5
|
+
env?: DeployEnvironment;
|
|
6
|
+
preview?: boolean;
|
|
4
7
|
yes: boolean;
|
|
5
8
|
};
|
|
6
9
|
export type PlatformCommandOptions = {
|
|
@@ -8,6 +11,11 @@ export type PlatformCommandOptions = {
|
|
|
8
11
|
target?: string;
|
|
9
12
|
yes: boolean;
|
|
10
13
|
};
|
|
14
|
+
export declare function readStringFlag<K extends string>(args: readonly string[], position: number, token: string, flags: Readonly<Record<string, K>>, values: Partial<Record<K, string>>): number | undefined;
|
|
15
|
+
export declare function readEnvFlag(args: readonly string[], position: number, token: string, current: DeployEnvironment | undefined, command: string): {
|
|
16
|
+
value: DeployEnvironment;
|
|
17
|
+
nextPosition: number;
|
|
18
|
+
} | undefined;
|
|
11
19
|
export declare function parseAppCommandArgs(args: readonly string[], command: string): AppCommandOptions;
|
|
12
20
|
export type PlatformInitOptions = {
|
|
13
21
|
force: boolean;
|
package/dist/args.js
CHANGED
|
@@ -1,32 +1,73 @@
|
|
|
1
|
-
import { invalidUsage, readOptionValue } from './support.js';
|
|
1
|
+
import { invalidUsage, matchOption, readOptionValue } from './support.js';
|
|
2
|
+
export function readStringFlag(args, position, token, flags, values) {
|
|
3
|
+
for (const [flag, key] of Object.entries(flags)) {
|
|
4
|
+
const matched = matchOption(args, position, token, flag);
|
|
5
|
+
if (matched) {
|
|
6
|
+
if (values[key] !== undefined) {
|
|
7
|
+
invalidUsage(`Option may be provided only once: ${flag}`, flag);
|
|
8
|
+
}
|
|
9
|
+
values[key] = matched.value;
|
|
10
|
+
return matched.consumedThrough + 1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
export function readEnvFlag(args, position, token, current, command) {
|
|
16
|
+
const matched = matchOption(args, position, token, '--env');
|
|
17
|
+
if (!matched)
|
|
18
|
+
return undefined;
|
|
19
|
+
if (current !== undefined) {
|
|
20
|
+
invalidUsage('Option may be provided only once: --env', '--env');
|
|
21
|
+
}
|
|
22
|
+
if (matched.value !== 'prod' && matched.value !== 'staging') {
|
|
23
|
+
invalidUsage('--env must be prod or staging', matched.value, { command });
|
|
24
|
+
}
|
|
25
|
+
return { value: matched.value, nextPosition: matched.consumedThrough + 1 };
|
|
26
|
+
}
|
|
27
|
+
const APP_STRING_FLAGS = { '--target': 'target' };
|
|
2
28
|
export function parseAppCommandArgs(args, command) {
|
|
3
29
|
let name;
|
|
4
|
-
|
|
5
|
-
let
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
const values = {};
|
|
31
|
+
let env;
|
|
32
|
+
const flags = { preview: false, yes: false };
|
|
33
|
+
let position = 0;
|
|
34
|
+
while (position < args.length) {
|
|
35
|
+
const token = args[position];
|
|
36
|
+
const nextPos = readStringFlag(args, position, token, APP_STRING_FLAGS, values);
|
|
37
|
+
if (nextPos !== undefined) {
|
|
38
|
+
position = nextPos;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const envOpt = readEnvFlag(args, position, token, env, command);
|
|
42
|
+
if (envOpt) {
|
|
43
|
+
env = envOpt.value;
|
|
44
|
+
position = envOpt.nextPosition;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (token === '--preview' || token === '--yes') {
|
|
48
|
+
const key = token === '--preview' ? 'preview' : 'yes';
|
|
49
|
+
if (flags[key])
|
|
50
|
+
invalidUsage(`Option may be provided only once: ${token}`, token);
|
|
51
|
+
flags[key] = true;
|
|
52
|
+
position += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (token.startsWith('--')) {
|
|
56
|
+
invalidUsage(`Unknown option: ${token}`, token, { command });
|
|
57
|
+
}
|
|
58
|
+
if (name !== undefined) {
|
|
59
|
+
invalidUsage(`Unexpected argument: ${token}`, token, { command });
|
|
27
60
|
}
|
|
61
|
+
name = token;
|
|
62
|
+
position += 1;
|
|
28
63
|
}
|
|
29
|
-
return {
|
|
64
|
+
return {
|
|
65
|
+
name,
|
|
66
|
+
target: values.target,
|
|
67
|
+
...(env ? { env } : {}),
|
|
68
|
+
...(flags.preview ? { preview: true } : {}),
|
|
69
|
+
yes: flags.yes,
|
|
70
|
+
};
|
|
30
71
|
}
|
|
31
72
|
export function parsePlatformInitArgs(args) {
|
|
32
73
|
let force = false;
|
|
@@ -44,18 +85,21 @@ export function parsePlatformInitArgs(args) {
|
|
|
44
85
|
export function parsePlatformCommandArgs(args, command) {
|
|
45
86
|
let target;
|
|
46
87
|
let yes = false;
|
|
47
|
-
|
|
48
|
-
|
|
88
|
+
let position = 0;
|
|
89
|
+
while (position < args.length) {
|
|
90
|
+
const token = args[position];
|
|
49
91
|
if (token === '--yes') {
|
|
50
92
|
if (yes)
|
|
51
93
|
invalidUsage(`Option may be provided only once: ${token}`, token);
|
|
52
94
|
yes = true;
|
|
95
|
+
position += 1;
|
|
53
96
|
continue;
|
|
54
97
|
}
|
|
55
98
|
if (token === '--target') {
|
|
56
99
|
if (target !== undefined)
|
|
57
100
|
invalidUsage(`Option may be provided only once: ${token}`, token);
|
|
58
|
-
target = readOptionValue(args,
|
|
101
|
+
target = readOptionValue(args, position + 1, token);
|
|
102
|
+
position += 2;
|
|
59
103
|
continue;
|
|
60
104
|
}
|
|
61
105
|
if (token.startsWith('--')) {
|
|
@@ -65,6 +109,7 @@ export function parsePlatformCommandArgs(args, command) {
|
|
|
65
109
|
invalidUsage(`Unexpected argument: ${token}`, token, { command });
|
|
66
110
|
}
|
|
67
111
|
target = token;
|
|
112
|
+
position += 1;
|
|
68
113
|
}
|
|
69
114
|
return { ...(target === undefined ? {} : { target }), yes };
|
|
70
115
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
This generated Pulumi project provisions platform resources only:
|
|
4
4
|
|
|
5
|
-
- a pinned k0s controller/worker in a stack- and workspace-scoped
|
|
6
|
-
- stack-scoped
|
|
5
|
+
- a pinned k0s controller/worker in a stack- and workspace-scoped container network;
|
|
6
|
+
- stack-scoped container volumes for k0s state and pod logs;
|
|
7
7
|
- an in-cluster, pinned OCI registry exposed to the host only through loopback;
|
|
8
8
|
- wasmCloud runtime operator 2.8.0 and its default HTTP host group;
|
|
9
9
|
- a generic loopback HTTP entrypoint.
|
|
@@ -37,6 +37,33 @@ push address (`http://127.0.0.1:25000` by default) and cluster pull address
|
|
|
37
37
|
(`di-framework-registry.wasmcloud.svc.cluster.local:5000`) reach the same
|
|
38
38
|
registry content.
|
|
39
39
|
|
|
40
|
+
## Container engine
|
|
41
|
+
|
|
42
|
+
Docker is the default. To run the k0s container with Podman (or another
|
|
43
|
+
Docker-compatible CLI on `PATH`), set `containerCli` before the first deployment:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
pulumi config set containerCli podman
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The value must be a plain command name or path. Resources stay owned by the
|
|
50
|
+
engine that created them, so to switch engines destroy the platform first and
|
|
51
|
+
deploy again; that removes cluster state.
|
|
52
|
+
|
|
53
|
+
## Registry mirrors
|
|
54
|
+
|
|
55
|
+
To pull images through a mirror (for example when Docker Hub is rate limited or
|
|
56
|
+
unreachable from the container engine), set `registryMirrors` before the first
|
|
57
|
+
deployment. It maps a registry host to an ordered list of mirror URLs; containerd
|
|
58
|
+
tries each mirror and then the registry itself:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
pulumi config set --path 'registryMirrors["docker.io"][0]' https://mirror.gcr.io
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Unset means no mirrors. The `@di-framework/platform` README lists the accepted
|
|
65
|
+
values. Changing mirrors later requires destroying and redeploying the platform.
|
|
66
|
+
|
|
40
67
|
## Output contract
|
|
41
68
|
|
|
42
69
|
| Output | Meaning |
|
|
@@ -50,6 +77,7 @@ registry content.
|
|
|
50
77
|
| `endpoints.kubernetes` | loopback API server URL |
|
|
51
78
|
| `endpoints.registry` | loopback registry URL |
|
|
52
79
|
| `endpoints.http` | loopback HTTP URL |
|
|
80
|
+
| `kubeconfigs` | secret: `{ [tenant]: { [user]: kubeconfig } }`, one per user membership |
|
|
53
81
|
|
|
54
82
|
## Lifecycle
|
|
55
83
|
|
|
@@ -71,9 +99,14 @@ Send the configured project name as the HTTP `Host` header, for example:
|
|
|
71
99
|
curl -H 'Host: greeter' http://127.0.0.1:28180/
|
|
72
100
|
```
|
|
73
101
|
|
|
74
|
-
|
|
102
|
+
`pulumi up` checks the platform configuration (tenants, users, route aliases,
|
|
103
|
+
tenant auth, runtime NATS, insecure registries, the tenant host image) before it
|
|
104
|
+
creates anything, so invalid configuration fails without creating the k0s
|
|
105
|
+
container, network, or volumes.
|
|
106
|
+
|
|
107
|
+
Platform destroy removes only container-engine and Kubernetes resources bearing this
|
|
75
108
|
project/stack scope, along with the generated kubeconfig. It refuses to adopt
|
|
76
|
-
or replace an already-existing
|
|
109
|
+
or replace an already-existing container, network, or volume with the same name. Teardown
|
|
77
110
|
uses the `kubectl` bundled in the scoped k0s container, so no host-side
|
|
78
111
|
`kubectl` installation is needed for platform lifecycle commands.
|
|
79
112
|
|
|
@@ -107,8 +140,8 @@ are no additional platform CLI subcommands. Controller TypeScript is compiled to
|
|
|
107
140
|
JavaScript when Pulumi builds its ConfigMap; no custom container build is needed.
|
|
108
141
|
Run `bun run check` in this directory to check all generated TypeScript.
|
|
109
142
|
|
|
110
|
-
Each tenant gets `di-tenant-<name>` for workloads
|
|
111
|
-
host pool, Redis, and NATS. Host environments match the workload namespace, and
|
|
143
|
+
Each tenant gets `di-tenant-<name>` for workloads, `di-runtime-<name>` for its
|
|
144
|
+
host pool, Redis, and NATS, and `di-apikeys-<name>` for its API keys (no pods). Host environments match the workload namespace, and
|
|
112
145
|
`allowSharedHosts` is false. Runtime certificates remain in the runtime namespace.
|
|
113
146
|
Pulumi seeds these namespaces before Helm so the wasmCloud operator can watch
|
|
114
147
|
host pods there; the controller then manages their resources and lifecycle.
|
|
@@ -119,7 +152,8 @@ objects. Increase `resources.cpu` and `resources.memory` when increasing
|
|
|
119
152
|
`runtime.replicas`; these quotas cover runtime pods and aggregate
|
|
120
153
|
`requests.storage` (50Gi hard) for stock and future `di-bs-*` backends, not
|
|
121
154
|
individual Wasm invocations. Override concurrent service/binding counts with
|
|
122
|
-
`resources.backingServices` / `resources.serviceBindings`.
|
|
155
|
+
`resources.backingServices` / `resources.serviceBindings`. A tenant may hold
|
|
156
|
+
1000 API keys; override with `resources.apiKeys` (1–10000).
|
|
123
157
|
|
|
124
158
|
Users get a ServiceAccount in `wasmcloud` and tenant RoleBindings. Developers
|
|
125
159
|
can manage WorkloadDeployments, `BackingService`, `ServiceBinding`, ConfigMaps,
|
|
@@ -135,19 +169,22 @@ tenant; the platform does **not** claim finer credential isolation. Admission
|
|
|
135
169
|
still blocks CLI/API bypass for forged hostInterfaces and mutation of
|
|
136
170
|
controller-managed config (see `@di-framework/platform` README).
|
|
137
171
|
|
|
138
|
-
|
|
172
|
+
Each membership gets a kubeconfig built from a controller-managed ServiceAccount
|
|
173
|
+
token Secret (`di-user-<user>-<tenant>-token` in `wasmcloud`), with the loopback API
|
|
174
|
+
server, the cluster CA, and the tenant workload namespace selected. Pulumi reads it
|
|
175
|
+
once the User is Ready and exports it in the secret `kubeconfigs` output:
|
|
139
176
|
|
|
140
177
|
```sh
|
|
141
|
-
|
|
142
|
-
|
|
178
|
+
pulumi stack output kubeconfigs --show-secrets | jq -r '.warehouse.alice' > alice.kubeconfig
|
|
179
|
+
chmod 600 alice.kubeconfig
|
|
143
180
|
```
|
|
144
181
|
|
|
145
|
-
|
|
146
|
-
kubeconfig
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
182
|
+
The token is the kubeconfig's **only** credential; do not distribute the admin
|
|
183
|
+
kubeconfig or its client certificate/key. `viewer` users get read-only access.
|
|
184
|
+
The token does not expire: removing the membership or suspending the user deletes
|
|
185
|
+
its Secret and invalidates it. Tokens are never stored in User status. The `users`
|
|
186
|
+
output identifies the ServiceAccount; `tenants` identifies the namespaces and host
|
|
187
|
+
group.
|
|
151
188
|
|
|
152
189
|
Configure a deployment target with the user's kubeconfig and `tenant = "warehouse"`,
|
|
153
190
|
which selects `namespace = "di-tenant-warehouse"` and `hostgroup = "tenant-warehouse"`:
|
|
@@ -171,8 +208,11 @@ For shared tenant keyvalue storage, reference the controller-managed ConfigMap
|
|
|
171
208
|
services use ConfigMaps named `di-bs-*` and binding-projected Secrets/ConfigMaps
|
|
172
209
|
named `di-binding-*` (#450/#451). The warehouse's HTTP, Redis, and NATS sync flow
|
|
173
210
|
has been verified on wash 2.8.0. The platform default host image is
|
|
174
|
-
`ghcr.io/di-framework/wash:2.8.0-wasi-tls@sha256:
|
|
175
|
-
which links `wasi:tls
|
|
211
|
+
`ghcr.io/di-framework/wash:2.8.0-wasi-tls@sha256:d88158b0b09edd9fc3e79d787762697c60f65baf134d895529e85d6c47cd80ad`,
|
|
212
|
+
which links `wasi:tls` (and `ghcr.io/di-framework/wash:2.8.0-wasi-tls-exclusive@sha256:0ee414e9db4b0d4fc923eb477f1b1afd20f707b8ab3e552957575ff4f8e6a528`
|
|
213
|
+
adds the exclusive-instance patch); the tenant host pin PR moves it with each canonical host publish, so an
|
|
214
|
+
install without `tenantHostImage` moves its tenant hosts on the first deploy of a release that
|
|
215
|
+
contains that pin (set `tenantHostImage` to a digest to hold a build). Native keyvalue needs no custom image. The warehouse uses this same ConfigMap reference
|
|
176
216
|
in its external-cluster setup. Messaging uses the tenant's dedicated NATS backend.
|
|
177
217
|
Tenant admission restricts native interfaces, forbids host volumes and guest
|
|
178
218
|
network capabilities, and reserves `di-tenant-stock`, `di-bs-*`, and
|
|
@@ -202,6 +242,15 @@ registries, production storage, and stronger resource accounting are separate
|
|
|
202
242
|
work. Namespace NetworkPolicies require an enforcing CNI (the generated k0s
|
|
203
243
|
cluster uses kube-router). `tenantHostImage` and `tenantHostImagePullPolicy`
|
|
204
244
|
override the default wasi-tls host image when a stack needs a different runtime.
|
|
245
|
+
`insecureRegistry` gives only the platform host group `--allow-insecure-registries`;
|
|
246
|
+
tenant hosts never run `--allow-insecure-registries` and instead get
|
|
247
|
+
`--insecure-registry <host:port>` for the local platform registry (and each
|
|
248
|
+
`insecureRegistries` entry on existing-cluster installs when `insecureRegistry`
|
|
249
|
+
is enabled), so their other pulls stay TLS: an override image must be built
|
|
250
|
+
with wash patch 0002 (see `platform/tenant-host/README.md` in the platform
|
|
251
|
+
repository). `createPlatform` refuses the one published pre-0002 digest up front;
|
|
252
|
+
other older builds (for example locally built images) reject that argument and
|
|
253
|
+
the tenant hosts crash-loop.
|
|
205
254
|
|
|
206
255
|
## Shared implementation
|
|
207
256
|
|
|
@@ -213,7 +262,7 @@ changes belong in the shared package rather than copied tenancy files.
|
|
|
213
262
|
Backing-service CRD contracts (`BackingServiceClass`, `BackingService`,
|
|
214
263
|
`ServiceBinding`), authorization boundaries, and runtime feasibility notes live in
|
|
215
264
|
the `@di-framework/platform` package README. Platform install seeds the approved
|
|
216
|
-
default classes (`keyvalue-redis`, `messaging-nats`), retains CRDs on stack destroy,
|
|
265
|
+
default classes (`keyvalue-redis`, `messaging-nats`, `blobstore-nats`, `postgres-dedicated`, `egress-public`), retains CRDs on stack destroy,
|
|
217
266
|
ships compiled controller scripts including `backing-services.js`, and enforces
|
|
218
267
|
tenant RBAC / admission / quotas / backend NetworkPolicy isolation (#452).
|
|
219
268
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Platform implementation is shared with di-framework-kube.
|
|
2
|
-
export { schemaVersion, kubeconfig, namespace, registry, endpoints, tenants, users } from '@di-framework/platform/local';
|
|
2
|
+
export { schemaVersion, kubeconfig, namespace, registry, endpoints, tenants, users, kubeconfigs } from '@di-framework/platform/local';
|
package/dist/build.js
CHANGED
|
@@ -2,9 +2,10 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
3
3
|
import { basename, dirname, join, relative, sep } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { CommandFailure } from '@di-framework/cli-extension';
|
|
5
|
+
import { CommandFailure, } from '@di-framework/cli-extension';
|
|
6
6
|
import { discoverActors, renderActorsModule } from './actors.js';
|
|
7
7
|
import { discoverBindings, requirementsFromBindings } from './bindings.js';
|
|
8
|
+
import { buildDeployBundle, parseBuildArgs } from './bundle.js';
|
|
8
9
|
import { copyProviderWit, discoverComponentProviders, providerNamespaces, providerRequirementsFromJavaScript, providersToCompose, } from './components.js';
|
|
9
10
|
import { discoverScheduledJobs, renderCronAdapterModule, renderCronInvokerModule } from './cron.js';
|
|
10
11
|
import { DEFAULT_DEPS } from './deps.js';
|
|
@@ -15,7 +16,7 @@ import { ENCFS_SECTION, encfsSection, encryptionComposition, LAYER_PACKAGE, PROV
|
|
|
15
16
|
import { loadProject } from './project.js';
|
|
16
17
|
import { discoverQueueHandlers, isQueueWorkerProject } from './queues.js';
|
|
17
18
|
import { renderQueuesModule } from './queues-module.js';
|
|
18
|
-
import {
|
|
19
|
+
import { requireNodeBinary, toolFailed } from './support.js';
|
|
19
20
|
import { buildWitLock, COMPONENT_MODEL, defaultProjectRequirements, digestBytes, queueProjectRequirements, renderWorldWit, runtimeRequirementsFromJavaScript, sqliteProjectRequirements, WASI_HTTP_INTERFACE, WASI_HTTP_VERSION, } from './wit.js';
|
|
20
21
|
import { renderWorkloadServiceAdapter } from './workload-members.js';
|
|
21
22
|
export { COMPONENT_MODEL, WASI_HTTP_INTERFACE, WASI_HTTP_VERSION };
|
|
@@ -540,8 +541,20 @@ function listFiles(root) {
|
|
|
540
541
|
return files.sort();
|
|
541
542
|
}
|
|
542
543
|
export async function runWasmcloudBuild(args, io, deps = DEFAULT_DEPS) {
|
|
543
|
-
|
|
544
|
-
|
|
544
|
+
const parsed = parseBuildArgs(args);
|
|
545
|
+
if (parsed.bundle !== undefined) {
|
|
546
|
+
const bundle = await buildDeployBundle({
|
|
547
|
+
outputPath: parsed.bundle,
|
|
548
|
+
env: parsed.env,
|
|
549
|
+
target: parsed.target,
|
|
550
|
+
registry: parsed.registry,
|
|
551
|
+
tag: parsed.tag,
|
|
552
|
+
name: parsed.name,
|
|
553
|
+
}, io, deps);
|
|
554
|
+
return {
|
|
555
|
+
data: bundle,
|
|
556
|
+
text: `Wrote DeployBundle for ${bundle.service} (${bundle.env}) to ${parsed.bundle}`,
|
|
557
|
+
};
|
|
545
558
|
}
|
|
546
559
|
const project = loadProject(deps.cwd());
|
|
547
560
|
const summary = await buildComponent(project, io, deps);
|
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { CliIo } from '@di-framework/cli-extension';
|
|
2
|
+
import { type BuildSummary, canonicalBuildDigest } from './build.js';
|
|
3
|
+
import { type WasmcloudDeps } from './deps.js';
|
|
4
|
+
import { type DeployEnvironment, type ManifestBinding } from './manifest.js';
|
|
5
|
+
import { type WasmcloudProject } from './project.js';
|
|
6
|
+
import { type PublishedImage } from './publish.js';
|
|
7
|
+
import { type RegistryInput } from './registry.js';
|
|
8
|
+
import { type ClusterConnection } from './target.js';
|
|
9
|
+
export type { DeployEnvironment, ManifestBinding };
|
|
10
|
+
export { canonicalBuildDigest };
|
|
11
|
+
export declare const PASSTHROUGH_LABEL_PREFIX = "app.di-framework.dev/";
|
|
12
|
+
export type ComponentReference = {
|
|
13
|
+
reference: string;
|
|
14
|
+
digest: string;
|
|
15
|
+
};
|
|
16
|
+
export type DeployBinding = {
|
|
17
|
+
name: string;
|
|
18
|
+
capability: string;
|
|
19
|
+
serviceName: string;
|
|
20
|
+
config?: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
export type DeployBundle = {
|
|
23
|
+
env: DeployEnvironment;
|
|
24
|
+
service: string;
|
|
25
|
+
component: ComponentReference;
|
|
26
|
+
workload: Record<string, unknown>;
|
|
27
|
+
bindings: DeployBinding[];
|
|
28
|
+
secrets: string[];
|
|
29
|
+
};
|
|
30
|
+
export type BundleRegistryCredentials = {
|
|
31
|
+
registry?: RegistryInput;
|
|
32
|
+
repository?: string;
|
|
33
|
+
username?: string;
|
|
34
|
+
password?: string;
|
|
35
|
+
token?: string;
|
|
36
|
+
registryConfigPath?: string;
|
|
37
|
+
};
|
|
38
|
+
export type BundlePublishContext = {
|
|
39
|
+
project: WasmcloudProject;
|
|
40
|
+
connection: ClusterConnection;
|
|
41
|
+
build: BuildSummary;
|
|
42
|
+
io: CliIo;
|
|
43
|
+
deps: WasmcloudDeps;
|
|
44
|
+
tag?: string;
|
|
45
|
+
credentials?: BundleRegistryCredentials;
|
|
46
|
+
};
|
|
47
|
+
export type BuildDeployBundleOptions = {
|
|
48
|
+
name?: string;
|
|
49
|
+
project?: WasmcloudProject;
|
|
50
|
+
env?: DeployEnvironment;
|
|
51
|
+
target?: string;
|
|
52
|
+
registry?: RegistryInput;
|
|
53
|
+
tag?: string;
|
|
54
|
+
credentials?: BundleRegistryCredentials | (() => Promise<BundleRegistryCredentials> | BundleRegistryCredentials);
|
|
55
|
+
publish?: (context: BundlePublishContext) => Promise<PublishedImage | ComponentReference>;
|
|
56
|
+
bindings?: readonly DeployBinding[];
|
|
57
|
+
secrets?: readonly string[];
|
|
58
|
+
/** Optional passthrough labels (`app.di-framework.dev/*`) to merge onto workload.metadata.labels. */
|
|
59
|
+
labels?: Readonly<Record<string, string>>;
|
|
60
|
+
/** Optional passthrough annotations (`app.di-framework.dev/*`) to merge onto workload.metadata.annotations. */
|
|
61
|
+
annotations?: Readonly<Record<string, string>>;
|
|
62
|
+
outputPath?: string;
|
|
63
|
+
};
|
|
64
|
+
export type ParsedBuildArgs = {
|
|
65
|
+
bundle?: string;
|
|
66
|
+
env?: DeployEnvironment;
|
|
67
|
+
target?: string;
|
|
68
|
+
registry?: string;
|
|
69
|
+
tag?: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
};
|
|
72
|
+
export declare function parseBuildArgs(args: readonly string[]): ParsedBuildArgs;
|
|
73
|
+
export declare function normalizeSha256Digest(digest: string): string;
|
|
74
|
+
export declare function pinImageToDigest(reference: string, digest: string): string;
|
|
75
|
+
export type SanitizeWorkloadOptions = {
|
|
76
|
+
service: string;
|
|
77
|
+
env: DeployEnvironment;
|
|
78
|
+
component: ComponentReference;
|
|
79
|
+
publicIngress?: boolean;
|
|
80
|
+
labels?: Readonly<Record<string, string>>;
|
|
81
|
+
annotations?: Readonly<Record<string, string>>;
|
|
82
|
+
};
|
|
83
|
+
export declare function sanitizeWorkloadForBundle(workload: Record<string, unknown>, options: SanitizeWorkloadOptions): Record<string, unknown>;
|
|
84
|
+
export declare function parseWorkloadDeploymentYaml(manifestYaml: string): Record<string, unknown>;
|
|
85
|
+
export declare function buildDeployBundle(options: BuildDeployBundleOptions | undefined, io: CliIo, deps?: WasmcloudDeps): Promise<DeployBundle>;
|