From 964748cc35356976d78ddd4427aa83cc0258bebe Mon Sep 17 00:00:00 2001 From: Jennie Gao Date: Tue, 19 Nov 2024 14:52:35 -0800 Subject: [PATCH 1/4] add write config func --- airbyte-local-cli-nodejs/src/command.ts | 2 + airbyte-local-cli-nodejs/src/index.ts | 5 +- airbyte-local-cli-nodejs/src/utils.ts | 54 ++++++++++++++++++++- airbyte-local-cli-nodejs/test/utils.test.ts | 23 ++++++++- 4 files changed, 80 insertions(+), 4 deletions(-) diff --git a/airbyte-local-cli-nodejs/src/command.ts b/airbyte-local-cli-nodejs/src/command.ts index 2058705..77f0eea 100644 --- a/airbyte-local-cli-nodejs/src/command.ts +++ b/airbyte-local-cli-nodejs/src/command.ts @@ -65,6 +65,7 @@ export interface FarosConfig { rawMessages: boolean; keepContainers: boolean; logLevel: string; + debug: boolean; } // Command line program @@ -260,6 +261,7 @@ export async function parseAndValidateInputs(argv: string[]) { rawMessages: cliOptions.rawMessages ?? false, keepContainers: cliOptions.keepContainers ?? false, logLevel: cliOptions.logLevel ?? 'info', + debug: cliOptions.debug ?? false, }; if (cliOptions.srcImage || cliOptions.dstImage) { diff --git a/airbyte-local-cli-nodejs/src/index.ts b/airbyte-local-cli-nodejs/src/index.ts index 497a77a..8a2e393 100644 --- a/airbyte-local-cli-nodejs/src/index.ts +++ b/airbyte-local-cli-nodejs/src/index.ts @@ -1,9 +1,10 @@ import {parseAndValidateInputs} from './command'; -import {checkDockerInstalled, logger} from './utils'; +import {checkDockerInstalled, logger, writeConfig} from './utils'; async function main() { - await parseAndValidateInputs(process.argv); + const config = await parseAndValidateInputs(process.argv); checkDockerInstalled(); + writeConfig('', config); } main().catch((error) => { diff --git a/airbyte-local-cli-nodejs/src/utils.ts b/airbyte-local-cli-nodejs/src/utils.ts index 46ea73c..ffd2475 100644 --- a/airbyte-local-cli-nodejs/src/utils.ts +++ b/airbyte-local-cli-nodejs/src/utils.ts @@ -1,10 +1,16 @@ import {spawnSync} from 'node:child_process'; +import {writeFileSync} from 'node:fs'; import {readFile} from 'node:fs/promises'; +import {sep} from 'node:path'; import pino from 'pino'; import pretty from 'pino-pretty'; -import {AirbyteConfig} from './command'; +import {AirbyteConfig, FarosConfig} from './command'; + +// constants +export const TEMP_DIR = 'tmp-'; +export const FILENAME_PREFIX = 'faros_airbyte_cli'; // Create a pino logger instance export const logger = pino(pretty({colorize: true})); @@ -47,3 +53,49 @@ export function checkDockerInstalled(command = 'docker', args = ['--version']) { throw new Error(`Docker is not installed: ${result.stderr.toString()}`); } } + +// Write Airbyte config and catalog to temporary dir and a json file +// TODO: @FAI-14122 React secrets +// TODO: @FAI-14134 Discover catalog +export function writeConfig(tmpDir: string, config: FarosConfig) { + const airbyteConfig = { + src: config.src ?? ({} as AirbyteConfig), + dst: config.dst ?? ({} as AirbyteConfig), + }; + + // write Airbyte config for user's reference + logger.debug(`Writing Airbyte config for user reference...`); + writeFileSync(`${FILENAME_PREFIX}_config.json`, JSON.stringify(airbyteConfig, null, 2)); + logger.debug(airbyteConfig, `Airbyte config: `); + logger.debug(`Airbyte config written to: ${FILENAME_PREFIX}_config.json`); + + // add config `feed_cfg.debug` if debug is enabled + const regex = /^farosai\/airbyte-faros-feeds-source.*/; + if (config.debug && regex.exec(airbyteConfig.src.image ?? '')) { + airbyteConfig.src.config = { + ...airbyteConfig.src.config, + feed_cfg: {debug: true}, + }; + } + + // write config to temporary directory config files + logger.debug(`Writing Airbyte config to files...`); + const srcConfigFilePath = `${tmpDir}${sep}${FILENAME_PREFIX}_src_config.json`; + const dstConfigFilePath = `${tmpDir}${sep}${FILENAME_PREFIX}_dst_config.json`; + writeFileSync(srcConfigFilePath, JSON.stringify(airbyteConfig.src.config ?? {}, null, 2)); + writeFileSync(dstConfigFilePath, JSON.stringify(airbyteConfig.dst.config ?? {}, null, 2)); + logger.debug(`Airbyte config files written to: ${srcConfigFilePath}, ${dstConfigFilePath}`); + + // write catalog to temporary directory catalog files + const srcCatalogFilePath = `${tmpDir}${sep}${FILENAME_PREFIX}_src_catalog.json`; + const dstCatalogFilePath = `${tmpDir}${sep}${FILENAME_PREFIX}_dst_catalog.json`; + if ( + (!airbyteConfig.dst.catalog || Object.keys(airbyteConfig.dst.catalog).length === 0) && + airbyteConfig.src.catalog && + Object.keys(airbyteConfig.src.catalog).length > 0 + ) { + airbyteConfig.dst.catalog = airbyteConfig.src.catalog; + } + writeFileSync(srcCatalogFilePath, JSON.stringify(airbyteConfig.src.catalog ?? {}, null, 2)); + writeFileSync(dstCatalogFilePath, JSON.stringify(airbyteConfig.dst.catalog ?? {}, null, 2)); +} diff --git a/airbyte-local-cli-nodejs/test/utils.test.ts b/airbyte-local-cli-nodejs/test/utils.test.ts index 63fe428..39c8ee5 100644 --- a/airbyte-local-cli-nodejs/test/utils.test.ts +++ b/airbyte-local-cli-nodejs/test/utils.test.ts @@ -1,7 +1,9 @@ +import {writeFileSync} from 'node:fs'; import {readFile} from 'node:fs/promises'; -import {checkDockerInstalled, parseConfigFile} from '../src/utils'; +import {checkDockerInstalled, parseConfigFile, writeConfig} from '../src/utils'; +jest.mock('node:fs'); jest.mock('node:fs/promises', () => ({ readFile: jest.fn(), })); @@ -55,3 +57,22 @@ describe('checkDockerInstalled', () => { expect(() => checkDockerInstalled('bad-command')).toThrow(); }); }); + +describe.only('writeConfig', () => { + it('should pass if config is written to file', () => { + const config = { + src: { + image: 'source-image', + config: {}, + }, + dst: { + image: 'destination-image', + config: {}, + }, + }; + const tmpDir = 'test-tmp-dir'; + const expectedConfigFile = `${tmpDir}/faros_airbyte_cli_config.json`; + writeConfig(tmpDir, config); + expect(writeFileSync).toHaveBeenCalledWith(expectedConfigFile, JSON.stringify(config)); + }); +}); From 8c3f8764eb98b25bde1747b1e37ab0e86a3f63d6 Mon Sep 17 00:00:00 2001 From: Jennie Gao Date: Tue, 19 Nov 2024 16:33:42 -0800 Subject: [PATCH 2/4] add tests for write config --- airbyte-local-cli-nodejs/src/index.ts | 3 +- airbyte-local-cli-nodejs/src/utils.ts | 8 +- .../test/__snapshots__/utils.it.test.ts.snap | 10 +- airbyte-local-cli-nodejs/test/command.test.ts | 3 + .../test/utils.it.test.ts | 140 +++++++++++++++--- airbyte-local-cli-nodejs/test/utils.test.ts | 23 +-- 6 files changed, 140 insertions(+), 47 deletions(-) diff --git a/airbyte-local-cli-nodejs/src/index.ts b/airbyte-local-cli-nodejs/src/index.ts index 568420b..85ecae2 100644 --- a/airbyte-local-cli-nodejs/src/index.ts +++ b/airbyte-local-cli-nodejs/src/index.ts @@ -1,6 +1,6 @@ import {parseAndValidateInputs} from './command'; import {AirbyteCliContext} from './types'; -import {checkDockerInstalled, cleanUp, createTmpDir, loadStateFile, logger} from './utils'; +import {checkDockerInstalled, cleanUp, createTmpDir, loadStateFile, logger, writeConfig} from './utils'; function main() { const context: AirbyteCliContext = {}; @@ -9,6 +9,7 @@ function main() { checkDockerInstalled(); context.tmpDir = createTmpDir(); loadStateFile(context.tmpDir, cfg?.stateFile, cfg?.connectionName); + writeConfig(context.tmpDir, cfg); } catch (error: any) { logger.error(error.message, 'Error'); cleanUp(context); diff --git a/airbyte-local-cli-nodejs/src/utils.ts b/airbyte-local-cli-nodejs/src/utils.ts index 869fe38..4bf7f11 100644 --- a/airbyte-local-cli-nodejs/src/utils.ts +++ b/airbyte-local-cli-nodejs/src/utils.ts @@ -6,7 +6,7 @@ import {sep} from 'node:path'; import pino from 'pino'; import pretty from 'pino-pretty'; -import {AirbyteConfig} from './types'; +import {AirbyteCliContext, AirbyteConfig, FarosConfig} from './types'; // constants export const FILENAME_PREFIX = 'faros_airbyte_cli'; @@ -111,8 +111,6 @@ export function cleanUp(context: AirbyteCliContext): void { } // Write Airbyte config and catalog to temporary dir and a json file -// TODO: @FAI-14122 React secrets -// TODO: @FAI-14134 Discover catalog export function writeConfig(tmpDir: string, config: FarosConfig) { const airbyteConfig = { src: config.src ?? ({} as AirbyteConfig), @@ -120,6 +118,7 @@ export function writeConfig(tmpDir: string, config: FarosConfig) { }; // write Airbyte config for user's reference + // TODO: @FAI-14122 React secrets logger.debug(`Writing Airbyte config for user reference...`); writeFileSync(`${FILENAME_PREFIX}_config.json`, JSON.stringify(airbyteConfig, null, 2)); logger.debug(airbyteConfig, `Airbyte config: `); @@ -143,6 +142,8 @@ export function writeConfig(tmpDir: string, config: FarosConfig) { logger.debug(`Airbyte config files written to: ${srcConfigFilePath}, ${dstConfigFilePath}`); // write catalog to temporary directory catalog files + // TODO: @FAI-14134 Discover catalog + logger.debug(`Writing Airbyte catalog to files...`); const srcCatalogFilePath = `${tmpDir}${sep}${FILENAME_PREFIX}_src_catalog.json`; const dstCatalogFilePath = `${tmpDir}${sep}${FILENAME_PREFIX}_dst_catalog.json`; if ( @@ -154,4 +155,5 @@ export function writeConfig(tmpDir: string, config: FarosConfig) { } writeFileSync(srcCatalogFilePath, JSON.stringify(airbyteConfig.src.catalog ?? {}, null, 2)); writeFileSync(dstCatalogFilePath, JSON.stringify(airbyteConfig.dst.catalog ?? {}, null, 2)); + logger.debug(`Airbyte catalog files written to: ${srcCatalogFilePath}, ${dstCatalogFilePath}`); } diff --git a/airbyte-local-cli-nodejs/test/__snapshots__/utils.it.test.ts.snap b/airbyte-local-cli-nodejs/test/__snapshots__/utils.it.test.ts.snap index 12adcb4..b3b1e82 100644 --- a/airbyte-local-cli-nodejs/test/__snapshots__/utils.it.test.ts.snap +++ b/airbyte-local-cli-nodejs/test/__snapshots__/utils.it.test.ts.snap @@ -1,10 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`loadStateFile should pass with existing state file 1`] = ` -"{"format":"base64/gzip","data":"dGVzdA=="} -" -`; - exports[`parseConfigFile should pass 1`] = ` { "dst": { @@ -32,3 +27,8 @@ exports[`parseConfigFile should pass 1`] = ` }, } `; + +exports[`write files to temporary dir loadStateFile should pass with existing state file 1`] = ` +"{"format":"base64/gzip","data":"dGVzdA=="} +" +`; diff --git a/airbyte-local-cli-nodejs/test/command.test.ts b/airbyte-local-cli-nodejs/test/command.test.ts index 83343c7..a50ee39 100644 --- a/airbyte-local-cli-nodejs/test/command.test.ts +++ b/airbyte-local-cli-nodejs/test/command.test.ts @@ -12,6 +12,7 @@ const defaultConfig = { rawMessages: false, keepContainers: false, logLevel: 'info', + debug: false, }; afterEach(() => { @@ -196,6 +197,7 @@ describe('Check other options', () => { rawMessages: true, keepContainers: true, logLevel: 'debug', + debug: true, }); }); @@ -207,6 +209,7 @@ describe('Check other options', () => { src: {image: 'source-image', config: {}}, dst: {image: 'destination-image', config: {}}, logLevel: 'debug', + debug: true, }); }); diff --git a/airbyte-local-cli-nodejs/test/utils.it.test.ts b/airbyte-local-cli-nodejs/test/utils.it.test.ts index 4ed2f7c..5695462 100644 --- a/airbyte-local-cli-nodejs/test/utils.it.test.ts +++ b/airbyte-local-cli-nodejs/test/utils.it.test.ts @@ -1,6 +1,16 @@ import {existsSync, mkdtempSync, readFileSync, rmSync} from 'node:fs'; +import {tmpdir} from 'node:os'; -import {checkDockerInstalled, cleanUp, createTmpDir, loadStateFile, parseConfigFile} from '../src/utils'; +import {FarosConfig} from '../src/types'; +import { + checkDockerInstalled, + cleanUp, + createTmpDir, + FILENAME_PREFIX, + loadStateFile, + parseConfigFile, + writeConfig, +} from '../src/utils'; describe('parseConfigFile', () => { it('should pass', () => { @@ -35,31 +45,127 @@ describe('createTmpDir', () => { }); }); -describe('loadStateFile', () => { +describe('write files to temporary dir', () => { let tmpDirPath: string; beforeAll(() => { - tmpDirPath = mkdtempSync('test-temp-dir'); + tmpDirPath = mkdtempSync(`${tmpdir()}/test-temp-dir`); }); afterAll(() => { rmSync(tmpDirPath, {recursive: true, force: true}); }); - it('should pass without existing state file', () => { - expect(() => loadStateFile(tmpDirPath)).not.toThrow(); - expect(existsSync(`${tmpDirPath}/state.json`)).toBe(true); - expect(readFileSync(`${tmpDirPath}/state.json`, 'utf8')).toBe('{}'); - }); + describe('loadStateFile', () => { + it('should pass without existing state file', () => { + expect(() => loadStateFile(tmpDirPath)).not.toThrow(); + expect(existsSync(`${tmpDirPath}/state.json`)).toBe(true); + expect(readFileSync(`${tmpDirPath}/state.json`, 'utf8')).toBe('{}'); + }); + + it('should pass with existing state file', () => { + const testStateFile = 'test/resources/test__state.json'; + expect(() => loadStateFile(tmpDirPath, testStateFile)).not.toThrow(); + expect(existsSync(`${tmpDirPath}/state.json`)).toBe(true); + expect(readFileSync(`${tmpDirPath}/state.json`, 'utf8')).toMatchSnapshot(); + }); - it('should pass with existing state file', () => { - const testStateFile = 'test/resources/test__state.json'; - expect(() => loadStateFile(tmpDirPath, testStateFile)).not.toThrow(); - expect(existsSync(`${tmpDirPath}/state.json`)).toBe(true); - expect(readFileSync(`${tmpDirPath}/state.json`, 'utf8')).toMatchSnapshot(); + it('should fail if state file is not loaded', () => { + expect(() => loadStateFile(tmpDirPath, 'non-exist-state-file')).toThrow( + `State file 'non-exist-state-file' not found. Please make sure the state file exists and have read access.`, + ); + }); }); - it('should fail if state file is not loaded', () => { - expect(() => loadStateFile(tmpDirPath, 'non-exist-state-file')).toThrow( - `State file 'non-exist-state-file' not found. Please make sure the state file exists and have read access.`, - ); + describe('writeConfig', () => { + const testConfig: FarosConfig = { + src: { + image: 'farosai/airbyte-test-source', + config: { + username: 'test', + password: 'test', + url: 'test', + }, + catalog: { + tests: {disabled: true}, + projects: {disabled: true}, + }, + }, + dst: { + image: 'farosai/airbyte-test-destination', + config: { + edition_config: { + graph: 'default', + edition: 'cloud', + api_url: 'https://test.api.faros.ai', + }, + }, + }, + + // default values + srcCheckConnection: false, + dstUseHostNetwork: false, + srcPull: false, + dstPull: false, + fullRefresh: false, + rawMessages: false, + keepContainers: false, + logLevel: 'info', + debug: false, + stateFile: undefined, + connectionName: undefined, + srcOutputFile: undefined, + srcInputFile: undefined, + }; + + afterEach(() => { + rmSync(`${FILENAME_PREFIX}_config.json`, {force: true}); + rmSync(`${tmpDirPath}/${FILENAME_PREFIX}_src_config.json`, {force: true}); + rmSync(`${tmpDirPath}/${FILENAME_PREFIX}_dst_config.json`, {force: true}); + rmSync(`${tmpDirPath}/${FILENAME_PREFIX}_src_catalog.json`, {force: true}); + rmSync(`${tmpDirPath}/${FILENAME_PREFIX}_dst_catalog.json`, {force: true}); + }); + + it('should write files', () => { + expect(() => writeConfig(tmpDirPath, structuredClone(testConfig))).not.toThrow(); + expect(existsSync(`${FILENAME_PREFIX}_config.json`)).toBe(true); + expect(existsSync(`${tmpDirPath}/${FILENAME_PREFIX}_src_config.json`)).toBe(true); + expect(existsSync(`${tmpDirPath}/${FILENAME_PREFIX}_dst_config.json`)).toBe(true); + expect(existsSync(`${tmpDirPath}/${FILENAME_PREFIX}_src_catalog.json`)).toBe(true); + expect(existsSync(`${tmpDirPath}/${FILENAME_PREFIX}_dst_catalog.json`)).toBe(true); + + expect(readFileSync(`${FILENAME_PREFIX}_config.json`, 'utf8')).toEqual( + JSON.stringify({src: testConfig.src, dst: testConfig.dst}, null, 2), + ); + expect(readFileSync(`${tmpDirPath}/${FILENAME_PREFIX}_src_config.json`, 'utf8')).toEqual( + JSON.stringify(testConfig.src?.config, null, 2), + ); + expect(readFileSync(`${tmpDirPath}/${FILENAME_PREFIX}_dst_config.json`, 'utf8')).toEqual( + JSON.stringify(testConfig.dst?.config, null, 2), + ); + expect(readFileSync(`${tmpDirPath}/${FILENAME_PREFIX}_src_catalog.json`, 'utf8')).toEqual( + JSON.stringify(testConfig.src?.catalog, null, 2), + ); + expect(readFileSync(`${tmpDirPath}/${FILENAME_PREFIX}_dst_catalog.json`, 'utf8')).toEqual( + JSON.stringify(testConfig.src?.catalog, null, 2), + ); + }); + + it('should alter config if debug is enabled', () => { + const testConfigDebug = {...structuredClone(testConfig), debug: true}; + (testConfigDebug.src as any).image = 'farosai/airbyte-faros-feeds-source:v1'; + expect(() => writeConfig(tmpDirPath, structuredClone(testConfigDebug))).not.toThrow(); + expect(existsSync(`${FILENAME_PREFIX}_config.json`)).toBe(true); + expect(existsSync(`${tmpDirPath}/${FILENAME_PREFIX}_src_config.json`)).toBe(true); + expect(existsSync(`${tmpDirPath}/${FILENAME_PREFIX}_dst_config.json`)).toBe(true); + + expect(readFileSync(`${FILENAME_PREFIX}_config.json`, 'utf8')).toEqual( + JSON.stringify({src: testConfigDebug.src, dst: testConfigDebug.dst}, null, 2), + ); + expect(readFileSync(`${tmpDirPath}/${FILENAME_PREFIX}_src_config.json`, 'utf8')).toEqual( + JSON.stringify({...testConfigDebug.src?.config, feed_cfg: {debug: true}}, null, 2), + ); + expect(readFileSync(`${tmpDirPath}/${FILENAME_PREFIX}_dst_config.json`, 'utf8')).toEqual( + JSON.stringify(testConfigDebug.dst?.config, null, 2), + ); + }); }); }); diff --git a/airbyte-local-cli-nodejs/test/utils.test.ts b/airbyte-local-cli-nodejs/test/utils.test.ts index 7bb7273..40d3d81 100644 --- a/airbyte-local-cli-nodejs/test/utils.test.ts +++ b/airbyte-local-cli-nodejs/test/utils.test.ts @@ -1,7 +1,7 @@ import {spawnSync} from 'node:child_process'; -import {readFileSync, writeFileSync} from 'node:fs'; +import {readFileSync} from 'node:fs'; -import {checkDockerInstalled, parseConfigFile, writeConfig} from '../src/utils'; +import {checkDockerInstalled, parseConfigFile} from '../src/utils'; jest.mock('node:fs'); jest.mock('node:child_process'); @@ -57,22 +57,3 @@ describe('checkDockerInstalled', () => { expect(() => checkDockerInstalled()).toThrow('Docker is not installed: command not found'); }); }); - -describe.only('writeConfig', () => { - it('should pass if config is written to file', () => { - const config = { - src: { - image: 'source-image', - config: {}, - }, - dst: { - image: 'destination-image', - config: {}, - }, - }; - const tmpDir = 'test-tmp-dir'; - const expectedConfigFile = `${tmpDir}/faros_airbyte_cli_config.json`; - writeConfig(tmpDir, config); - expect(writeFileSync).toHaveBeenCalledWith(expectedConfigFile, JSON.stringify(config)); - }); -}); From de9a1f1315127d0a9fa8b243f8bf755f78fe72af Mon Sep 17 00:00:00 2001 From: Jennie Gao Date: Tue, 19 Nov 2024 16:34:53 -0800 Subject: [PATCH 3/4] add return type --- airbyte-local-cli-nodejs/src/command.ts | 6 +++--- airbyte-local-cli-nodejs/src/index.ts | 2 +- airbyte-local-cli-nodejs/src/utils.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/airbyte-local-cli-nodejs/src/command.ts b/airbyte-local-cli-nodejs/src/command.ts index a2d6a0b..dbe8589 100644 --- a/airbyte-local-cli-nodejs/src/command.ts +++ b/airbyte-local-cli-nodejs/src/command.ts @@ -126,7 +126,7 @@ function parseSrcAndDstConfig(argv: string[]) { } // Convert the options to CliOptions type -function convertToCliOptions(options: any) { +function convertToCliOptions(options: any): CliOptions { return { ...options, srcImage: options.src, @@ -135,7 +135,7 @@ function convertToCliOptions(options: any) { } // Validate the input options -function validateConfigFileInput(config: FarosConfig, inputType: AirbyteConfigInputType) { +function validateConfigFileInput(config: FarosConfig, inputType: AirbyteConfigInputType): void { if (!config.src?.image && !config.srcInputFile) { if (inputType === AirbyteConfigInputType.OPTION) { throw new Error(`Missing source image. Please use '--src ' to provide the source image`); @@ -156,7 +156,7 @@ function validateConfigFileInput(config: FarosConfig, inputType: AirbyteConfigIn } // parse the command line arguments -export function parseAndValidateInputs(argv: string[]) { +export function parseAndValidateInputs(argv: string[]): FarosConfig { // Parse the command line arguments const program = command().parse(argv); diff --git a/airbyte-local-cli-nodejs/src/index.ts b/airbyte-local-cli-nodejs/src/index.ts index 85ecae2..76964e3 100644 --- a/airbyte-local-cli-nodejs/src/index.ts +++ b/airbyte-local-cli-nodejs/src/index.ts @@ -2,7 +2,7 @@ import {parseAndValidateInputs} from './command'; import {AirbyteCliContext} from './types'; import {checkDockerInstalled, cleanUp, createTmpDir, loadStateFile, logger, writeConfig} from './utils'; -function main() { +function main(): void { const context: AirbyteCliContext = {}; try { const cfg = parseAndValidateInputs(process.argv); diff --git a/airbyte-local-cli-nodejs/src/utils.ts b/airbyte-local-cli-nodejs/src/utils.ts index 4bf7f11..4f8e280 100644 --- a/airbyte-local-cli-nodejs/src/utils.ts +++ b/airbyte-local-cli-nodejs/src/utils.ts @@ -111,7 +111,7 @@ export function cleanUp(context: AirbyteCliContext): void { } // Write Airbyte config and catalog to temporary dir and a json file -export function writeConfig(tmpDir: string, config: FarosConfig) { +export function writeConfig(tmpDir: string, config: FarosConfig): void { const airbyteConfig = { src: config.src ?? ({} as AirbyteConfig), dst: config.dst ?? ({} as AirbyteConfig), From 5aea512ce7a5a6e5d3c183ded626ca81e919c24d Mon Sep 17 00:00:00 2001 From: Jennie Gao Date: Tue, 19 Nov 2024 17:22:14 -0800 Subject: [PATCH 4/4] remove resources --- airbyte-local-cli-nodejs/.gitignore | 2 +- .../test/exec/resources/test_config_file.json | 25 ------------------- .../exec/resources/test_config_file_invalid | 5 ---- 3 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 airbyte-local-cli-nodejs/test/exec/resources/test_config_file.json delete mode 100644 airbyte-local-cli-nodejs/test/exec/resources/test_config_file_invalid diff --git a/airbyte-local-cli-nodejs/.gitignore b/airbyte-local-cli-nodejs/.gitignore index 3c31a09..ddef1ec 100644 --- a/airbyte-local-cli-nodejs/.gitignore +++ b/airbyte-local-cli-nodejs/.gitignore @@ -12,4 +12,4 @@ target/ out/pkg sample_command.sh *airbyte-local -test/exec/resources/ +test/exec/resources diff --git a/airbyte-local-cli-nodejs/test/exec/resources/test_config_file.json b/airbyte-local-cli-nodejs/test/exec/resources/test_config_file.json deleted file mode 100644 index 809431e..0000000 --- a/airbyte-local-cli-nodejs/test/exec/resources/test_config_file.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "src": { - "image": "farosai/airbyte-servicenow-source", - "config": { - "username": "test-username", - "password": "***", - "url": "https://test-instance.service-now.com" - }, - "catalog": {}, - "dockerOptions": "--memory 2048m --cpus 2" - }, - "dst": { - "image": "farosai/airbyte-servicenow-destination", - "config": { - "edition_config": { - "graph": "default", - "edition": "cloud", - "api_url": "https://prod.api.faros.ai", - "api_key": "***" - } - }, - "catalog": {}, - "dockerOptions": "--memory 2048m --cpus 2" - } -} diff --git a/airbyte-local-cli-nodejs/test/exec/resources/test_config_file_invalid b/airbyte-local-cli-nodejs/test/exec/resources/test_config_file_invalid deleted file mode 100644 index 17eab1a..0000000 --- a/airbyte-local-cli-nodejs/test/exec/resources/test_config_file_invalid +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": { - invalid-json - } -}