-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* rename uuid service to environment service * adapt resolve_uuid to directly use the configurations * move data folder creation to core * update generated doc * fix types * fix monitoring tests * move instanceUuid to plugin initializer context * update generated doc
- Loading branch information
1 parent
57637ef
commit de3fbdc
Showing
39 changed files
with
504 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
docs/development/core/server/kibana-plugin-core-server.coresetup.uuid.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,6 @@ | |
env: { | ||
mode: EnvironmentMode; | ||
packageInfo: Readonly<PackageInfo>; | ||
instanceUuid: string; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
...pment/core/server/kibana-plugin-core-server.uuidservicesetup.getinstanceuuid.md
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
docs/development/core/server/kibana-plugin-core-server.uuidservicesetup.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { PathConfigType } from '../path'; | ||
import { createDataFolder } from './create_data_folder'; | ||
import { mkdir } from './fs'; | ||
import { loggingSystemMock } from '../logging/logging_system.mock'; | ||
|
||
jest.mock('./fs', () => ({ | ||
mkdir: jest.fn(() => Promise.resolve('')), | ||
})); | ||
|
||
const mkdirMock = mkdir as jest.Mock; | ||
|
||
describe('createDataFolder', () => { | ||
let logger: ReturnType<typeof loggingSystemMock.createLogger>; | ||
let pathConfig: PathConfigType; | ||
|
||
beforeEach(() => { | ||
logger = loggingSystemMock.createLogger(); | ||
pathConfig = { | ||
data: '/path/to/data/folder', | ||
}; | ||
mkdirMock.mockResolvedValue(undefined); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('calls `mkdir` with the correct parameters', async () => { | ||
await createDataFolder({ pathConfig, logger }); | ||
expect(mkdirMock).toHaveBeenCalledTimes(1); | ||
expect(mkdirMock).toHaveBeenCalledWith(pathConfig.data, { recursive: true }); | ||
}); | ||
|
||
it('does not log error if the `mkdir` call is successful', async () => { | ||
await createDataFolder({ pathConfig, logger }); | ||
expect(logger.error).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('throws an error if the `mkdir` call fails', async () => { | ||
mkdirMock.mockRejectedValue('some-error'); | ||
await expect(() => createDataFolder({ pathConfig, logger })).rejects.toMatchInlineSnapshot( | ||
`"some-error"` | ||
); | ||
}); | ||
|
||
it('logs an error message if the `mkdir` call fails', async () => { | ||
mkdirMock.mockRejectedValue('some-error'); | ||
try { | ||
await createDataFolder({ pathConfig, logger }); | ||
} catch (e) { | ||
/* trap */ | ||
} | ||
expect(logger.error).toHaveBeenCalledTimes(1); | ||
expect(logger.error.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"Error trying to create data folder at /path/to/data/folder: some-error", | ||
] | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { mkdir } from './fs'; | ||
import { Logger } from '../logging'; | ||
import { PathConfigType } from '../path'; | ||
|
||
export async function createDataFolder({ | ||
pathConfig, | ||
logger, | ||
}: { | ||
pathConfig: PathConfigType; | ||
logger: Logger; | ||
}): Promise<void> { | ||
const dataFolder = pathConfig.data; | ||
try { | ||
// Create the data directory (recursively, if the a parent dir doesn't exist). | ||
// If it already exists, does nothing. | ||
await mkdir(dataFolder, { recursive: true }); | ||
} catch (e) { | ||
logger.error(`Error trying to create data folder at ${dataFolder}: ${e}`); | ||
throw e; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.