Skip to content

Commit

Permalink
add comments about dynamic require hack, try to fix pathing for k8 te…
Browse files Browse the repository at this point in the history
…mplates
  • Loading branch information
jsnoble committed Dec 5, 2023
1 parent d981d9b commit 0125814
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/teraslice/src/lib/cluster/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ function validateCleanupType(cleanupType: RecoveryCleanupType) {

async function getGotESM() {
if (gotESMModule) return gotESMModule;
// temporary hack as typescript will compile this to a require statement
// until we export esm modules, revert this back when we get there
const module = await eval("import('gotESM')"); // eslint-disable-line
gotESMModule = module.default;
return module.default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import type { TerasliceConfig, ExecutionConfig } from '@terascope/job-components
import { safeEncode } from '../../../../../utils/encoding_utils';
import { setMaxOldSpaceViaEnv } from './utils';

const resourcePath = path.join(process.cwd(), './packages/teraslice/src/lib/cluster/services/cluster/backends/kubernetes/');

interface K8sConfig {
clusterName: string,
clusterNameLabel: string,
Expand Down Expand Up @@ -155,7 +157,7 @@ export class K8sResource {
}

_makeTemplate(folder: string, fileName: string) {
const filePath = path.join(__dirname, folder, `${fileName}.hbs`);
const filePath = path.join(resourcePath, folder, `${fileName}.hbs`);
const templateData = fs.readFileSync(filePath, 'utf-8');
const templateKeys = ['{{', '}}'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { isTest } from '@terascope/utils';

const MAX_RETRIES = isTest ? 2 : 3;
const RETRY_DELAY = isTest ? 50 : 1000; // time in ms
const resourcePath = path.join(process.cwd(), './packages/teraslice/src/lib/cluster/services/cluster/backends/kubernetes/');

export function makeTemplate(folder: string, fileName: string) {
const filePath = path.join(__dirname, folder, `${fileName}.hbs`);
const filePath = path.join(resourcePath, folder, `${fileName}.hbs`);
const templateData = fs.readFileSync(filePath, 'utf-8');
const templateKeys = ['{{', '}}'];

Expand Down

0 comments on commit 0125814

Please sign in to comment.