Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
98 lines
2.7 KiB
JavaScript
98 lines
2.7 KiB
JavaScript
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import {
|
|
fileExists,
|
|
listSiteIds,
|
|
resolveConfigBase,
|
|
resolveSitePaths,
|
|
resolveRuntimePaths,
|
|
} from './runtime-paths.mjs';
|
|
|
|
function readTextIfExists(filePath) {
|
|
if (!fileExists(filePath)) {
|
|
return null;
|
|
}
|
|
return fs.readFileSync(filePath, 'utf8').trim();
|
|
}
|
|
|
|
function resolveDefaultSite(siteIds) {
|
|
if (siteIds.includes('appliance-single-node')) {
|
|
return 'appliance-single-node';
|
|
}
|
|
return siteIds[0] || 'appliance-single-node';
|
|
}
|
|
|
|
function resolveSelectedSiteId(siteIds, options = {}) {
|
|
if (options.siteId) {
|
|
return {
|
|
siteId: options.siteId,
|
|
requiresSelection: false,
|
|
};
|
|
}
|
|
|
|
if (siteIds.length <= 1) {
|
|
return {
|
|
siteId: resolveDefaultSite(siteIds),
|
|
requiresSelection: false,
|
|
};
|
|
}
|
|
|
|
if (options.allowAmbiguousSiteSelection) {
|
|
return {
|
|
siteId: null,
|
|
requiresSelection: true,
|
|
};
|
|
}
|
|
|
|
throw new Error(
|
|
`Multiple appliance sites found: ${siteIds.join(', ')}. Re-run with --site-id.`,
|
|
);
|
|
}
|
|
|
|
export function discoverEnvironment(options = {}) {
|
|
const runtime = resolveRuntimePaths(options);
|
|
const homeDir = options.homeDir || os.homedir();
|
|
const configBaseDir = options.configBaseDir || resolveConfigBase(homeDir);
|
|
const siteIds = listSiteIds(configBaseDir);
|
|
const selectedSite = resolveSelectedSiteId(siteIds, options);
|
|
const site = selectedSite.siteId ? resolveSitePaths(configBaseDir, selectedSite.siteId) : null;
|
|
const discoveredNodeIp =
|
|
options.nodeIp || (site ? readTextIfExists(site.nodeIpFile) : null) || null;
|
|
const discoveredAppUrl =
|
|
options.appUrl || (site ? readTextIfExists(site.appUrlFile) : null) || null;
|
|
|
|
return {
|
|
runtime,
|
|
configBaseDir,
|
|
siteIds,
|
|
suggestedSiteId: resolveDefaultSite(siteIds),
|
|
siteSelectionRequired: selectedSite.requiresSelection,
|
|
site,
|
|
paths: {
|
|
kubeconfig: options.kubeconfig || site?.kubeconfig || null,
|
|
talosconfig: options.talosconfig || site?.talosconfig || null,
|
|
},
|
|
nodeIp: discoveredNodeIp,
|
|
appUrl: discoveredAppUrl,
|
|
};
|
|
}
|
|
|
|
export function selectDiscoveredSite(environment, siteId) {
|
|
const site = resolveSitePaths(environment.configBaseDir, siteId);
|
|
return {
|
|
...environment,
|
|
siteIds: environment.siteIds.includes(siteId)
|
|
? environment.siteIds
|
|
: [...environment.siteIds, siteId].sort(),
|
|
siteSelectionRequired: false,
|
|
site,
|
|
paths: {
|
|
...environment.paths,
|
|
kubeconfig: environment.paths.kubeconfig || site.kubeconfig,
|
|
talosconfig: environment.paths.talosconfig || site.talosconfig,
|
|
},
|
|
nodeIp: environment.nodeIp || readTextIfExists(site.nodeIpFile) || null,
|
|
appUrl: environment.appUrl || readTextIfExists(site.appUrlFile) || null,
|
|
};
|
|
}
|