@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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { rootCertificates } from 'node:tls';
|
|
3
|
+
import { CliError } from './credentials.js';
|
|
4
|
+
const PEM_CERTIFICATE = /-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g;
|
|
5
|
+
/**
|
|
6
|
+
* Reads `--ca-file`: one or more PEM certificates, such as the tenant's `tenant-controller-ca`.
|
|
7
|
+
* Returns them base64-encoded, the form `controller.certificateAuthorityData` takes in the
|
|
8
|
+
* credential store.
|
|
9
|
+
*/
|
|
10
|
+
export function readCaFile(path) {
|
|
11
|
+
let text;
|
|
12
|
+
try {
|
|
13
|
+
text = readFileSync(path, 'utf8');
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw new CliError(`--ca-file ${path}: ${error.message}`);
|
|
17
|
+
}
|
|
18
|
+
const certificates = text.match(PEM_CERTIFICATE);
|
|
19
|
+
if (!certificates)
|
|
20
|
+
throw new CliError(`--ca-file ${path} holds no PEM certificate`);
|
|
21
|
+
return Buffer.from(`${certificates.join('\n')}\n`).toString('base64');
|
|
22
|
+
}
|
|
23
|
+
/** The PEM of the CA stored with the credential, if any. */
|
|
24
|
+
export function caPem(controller) {
|
|
25
|
+
const data = controller.certificateAuthorityData;
|
|
26
|
+
return data ? Buffer.from(data, 'base64').toString('utf8') : undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A `fetch` that also trusts `pem` (on top of the bundled public roots) for TLS. Without a CA it
|
|
30
|
+
* is the given `fetch` unchanged, so `NODE_EXTRA_CA_CERTS` keeps working as before.
|
|
31
|
+
*/
|
|
32
|
+
export function trusting(base, pem) {
|
|
33
|
+
if (!pem)
|
|
34
|
+
return base;
|
|
35
|
+
const doFetch = base ?? fetch;
|
|
36
|
+
const ca = [...rootCertificates, pem];
|
|
37
|
+
const wrapped = (input, init) => doFetch(input, { ...init, tls: { ...init?.tls, ca } });
|
|
38
|
+
return wrapped;
|
|
39
|
+
}
|
package/dist/deploy.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { CliIo, CommandResult } from '@di-framework/cli-extension';
|
|
2
2
|
import { type BuildSummary } from './build.js';
|
|
3
|
+
import { type Deployment, type DeployPlan } from './controller/index.js';
|
|
3
4
|
import { type WasmcloudDeps } from './deps.js';
|
|
4
|
-
import type
|
|
5
|
+
import { type DeployEnvironment } from './manifest.js';
|
|
6
|
+
import { type RegistryLocation } from './registry.js';
|
|
5
7
|
export type WasmcloudDeployData = {
|
|
6
8
|
cronJobs?: Array<{
|
|
7
9
|
jobId: string;
|
|
@@ -17,6 +19,11 @@ export type WasmcloudDeployData = {
|
|
|
17
19
|
digest: string;
|
|
18
20
|
deploymentDigest: string;
|
|
19
21
|
service: string;
|
|
22
|
+
env?: DeployEnvironment;
|
|
23
|
+
account?: string;
|
|
24
|
+
controller?: string;
|
|
25
|
+
deployment?: Deployment;
|
|
26
|
+
preview?: DeployPlan;
|
|
20
27
|
http?: {
|
|
21
28
|
url: string;
|
|
22
29
|
host: string;
|
package/dist/deploy.js
CHANGED
|
@@ -1,14 +1,98 @@
|
|
|
1
1
|
import { parseAppCommandArgs } from './args.js';
|
|
2
2
|
import { buildComponent } from './build.js';
|
|
3
|
+
import { buildDeployBundle } from './bundle.js';
|
|
4
|
+
import { bearer, registryOrigin, registryUsername, resolveControllerSession, wrapControllerError, } from './controller/index.js';
|
|
3
5
|
import { discoverScheduledJobs } from './cron.js';
|
|
4
6
|
import { DEFAULT_DEPS } from './deps.js';
|
|
5
7
|
import { discoverProjects, resolveApplication } from './discovery.js';
|
|
6
|
-
import { loadDeployManifest } from './manifest.js';
|
|
8
|
+
import { loadDeployManifest, tenantNamespace, } from './manifest.js';
|
|
7
9
|
import { assertDistinctPgliteRoots } from './pglite.js';
|
|
8
10
|
import { publishComponent } from './publish.js';
|
|
9
|
-
import {
|
|
11
|
+
import { materializeRegistry } from './registry.js';
|
|
12
|
+
import { isControllerBackedTarget, resolveConnection, resolveTarget } from './target.js';
|
|
10
13
|
import { applyWorkload, deploymentResourceName } from './workload.js';
|
|
11
14
|
import { writeWorkloadManifest } from './workload-members.js';
|
|
15
|
+
async function runControllerDeploy(project, target, manifest, options, io, deps) {
|
|
16
|
+
try {
|
|
17
|
+
const { credential, client } = await resolveControllerSession({ target }, deps);
|
|
18
|
+
const registryInfo = await client.registry();
|
|
19
|
+
const regOrigin = registryOrigin(registryInfo.url);
|
|
20
|
+
const username = registryUsername(registryInfo.username);
|
|
21
|
+
const env = options.env ?? target.env ?? manifest.env ?? 'prod';
|
|
22
|
+
const repository = registryInfo.repositoryPrefix
|
|
23
|
+
? `${registryInfo.repositoryPrefix}/${project.witName}`
|
|
24
|
+
: project.witName;
|
|
25
|
+
io.stdout.write(`Deploying ${project.applicationName} to target ${target.name} (${credential.account}/${env})...\n`);
|
|
26
|
+
const bundle = await buildDeployBundle({
|
|
27
|
+
project,
|
|
28
|
+
target: target.name,
|
|
29
|
+
env,
|
|
30
|
+
registry: regOrigin.origin,
|
|
31
|
+
credentials: {
|
|
32
|
+
username,
|
|
33
|
+
password: bearer(credential),
|
|
34
|
+
repository,
|
|
35
|
+
},
|
|
36
|
+
}, io, deps);
|
|
37
|
+
const cronJobs = discoverScheduledJobs(project.projectRoot);
|
|
38
|
+
const namespace = tenantNamespace(credential.account);
|
|
39
|
+
const registry = materializeRegistry(regOrigin.origin);
|
|
40
|
+
const deploymentDigest = bundle.component.digest.replace(/^sha256:/, '');
|
|
41
|
+
if (options.preview) {
|
|
42
|
+
const plan = await client.previewDeploy(bundle);
|
|
43
|
+
const changesSummary = plan.changes.length === 0
|
|
44
|
+
? 'no changes'
|
|
45
|
+
: plan.changes.map((c) => `${c.kind} ${c.resource}/${c.name}`).join(', ');
|
|
46
|
+
const data = {
|
|
47
|
+
application: project.applicationName,
|
|
48
|
+
target: target.name,
|
|
49
|
+
namespace,
|
|
50
|
+
registry,
|
|
51
|
+
image: bundle.component.reference,
|
|
52
|
+
publishedImage: bundle.component.reference,
|
|
53
|
+
digest: bundle.component.digest,
|
|
54
|
+
deploymentDigest,
|
|
55
|
+
service: bundle.service,
|
|
56
|
+
env,
|
|
57
|
+
account: credential.account,
|
|
58
|
+
controller: credential.controller.url,
|
|
59
|
+
preview: plan,
|
|
60
|
+
};
|
|
61
|
+
const text = `Previewed ${project.applicationName} in ${plan.env} (${credential.account}): ${changesSummary}.`;
|
|
62
|
+
return { data, text };
|
|
63
|
+
}
|
|
64
|
+
const deployment = await client.deploy(bundle);
|
|
65
|
+
const cronSummary = cronJobs.map((j) => ({
|
|
66
|
+
jobId: j.jobId,
|
|
67
|
+
schedule: j.schedule,
|
|
68
|
+
cronExpression: j.cronExpression,
|
|
69
|
+
}));
|
|
70
|
+
const data = {
|
|
71
|
+
application: project.applicationName,
|
|
72
|
+
target: target.name,
|
|
73
|
+
namespace,
|
|
74
|
+
registry,
|
|
75
|
+
image: bundle.component.reference,
|
|
76
|
+
publishedImage: bundle.component.reference,
|
|
77
|
+
digest: bundle.component.digest,
|
|
78
|
+
deploymentDigest,
|
|
79
|
+
service: bundle.service,
|
|
80
|
+
env,
|
|
81
|
+
account: credential.account,
|
|
82
|
+
controller: credential.controller.url,
|
|
83
|
+
deployment,
|
|
84
|
+
...(cronSummary.length > 0 ? { cronJobs: cronSummary } : {}),
|
|
85
|
+
};
|
|
86
|
+
const cronNote = cronJobs.length > 0
|
|
87
|
+
? ` Scheduled jobs (${cronJobs.length}): ${cronJobs.map((j) => j.jobId).join(', ')}`
|
|
88
|
+
: '';
|
|
89
|
+
const text = `Deployed ${project.applicationName} to ${target.name} (${credential.account}/${deployment.env}: ${deployment.id} ${deployment.status}, ${bundle.component.reference}).${cronNote}`;
|
|
90
|
+
return { data, text };
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
wrapControllerError(error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
12
96
|
export async function runWasmcloudDeploy(args, io, deps = DEFAULT_DEPS) {
|
|
13
97
|
const options = parseAppCommandArgs(args, 'platform deploy');
|
|
14
98
|
const manifest = loadDeployManifest(deps.cwd(), deps.env);
|
|
@@ -20,6 +104,9 @@ export async function runWasmcloudDeploy(args, io, deps = DEFAULT_DEPS) {
|
|
|
20
104
|
const path = writeWorkloadManifest(manifest.workspaceRoot, project.workload, members);
|
|
21
105
|
io.stdout.write(`Generated workload manifest ${path}\n`);
|
|
22
106
|
}
|
|
107
|
+
if (isControllerBackedTarget(target)) {
|
|
108
|
+
return runControllerDeploy(project, target, manifest, options, io, deps);
|
|
109
|
+
}
|
|
23
110
|
const build = await buildComponent(project, io, deps, { deploy: true });
|
|
24
111
|
const connection = await resolveConnection(target, manifest.workspaceRoot, manifest.path, deps);
|
|
25
112
|
io.stdout.write(`Deploying ${project.applicationName} to target ${connection.target}...\n`);
|
package/dist/deps.d.ts
CHANGED
|
@@ -61,6 +61,10 @@ export type WasmcloudDeps = {
|
|
|
61
61
|
resolveFromProject(projectRoot: string, specifier: string): string | undefined;
|
|
62
62
|
env: Record<string, string | undefined>;
|
|
63
63
|
cwd(): string;
|
|
64
|
+
fetch?: typeof fetch;
|
|
65
|
+
openBrowser?(url: string): void;
|
|
66
|
+
loginTimeoutMs?: number;
|
|
67
|
+
stdin?(): string;
|
|
64
68
|
};
|
|
65
69
|
export type NodeCompatibilityPaths = {
|
|
66
70
|
guestsPath?: string;
|
package/dist/destroy.js
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
import { parseAppCommandArgs } from './args.js';
|
|
2
|
+
import { resolveControllerSession, wrapControllerError } from './controller/index.js';
|
|
2
3
|
import { DEFAULT_DEPS } from './deps.js';
|
|
3
4
|
import { resolveApplication } from './discovery.js';
|
|
4
|
-
import { loadDeployManifest } from './manifest.js';
|
|
5
|
-
import { resolveConnection, resolveTarget } from './target.js';
|
|
5
|
+
import { loadDeployManifest, tenantNamespace } from './manifest.js';
|
|
6
|
+
import { isControllerBackedTarget, resolveConnection, resolveTarget } from './target.js';
|
|
6
7
|
import { deleteWorkload, deploymentResourceName } from './workload.js';
|
|
7
8
|
export async function runWasmcloudDestroy(args, io, deps = DEFAULT_DEPS) {
|
|
8
9
|
const options = parseAppCommandArgs(args, 'platform destroy');
|
|
9
10
|
const manifest = loadDeployManifest(deps.cwd(), deps.env);
|
|
10
11
|
const target = resolveTarget(manifest, options.target);
|
|
11
12
|
const project = resolveApplication(deps.cwd(), options.name, manifest.workspaceRoot, manifest.discovery);
|
|
13
|
+
if (isControllerBackedTarget(target)) {
|
|
14
|
+
try {
|
|
15
|
+
const { credential, client } = await resolveControllerSession({ target }, deps);
|
|
16
|
+
const env = options.env ?? target.env ?? manifest.env ?? 'prod';
|
|
17
|
+
const service = deploymentResourceName(project);
|
|
18
|
+
await client.removeDeployment(env, service);
|
|
19
|
+
const namespace = tenantNamespace(credential.account);
|
|
20
|
+
return {
|
|
21
|
+
data: {
|
|
22
|
+
application: project.applicationName,
|
|
23
|
+
target: target.name,
|
|
24
|
+
account: credential.account,
|
|
25
|
+
env,
|
|
26
|
+
namespace,
|
|
27
|
+
service,
|
|
28
|
+
},
|
|
29
|
+
text: `Removed ${project.applicationName} from ${target.name} (${credential.account}/${env}).`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
wrapControllerError(error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
12
36
|
const connection = await resolveConnection(target, manifest.workspaceRoot, manifest.path, deps);
|
|
13
37
|
await deleteWorkload(project, connection, io, deps);
|
|
14
38
|
const service = deploymentResourceName(project);
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ export { ACTORS_INVOCATION_PATH, type ActorDiscoveredRecord, type ActorMethodRec
|
|
|
3
3
|
export { parseAppCommandArgs, parsePlatformCommandArgs, parsePlatformInitArgs } from './args.js';
|
|
4
4
|
export { type BindingRecord, defaultSecretName, discoverBindings, parseBindingsFile, requirementsFromBindings, } from './bindings.js';
|
|
5
5
|
export { BUILD_PROFILE, buildComponent, canonicalBuildDigest, requirementsForProject, runWasmcloudBuild, WASI_HTTP_INTERFACE, WASI_HTTP_VERSION, } from './build.js';
|
|
6
|
+
export { type BuildDeployBundleOptions, type BundlePublishContext, type BundleRegistryCredentials, buildDeployBundle, type ComponentReference, type DeployBinding, type DeployBundle, type DeployEnvironment, type ManifestBinding, normalizeSha256Digest, PASSTHROUGH_LABEL_PREFIX, type ParsedBuildArgs, parseBuildArgs, parseWorkloadDeploymentYaml, pinImageToDigest, type SanitizeWorkloadOptions, sanitizeWorkloadForBundle, } from './bundle.js';
|
|
6
7
|
export { createWasmcloudCommand } from './command.js';
|
|
7
8
|
export { runWasmcloudConsole } from './console/run.js';
|
|
9
|
+
export { type AccountCommandOptions, type AuthInfo, type AuthorizationRequest, authorizationUrl, base64url, bearer, CliError, type ClientOptions, type ConfigAction, type ConfigCommandOptions, type ConfigList, type ControllerDeployBundle, ControllerError, type CreateServiceRequest, type Credential, type CredentialStore, caPem, createClient, type Deployment, type DeploymentList, type DeploymentStats, type DeployPlan, discover, type Env, events, exchangeCode, home, issuedTokens, type LogEvent, type LoginOptions, type LogsCommandOptions, type LogsQuery, load, needsRefresh, OidcError, type Principal, type Problem, type ProviderMetadata, type ProxyRequest, type ProxySession, parseAccountCommandArgs, parseConfigArgs, parseLoginArgs, parseLogsArgs, pkce, type RegistryInfo, type RegistryOrigin, type ResolveControllerSessionOptions, type RollbackRequest, randomToken, readCaFile, readStore, refreshCredential, refreshTokens, registryOrigin, registryUsername, resolveAccount, resolveControllerSession, revokeToken, runWasmcloudLogin, runWasmcloudLogout, runWasmcloudLogs, runWasmcloudSecrets, runWasmcloudVars, runWasmcloudWhoami, type SecretList, type Service, type SseEvent, type TenantClient, type TokenResponse, tlsTrustCode, trusting, type VarUnset, wrapControllerError, writeStore, } from './controller/index.js';
|
|
8
10
|
export { runWasmcloudDeploy, type WasmcloudDeployData, type WasmcloudDeployResult, } from './deploy.js';
|
|
9
11
|
export { type BundleOptions, COMPONENT_IMPORT_EXTERNAL, COMPONENTIZE_QJS_ENV, COMPONENTIZE_QJS_PACKAGE, componentizeQjsPlatformPackageName, DEFAULT_DEPS, findInstalledComponentizeQjsCli, nativeComponentizeQjsOnPath, nodeCompatibilityPlugin, resolveComponentizeQjsPath, type WasmcloudDeps, } from './deps.js';
|
|
10
12
|
export { runWasmcloudDestroy } from './destroy.js';
|
|
@@ -14,7 +16,7 @@ export { discoverProjects, findConfigFiles, resolveApplication, } from './discov
|
|
|
14
16
|
export { runWasmcloudDoctor } from './doctor.js';
|
|
15
17
|
export { emptyGuestsModule, renderGuestsModule, WASMCLOUD_GUESTS_GLOBAL } from './guests.js';
|
|
16
18
|
export { hostInterfacesFromRequirements } from './host-interface.js';
|
|
17
|
-
export { DEPLOY_MANIFEST_NAME, type DeployManifest, type DeployTarget, loadDeployManifest, parseDeployManifest, } from './manifest.js';
|
|
19
|
+
export { type AccountTarget, type ControllerTarget, DEPLOY_MANIFEST_NAME, type DeployManifest, type DeployTarget, type ExternalTarget, isControllerDomain, isTenantName, loadDeployManifest, type ManagedTarget, normalizeControllerUrl, parseDeployManifest, tenantHostgroup, tenantNamespace, } from './manifest.js';
|
|
18
20
|
export { wasmcloudNodeEnv, wasmcloudUnenvPreset } from './node-compat/env.js';
|
|
19
21
|
export { compactEnviron, createNodeCompatSeed, NODE_COMPAT_SEED_ID, type NodeCompatSeed, } from './node-compat/seed.js';
|
|
20
22
|
export { OCI_ARTIFACT_PLATFORM } from './oci.js';
|
|
@@ -26,7 +28,7 @@ export { pulumiEnvironment, runPulumi } from './pulumi.js';
|
|
|
26
28
|
export { type DiscoveredQueueHandler, discoverQueueHandlers, isQueueWorkerProject, parseQueueHandlersInFile, } from './queues.js';
|
|
27
29
|
export { materializeRegistry, type RegistryInput, type RegistryLocation, registryReferenceHost, registryUsesPlainHttp, } from './registry.js';
|
|
28
30
|
export { BACKING_SERVICE_API_VERSION, BACKING_SERVICE_KIND, BACKING_SERVICE_RESOURCE, buildBackingServiceManifest, DEFAULT_SERVICE_CLASSES, isBackingServiceName, isServiceType, parseServiceCreateArgs, parseServiceListArgs, parseServiceNameArgs, runWasmcloudServiceClasses, runWasmcloudServiceCreate, runWasmcloudServiceDelete, runWasmcloudServiceGet, runWasmcloudServiceList, SERVICE_TYPES, summarizeService, } from './service.js';
|
|
29
|
-
export { resolveConnection, resolveTarget } from './target.js';
|
|
31
|
+
export { type ClusterConnection, discoverAccountControllerUrl, isControllerBackedTarget, resolveConnection, resolveTarget, } from './target.js';
|
|
30
32
|
export { renderWashDevYaml, writeWashDevConfig } from './wash-dev.js';
|
|
31
33
|
export { aggregateRequirements, COMPONENT_MODEL, DI_QUEUES_INTERFACE, DI_QUEUES_PACKAGE, DI_QUEUES_VERSION, defaultProjectRequirements, HTTP_ADAPTER_REQUIREMENTS, QUEUE_ADAPTER_REQUIREMENTS, QUEUE_ADAPTER_SOURCE, queueProjectRequirements, renderWorldWit, runtimeRequirementsFromJavaScript, socketRequirementsFromJavaScript, type WitRequirement, } from './wit.js';
|
|
32
34
|
export { applyWorkload, CONTROL_SECRET_CLI_KEYS, type ControlSecretWrite, CRON_INVOKER_IMAGE, controlSecretDocument, controlSecretResourceName, DEFAULT_STORAGE_MOUNT, deleteControlSecret, deleteWorkload, HOST_STORAGE_ROOT, hostStoragePath, isReady, renderWorkloadManifest, STORAGE_HOSTGROUP, type WorkloadManifestOptions, writeControlSecret, } from './workload.js';
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,10 @@ export { ACTORS_INVOCATION_PATH, createWasmcloudActorAdapter, discoverActors, em
|
|
|
5
5
|
export { parseAppCommandArgs, parsePlatformCommandArgs, parsePlatformInitArgs } from './args.js';
|
|
6
6
|
export { defaultSecretName, discoverBindings, parseBindingsFile, requirementsFromBindings, } from './bindings.js';
|
|
7
7
|
export { BUILD_PROFILE, buildComponent, canonicalBuildDigest, requirementsForProject, runWasmcloudBuild, WASI_HTTP_INTERFACE, WASI_HTTP_VERSION, } from './build.js';
|
|
8
|
+
export { buildDeployBundle, normalizeSha256Digest, PASSTHROUGH_LABEL_PREFIX, parseBuildArgs, parseWorkloadDeploymentYaml, pinImageToDigest, sanitizeWorkloadForBundle, } from './bundle.js';
|
|
8
9
|
export { createWasmcloudCommand } from './command.js';
|
|
9
10
|
export { runWasmcloudConsole } from './console/run.js';
|
|
11
|
+
export { authorizationUrl, base64url, bearer, CliError, ControllerError, caPem, createClient, discover, events, exchangeCode, home, issuedTokens, load, needsRefresh, OidcError, parseAccountCommandArgs, parseConfigArgs, parseLoginArgs, parseLogsArgs, pkce, randomToken, readCaFile, readStore, refreshCredential, refreshTokens, registryOrigin, registryUsername, resolveAccount, resolveControllerSession, revokeToken, runWasmcloudLogin, runWasmcloudLogout, runWasmcloudLogs, runWasmcloudSecrets, runWasmcloudVars, runWasmcloudWhoami, tlsTrustCode, trusting, wrapControllerError, writeStore, } from './controller/index.js';
|
|
10
12
|
export { runWasmcloudDeploy, } from './deploy.js';
|
|
11
13
|
export { COMPONENT_IMPORT_EXTERNAL, COMPONENTIZE_QJS_ENV, COMPONENTIZE_QJS_PACKAGE, componentizeQjsPlatformPackageName, DEFAULT_DEPS, findInstalledComponentizeQjsCli, nativeComponentizeQjsOnPath, nodeCompatibilityPlugin, resolveComponentizeQjsPath, } from './deps.js';
|
|
12
14
|
export { runWasmcloudDestroy } from './destroy.js';
|
|
@@ -16,7 +18,7 @@ export { discoverProjects, findConfigFiles, resolveApplication, } from './discov
|
|
|
16
18
|
export { runWasmcloudDoctor } from './doctor.js';
|
|
17
19
|
export { emptyGuestsModule, renderGuestsModule, WASMCLOUD_GUESTS_GLOBAL } from './guests.js';
|
|
18
20
|
export { hostInterfacesFromRequirements } from './host-interface.js';
|
|
19
|
-
export { DEPLOY_MANIFEST_NAME, loadDeployManifest, parseDeployManifest, } from './manifest.js';
|
|
21
|
+
export { DEPLOY_MANIFEST_NAME, isControllerDomain, isTenantName, loadDeployManifest, normalizeControllerUrl, parseDeployManifest, tenantHostgroup, tenantNamespace, } from './manifest.js';
|
|
20
22
|
export { wasmcloudNodeEnv, wasmcloudUnenvPreset } from './node-compat/env.js';
|
|
21
23
|
export { compactEnviron, createNodeCompatSeed, NODE_COMPAT_SEED_ID, } from './node-compat/seed.js';
|
|
22
24
|
export { OCI_ARTIFACT_PLATFORM } from './oci.js';
|
|
@@ -28,7 +30,7 @@ export { pulumiEnvironment, runPulumi } from './pulumi.js';
|
|
|
28
30
|
export { discoverQueueHandlers, isQueueWorkerProject, parseQueueHandlersInFile, } from './queues.js';
|
|
29
31
|
export { materializeRegistry, registryReferenceHost, registryUsesPlainHttp, } from './registry.js';
|
|
30
32
|
export { BACKING_SERVICE_API_VERSION, BACKING_SERVICE_KIND, BACKING_SERVICE_RESOURCE, buildBackingServiceManifest, DEFAULT_SERVICE_CLASSES, isBackingServiceName, isServiceType, parseServiceCreateArgs, parseServiceListArgs, parseServiceNameArgs, runWasmcloudServiceClasses, runWasmcloudServiceCreate, runWasmcloudServiceDelete, runWasmcloudServiceGet, runWasmcloudServiceList, SERVICE_TYPES, summarizeService, } from './service.js';
|
|
31
|
-
export { resolveConnection, resolveTarget } from './target.js';
|
|
33
|
+
export { discoverAccountControllerUrl, isControllerBackedTarget, resolveConnection, resolveTarget, } from './target.js';
|
|
32
34
|
export { renderWashDevYaml, writeWashDevConfig } from './wash-dev.js';
|
|
33
35
|
export { aggregateRequirements, COMPONENT_MODEL, DI_QUEUES_INTERFACE, DI_QUEUES_PACKAGE, DI_QUEUES_VERSION, defaultProjectRequirements, HTTP_ADAPTER_REQUIREMENTS, QUEUE_ADAPTER_REQUIREMENTS, QUEUE_ADAPTER_SOURCE, queueProjectRequirements, renderWorldWit, runtimeRequirementsFromJavaScript, socketRequirementsFromJavaScript, } from './wit.js';
|
|
34
36
|
export { applyWorkload, CONTROL_SECRET_CLI_KEYS, CRON_INVOKER_IMAGE, controlSecretDocument, controlSecretResourceName, DEFAULT_STORAGE_MOUNT, deleteControlSecret, deleteWorkload, HOST_STORAGE_ROOT, hostStoragePath, isReady, renderWorkloadManifest, STORAGE_HOSTGROUP, writeControlSecret, } from './workload.js';
|
package/dist/manifest.d.ts
CHANGED
|
@@ -6,11 +6,21 @@ export type DiscoveryConfig = {
|
|
|
6
6
|
include: string[];
|
|
7
7
|
exclude: string[];
|
|
8
8
|
};
|
|
9
|
+
export type DeployEnvironment = 'prod' | 'staging';
|
|
10
|
+
export type ManifestBinding = {
|
|
11
|
+
name: string;
|
|
12
|
+
capability: string;
|
|
13
|
+
serviceName: string;
|
|
14
|
+
config?: Record<string, string>;
|
|
15
|
+
};
|
|
9
16
|
export type ManagedTarget = {
|
|
10
17
|
kind: 'managed';
|
|
11
18
|
name: string;
|
|
12
19
|
platform: string;
|
|
13
20
|
stack: string;
|
|
21
|
+
env?: DeployEnvironment;
|
|
22
|
+
bindings?: ManifestBinding[];
|
|
23
|
+
secrets?: string[];
|
|
14
24
|
};
|
|
15
25
|
export type ExternalTarget = {
|
|
16
26
|
kind: 'external';
|
|
@@ -23,21 +33,55 @@ export type ExternalTarget = {
|
|
|
23
33
|
context?: string;
|
|
24
34
|
hostgroup?: string;
|
|
25
35
|
storageHostgroup?: string;
|
|
36
|
+
env?: DeployEnvironment;
|
|
37
|
+
bindings?: ManifestBinding[];
|
|
38
|
+
secrets?: string[];
|
|
39
|
+
};
|
|
40
|
+
export type AccountTarget = {
|
|
41
|
+
kind: 'account';
|
|
42
|
+
name: string;
|
|
43
|
+
account: string;
|
|
44
|
+
domain?: string;
|
|
45
|
+
env?: DeployEnvironment;
|
|
46
|
+
bindings?: ManifestBinding[];
|
|
47
|
+
secrets?: string[];
|
|
48
|
+
};
|
|
49
|
+
export type ControllerTarget = {
|
|
50
|
+
kind: 'controller';
|
|
51
|
+
name: string;
|
|
52
|
+
controller: string;
|
|
53
|
+
account?: string;
|
|
54
|
+
env?: DeployEnvironment;
|
|
55
|
+
bindings?: ManifestBinding[];
|
|
56
|
+
secrets?: string[];
|
|
26
57
|
};
|
|
27
|
-
export type DeployTarget = ManagedTarget | ExternalTarget;
|
|
58
|
+
export type DeployTarget = ManagedTarget | ExternalTarget | AccountTarget | ControllerTarget;
|
|
28
59
|
export type DeployManifest = {
|
|
29
60
|
path: string;
|
|
30
61
|
workspaceRoot: string;
|
|
31
62
|
defaultTarget?: string;
|
|
32
63
|
discovery: DiscoveryConfig;
|
|
33
64
|
targets: Record<string, DeployTarget>;
|
|
65
|
+
env?: DeployEnvironment;
|
|
66
|
+
bindings?: ManifestBinding[];
|
|
67
|
+
secrets?: string[];
|
|
34
68
|
};
|
|
35
69
|
export declare function isTenantName(value: string): boolean;
|
|
36
70
|
/** Workload namespace the platform creates for a tenant. */
|
|
37
71
|
export declare function tenantNamespace(tenant: string): string;
|
|
38
72
|
/** Host group the platform creates for a tenant. */
|
|
39
73
|
export declare function tenantHostgroup(tenant: string): string;
|
|
74
|
+
/** Valid DNS domain (and optional port) used to derive `https://<account>.controller.<domain>`. */
|
|
75
|
+
export declare function isControllerDomain(value: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Validates and normalizes a tenant controller URL (without trailing slash).
|
|
78
|
+
* Requires `https://`, or `http://` for loopback and in-cluster (`*.svc`) hosts only.
|
|
79
|
+
*/
|
|
80
|
+
export declare function normalizeControllerUrl(value: string): string | undefined;
|
|
40
81
|
export declare function findDeployManifest(startDirectory: string): string | undefined;
|
|
41
82
|
export declare function loadDeployManifest(startDirectory: string, env: Record<string, string | undefined>): DeployManifest;
|
|
42
83
|
export declare function parseDeployManifest(path: string, source: string, env: Record<string, string | undefined>): DeployManifest;
|
|
43
84
|
export declare function interpolateEnv(value: unknown, env: Record<string, string | undefined>, manifestPath: string): unknown;
|
|
85
|
+
export declare function optionalDeployEnvironment(value: unknown, label: string, manifestPath: string): DeployEnvironment | undefined;
|
|
86
|
+
export declare function parseManifestSecrets(value: unknown, label: string, manifestPath: string): string[] | undefined;
|
|
87
|
+
export declare function parseManifestBindings(value: unknown, label: string, manifestPath: string): ManifestBinding[] | undefined;
|
package/dist/manifest.js
CHANGED
|
@@ -21,6 +21,57 @@ export function tenantNamespace(tenant) {
|
|
|
21
21
|
export function tenantHostgroup(tenant) {
|
|
22
22
|
return `tenant-${tenant}`;
|
|
23
23
|
}
|
|
24
|
+
const DOMAIN_LABEL = '[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?';
|
|
25
|
+
const CONTROLLER_DOMAIN_PATTERN = new RegExp(String.raw `^${DOMAIN_LABEL}(?:\.${DOMAIN_LABEL})*(?::([1-9][0-9]{0,4}))?$`);
|
|
26
|
+
const IPV6_HOST_PATTERN = /^\[[0-9a-f:.]+\]$/;
|
|
27
|
+
/** Valid DNS domain (and optional port) used to derive `https://<account>.controller.<domain>`. */
|
|
28
|
+
export function isControllerDomain(value) {
|
|
29
|
+
const match = CONTROLLER_DOMAIN_PATTERN.exec(value);
|
|
30
|
+
if (match === null || value.length > 260)
|
|
31
|
+
return false;
|
|
32
|
+
return match[1] === undefined || Number(match[1]) <= 65535;
|
|
33
|
+
}
|
|
34
|
+
function isPlainHttpAllowedControllerHost(hostname) {
|
|
35
|
+
if (hostname === 'localhost' || hostname === '[::1]')
|
|
36
|
+
return true;
|
|
37
|
+
if (/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(hostname))
|
|
38
|
+
return true;
|
|
39
|
+
return hostname.endsWith('.svc') || hostname.endsWith('.svc.cluster.local');
|
|
40
|
+
}
|
|
41
|
+
function trimTrailingSlashes(value) {
|
|
42
|
+
let result = value;
|
|
43
|
+
while (result.endsWith('/')) {
|
|
44
|
+
result = result.slice(0, -1);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validates and normalizes a tenant controller URL (without trailing slash).
|
|
50
|
+
* Requires `https://`, or `http://` for loopback and in-cluster (`*.svc`) hosts only.
|
|
51
|
+
*/
|
|
52
|
+
export function normalizeControllerUrl(value) {
|
|
53
|
+
let url;
|
|
54
|
+
try {
|
|
55
|
+
url = new URL(value);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:')
|
|
61
|
+
return undefined;
|
|
62
|
+
if (url.username || url.password || url.search || url.hash)
|
|
63
|
+
return undefined;
|
|
64
|
+
const hostname = url.hostname.toLowerCase();
|
|
65
|
+
const validHost = new RegExp(String.raw `^${DOMAIN_LABEL}(?:\.${DOMAIN_LABEL})*$`).test(hostname) ||
|
|
66
|
+
IPV6_HOST_PATTERN.test(hostname);
|
|
67
|
+
if (!validHost)
|
|
68
|
+
return undefined;
|
|
69
|
+
if (url.protocol === 'http:' && !isPlainHttpAllowedControllerHost(hostname)) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
const path = url.pathname === '/' ? '' : trimTrailingSlashes(url.pathname);
|
|
73
|
+
return `${url.origin}${path}`;
|
|
74
|
+
}
|
|
24
75
|
const ENV_TOKEN = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
25
76
|
function manifestInvalid(message, details) {
|
|
26
77
|
throw new CommandFailure('WASMCLOUD_DEPLOY_MANIFEST_INVALID', message, 2, details);
|
|
@@ -50,6 +101,9 @@ export function parseDeployManifest(path, source, env) {
|
|
|
50
101
|
const interpolated = interpolateEnv(parsed, env, path);
|
|
51
102
|
const defaultTarget = optionalString(interpolated['default-target'], 'default-target', path);
|
|
52
103
|
const discovery = parseDiscovery(interpolated.discovery, path);
|
|
104
|
+
const manifestEnv = optionalDeployEnvironment(interpolated.env, 'env', path);
|
|
105
|
+
const bindings = parseManifestBindings(interpolated.bindings, 'bindings', path);
|
|
106
|
+
const secrets = parseManifestSecrets(interpolated.secrets, 'secrets', path);
|
|
53
107
|
const targetsValue = interpolated.targets;
|
|
54
108
|
if (targetsValue === undefined) {
|
|
55
109
|
manifestInvalid(`${DEPLOY_MANIFEST_NAME} must declare at least one [targets.<name>] table`, {
|
|
@@ -68,10 +122,17 @@ export function parseDeployManifest(path, source, env) {
|
|
|
68
122
|
if (defaultTarget !== undefined && targets[defaultTarget] === undefined) {
|
|
69
123
|
manifestInvalid(`default-target "${defaultTarget}" does not match any declared target. Known targets: ${Object.keys(targets).join(', ')}`, { manifestPath: path, defaultTarget, targets: Object.keys(targets) });
|
|
70
124
|
}
|
|
71
|
-
const knownKeys = new Set([
|
|
125
|
+
const knownKeys = new Set([
|
|
126
|
+
'default-target',
|
|
127
|
+
'discovery',
|
|
128
|
+
'targets',
|
|
129
|
+
'env',
|
|
130
|
+
'bindings',
|
|
131
|
+
'secrets',
|
|
132
|
+
]);
|
|
72
133
|
const unknown = Object.keys(interpolated).filter((key) => !knownKeys.has(key));
|
|
73
134
|
if (unknown.length > 0) {
|
|
74
|
-
manifestInvalid(`${DEPLOY_MANIFEST_NAME} has unsupported fields: ${unknown.join(', ')}. Valid fields are default-target, discovery, and
|
|
135
|
+
manifestInvalid(`${DEPLOY_MANIFEST_NAME} has unsupported fields: ${unknown.join(', ')}. Valid fields are default-target, discovery, targets, env, bindings, and secrets.`, { manifestPath: path, fields: unknown });
|
|
75
136
|
}
|
|
76
137
|
return {
|
|
77
138
|
path,
|
|
@@ -79,6 +140,9 @@ export function parseDeployManifest(path, source, env) {
|
|
|
79
140
|
defaultTarget,
|
|
80
141
|
discovery,
|
|
81
142
|
targets,
|
|
143
|
+
...(manifestEnv ? { env: manifestEnv } : {}),
|
|
144
|
+
...(bindings ? { bindings } : {}),
|
|
145
|
+
...(secrets ? { secrets } : {}),
|
|
82
146
|
};
|
|
83
147
|
}
|
|
84
148
|
export function interpolateEnv(value, env, manifestPath) {
|
|
@@ -151,6 +215,26 @@ function parseTarget(name, value, manifestPath) {
|
|
|
151
215
|
manifestInvalid(`targets.${name}.namespace must be a Kubernetes namespace (a DNS label of at most 63 characters)`, { manifestPath, target: name });
|
|
152
216
|
}
|
|
153
217
|
const registry = optionalRegistry(value.registry, `targets.${name}.registry`, manifestPath);
|
|
218
|
+
const account = optionalString(value.account, `targets.${name}.account`, manifestPath);
|
|
219
|
+
if (account !== undefined && !isTenantName(account)) {
|
|
220
|
+
manifestInvalid(`targets.${name}.account must be a platform tenant name: 1-40 lowercase letters, digits, and single hyphens, starting with a letter (got "${account}")`, { manifestPath, target: name, account });
|
|
221
|
+
}
|
|
222
|
+
const domain = optionalString(value.domain, `targets.${name}.domain`, manifestPath);
|
|
223
|
+
if (domain !== undefined && !isControllerDomain(domain)) {
|
|
224
|
+
manifestInvalid(`targets.${name}.domain must be a valid DNS domain (got "${domain}")`, {
|
|
225
|
+
manifestPath,
|
|
226
|
+
target: name,
|
|
227
|
+
domain,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
const rawController = optionalString(value.controller, `targets.${name}.controller`, manifestPath);
|
|
231
|
+
const controller = rawController === undefined ? undefined : normalizeControllerUrl(rawController);
|
|
232
|
+
if (rawController !== undefined && controller === undefined) {
|
|
233
|
+
manifestInvalid(`targets.${name}.controller must be an https:// URL (or http:// for loopback or in-cluster *.svc hosts)`, { manifestPath, target: name, controller: rawController });
|
|
234
|
+
}
|
|
235
|
+
const env = optionalDeployEnvironment(value.env, `targets.${name}.env`, manifestPath);
|
|
236
|
+
const bindings = parseManifestBindings(value.bindings, `targets.${name}.bindings`, manifestPath);
|
|
237
|
+
const secrets = parseManifestSecrets(value.secrets, `targets.${name}.secrets`, manifestPath);
|
|
154
238
|
const known = new Set([
|
|
155
239
|
'platform',
|
|
156
240
|
'stack',
|
|
@@ -161,10 +245,16 @@ function parseTarget(name, value, manifestPath) {
|
|
|
161
245
|
'registry',
|
|
162
246
|
'hostgroup',
|
|
163
247
|
'storage-hostgroup',
|
|
248
|
+
'account',
|
|
249
|
+
'controller',
|
|
250
|
+
'domain',
|
|
251
|
+
'env',
|
|
252
|
+
'bindings',
|
|
253
|
+
'secrets',
|
|
164
254
|
]);
|
|
165
255
|
const unknown = Object.keys(value).filter((key) => !known.has(key));
|
|
166
256
|
if (unknown.length > 0) {
|
|
167
|
-
manifestInvalid(`Target "${name}" has unsupported fields: ${unknown.join(', ')}. Managed targets accept platform and stack; external targets accept kubeconfig, context, tenant, namespace, registry, hostgroup, and storage-hostgroup.`, { manifestPath, target: name, fields: unknown });
|
|
257
|
+
manifestInvalid(`Target "${name}" has unsupported fields: ${unknown.join(', ')}. Managed targets accept platform and stack; external targets accept kubeconfig, context, tenant, namespace, registry, hostgroup, and storage-hostgroup; tenant controller targets accept account, domain, and controller.`, { manifestPath, target: name, fields: unknown });
|
|
168
258
|
}
|
|
169
259
|
const managedFields = [platform ? 'platform' : undefined, stack ? 'stack' : undefined].filter((field) => field !== undefined);
|
|
170
260
|
const externalFields = [
|
|
@@ -176,14 +266,51 @@ function parseTarget(name, value, manifestPath) {
|
|
|
176
266
|
namespace ? 'namespace' : undefined,
|
|
177
267
|
registry ? 'registry' : undefined,
|
|
178
268
|
].filter((field) => field !== undefined);
|
|
269
|
+
const controllerFields = [
|
|
270
|
+
account ? 'account' : undefined,
|
|
271
|
+
controller ? 'controller' : undefined,
|
|
272
|
+
domain ? 'domain' : undefined,
|
|
273
|
+
].filter((field) => field !== undefined);
|
|
179
274
|
if (managedFields.length > 0 && externalFields.length > 0) {
|
|
180
275
|
manifestInvalid(`Target "${name}" mixes managed-platform and kubeconfig fields (${[...managedFields, ...externalFields].join(', ')}). Use either platform (and optional stack), or kubeconfig + registry + tenant or namespace.`, { manifestPath, target: name });
|
|
181
276
|
}
|
|
277
|
+
if (controllerFields.length > 0 && (managedFields.length > 0 || externalFields.length > 0)) {
|
|
278
|
+
manifestInvalid(`Target "${name}" mixes controller/account fields with operator fields (${[...managedFields, ...externalFields, ...controllerFields].join(', ')}). Use account (and optional domain) or controller (and optional account) for tenant controller targets.`, { manifestPath, target: name });
|
|
279
|
+
}
|
|
280
|
+
if (domain !== undefined && controller !== undefined) {
|
|
281
|
+
manifestInvalid(`Target "${name}" sets domain with controller. domain is only valid on account targets without an explicit controller URL.`, { manifestPath, target: name });
|
|
282
|
+
}
|
|
283
|
+
if (domain !== undefined && account === undefined) {
|
|
284
|
+
manifestInvalid(`Target "${name}" sets domain without account. domain is only valid on account targets.`, { manifestPath, target: name });
|
|
285
|
+
}
|
|
182
286
|
if (stack !== undefined && platform === undefined) {
|
|
183
287
|
manifestInvalid(`Target "${name}" sets stack without platform. stack is only valid on managed Pulumi targets.`, { manifestPath, target: name });
|
|
184
288
|
}
|
|
289
|
+
const bundleExtras = {
|
|
290
|
+
...(env ? { env } : {}),
|
|
291
|
+
...(bindings ? { bindings } : {}),
|
|
292
|
+
...(secrets ? { secrets } : {}),
|
|
293
|
+
};
|
|
294
|
+
if (controller !== undefined) {
|
|
295
|
+
return {
|
|
296
|
+
kind: 'controller',
|
|
297
|
+
name,
|
|
298
|
+
controller,
|
|
299
|
+
...(account ? { account } : {}),
|
|
300
|
+
...bundleExtras,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
if (account !== undefined) {
|
|
304
|
+
return {
|
|
305
|
+
kind: 'account',
|
|
306
|
+
name,
|
|
307
|
+
account,
|
|
308
|
+
...(domain ? { domain } : {}),
|
|
309
|
+
...bundleExtras,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
185
312
|
if (platform !== undefined) {
|
|
186
|
-
return { kind: 'managed', name, platform, stack: stack ?? 'dev' };
|
|
313
|
+
return { kind: 'managed', name, platform, stack: stack ?? 'dev', ...bundleExtras };
|
|
187
314
|
}
|
|
188
315
|
if (kubeconfig !== undefined ||
|
|
189
316
|
tenant !== undefined ||
|
|
@@ -210,10 +337,76 @@ function parseTarget(name, value, manifestPath) {
|
|
|
210
337
|
...(tenant ? { tenant } : {}),
|
|
211
338
|
...(resolvedHostgroup ? { hostgroup: resolvedHostgroup } : {}),
|
|
212
339
|
...(storageHostgroup ? { storageHostgroup } : {}),
|
|
340
|
+
...bundleExtras,
|
|
213
341
|
};
|
|
214
342
|
}
|
|
215
343
|
manifestInvalid(`Target "${name}" is empty. Set platform (and optional stack) for a managed Pulumi platform, or kubeconfig, registry, and tenant (or namespace) for an external cluster.`, { manifestPath, target: name });
|
|
216
344
|
}
|
|
345
|
+
export function optionalDeployEnvironment(value, label, manifestPath) {
|
|
346
|
+
if (value === undefined)
|
|
347
|
+
return undefined;
|
|
348
|
+
if (value !== 'prod' && value !== 'staging') {
|
|
349
|
+
manifestInvalid(`${label} must be "prod" or "staging"`, { manifestPath, field: label });
|
|
350
|
+
}
|
|
351
|
+
return value;
|
|
352
|
+
}
|
|
353
|
+
export function parseManifestSecrets(value, label, manifestPath) {
|
|
354
|
+
const entries = optionalStringArray(value, label, manifestPath);
|
|
355
|
+
return entries === undefined ? undefined : [...new Set(entries)];
|
|
356
|
+
}
|
|
357
|
+
export function parseManifestBindings(value, label, manifestPath) {
|
|
358
|
+
if (value === undefined)
|
|
359
|
+
return undefined;
|
|
360
|
+
if (!isRecord(value)) {
|
|
361
|
+
manifestInvalid(`${label} must be a table of named bindings`, { manifestPath, field: label });
|
|
362
|
+
}
|
|
363
|
+
const result = [];
|
|
364
|
+
for (const [name, entry] of Object.entries(value)) {
|
|
365
|
+
if (!isRecord(entry)) {
|
|
366
|
+
manifestInvalid(`${label}.${name} must be a table`, {
|
|
367
|
+
manifestPath,
|
|
368
|
+
field: `${label}.${name}`,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
const known = new Set(['capability', 'service', 'serviceName', 'service-name', 'config']);
|
|
372
|
+
const unknown = Object.keys(entry).filter((key) => !known.has(key));
|
|
373
|
+
if (unknown.length > 0) {
|
|
374
|
+
manifestInvalid(`${label}.${name} has unsupported fields: ${unknown.join(', ')}`, {
|
|
375
|
+
manifestPath,
|
|
376
|
+
field: `${label}.${name}`,
|
|
377
|
+
fields: unknown,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
const capability = optionalString(entry.capability, `${label}.${name}.capability`, manifestPath);
|
|
381
|
+
if (capability === undefined) {
|
|
382
|
+
manifestInvalid(`${label}.${name}.capability is required`, {
|
|
383
|
+
manifestPath,
|
|
384
|
+
field: `${label}.${name}.capability`,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
const serviceName = optionalString(entry.serviceName ?? entry['service-name'] ?? entry.service, `${label}.${name}.serviceName`, manifestPath) ?? name;
|
|
388
|
+
let config;
|
|
389
|
+
if (entry.config !== undefined) {
|
|
390
|
+
if (!isRecord(entry.config) ||
|
|
391
|
+
Object.values(entry.config).some((v) => typeof v !== 'string')) {
|
|
392
|
+
manifestInvalid(`${label}.${name}.config must be a table of string values`, {
|
|
393
|
+
manifestPath,
|
|
394
|
+
field: `${label}.${name}.config`,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
if (Object.keys(entry.config).length > 0) {
|
|
398
|
+
config = { ...entry.config };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
result.push({
|
|
402
|
+
name,
|
|
403
|
+
capability,
|
|
404
|
+
serviceName,
|
|
405
|
+
...(config ? { config } : {}),
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return result;
|
|
409
|
+
}
|
|
217
410
|
function optionalString(value, label, manifestPath) {
|
|
218
411
|
if (value === undefined)
|
|
219
412
|
return undefined;
|