@aifabrix/builder 2.44.6 → 2.45.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/cli-layout.mdc +7 -3
- package/.cursor/rules/docs-rules.mdc +3 -1
- package/integration/hubspot-test/test-artifacts/wizard-hubspot-credential-real.yaml +1 -1
- package/integration/hubspot-test/test-artifacts/wizard-hubspot-env-vars.yaml +1 -1
- package/integration/hubspot-test/wizard-hubspot-e2e.yaml +1 -1
- package/jest.projects.js +100 -1
- package/lib/api/agent-metadata-validation.api.js +93 -0
- package/lib/api/audit-api-helpers.js +68 -0
- package/lib/api/audit.api.js +119 -0
- package/lib/api/auth-cache.api.js +44 -0
- package/lib/api/certificates.api.js +4 -4
- package/lib/api/credential.api.js +2 -2
- package/lib/api/dataplane-health.api.js +137 -0
- package/lib/api/dataplane-sync.api.js +27 -0
- package/lib/api/datasources-core.api.js +21 -18
- package/lib/api/datasources-extended.api.js +22 -22
- package/lib/api/dimensions.api.js +3 -0
- package/lib/api/external-systems.api.js +13 -13
- package/lib/api/governance-scenarios.api.js +39 -0
- package/lib/api/groups.api.js +79 -0
- package/lib/api/index.js +45 -2
- package/lib/api/pipeline.api.js +4 -4
- package/lib/api/protection.api.js +157 -0
- package/lib/api/records-bulk.api.js +30 -0
- package/lib/api/records-search-parse.js +49 -0
- package/lib/api/records-search.api.js +29 -0
- package/lib/api/types/agent-metadata-validation.types.js +67 -0
- package/lib/api/types/audit.types.js +72 -0
- package/lib/api/types/dataplane-health.types.js +27 -0
- package/lib/api/types/dimensions.types.js +2 -0
- package/lib/api/types/governance-scenarios.types.js +39 -0
- package/lib/api/types/protection.types.js +69 -0
- package/lib/api/types/records-bulk.types.js +35 -0
- package/lib/api/types/records-search.types.js +28 -0
- package/lib/api/user-groups.api.js +50 -0
- package/lib/api/users.api.js +95 -0
- package/lib/api/validation-run.api.js +3 -3
- package/lib/api/validation-runner.js +3 -3
- package/lib/api/wizard-platform.api.js +3 -3
- package/lib/api/wizard.api.js +21 -21
- package/lib/app/deploy.js +34 -19
- package/lib/app/helpers.js +3 -3
- package/lib/app/index.js +3 -3
- package/lib/app/register.js +7 -6
- package/lib/app/restart-display.js +52 -21
- package/lib/app/rotate-secret.js +7 -6
- package/lib/app/run-helpers.js +15 -8
- package/lib/app/run.js +57 -9
- package/lib/app/show-display.js +7 -0
- package/lib/app/show.js +87 -5
- package/lib/build/index.js +9 -5
- package/lib/cli/index.js +4 -2
- package/lib/cli/infra-guided.js +62 -28
- package/lib/cli/installation-log-command.js +73 -0
- package/lib/cli/setup-app.help.js +50 -2
- package/lib/cli/setup-app.js +44 -25
- package/lib/cli/setup-app.test-commands.js +80 -21
- package/lib/cli/setup-auth.js +124 -52
- package/lib/cli/setup-external-system.js +37 -3
- package/lib/cli/setup-infra-up-dataplane-action.js +111 -0
- package/lib/cli/setup-infra-up-platform-action.js +131 -0
- package/lib/cli/setup-infra.js +60 -119
- package/lib/cli/setup-platform.js +1 -1
- package/lib/cli/setup-utility-help-after.js +45 -0
- package/lib/cli/setup-utility-resolve.js +132 -0
- package/lib/cli/setup-utility.js +148 -116
- package/lib/commands/app-logs.js +81 -33
- package/lib/commands/auth-config.js +116 -18
- package/lib/commands/auth-status-dataplane-version.js +231 -0
- package/lib/commands/auth-status-display.js +94 -0
- package/lib/commands/auth-status.js +70 -6
- package/lib/commands/credential-push.js +10 -5
- package/lib/commands/datasource-load-export-cli.js +178 -0
- package/lib/commands/datasource-test-trust-cli.js +114 -0
- package/lib/commands/datasource-unified-test-cli.js +25 -17
- package/lib/commands/datasource-unified-test-cli.options.js +18 -3
- package/lib/commands/datasource-unified-test-e2e-cli-helpers.js +5 -5
- package/lib/commands/datasource-verify-audit-cli.js +96 -0
- package/lib/commands/datasource.js +68 -1
- package/lib/commands/dimension-value.js +43 -13
- package/lib/commands/dimension.js +38 -7
- package/lib/commands/identity-apply-sync.js +131 -0
- package/lib/commands/identity-group-cli.js +146 -0
- package/lib/commands/identity-membership-role-cache.js +175 -0
- package/lib/commands/identity-shared.js +94 -0
- package/lib/commands/identity-user-cli.js +158 -0
- package/lib/commands/identity.js +43 -0
- package/lib/commands/login.js +46 -16
- package/lib/commands/protection-cli-leaves.js +286 -0
- package/lib/commands/protection.js +50 -0
- package/lib/commands/repair.js +13 -3
- package/lib/commands/setup-modes.js +19 -6
- package/lib/commands/setup-prompts.js +41 -8
- package/lib/commands/setup.js +114 -9
- package/lib/commands/teardown.js +54 -5
- package/lib/commands/test-e2e-external.js +40 -9
- package/lib/commands/test-governance-cli-options.js +47 -0
- package/lib/commands/test-governance-command-action.js +55 -0
- package/lib/commands/test-governance-external.js +88 -0
- package/lib/commands/test-trust-cli-options.js +32 -0
- package/lib/commands/test-trust-command-action.js +118 -0
- package/lib/commands/test-trust-external.js +127 -0
- package/lib/commands/up-common.js +48 -14
- package/lib/commands/up-dataplane.js +21 -18
- package/lib/commands/up-miso.js +12 -8
- package/lib/commands/upload.js +38 -15
- package/lib/commands/wizard-core.js +3 -0
- package/lib/core/audit-logger.js +1 -34
- package/lib/core/config-admin-email.js +56 -0
- package/lib/core/config-device-dataplane.js +185 -0
- package/lib/core/config-normalize.js +60 -0
- package/lib/core/config-registered-controller-urls.js +54 -0
- package/lib/core/config.js +33 -50
- package/lib/core/secrets-ensure-infra.js +1 -1
- package/lib/core/secrets-env-content.js +86 -90
- package/lib/core/secrets-env-declarative-expand.js +170 -0
- package/lib/core/secrets-env-write.js +2 -0
- package/lib/core/secrets-load.js +106 -102
- package/lib/datasource/agent-trust-debug-log.js +45 -0
- package/lib/datasource/agent-trust-fetch.js +115 -0
- package/lib/datasource/agent-trust-map.js +101 -0
- package/lib/datasource/agent-trust-mock.js +44 -0
- package/lib/datasource/agent-trust-run.js +93 -0
- package/lib/datasource/agent-trust-timeout.js +25 -0
- package/lib/datasource/audit-evidence-display.js +80 -0
- package/lib/datasource/audit-evidence-extract-debug.js +103 -0
- package/lib/datasource/audit-evidence-extract.js +177 -0
- package/lib/datasource/audit-evidence-matrix-rows.js +158 -0
- package/lib/datasource/audit-evidence-operation-aliases.js +63 -0
- package/lib/datasource/audit-evidence-poll.js +109 -0
- package/lib/datasource/audit-evidence-run.js +177 -0
- package/lib/datasource/audit-evidence-verify-helpers.js +167 -0
- package/lib/datasource/audit-evidence-verify-matrix.js +177 -0
- package/lib/datasource/audit-evidence-verify.js +108 -0
- package/lib/datasource/bulk-loader-run-batches.js +88 -0
- package/lib/datasource/bulk-loader-service-retry.js +52 -0
- package/lib/datasource/bulk-loader-service.js +127 -0
- package/lib/datasource/capability/run-capability-dimension.js +2 -1
- package/lib/datasource/datasource-exporter-resolve.js +82 -0
- package/lib/datasource/datasource-exporter-service.js +144 -0
- package/lib/datasource/datasource-identifier.js +148 -0
- package/lib/datasource/datasource-load-export-context.js +92 -0
- package/lib/datasource/integration-context.js +6 -4
- package/lib/datasource/local-data-paths.js +145 -0
- package/lib/datasource/log-cleaner.js +241 -0
- package/lib/datasource/log-viewer.js +111 -6
- package/lib/datasource/record-file-parser.js +85 -0
- package/lib/datasource/record-mapper.js +129 -0
- package/lib/datasource/resolve-app.js +74 -55
- package/lib/datasource/test-e2e.js +26 -2
- package/lib/datasource/unified-validation-run-resolve.js +45 -12
- package/lib/datasource/unified-validation-run.js +43 -17
- package/lib/datasource/validate.js +37 -20
- package/lib/external-system/deploy.js +5 -1
- package/lib/external-system/test-system-level.js +25 -4
- package/lib/external-system/test.js +3 -1
- package/lib/governance/governance-pack-loader.js +70 -0
- package/lib/governance/governance-run-display.js +119 -0
- package/lib/identity/identity-apply-core.js +108 -0
- package/lib/identity/identity-apply-phases.js +244 -0
- package/lib/identity/identity-apply-service.js +77 -0
- package/lib/identity/identity-csv-parser.js +114 -0
- package/lib/internal/fs-real-sync.js +29 -1
- package/lib/internal/node-fs.js +2 -0
- package/lib/protection/auth-context.js +45 -0
- package/lib/protection/convert-batch.js +90 -0
- package/lib/protection/load.js +41 -0
- package/lib/protection/paths.js +158 -0
- package/lib/protection/preflight-datasource-ready.js +46 -0
- package/lib/protection/protection-create-probe-lines.js +142 -0
- package/lib/protection/protection-create-probes.js +95 -0
- package/lib/protection/protection-create-scaffold.js +281 -0
- package/lib/protection/protection-display-helpers.js +445 -0
- package/lib/protection/protection-display.js +215 -0
- package/lib/protection/protection-preset-registry.js +97 -0
- package/lib/protection/report-exit.js +62 -0
- package/lib/protection/resolve.js +202 -0
- package/lib/protection/run-commands-validate.js +130 -0
- package/lib/protection/run-commands.js +216 -0
- package/lib/protection/run-protection-create-helpers.js +134 -0
- package/lib/protection/run-protection-create-probes-flow.js +43 -0
- package/lib/protection/run-protection-create.js +191 -0
- package/lib/protection/scope.js +22 -0
- package/lib/protection/sync-after-upload.js +64 -0
- package/lib/protection/upload-batch.js +127 -0
- package/lib/protection/validate-batch.js +113 -0
- package/lib/protection/validate-local.js +65 -0
- package/lib/resolvers/dimension-file.js +29 -4
- package/lib/schema/application-schema.json +4 -0
- package/lib/schema/external-datasource.schema.json +47 -13
- package/lib/schema/flag-map-validation-run.json +2 -2
- package/lib/schema/infra.parameter.yaml +10 -0
- package/lib/schema/protection.schema.json +374 -0
- package/lib/schema/type/credential-field-registry.json +636 -0
- package/lib/schema/wizard-config.schema.json +1 -1
- package/lib/utils/agent-trust-run-display.js +231 -0
- package/lib/utils/agent-trust-run-exit.js +59 -0
- package/lib/utils/agent-trust-wait-ui.js +94 -0
- package/lib/utils/app-config-resolver.js +24 -1
- package/lib/utils/applications-config-defaults.js +206 -0
- package/lib/utils/auth-config-validator.js +2 -12
- package/lib/utils/bash-secret-env.js +1 -1
- package/lib/utils/cli-exit-codes.js +30 -0
- package/lib/utils/cli-sync-options.js +33 -0
- package/lib/utils/compose-generate-docker-compose.js +111 -6
- package/lib/utils/compose-generator.js +17 -8
- package/lib/utils/controller-url.js +50 -7
- package/lib/utils/credential-push-ui.js +90 -0
- package/lib/utils/dataplane-cli-version-gate.js +202 -0
- package/lib/utils/dataplane-cli-version-help.js +74 -0
- package/lib/utils/datasource-export-display.js +137 -0
- package/lib/utils/datasource-load-display.js +174 -0
- package/lib/utils/datasource-load-export-ui.js +120 -0
- package/lib/utils/datasource-test-run-capability-scope.js +3 -3
- package/lib/utils/datasource-test-run-display.js +3 -3
- package/lib/utils/datasource-test-run-tty-log.js +5 -1
- package/lib/utils/env-copy.js +99 -14
- package/lib/utils/env-template.js +5 -1
- package/lib/utils/health-check-url.js +18 -15
- package/lib/utils/health-check.js +7 -5
- package/lib/utils/help-builder.js +30 -24
- package/lib/utils/infra-optional-service-flags.js +69 -0
- package/lib/utils/installation-log-core.js +282 -0
- package/lib/utils/installation-log-record.js +237 -0
- package/lib/utils/installation-log.js +123 -0
- package/lib/utils/log-redaction.js +105 -0
- package/lib/utils/manifest-location.js +164 -0
- package/lib/utils/manifest-source-emit.js +184 -0
- package/lib/utils/paths.js +238 -89
- package/lib/utils/remote-secrets-loader.js +7 -1
- package/lib/utils/run-cli-flags.js +29 -0
- package/lib/utils/secrets-canonical.js +10 -3
- package/lib/utils/secrets-path.js +3 -4
- package/lib/utils/secrets-utils.js +20 -10
- package/lib/utils/semver-compare.js +127 -0
- package/lib/utils/system-builder-root.js +10 -2
- package/lib/utils/upload-pipeline-ui.js +91 -0
- package/lib/utils/url-declarative-public-base.js +80 -12
- package/lib/utils/url-declarative-resolve-build-urls.js +238 -0
- package/lib/utils/url-declarative-resolve-build.js +24 -393
- package/lib/utils/url-declarative-resolve-expand-token.js +189 -0
- package/lib/utils/url-declarative-resolve-load-doc.js +12 -3
- package/lib/utils/url-declarative-resolve-surface-state.js +102 -0
- package/lib/utils/url-declarative-resolve.js +47 -7
- package/lib/utils/url-declarative-runtime-base-path.js +21 -1
- package/lib/utils/urls-local-registry-scan.js +103 -0
- package/lib/utils/urls-local-registry.js +161 -90
- package/lib/utils/validation-poll-ui.js +14 -7
- package/lib/validation/wizard-config-validator.js +58 -19
- package/package.json +3 -1
- package/templates/applications/dataplane/application.yaml +4 -0
- package/templates/applications/dataplane/env.template +13 -1
- package/templates/applications/dataplane/rbac.yaml +4 -0
- package/templates/applications/miso-controller/application.yaml +2 -0
- package/templates/applications/miso-controller/env.template +27 -29
- package/templates/external-system/README.md.hbs +56 -8
- package/.npmrc.token +0 -1
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for installation.log (no append I/O).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview installation log core utilities
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const fsSync = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const paths = require('./paths');
|
|
14
|
+
const { maskSensitiveData } = require('./log-redaction');
|
|
15
|
+
const { loadConfigFile } = require('./config-format');
|
|
16
|
+
const { resolveDockerImageRef } = require('./resolve-docker-image-ref');
|
|
17
|
+
const { parseImageOptions } = require('../commands/up-miso');
|
|
18
|
+
|
|
19
|
+
let opCounter = 0;
|
|
20
|
+
let opDay = '';
|
|
21
|
+
|
|
22
|
+
let cachedCliVersion = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
function getCliVersion() {
|
|
28
|
+
if (cachedCliVersion) {
|
|
29
|
+
return cachedCliVersion;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const pkgPath = path.join(__dirname, '..', '..', 'package.json');
|
|
33
|
+
const raw = fsSync.readFileSync(pkgPath, 'utf8');
|
|
34
|
+
const pkg = JSON.parse(raw);
|
|
35
|
+
cachedCliVersion = typeof pkg.version === 'string' ? pkg.version : 'unknown';
|
|
36
|
+
} catch {
|
|
37
|
+
cachedCliVersion = 'unknown';
|
|
38
|
+
}
|
|
39
|
+
return cachedCliVersion;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @returns {string} e.g. op_20260513_001
|
|
44
|
+
*/
|
|
45
|
+
function createOperationId() {
|
|
46
|
+
const d = new Date();
|
|
47
|
+
const day = d.toISOString().slice(0, 10).replace(/-/g, '');
|
|
48
|
+
if (day !== opDay) {
|
|
49
|
+
opDay = day;
|
|
50
|
+
opCounter = 0;
|
|
51
|
+
}
|
|
52
|
+
opCounter += 1;
|
|
53
|
+
return `op_${day}_${String(opCounter).padStart(3, '0')}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {string} ref
|
|
58
|
+
* @returns {string}
|
|
59
|
+
*/
|
|
60
|
+
function stripDockerDigest(ref) {
|
|
61
|
+
if (!ref || typeof ref !== 'string') {
|
|
62
|
+
return ref;
|
|
63
|
+
}
|
|
64
|
+
return ref.replace(/@sha256:[a-f0-9]+$/i, '');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param {string|undefined} url
|
|
69
|
+
* @returns {string|undefined}
|
|
70
|
+
*/
|
|
71
|
+
function sanitizeUrl(url) {
|
|
72
|
+
if (!url || typeof url !== 'string') {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const u = new URL(url);
|
|
77
|
+
u.username = '';
|
|
78
|
+
u.password = '';
|
|
79
|
+
let s = u.toString();
|
|
80
|
+
if (s.endsWith('/')) {
|
|
81
|
+
s = s.slice(0, -1);
|
|
82
|
+
}
|
|
83
|
+
return s;
|
|
84
|
+
} catch {
|
|
85
|
+
return maskSensitiveData(url);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {Object} [options]
|
|
91
|
+
* @returns {'interactive'|'automation'}
|
|
92
|
+
*/
|
|
93
|
+
function resolveLogMode(options = {}) {
|
|
94
|
+
const assume =
|
|
95
|
+
options.yes === true ||
|
|
96
|
+
options.assumeYes === true ||
|
|
97
|
+
process.env.CI === 'true' ||
|
|
98
|
+
process.env.CI === '1';
|
|
99
|
+
if (assume) {
|
|
100
|
+
return 'automation';
|
|
101
|
+
}
|
|
102
|
+
if (process.stdin && process.stdin.isTTY && process.stdout && process.stdout.isTTY) {
|
|
103
|
+
return 'interactive';
|
|
104
|
+
}
|
|
105
|
+
return 'automation';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {boolean|undefined} optVal
|
|
110
|
+
* @returns {boolean}
|
|
111
|
+
*/
|
|
112
|
+
function cliBoolExplicit(optVal) {
|
|
113
|
+
return optVal === true || optVal === false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @param {string} label
|
|
118
|
+
* @param {boolean} value
|
|
119
|
+
* @param {boolean} fromCli
|
|
120
|
+
* @returns {string}
|
|
121
|
+
*/
|
|
122
|
+
function infraLine(label, value, fromCli) {
|
|
123
|
+
const src = fromCli ? 'cli override' : 'config';
|
|
124
|
+
return ` ${label}: ${value} (${src})`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param {Object} cfg
|
|
129
|
+
* @param {Object} options
|
|
130
|
+
* @returns {{ lines: string[] }}
|
|
131
|
+
*/
|
|
132
|
+
function buildInfraSectionLines(cfg, options = {}) {
|
|
133
|
+
const { computeEffectiveInfraOptionalFlags } = require('./infra-optional-service-flags');
|
|
134
|
+
const effective = computeEffectiveInfraOptionalFlags(cfg, options);
|
|
135
|
+
const tls = cfg.tlsEnabled === true;
|
|
136
|
+
const tlsFromCli = cliBoolExplicit(options.tls);
|
|
137
|
+
const lines = [
|
|
138
|
+
'Infra',
|
|
139
|
+
infraLine('traefik', effective.traefik, cliBoolExplicit(options.traefik)),
|
|
140
|
+
infraLine('tlsEnabled', tls, tlsFromCli),
|
|
141
|
+
infraLine('pgAdmin', effective.pgadmin, cliBoolExplicit(options.pgAdmin)),
|
|
142
|
+
infraLine('redisCommander', effective.redisCommander, cliBoolExplicit(options.redisAdmin))
|
|
143
|
+
];
|
|
144
|
+
return { lines };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @param {string} appName
|
|
149
|
+
* @returns {Object|null}
|
|
150
|
+
*/
|
|
151
|
+
function loadBuilderAppVariables(appName) {
|
|
152
|
+
try {
|
|
153
|
+
const dir = paths.getBuilderPath(appName);
|
|
154
|
+
if (!fsSync.existsSync(dir)) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const configPath = paths.resolveApplicationConfigPath(dir);
|
|
158
|
+
return loadConfigFile(configPath) || {};
|
|
159
|
+
} catch {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @param {string} appName
|
|
166
|
+
* @param {Object} map
|
|
167
|
+
* @param {Object} runOpts
|
|
168
|
+
* @returns {void}
|
|
169
|
+
*/
|
|
170
|
+
function applyParsedImageMapToRunOpts(appName, map, runOpts) {
|
|
171
|
+
if (appName === 'keycloak' && map.keycloak) {
|
|
172
|
+
runOpts.image = map.keycloak;
|
|
173
|
+
}
|
|
174
|
+
if (appName === 'miso-controller' && map['miso-controller']) {
|
|
175
|
+
runOpts.image = map['miso-controller'];
|
|
176
|
+
}
|
|
177
|
+
if (appName === 'dataplane' && map.dataplane) {
|
|
178
|
+
runOpts.image = map.dataplane;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @param {string} appName
|
|
184
|
+
* @param {Object} options
|
|
185
|
+
* @returns {Object}
|
|
186
|
+
*/
|
|
187
|
+
function buildImageResolveOpts(appName, options) {
|
|
188
|
+
const runOpts = {
|
|
189
|
+
registry: options.registry || undefined,
|
|
190
|
+
base: options.base !== false
|
|
191
|
+
};
|
|
192
|
+
const imageList = options.image;
|
|
193
|
+
if (Array.isArray(imageList)) {
|
|
194
|
+
applyParsedImageMapToRunOpts(appName, parseImageOptions(imageList), runOpts);
|
|
195
|
+
} else if (typeof imageList === 'string' && imageList.trim()) {
|
|
196
|
+
const t = imageList.trim();
|
|
197
|
+
if (!t.includes('=') && appName === 'dataplane') {
|
|
198
|
+
runOpts.image = t;
|
|
199
|
+
} else if (t.includes('=')) {
|
|
200
|
+
applyParsedImageMapToRunOpts(appName, parseImageOptions([t]), runOpts);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return runOpts;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @param {string} imageRef
|
|
208
|
+
* @returns {string}
|
|
209
|
+
*/
|
|
210
|
+
function imageRefForLog(imageRef) {
|
|
211
|
+
return stripDockerDigest(String(imageRef).trim());
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @param {string} appName
|
|
216
|
+
* @param {Object} options
|
|
217
|
+
* @returns {string}
|
|
218
|
+
*/
|
|
219
|
+
function resolveAppImageDisplay(appName, options) {
|
|
220
|
+
const variables = loadBuilderAppVariables(appName);
|
|
221
|
+
if (!variables) {
|
|
222
|
+
return 'unknown';
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const runOpts = buildImageResolveOpts(appName, options);
|
|
226
|
+
const { imageName, imageTag } = resolveDockerImageRef(appName, variables, runOpts);
|
|
227
|
+
return imageRefForLog(`${imageName}:${imageTag}`);
|
|
228
|
+
} catch {
|
|
229
|
+
return 'unknown';
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @param {string[]} appNames
|
|
235
|
+
* @param {Object} options
|
|
236
|
+
* @returns {Record<string,string>}
|
|
237
|
+
*/
|
|
238
|
+
function collectPlatformAppImages(appNames, options = {}) {
|
|
239
|
+
/** @type {Record<string,string>} */
|
|
240
|
+
const out = {};
|
|
241
|
+
for (const app of appNames) {
|
|
242
|
+
out[app] = resolveAppImageDisplay(app, options);
|
|
243
|
+
}
|
|
244
|
+
return out;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @param {Record<string,string>} platformApps
|
|
249
|
+
* @returns {string}
|
|
250
|
+
*/
|
|
251
|
+
function derivePlatformVersion(platformApps) {
|
|
252
|
+
const tags = new Set();
|
|
253
|
+
for (const ref of Object.values(platformApps)) {
|
|
254
|
+
if (!ref || ref === 'unknown') {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const noDig = stripDockerDigest(ref);
|
|
258
|
+
const idx = noDig.lastIndexOf(':');
|
|
259
|
+
if (idx <= 0 || idx >= noDig.length - 1) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const tag = noDig.slice(idx + 1);
|
|
263
|
+
if (!tag.includes('/')) {
|
|
264
|
+
tags.add(tag);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (tags.size === 0) {
|
|
268
|
+
return 'unknown';
|
|
269
|
+
}
|
|
270
|
+
return [...tags].sort().join('|');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
module.exports = {
|
|
274
|
+
getCliVersion,
|
|
275
|
+
createOperationId,
|
|
276
|
+
stripDockerDigest,
|
|
277
|
+
sanitizeUrl,
|
|
278
|
+
resolveLogMode,
|
|
279
|
+
buildInfraSectionLines,
|
|
280
|
+
collectPlatformAppImages,
|
|
281
|
+
derivePlatformVersion
|
|
282
|
+
};
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build deterministic installation.log record lines (no I/O).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview installation record body formatting
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const config = require('../core/config');
|
|
12
|
+
const { maskSensitiveData } = require('./log-redaction');
|
|
13
|
+
const {
|
|
14
|
+
createOperationId,
|
|
15
|
+
getCliVersion,
|
|
16
|
+
collectPlatformAppImages,
|
|
17
|
+
derivePlatformVersion,
|
|
18
|
+
buildInfraSectionLines,
|
|
19
|
+
resolveLogMode,
|
|
20
|
+
sanitizeUrl
|
|
21
|
+
} = require('./installation-log-core');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string[]} lines
|
|
25
|
+
* @param {string} isoHeader
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
function pushTopBanner(lines, isoHeader) {
|
|
29
|
+
lines.push('='.repeat(80));
|
|
30
|
+
lines.push(`INSTALLATION ${isoHeader}`);
|
|
31
|
+
lines.push('-'.repeat(80));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {string[]} lines
|
|
36
|
+
* @param {Object} payload
|
|
37
|
+
* @param {Object} identity
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
40
|
+
function pushIdentityCore(lines, payload, identity) {
|
|
41
|
+
const { startedAt, completedAt, developerId, mode, platformVersion, durationSec } = identity;
|
|
42
|
+
lines.push('recordVersion: 1');
|
|
43
|
+
lines.push(`operationId: ${createOperationId()}`);
|
|
44
|
+
lines.push(`command: ${payload.command}`);
|
|
45
|
+
lines.push(`outcome: ${payload.outcome}`);
|
|
46
|
+
lines.push(`durationSec: ${durationSec}`);
|
|
47
|
+
lines.push(`cliVersion: ${getCliVersion()}`);
|
|
48
|
+
lines.push(`platformVersion: ${platformVersion}`);
|
|
49
|
+
lines.push(`developerId: ${developerId}`);
|
|
50
|
+
lines.push(`mode: ${mode}`);
|
|
51
|
+
lines.push(`startedAt: ${startedAt.toISOString()}`);
|
|
52
|
+
lines.push(`completedAt: ${completedAt.toISOString()}`);
|
|
53
|
+
|
|
54
|
+
if (payload.setupMode) {
|
|
55
|
+
lines.push(`setupMode: ${payload.setupMode}`);
|
|
56
|
+
}
|
|
57
|
+
if (payload.upPlatformForce) {
|
|
58
|
+
lines.push('upPlatformForce: true');
|
|
59
|
+
}
|
|
60
|
+
lines.push('');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {string[]} lines
|
|
65
|
+
* @param {Object} payload
|
|
66
|
+
* @param {Object} identity
|
|
67
|
+
* @param {Date} identity.startedAt
|
|
68
|
+
* @param {Date} identity.completedAt
|
|
69
|
+
* @param {string} identity.developerId
|
|
70
|
+
* @param {string} identity.mode
|
|
71
|
+
* @param {string} identity.platformVersion
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
function pushHeaderAndIdentity(lines, payload, identity) {
|
|
75
|
+
const { startedAt, completedAt } = identity;
|
|
76
|
+
const durationSec = Math.round(
|
|
77
|
+
Math.max(0, completedAt.getTime() - startedAt.getTime()) / 1000
|
|
78
|
+
);
|
|
79
|
+
const isoHeader = completedAt.toISOString();
|
|
80
|
+
pushTopBanner(lines, isoHeader);
|
|
81
|
+
pushIdentityCore(lines, payload, { ...identity, durationSec });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {string[]} lines
|
|
86
|
+
* @param {Object} payload
|
|
87
|
+
* @returns {void}
|
|
88
|
+
*/
|
|
89
|
+
function pushInfraBlock(lines, payload) {
|
|
90
|
+
if (!payload.infra || !payload.infra.cfg) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const { lines: infraLines } = buildInfraSectionLines(payload.infra.cfg, payload.infra.options || {});
|
|
94
|
+
lines.push(...infraLines);
|
|
95
|
+
lines.push('');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param {string[]} lines
|
|
100
|
+
* @param {Record<string,string>|undefined} platformApps
|
|
101
|
+
* @returns {void}
|
|
102
|
+
*/
|
|
103
|
+
function pushPlatformAppsBlock(lines, platformApps) {
|
|
104
|
+
if (!platformApps || Object.keys(platformApps).length === 0) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
lines.push('Platform Apps');
|
|
108
|
+
for (const key of Object.keys(platformApps).sort()) {
|
|
109
|
+
lines.push(` ${key}: ${platformApps[key]}`);
|
|
110
|
+
}
|
|
111
|
+
lines.push('');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {string[]} lines
|
|
116
|
+
* @param {Object} payload
|
|
117
|
+
* @returns {void}
|
|
118
|
+
*/
|
|
119
|
+
function pushConfigBlock(lines, payload) {
|
|
120
|
+
const cfgExtra = payload.configExtra || {};
|
|
121
|
+
const hasConfig =
|
|
122
|
+
cfgExtra.controllerUrl ||
|
|
123
|
+
cfgExtra.adminEmail === 'set' ||
|
|
124
|
+
cfgExtra.adminEmail === 'unset';
|
|
125
|
+
if (!hasConfig) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
lines.push('Config');
|
|
129
|
+
if (cfgExtra.controllerUrl) {
|
|
130
|
+
lines.push(` controllerUrl: ${sanitizeUrl(cfgExtra.controllerUrl)}`);
|
|
131
|
+
}
|
|
132
|
+
if (cfgExtra.adminEmail === 'set' || cfgExtra.adminEmail === 'unset') {
|
|
133
|
+
lines.push(` adminEmail: ${cfgExtra.adminEmail}`);
|
|
134
|
+
}
|
|
135
|
+
lines.push('');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param {string[]} lines
|
|
140
|
+
* @param {Object} payload
|
|
141
|
+
* @returns {void}
|
|
142
|
+
*/
|
|
143
|
+
function pushCleanupBlock(lines, payload) {
|
|
144
|
+
const cleanup = payload.cleanup;
|
|
145
|
+
if (!cleanup || typeof cleanup !== 'object' || Object.keys(cleanup).length === 0) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
lines.push('Cleanup');
|
|
149
|
+
if (cleanup.volumesRemoved !== undefined) {
|
|
150
|
+
lines.push(` volumesRemoved: ${cleanup.volumesRemoved}`);
|
|
151
|
+
}
|
|
152
|
+
if (cleanup.configPreserved !== undefined) {
|
|
153
|
+
lines.push(` configPreserved: ${cleanup.configPreserved}`);
|
|
154
|
+
}
|
|
155
|
+
if (Array.isArray(cleanup.cleanedAppKeys) && cleanup.cleanedAppKeys.length > 0) {
|
|
156
|
+
lines.push(` cleanedAppKeys: ${cleanup.cleanedAppKeys.sort().join(', ')}`);
|
|
157
|
+
}
|
|
158
|
+
lines.push('');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @param {string[]} lines
|
|
163
|
+
* @param {Object} payload
|
|
164
|
+
* @returns {void}
|
|
165
|
+
*/
|
|
166
|
+
function pushErrorSection(lines, payload) {
|
|
167
|
+
if (payload.outcome !== 'failure' || !payload.error) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const msg =
|
|
171
|
+
typeof payload.error.message === 'string'
|
|
172
|
+
? payload.error.message
|
|
173
|
+
: String(payload.error);
|
|
174
|
+
lines.push('Error');
|
|
175
|
+
lines.push(` message: ${maskSensitiveData(msg)}`);
|
|
176
|
+
if (payload.errorCode) {
|
|
177
|
+
lines.push(` code: ${maskSensitiveData(String(payload.errorCode))}`);
|
|
178
|
+
}
|
|
179
|
+
lines.push('');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @param {Object} payload
|
|
184
|
+
* @returns {Promise<Object>}
|
|
185
|
+
*/
|
|
186
|
+
async function resolvePlatformContextForRecord(payload) {
|
|
187
|
+
const completedAt = payload.completedAt || new Date();
|
|
188
|
+
const startedAt = payload.startedAt || completedAt;
|
|
189
|
+
const options = payload.options || {};
|
|
190
|
+
const mode = resolveLogMode(options);
|
|
191
|
+
|
|
192
|
+
let developerId = 'unknown';
|
|
193
|
+
try {
|
|
194
|
+
const id = await config.getDeveloperId();
|
|
195
|
+
developerId = id === null || id === undefined ? 'unknown' : String(id);
|
|
196
|
+
} catch {
|
|
197
|
+
// ignore
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
let platformApps = payload.platformApps;
|
|
201
|
+
if (!platformApps && Array.isArray(payload.platformAppList) && payload.platformAppList.length > 0) {
|
|
202
|
+
platformApps = collectPlatformAppImages(payload.platformAppList, options);
|
|
203
|
+
}
|
|
204
|
+
const platformVersion =
|
|
205
|
+
payload.platformVersion ||
|
|
206
|
+
(platformApps ? derivePlatformVersion(platformApps) : 'unknown');
|
|
207
|
+
|
|
208
|
+
return { completedAt, startedAt, mode, developerId, platformApps, platformVersion };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @param {Object} payload
|
|
213
|
+
* @returns {Promise<string[]>}
|
|
214
|
+
*/
|
|
215
|
+
async function buildInstallationRecordLines(payload) {
|
|
216
|
+
const ctx = await resolvePlatformContextForRecord(payload);
|
|
217
|
+
const lines = [];
|
|
218
|
+
pushHeaderAndIdentity(lines, payload, {
|
|
219
|
+
startedAt: ctx.startedAt,
|
|
220
|
+
completedAt: ctx.completedAt,
|
|
221
|
+
developerId: ctx.developerId,
|
|
222
|
+
mode: ctx.mode,
|
|
223
|
+
platformVersion: ctx.platformVersion
|
|
224
|
+
});
|
|
225
|
+
pushInfraBlock(lines, payload);
|
|
226
|
+
pushPlatformAppsBlock(lines, ctx.platformApps);
|
|
227
|
+
pushConfigBlock(lines, payload);
|
|
228
|
+
pushCleanupBlock(lines, payload);
|
|
229
|
+
pushErrorSection(lines, payload);
|
|
230
|
+
lines.push('='.repeat(80));
|
|
231
|
+
lines.push('');
|
|
232
|
+
return lines;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
module.exports = {
|
|
236
|
+
buildInstallationRecordLines
|
|
237
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Append-only operational log for platform install / infra commands.
|
|
3
|
+
* One record per top-level CLI command; no secrets; deterministic section order.
|
|
4
|
+
*
|
|
5
|
+
* @fileoverview installation.log writer beside config.yaml
|
|
6
|
+
* @author AI Fabrix Team
|
|
7
|
+
* @version 2.0.0
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const fs = require('fs').promises;
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const paths = require('./paths');
|
|
15
|
+
const config = require('../core/config');
|
|
16
|
+
const logger = require('./logger');
|
|
17
|
+
const { buildInstallationRecordLines } = require('./installation-log-record');
|
|
18
|
+
const { sanitizeUrl } = require('./installation-log-core');
|
|
19
|
+
|
|
20
|
+
const INSTALLATION_LOG = 'installation.log';
|
|
21
|
+
/** Rotate when log exceeds this size; keep .1 and .2 backups. */
|
|
22
|
+
const MAX_LOG_BYTES = 10 * 1024 * 1024;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {string} logPath
|
|
26
|
+
* @param {number} [maxBytes]
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
async function rotateInstallationLogIfNeeded(logPath, maxBytes = MAX_LOG_BYTES) {
|
|
30
|
+
let st;
|
|
31
|
+
try {
|
|
32
|
+
st = await fs.stat(logPath);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
if (e && e.code === 'ENOENT') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
if (st.size < maxBytes) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const dir = path.dirname(logPath);
|
|
43
|
+
const base = path.basename(logPath);
|
|
44
|
+
const p2 = path.join(dir, `${base}.2`);
|
|
45
|
+
const p1 = path.join(dir, `${base}.1`);
|
|
46
|
+
try {
|
|
47
|
+
await fs.unlink(p2);
|
|
48
|
+
} catch {
|
|
49
|
+
// ignore
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
await fs.rename(p1, p2);
|
|
53
|
+
} catch {
|
|
54
|
+
// ignore
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await fs.rename(logPath, p1);
|
|
58
|
+
} catch {
|
|
59
|
+
// ignore
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {Object} payload
|
|
65
|
+
* @returns {Promise<void>}
|
|
66
|
+
*/
|
|
67
|
+
async function appendInstallationRecord(payload) {
|
|
68
|
+
const lines = await buildInstallationRecordLines(payload);
|
|
69
|
+
const body = lines.join('\n');
|
|
70
|
+
const logDir = paths.getAifabrixSystemDir();
|
|
71
|
+
const logPath = path.join(logDir, INSTALLATION_LOG);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
await fs.mkdir(logDir, { recursive: true });
|
|
75
|
+
await rotateInstallationLogIfNeeded(logPath);
|
|
76
|
+
await fs.appendFile(logPath, body, 'utf8');
|
|
77
|
+
} catch (err) {
|
|
78
|
+
logger.warn(`installation.log: could not append (${err && err.message ? err.message : err})`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @returns {Promise<string|undefined>}
|
|
84
|
+
*/
|
|
85
|
+
async function resolveControllerUrlForLog() {
|
|
86
|
+
try {
|
|
87
|
+
const { resolveControllerUrl } = require('./controller-url');
|
|
88
|
+
const u = await resolveControllerUrl();
|
|
89
|
+
return sanitizeUrl(u);
|
|
90
|
+
} catch {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @returns {Promise<'set'|'unset'>}
|
|
97
|
+
*/
|
|
98
|
+
async function resolveAdminEmailPresence() {
|
|
99
|
+
try {
|
|
100
|
+
const e = await config.getAdminEmail();
|
|
101
|
+
return e && String(e).trim() ? 'set' : 'unset';
|
|
102
|
+
} catch {
|
|
103
|
+
return 'unset';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const core = require('./installation-log-core');
|
|
108
|
+
|
|
109
|
+
module.exports = {
|
|
110
|
+
appendInstallationRecord,
|
|
111
|
+
createOperationId: core.createOperationId,
|
|
112
|
+
stripDockerDigest: core.stripDockerDigest,
|
|
113
|
+
collectPlatformAppImages: core.collectPlatformAppImages,
|
|
114
|
+
derivePlatformVersion: core.derivePlatformVersion,
|
|
115
|
+
resolveControllerUrlForLog,
|
|
116
|
+
resolveAdminEmailPresence,
|
|
117
|
+
buildInfraSectionLines: core.buildInfraSectionLines,
|
|
118
|
+
resolveLogMode: core.resolveLogMode,
|
|
119
|
+
getCliVersion: core.getCliVersion,
|
|
120
|
+
rotateInstallationLogIfNeeded,
|
|
121
|
+
INSTALLATION_LOG,
|
|
122
|
+
MAX_LOG_BYTES
|
|
123
|
+
};
|