mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.9`: - [[Ops] Fix es snapshot startup for params with dots in their path (#161022)](https://github.com/elastic/kibana/pull/161022) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Alex Szabo","email":"alex.szabo@elastic.co"},"sourceCommit":{"committedDate":"2023-07-03T08:42:21Z","message":"[Ops] Fix es snapshot startup for params with dots in their path (#161022)\n\n## Summary\r\nIn a module where we'd copy configuration files, an `isFile` function\r\nwould give false positives on folders with `.` in their names (mistaking\r\nthem for extensions). It's now fixed to use `statSync(...).isFile()`.\r\n\r\nCloses #161013\r\n\r\n### Checklist\r\n[x] Unit test added, and works","sha":"995d8f1e01f1c1ae5635e71a044eaa3f8f248de7","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:fix","backport:prev-minor","v8.10.0"],"number":161022,"url":"https://github.com/elastic/kibana/pull/161022","mergeCommit":{"message":"[Ops] Fix es snapshot startup for params with dots in their path (#161022)\n\n## Summary\r\nIn a module where we'd copy configuration files, an `isFile` function\r\nwould give false positives on folders with `.` in their names (mistaking\r\nthem for extensions). It's now fixed to use `statSync(...).isFile()`.\r\n\r\nCloses #161013\r\n\r\n### Checklist\r\n[x] Unit test added, and works","sha":"995d8f1e01f1c1ae5635e71a044eaa3f8f248de7"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/161022","number":161022,"mergeCommit":{"message":"[Ops] Fix es snapshot startup for params with dots in their path (#161022)\n\n## Summary\r\nIn a module where we'd copy configuration files, an `isFile` function\r\nwould give false positives on folders with `.` in their names (mistaking\r\nthem for extensions). It's now fixed to use `statSync(...).isFile()`.\r\n\r\nCloses #161013\r\n\r\n### Checklist\r\n[x] Unit test added, and works","sha":"995d8f1e01f1c1ae5635e71a044eaa3f8f248de7"}}]}] BACKPORT--> Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
This commit is contained in:
parent
ef9d9ebe64
commit
58f3d8111a
2 changed files with 14 additions and 1 deletions
|
@ -10,6 +10,11 @@ jest.mock('fs', () => ({
|
|||
readFileSync: jest.fn(),
|
||||
existsSync: jest.fn().mockImplementation(() => true),
|
||||
writeFileSync: jest.fn(),
|
||||
statSync: jest.fn((fileName) => {
|
||||
return {
|
||||
isFile: () => fileName.endsWith('.yml'),
|
||||
};
|
||||
}),
|
||||
}));
|
||||
|
||||
const { extractConfigFiles } = require('./extract_config_files');
|
||||
|
@ -63,3 +68,10 @@ test('ignores directories', () => {
|
|||
|
||||
expect(config).toEqual(['path=foo.yml', 'foo.bar=/data/bar']);
|
||||
});
|
||||
|
||||
test('ignores directories with dots in their names', () => {
|
||||
fs.existsSync = () => true;
|
||||
const config = extractConfigFiles(['path=/data/foo.yml', 'foo.bar=/data/ba/r.baz'], '/es');
|
||||
|
||||
expect(config).toEqual(['path=foo.yml', 'foo.bar=/data/ba/r.baz']);
|
||||
});
|
||||
|
|
|
@ -29,6 +29,7 @@ export function extractConfigFiles(
|
|||
if (isFile(value)) {
|
||||
const filename = path.basename(value);
|
||||
const destPath = path.resolve(dest, 'config', filename);
|
||||
|
||||
copyFileSync(value, destPath);
|
||||
|
||||
options?.log.info('moved %s in config to %s', value, destPath);
|
||||
|
@ -43,7 +44,7 @@ export function extractConfigFiles(
|
|||
}
|
||||
|
||||
function isFile(dest = '') {
|
||||
return path.isAbsolute(dest) && path.extname(dest).length > 0 && fs.existsSync(dest);
|
||||
return fs.existsSync(dest) && fs.statSync(dest).isFile();
|
||||
}
|
||||
|
||||
function copyFileSync(src: string, dest: string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue