@puls-atlas/cli
Version:
The Puls Atlas CLI tool for managing Atlas projects
51 lines • 2.02 kB
JavaScript
import inquirer from 'inquirer';
import { normalizeOptionalString } from '../../../../utils/value.js';
import { createDefaultAirbyteServiceConfigSection } from './config.js';
export const resolveAirbyteServiceSelection = async (currentConfig = {}, options = {}, dependencies = {}) => {
const promptImpl = dependencies.prompt ?? inquirer.prompt;
const defaults = createDefaultAirbyteServiceConfigSection();
let host = normalizeOptionalString(options.host ?? currentConfig.host);
let adminEmail = normalizeOptionalString(options.adminEmail ?? currentConfig.adminEmail);
if (!host) {
const answer = await promptImpl([{
default: currentConfig.host ?? null,
message: 'Which public hostname should serve Airbyte?',
name: 'host',
type: 'input'
}]);
host = normalizeOptionalString(answer.host);
}
if (!adminEmail) {
const answer = await promptImpl([{
default: currentConfig.adminEmail ?? null,
message: 'Which email address should become the initial Airbyte admin?',
name: 'adminEmail',
type: 'input'
}]);
adminEmail = normalizeOptionalString(answer.adminEmail);
}
if (!host) {
throw new Error('Atlas deploy service airbyte requires --host for the Airbyte ingress.');
}
if (!adminEmail) {
throw new Error('Atlas deploy service airbyte requires --admin-email for the initial Airbyte administrator.');
}
return {
...defaults,
...currentConfig,
...(normalizeOptionalString(options.chartVersion) ? {
chartVersion: normalizeOptionalString(options.chartVersion)
} : {}),
...(normalizeOptionalString(options.clusterLocation) ? {
clusterLocation: normalizeOptionalString(options.clusterLocation)
} : {}),
...(normalizeOptionalString(options.clusterName) ? {
clusterName: normalizeOptionalString(options.clusterName)
} : {}),
...(normalizeOptionalString(options.namespace) ? {
namespace: normalizeOptionalString(options.namespace)
} : {}),
adminEmail,
host
};
};