Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Use chromium path relative to constant file #236

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions kibana-reports/server/routes/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,4 @@ export const DEFAULT_REPORT_HEADER = '<h1>Open Distro Kibana Reports</h1>';

export const SECURITY_AUTH_COOKIE_NAME = 'security_authentication';

export const CHROMIUM_PATHS = [
`./plugins/${PLUGIN_ID}/.chromium/headless_shell`,
'./plugins/kibana-reports/.chromium/headless_shell',
'./.chromium/headless_shell',
`../plugins/${PLUGIN_ID}/.chromium/headless_shell`,
'../plugins/kibana-reports/.chromium/headless_shell',
];
export const CHROMIUM_PATH = `${__dirname}/../../../.chromium/headless_shell`;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
REPORT_TYPE,
FORMAT,
SELECTOR,
CHROMIUM_PATHS,
CHROMIUM_PATH,
} from '../constants';
import { getFileName } from '../helpers';
import { CreateReportResultType } from '../types';
Expand Down Expand Up @@ -50,16 +50,6 @@ export const createVisualReport = async (
report_format: reportFormat,
} = coreParams;

const getChromiumPath = () => {
const path = CHROMIUM_PATHS.find((path) => {
try {
return fs.existsSync(path);
} catch (error) {}
});
if (path) return path;
logger.error('cannot find headless chromium for puppeteer');
};

// TODO: polish default header, maybe add a logo, depends on UX design
const window = new JSDOM('').window;
const DOMPurify = createDOMPurify(window);
Expand All @@ -77,7 +67,7 @@ export const createVisualReport = async (
* https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#setting-up-chrome-linux-sandbox
*/
args: ['--no-sandbox', '--disable-setuid-sandbox'],
executablePath: getChromiumPath(),
executablePath: CHROMIUM_PATH,
});
const page = await browser.newPage();
page.setDefaultNavigationTimeout(0);
Expand Down