@di-framework/cli-plugin-platform 6.0.3 → 6.0.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.
Files changed (69) hide show
  1. package/README.md +196 -21
  2. package/dist/args.d.ts +2 -1
  3. package/dist/args.js +9 -5
  4. package/dist/assets/http-adapter.js +63 -0
  5. package/dist/assets/platform/README.md +22 -6
  6. package/dist/assets/sqlite/BUILD-INFO.txt +1 -1
  7. package/dist/assets/wit/deps/wasi-clocks-0.2.12/package.wit +43 -0
  8. package/dist/assets/wit/deps/wasi-filesystem-0.2.12/package.wit +196 -0
  9. package/dist/assets/wit/deps/wasi-io-0.2.12/package.wit +66 -0
  10. package/dist/assets/wit/deps/wasi-logging/package.wit +36 -0
  11. package/dist/build.d.ts +3 -1
  12. package/dist/build.js +4 -2
  13. package/dist/command.js +31 -13
  14. package/dist/console/auth.d.ts +20 -0
  15. package/dist/console/auth.js +82 -0
  16. package/dist/console/catalog.d.ts +196 -0
  17. package/dist/console/catalog.js +821 -0
  18. package/dist/console/cluster.d.ts +30 -0
  19. package/dist/console/cluster.js +299 -0
  20. package/dist/console/errors.d.ts +10 -0
  21. package/dist/console/errors.js +32 -0
  22. package/dist/console/run.d.ts +18 -0
  23. package/dist/console/run.js +102 -0
  24. package/dist/console/server.d.ts +25 -0
  25. package/dist/console/server.js +668 -0
  26. package/dist/console/services.d.ts +47 -0
  27. package/dist/console/services.js +111 -0
  28. package/dist/console-ui/app.css +1 -0
  29. package/dist/console-ui/app.js +260 -0
  30. package/dist/console-ui/di-framework-mark.png +0 -0
  31. package/dist/console-ui/index.html +13 -0
  32. package/dist/deps.d.ts +2 -0
  33. package/dist/deps.js +5 -3
  34. package/dist/dev.js +10 -5
  35. package/dist/egress.d.ts +40 -0
  36. package/dist/egress.js +214 -0
  37. package/dist/host-interface.js +2 -1
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.js +1 -0
  40. package/dist/manifest.d.ts +7 -0
  41. package/dist/manifest.js +35 -8
  42. package/dist/node-compat/console.d.ts +18 -0
  43. package/dist/node-compat/console.js +42 -0
  44. package/dist/node-compat/env.js +6 -0
  45. package/dist/node-compat/events.d.ts +20 -0
  46. package/dist/node-compat/events.js +55 -0
  47. package/dist/node-compat/fetch-runtime.d.ts +31 -0
  48. package/dist/node-compat/fetch-runtime.js +62 -0
  49. package/dist/node-compat/fs-promises.d.ts +30 -0
  50. package/dist/node-compat/fs-promises.js +3 -0
  51. package/dist/node-compat/fs.d.ts +79 -0
  52. package/dist/node-compat/fs.js +112 -5
  53. package/dist/node-compat/net.d.ts +2 -1
  54. package/dist/node-compat/net.js +3 -1
  55. package/dist/node-compat/storage.d.ts +87 -0
  56. package/dist/node-compat/storage.js +244 -0
  57. package/dist/node-compat/stream.d.ts +24 -0
  58. package/dist/node-compat/stream.js +70 -0
  59. package/dist/platform.js +2 -4
  60. package/dist/project.d.ts +5 -0
  61. package/dist/project.js +4 -0
  62. package/dist/service.d.ts +21 -2
  63. package/dist/service.js +71 -5
  64. package/dist/target.js +6 -1
  65. package/dist/wit.d.ts +8 -0
  66. package/dist/wit.js +28 -0
  67. package/dist/workload.d.ts +45 -0
  68. package/dist/workload.js +98 -26
  69. package/package.json +14 -4
package/dist/target.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { resolve } from 'node:path';
1
2
  import { CommandFailure } from '@di-framework/cli-extension';
2
3
  import { loadPlatformOutputs, resolvePlatformDirectory } from './platform.js';
3
4
  import { materializeRegistry } from './registry.js';
@@ -16,7 +17,11 @@ export async function resolveConnection(target, workspaceRoot, manifestPath, dep
16
17
  if (target.kind === 'managed') {
17
18
  return resolveManagedConnection(target, workspaceRoot, manifestPath, deps);
18
19
  }
19
- return resolveExternalConnection(target);
20
+ const connection = resolveExternalConnection(target);
21
+ // kubectl runs from the project directory; a relative kubeconfig (e.g. from
22
+ // ${KUBECONFIG}) means the directory the command was invoked from.
23
+ connection.kubeconfig = resolve(deps.cwd(), connection.kubeconfig);
24
+ return connection;
20
25
  }
21
26
  async function resolveManagedConnection(target, workspaceRoot, manifestPath, deps) {
22
27
  const platformRoot = resolvePlatformDirectory(target, workspaceRoot, manifestPath);
package/dist/wit.d.ts CHANGED
@@ -2,12 +2,18 @@
2
2
  export declare const COMPONENT_MODEL = "0.3";
3
3
  export declare const HTTP_ADAPTER_SOURCE = "http-adapter";
4
4
  export declare const NODE_COMPAT_SOURCE = "node-compat";
5
+ export declare const WASI_LOGGING_PACKAGE = "wasi:logging";
6
+ export declare const WASI_LOGGING_VERSION = "0.1.0-draft";
7
+ export declare const GUEST_CONSOLE_SOURCE = "guest-console";
5
8
  export declare const WASI_HTTP_PACKAGE = "wasi:http";
6
9
  export declare const WASI_HTTP_VERSION = "0.3.0";
7
10
  export declare const WASI_HTTP_INTERFACE = "handler";
8
11
  export declare const WASI_SOCKETS_PACKAGE = "wasi:sockets";
9
12
  export declare const WASI_SOCKETS_VERSION = "0.3.0";
10
13
  export declare const WASI_RANDOM_PACKAGE = "wasi:random";
14
+ /** The sync preview-2 filesystem: node:fs storage paths and the SQLite provider use it. */
15
+ export declare const WASI_FILESYSTEM_PACKAGE = "wasi:filesystem";
16
+ export declare const WASI_FILESYSTEM_VERSION = "0.2.12";
11
17
  export declare const WASI_RANDOM_VERSION = "0.3.0";
12
18
  export declare const QUEUE_ADAPTER_SOURCE = "queue-adapter";
13
19
  export declare const DI_QUEUES_PACKAGE = "di-framework:queues";
@@ -63,6 +69,8 @@ export declare function sqliteProjectRequirements(): WitRequirement[];
63
69
  * actually imports those specifiers.
64
70
  */
65
71
  export declare function runtimeRequirementsFromJavaScript(source: string): WitRequirement[];
72
+ /** Guest console lines; the host binds its logging plugin only when this is declared. */
73
+ export declare function guestLoggingRequirement(): WitRequirement;
66
74
  /** @deprecated Use {@link runtimeRequirementsFromJavaScript}. */
67
75
  export declare function socketRequirementsFromJavaScript(source: string): WitRequirement[];
68
76
  export declare function parsePackageId(id: string): {
package/dist/wit.js CHANGED
@@ -5,12 +5,18 @@ import { join } from 'node:path';
5
5
  export const COMPONENT_MODEL = '0.3';
6
6
  export const HTTP_ADAPTER_SOURCE = 'http-adapter';
7
7
  export const NODE_COMPAT_SOURCE = 'node-compat';
8
+ export const WASI_LOGGING_PACKAGE = 'wasi:logging';
9
+ export const WASI_LOGGING_VERSION = '0.1.0-draft';
10
+ export const GUEST_CONSOLE_SOURCE = 'guest-console';
8
11
  export const WASI_HTTP_PACKAGE = 'wasi:http';
9
12
  export const WASI_HTTP_VERSION = '0.3.0';
10
13
  export const WASI_HTTP_INTERFACE = 'handler';
11
14
  export const WASI_SOCKETS_PACKAGE = 'wasi:sockets';
12
15
  export const WASI_SOCKETS_VERSION = '0.3.0';
13
16
  export const WASI_RANDOM_PACKAGE = 'wasi:random';
17
+ /** The sync preview-2 filesystem: node:fs storage paths and the SQLite provider use it. */
18
+ export const WASI_FILESYSTEM_PACKAGE = 'wasi:filesystem';
19
+ export const WASI_FILESYSTEM_VERSION = '0.2.12';
14
20
  export const WASI_RANDOM_VERSION = '0.3.0';
15
21
  export const QUEUE_ADAPTER_SOURCE = 'queue-adapter';
16
22
  export const DI_QUEUES_PACKAGE = 'di-framework:queues';
@@ -103,6 +109,15 @@ export function runtimeRequirementsFromJavaScript(source) {
103
109
  source: NODE_COMPAT_SOURCE,
104
110
  });
105
111
  }
112
+ if (source.includes(`${WASI_FILESYSTEM_PACKAGE}/preopens@${WASI_FILESYSTEM_VERSION}`)) {
113
+ requirements.push({
114
+ package: WASI_FILESYSTEM_PACKAGE,
115
+ version: WASI_FILESYSTEM_VERSION,
116
+ interfaces: ['types', 'preopens'],
117
+ direction: 'import',
118
+ source: NODE_COMPAT_SOURCE,
119
+ });
120
+ }
106
121
  if (source.includes('wasi:clocks/monotonic-clock@0.3.0')) {
107
122
  requirements.push({
108
123
  package: 'wasi:clocks',
@@ -112,6 +127,9 @@ export function runtimeRequirementsFromJavaScript(source) {
112
127
  source: NODE_COMPAT_SOURCE,
113
128
  });
114
129
  }
130
+ if (source.includes(`${WASI_LOGGING_PACKAGE}/logging@${WASI_LOGGING_VERSION}`)) {
131
+ requirements.push(guestLoggingRequirement());
132
+ }
115
133
  if (source.includes('wasi:cli/environment@0.3.0')) {
116
134
  requirements.push({
117
135
  package: 'wasi:cli',
@@ -132,6 +150,16 @@ export function runtimeRequirementsFromJavaScript(source) {
132
150
  }
133
151
  return requirements;
134
152
  }
153
+ /** Guest console lines; the host binds its logging plugin only when this is declared. */
154
+ export function guestLoggingRequirement() {
155
+ return {
156
+ package: WASI_LOGGING_PACKAGE,
157
+ version: WASI_LOGGING_VERSION,
158
+ interfaces: ['logging'],
159
+ direction: 'import',
160
+ source: GUEST_CONSOLE_SOURCE,
161
+ };
162
+ }
135
163
  /** @deprecated Use {@link runtimeRequirementsFromJavaScript}. */
136
164
  export function socketRequirementsFromJavaScript(source) {
137
165
  return runtimeRequirementsFromJavaScript(source);
@@ -17,11 +17,56 @@ export declare const HOST_STORAGE_ROOT = "/var/lib/di-framework/storage";
17
17
  export declare const STORAGE_HOSTGROUP = "storage";
18
18
  /** Guest mount path for application SQLite storage. */
19
19
  export declare const DEFAULT_STORAGE_MOUNT = "/data";
20
+ /**
21
+ * Tenant workloads ask the platform for storage instead of naming a host path. The
22
+ * controller creates a tenant-scoped directory per workload and injects the volume and
23
+ * the preopen; tenant credentials cannot set either.
24
+ */
25
+ export declare const PERSISTENT_STORAGE_ANNOTATION = "di-framework.dev/persistent-storage";
26
+ /**
27
+ * "false" when the project opts out of guest logs: the platform publishes no wasi:logging
28
+ * lines for the deployment, only host failure lines.
29
+ */
30
+ export declare const LOGS_ANNOTATION = "di-framework.dev/logs";
31
+ /** Guest mount when it is not the default `/data`; the controller accepts only these two. */
32
+ export declare const STORAGE_MOUNT_ANNOTATION = "di-framework.dev/storage-mount";
33
+ /** A tenant target names its host group; its storage belongs to the platform. */
34
+ export declare function usesPlatformStorage(connection: Pick<ClusterConnection, 'hostgroup'>): boolean;
20
35
  /** Pinned CronJob invoker image that POSTs to the Wasm HTTP control API. */
21
36
  export declare const CRON_INVOKER_IMAGE = "curlimages/curl:8.11.1";
22
37
  export declare function deploymentResourceName(project: WasmcloudProject): string;
23
38
  export declare function generatedManifestPath(project: WasmcloudProject): string;
24
39
  export declare function hostStoragePath(applicationName: string): string;
40
+ /** Members of one persistent workload share a directory. Other apps keep their own. */
41
+ export declare function storageDirectoryName(project: {
42
+ applicationName: string;
43
+ workload?: string;
44
+ persistentStorage?: boolean;
45
+ }): string;
46
+ export type StorageClaim = {
47
+ metadata?: {
48
+ name?: string;
49
+ labels?: Record<string, string>;
50
+ };
51
+ spec?: {
52
+ template?: {
53
+ spec?: {
54
+ volumes?: Array<{
55
+ hostPath?: {
56
+ path?: string;
57
+ };
58
+ }>;
59
+ };
60
+ };
61
+ };
62
+ };
63
+ /** Another deployment may use the path only when it belongs to the same workload. */
64
+ export declare function storageOwnershipConflict(project: {
65
+ applicationName: string;
66
+ workload?: string;
67
+ }, hostPath: string, items: readonly StorageClaim[]): {
68
+ owner: string;
69
+ } | undefined;
25
70
  /** Kubernetes Secret that holds DI_CONTROL_TOKEN for a workload. */
26
71
  export declare function controlSecretResourceName(workloadName: string): string;
27
72
  export interface WorkloadManifestOptions {
package/dist/workload.js CHANGED
@@ -5,12 +5,13 @@ import { CommandFailure } from '@di-framework/cli-extension';
5
5
  import { discoverActors } from './actors.js';
6
6
  import { discoverBindings, requirementsFromBindings } from './bindings.js';
7
7
  import { discoverScheduledJobs } from './cron.js';
8
+ import { applyWorkloadEgress, removeWorkloadEgress, reportEgressStatus, usesPlatformEgress, warnIfTenantHostLacksTls, } from './egress.js';
8
9
  import { hostInterfacesFromRequirements, renderHostInterfacesYaml } from './host-interface.js';
9
10
  import { captureKubectl, runKubectl } from './kubernetes.js';
10
11
  import { applyManagedBindings, cleanupManagedBindings } from './managed-bindings.js';
11
12
  import { asWitIdentifier } from './project.js';
12
13
  import { discoverQueueHandlers, isQueueWorkerProject } from './queues.js';
13
- import { defaultProjectRequirements, queueProjectRequirements } from './wit.js';
14
+ import { defaultProjectRequirements, guestLoggingRequirement, queueProjectRequirements, } from './wit.js';
14
15
  export const MANAGED_BY_LABEL = 'di-framework';
15
16
  export const WAIT_ATTEMPTS = 30;
16
17
  export const WAIT_INTERVAL_MS = 2_000;
@@ -22,6 +23,24 @@ export const HOST_STORAGE_ROOT = '/var/lib/di-framework/storage';
22
23
  export const STORAGE_HOSTGROUP = 'storage';
23
24
  /** Guest mount path for application SQLite storage. */
24
25
  export const DEFAULT_STORAGE_MOUNT = '/data';
26
+ /**
27
+ * Tenant workloads ask the platform for storage instead of naming a host path. The
28
+ * controller creates a tenant-scoped directory per workload and injects the volume and
29
+ * the preopen; tenant credentials cannot set either.
30
+ */
31
+ export const PERSISTENT_STORAGE_ANNOTATION = 'di-framework.dev/persistent-storage';
32
+ /**
33
+ * "false" when the project opts out of guest logs: the platform publishes no wasi:logging
34
+ * lines for the deployment, only host failure lines.
35
+ */
36
+ export const LOGS_ANNOTATION = 'di-framework.dev/logs';
37
+ /** Guest mount when it is not the default `/data`; the controller accepts only these two. */
38
+ export const STORAGE_MOUNT_ANNOTATION = 'di-framework.dev/storage-mount';
39
+ const PLATFORM_STORAGE_MOUNTS = [DEFAULT_STORAGE_MOUNT, `${DEFAULT_STORAGE_MOUNT}/actors`];
40
+ /** A tenant target names its host group; its storage belongs to the platform. */
41
+ export function usesPlatformStorage(connection) {
42
+ return connection.hostgroup !== undefined;
43
+ }
25
44
  /** Pinned CronJob invoker image that POSTs to the Wasm HTTP control API. */
26
45
  export const CRON_INVOKER_IMAGE = 'curlimages/curl:8.11.1';
27
46
  export function deploymentResourceName(project) {
@@ -33,6 +52,27 @@ export function generatedManifestPath(project) {
33
52
  export function hostStoragePath(applicationName) {
34
53
  return `${HOST_STORAGE_ROOT}/${asWitIdentifier(applicationName)}`;
35
54
  }
55
+ /** Members of one persistent workload share a directory. Other apps keep their own. */
56
+ export function storageDirectoryName(project) {
57
+ return project.persistentStorage === true && project.workload
58
+ ? project.workload
59
+ : project.applicationName;
60
+ }
61
+ /** Another deployment may use the path only when it belongs to the same workload. */
62
+ export function storageOwnershipConflict(project, hostPath, items) {
63
+ for (const item of items) {
64
+ const labels = item.metadata?.labels;
65
+ if (project.workload !== undefined &&
66
+ labels?.['di-framework.dev/workload'] === project.workload) {
67
+ continue;
68
+ }
69
+ const volumes = item.spec?.template?.spec?.volumes ?? [];
70
+ if (volumes.some((volume) => volume.hostPath?.path === hostPath)) {
71
+ return { owner: item.metadata?.name ?? 'unknown' };
72
+ }
73
+ }
74
+ return undefined;
75
+ }
36
76
  /** Kubernetes Secret that holds DI_CONTROL_TOKEN for a workload. */
37
77
  export function controlSecretResourceName(workloadName) {
38
78
  return `${workloadName}-control`;
@@ -65,7 +105,19 @@ export function renderWorkloadManifest(project, connection, image, requirements
65
105
  const volumeName = opts.storageVolume?.volumeName ?? 'app-storage';
66
106
  const mountPath = opts.storageVolume?.mountPath ??
67
107
  (hasActors ? `${DEFAULT_STORAGE_MOUNT}/actors` : DEFAULT_STORAGE_MOUNT);
68
- const hostPath = opts.storageVolume?.hostPath ?? hostStoragePath(project.applicationName);
108
+ const hostPath = opts.storageVolume?.hostPath ?? hostStoragePath(storageDirectoryName(project));
109
+ const platformStorage = needsPersistentStorage && usesPlatformStorage(connection);
110
+ if (platformStorage && !PLATFORM_STORAGE_MOUNTS.includes(mountPath)) {
111
+ throw new CommandFailure('WASMCLOUD_STORAGE_MOUNT_UNSUPPORTED', `Tenant storage mounts at ${PLATFORM_STORAGE_MOUNTS.join(' or ')}, not ${mountPath}`, 2, { mountPath });
112
+ }
113
+ const annotationLines = [
114
+ ...(platformStorage ? [` ${PERSISTENT_STORAGE_ANNOTATION}: "true"`] : []),
115
+ ...(platformStorage && mountPath !== DEFAULT_STORAGE_MOUNT
116
+ ? [` ${STORAGE_MOUNT_ANNOTATION}: ${yamlQuote(mountPath)}`]
117
+ : []),
118
+ ...(project.logs === false ? [` ${LOGS_ANNOTATION}: "false"`] : []),
119
+ ];
120
+ const annotations = annotationLines.length > 0 ? [' annotations:', ...annotationLines] : [];
69
121
  const environment = { ...(opts.environment ?? {}) };
70
122
  if (needsPersistentStorage) {
71
123
  environment.DI_SQLITE_BACKEND = 'wasm';
@@ -122,6 +174,8 @@ spec:
122
174
  protocol: TCP`);
123
175
  }
124
176
  const localResourcesLines = [];
177
+ // Tenant admission rejects these fields; the platform's egress binding writes them.
178
+ const ipNameLookups = usesPlatformEgress(connection) ? undefined : project.allowedIpNameLookups;
125
179
  const envKeys = Object.keys(environment).sort();
126
180
  if (envKeys.length > 0 || controlSecretName !== undefined) {
127
181
  localResourcesLines.push(' localResources:');
@@ -137,20 +191,30 @@ spec:
137
191
  localResourcesLines.push(` - name: ${controlSecretName}`);
138
192
  }
139
193
  }
140
- else if (project.allowedIpNameLookups !== undefined) {
194
+ else if (ipNameLookups !== undefined) {
141
195
  localResourcesLines.push(' localResources:');
142
196
  }
143
- if (needsPersistentStorage) {
197
+ if (needsPersistentStorage && !platformStorage) {
144
198
  localResourcesLines.push(' volumeMounts:');
145
199
  localResourcesLines.push(` - name: ${volumeName}`);
146
200
  localResourcesLines.push(` mountPath: ${mountPath}`);
147
201
  }
148
- if (project.allowedIpNameLookups !== undefined) {
149
- localResourcesLines.push(` allowedIpNameLookups: ${JSON.stringify(project.allowedIpNameLookups)}`);
202
+ if (ipNameLookups !== undefined) {
203
+ localResourcesLines.push(` allowedIpNameLookups: ${JSON.stringify(ipNameLookups)}`);
150
204
  }
151
- const hostInterfaces = renderHostInterfacesYaml(hostInterfacesFromRequirements(hasHttp && !requirements.some((r) => r.package === 'wasi:http' && r.direction === 'export')
205
+ // A long-lived wasi:cli/run program is a WorkloadService: wash runs it only from
206
+ // spec.template.spec.service, never as a component export.
207
+ const runsAsService = !hasHttp &&
208
+ !isWorker &&
209
+ project.workloadEntry?.kind === 'service' &&
210
+ project.workloadEntry.subscriptions === undefined;
211
+ // Deploy builds link the wasi:logging console unless the project opts out of logs
212
+ // (see buildComponent).
213
+ const interfaceRequirements = project.logs === false ? requirements : [...requirements, guestLoggingRequirement()];
214
+ const hostInterfaces = renderHostInterfacesYaml(hostInterfacesFromRequirements(hasHttp &&
215
+ !interfaceRequirements.some((r) => r.package === 'wasi:http' && r.direction === 'export')
152
216
  ? [
153
- ...requirements,
217
+ ...interfaceRequirements,
154
218
  {
155
219
  package: 'wasi:http',
156
220
  version: '0.3.0',
@@ -159,7 +223,7 @@ spec:
159
223
  source: 'control-http',
160
224
  },
161
225
  ]
162
- : requirements, {
226
+ : interfaceRequirements, {
163
227
  ...(hasHttp ? { httpHost: advertisedHttpHost } : {}),
164
228
  subscriptions: project.workloadEntry?.subscriptions,
165
229
  }, bindings.map((binding) => ({
@@ -176,14 +240,14 @@ metadata:
176
240
  namespace: ${connection.namespace}
177
241
  labels:
178
242
  ${labels}
179
- spec:
243
+ ${annotations.length > 0 ? `${annotations.join('\n')}\n` : ''}spec:
180
244
  replicas: 1
181
245
  ${needsPersistentStorage ? ' deployPolicy: Recreate\n' : ''} template:
182
246
  spec:
183
247
  environment: ${yamlQuote(connection.namespace)}
184
248
  hostSelector:
185
- hostgroup: ${needsPersistentStorage ? (connection.storageHostgroup ?? STORAGE_HOSTGROUP) : (connection.hostgroup ?? 'default')}
186
- ${needsPersistentStorage
249
+ hostgroup: ${needsPersistentStorage && !platformStorage ? (connection.storageHostgroup ?? STORAGE_HOSTGROUP) : (connection.hostgroup ?? 'default')}
250
+ ${needsPersistentStorage && !platformStorage
187
251
  ? ` volumes:
188
252
  - name: ${volumeName}
189
253
  hostPath:
@@ -194,10 +258,14 @@ ${needsPersistentStorage
194
258
  service:
195
259
  name: ${name}
196
260
  `
197
- : ''} components:
261
+ : ''}${runsAsService
262
+ ? ` service:
263
+ image: ${yamlQuote(image)}
264
+ ${localResourcesLines.length > 0 ? `${localResourcesLines.map((line) => line.slice(2)).join('\n')}\n` : ''}`
265
+ : ` components:
198
266
  - name: ${name}
199
267
  image: ${yamlQuote(image)}
200
- ${localResourcesLines.length > 0 ? `${localResourcesLines.join('\n')}\n` : ''}${hostInterfaces}`;
268
+ ${localResourcesLines.length > 0 ? `${localResourcesLines.join('\n')}\n` : ''}`}${hostInterfaces}`;
201
269
  sections.push(workloadDeployment);
202
270
  for (const job of cronJobs) {
203
271
  const jobKebab = job.kebabId || asWitIdentifier(job.name || `${job.className}-${job.methodName}`);
@@ -311,7 +379,11 @@ export async function applyWorkload(project, connection, image, io, deps) {
311
379
  direction: 'export',
312
380
  source: 'workload-service',
313
381
  });
382
+ await warnIfTenantHostLacksTls(project, connection, io, deps);
314
383
  const associations = await applyManagedBindings(project, connection, bindings, deps);
384
+ const egress = await applyWorkloadEgress(project, connection, deps);
385
+ if (egress !== undefined)
386
+ associations.add(egress);
315
387
  await assertStorageOwnership(project, connection, deps, {
316
388
  hasActors,
317
389
  hasQueues: queueHandlers.length > 0,
@@ -329,13 +401,19 @@ export async function applyWorkload(project, connection, image, io, deps) {
329
401
  await runKubectl(deps, connection, ['apply', '-f', path], project.projectRoot);
330
402
  await waitForReady(project, connection, deps, io);
331
403
  await cleanupManagedBindings(project, connection, associations, deps);
404
+ if (egress === undefined)
405
+ await removeWorkloadEgress(project, connection, deps);
406
+ else
407
+ await reportEgressStatus(project, connection, io, deps);
332
408
  return path;
333
409
  }
334
410
  async function assertStorageOwnership(project, connection, deps, flags) {
335
411
  if (!flags.hasActors && !flags.hasQueues && !flags.hasPersistentStorage)
336
412
  return;
337
- const name = deploymentResourceName(project);
338
- const hostPath = hostStoragePath(project.applicationName);
413
+ // The platform keys tenant storage by workload, so another app cannot reach this path.
414
+ if (usesPlatformStorage(connection))
415
+ return;
416
+ const hostPath = hostStoragePath(storageDirectoryName(project));
339
417
  const result = await captureKubectl(deps, connection, [
340
418
  'get',
341
419
  WORKLOAD_DEPLOYMENT_RESOURCE,
@@ -348,22 +426,15 @@ async function assertStorageOwnership(project, connection, deps, flags) {
348
426
  return;
349
427
  try {
350
428
  const list = JSON.parse(result.stdout);
351
- let conflict;
352
- for (const item of list.items ?? []) {
353
- for (const volume of item.spec?.template?.spec?.volumes ?? []) {
354
- if (volume.hostPath?.path === hostPath) {
355
- conflict = new CommandFailure('WASMCLOUD_STORAGE_OWNERSHIP_CONFLICT', `Storage path ${hostPath} is already claimed by WorkloadDeployment ${item.metadata?.name ?? 'unknown'}`, 2, { application: project.applicationName, path: hostPath, owner: item.metadata?.name });
356
- }
357
- }
429
+ const conflict = storageOwnershipConflict(project, hostPath, list.items ?? []);
430
+ if (conflict) {
431
+ throw new CommandFailure('WASMCLOUD_STORAGE_OWNERSHIP_CONFLICT', `Storage path ${hostPath} is already claimed by WorkloadDeployment ${conflict.owner}`, 2, { application: project.applicationName, path: hostPath, owner: conflict.owner });
358
432
  }
359
- if (conflict)
360
- throw conflict;
361
433
  }
362
434
  catch (error) {
363
435
  if (error instanceof CommandFailure)
364
436
  throw error;
365
437
  }
366
- void name;
367
438
  }
368
439
  export async function deleteWorkload(project, connection, io, deps) {
369
440
  const name = deploymentResourceName(project);
@@ -378,6 +449,7 @@ export async function deleteWorkload(project, connection, io, deps) {
378
449
  '--timeout=180s',
379
450
  ], project.projectRoot);
380
451
  await cleanupManagedBindings(project, connection, new Set(), deps);
452
+ await removeWorkloadEgress(project, connection, deps);
381
453
  }
382
454
  export async function waitForReady(project, connection, deps, io) {
383
455
  const name = deploymentResourceName(project);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@di-framework/cli-plugin-platform",
3
- "version": "6.0.3",
3
+ "version": "6.0.5",
4
4
  "description": "di-framework CLI extension that builds, serves, and deploys DI Framework apps as platform WebAssembly components.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "scripts": {
30
30
  "test": "bun test",
31
- "build": "rm -rf dist && bun x tsc -p tsconfig.dist.json && bun build assets/http-adapter.ts --outfile dist/assets/http-adapter.js --packages bundle --external 'wasi:*' --external 'wasmcloud:*' --external 'di-framework:*' --external '@di-framework/actors' --external '@di-framework/actors/portable' --external '@di-framework/repo' --external '@di-framework/repo/portable' --external '@di-framework/queues' --external '@di-framework/queues/portable' --external 'virtual:di-framework-application' --external 'virtual:di-framework-wasmcloud-guests' --external 'virtual:di-framework-wasmcloud-actors' --external 'virtual:di-framework-wasmcloud-cron' --external 'virtual:di-framework-wasmcloud-queues' --external 'virtual:di-framework-wasmcloud-runtime' && bun build assets/queue-adapter.ts --outfile dist/assets/queue-adapter.js --packages bundle --external 'wasi:*' --external 'wasmcloud:*' --external 'di-framework:*' --external '@di-framework/actors' --external '@di-framework/actors/portable' --external 'virtual:di-framework-application' --external 'virtual:di-framework-wasmcloud-guests' --external 'virtual:di-framework-wasmcloud-actors' && cp -R assets/wit dist/assets/wit && cp -R assets/platform dist/assets/platform && bun ../../scripts/copy-sqlite-asset.ts && bun ../../scripts/fix-esm-imports.ts dist"
31
+ "build": "rm -rf dist && bun x tsc -p tsconfig.dist.json && bun build assets/http-adapter.ts --outfile dist/assets/http-adapter.js --packages bundle --external 'wasi:*' --external 'wasmcloud:*' --external 'di-framework:*' --external '@di-framework/actors' --external '@di-framework/actors/portable' --external '@di-framework/repo' --external '@di-framework/repo/portable' --external '@di-framework/queues' --external '@di-framework/queues/portable' --external 'virtual:di-framework-application' --external 'virtual:di-framework-wasmcloud-guests' --external 'virtual:di-framework-wasmcloud-actors' --external 'virtual:di-framework-wasmcloud-cron' --external 'virtual:di-framework-wasmcloud-queues' --external 'virtual:di-framework-wasmcloud-runtime' && bun build assets/queue-adapter.ts --outfile dist/assets/queue-adapter.js --packages bundle --external 'wasi:*' --external 'wasmcloud:*' --external 'di-framework:*' --external '@di-framework/actors' --external '@di-framework/actors/portable' --external 'virtual:di-framework-application' --external 'virtual:di-framework-wasmcloud-guests' --external 'virtual:di-framework-wasmcloud-actors' && cp -R assets/wit dist/assets/wit && cp -R assets/platform dist/assets/platform && bun ../../scripts/copy-sqlite-asset.ts && bun ../../scripts/fix-esm-imports.ts dist && bun build console-ui/src/main.tsx --outdir dist/console-ui --target browser --minify --entry-naming 'app.[ext]' --asset-naming '[name].[ext]' --public-path /assets/ && cp console-ui/index.html dist/console-ui/index.html"
32
32
  },
33
33
  "exports": {
34
34
  ".": {
@@ -61,9 +61,19 @@
61
61
  "README.md"
62
62
  ],
63
63
  "devDependencies": {
64
+ "@di-framework/bindings": "^6",
64
65
  "@di-framework/config": "^5",
65
66
  "@di-framework/core": "^5",
66
- "@di-framework/bindings": "^6",
67
- "@types/babel__core": "^7.20.5"
67
+ "@patternfly/react-core": "^6.6.1",
68
+ "@patternfly/react-icons": "^6.6.1",
69
+ "@patternfly/react-table": "^6.6.1",
70
+ "@types/babel__core": "^7.20.5",
71
+ "@types/react": "^19.3.0",
72
+ "@types/react-dom": "^19.3.0",
73
+ "mobx": "^7.0.5",
74
+ "mobx-react-lite": "^5.1.0",
75
+ "mobx-state-tree": "^8.0.0",
76
+ "react": "19",
77
+ "react-dom": "19"
68
78
  }
69
79
  }