-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move kibana-keystore from data/ to config/ (#57856)
* Move kibana-keystore from data/ to config/ This is a breaking change to move the location of kibana-keystore. Keystores in other stack products live in the config directory, so this updates our current path to be consistent. Closes #25746 * add breaking changes * update comment * wip * fix docs * read from both keystore locations, write priority to non-deprecated * note data directory fallback * add tests for get_keystore Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
ac93ac6
commit c9b6f8a
Showing
5 changed files
with
119 additions
and
8 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
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 { existsSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
import Logger from '../cli_plugin/lib/logger'; | ||
import { getConfigDirectory, getDataPath } from '../core/server/path'; | ||
|
||
export function getKeystore() { | ||
const configKeystore = join(getConfigDirectory(), 'kibana.keystore'); | ||
const dataKeystore = join(getDataPath(), 'kibana.keystore'); | ||
let keystorePath = null; | ||
if (existsSync(dataKeystore)) { | ||
const logger = new Logger(); | ||
logger.log( | ||
`kibana.keystore located in the data folder is deprecated. Future versions will use the config folder.` | ||
); | ||
keystorePath = dataKeystore; | ||
} else { | ||
keystorePath = configKeystore; | ||
} | ||
return keystorePath; | ||
} |
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,57 @@ | ||
/* | ||
* 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 { getKeystore } from './get_keystore'; | ||
import Logger from '../cli_plugin/lib/logger'; | ||
import fs from 'fs'; | ||
import sinon from 'sinon'; | ||
|
||
describe('get_keystore', () => { | ||
const sandbox = sinon.createSandbox(); | ||
|
||
beforeEach(() => { | ||
sandbox.stub(Logger.prototype, 'log'); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('uses the config directory if there is no pre-existing keystore', () => { | ||
sandbox.stub(fs, 'existsSync').returns(false); | ||
expect(getKeystore()).toContain('config'); | ||
expect(getKeystore()).not.toContain('data'); | ||
}); | ||
|
||
it('uses the data directory if there is a pre-existing keystore in the data directory', () => { | ||
sandbox.stub(fs, 'existsSync').returns(true); | ||
expect(getKeystore()).toContain('data'); | ||
expect(getKeystore()).not.toContain('config'); | ||
}); | ||
|
||
it('logs a deprecation warning if the data directory is used', () => { | ||
sandbox.stub(fs, 'existsSync').returns(true); | ||
getKeystore(); | ||
sandbox.assert.calledOnce(Logger.prototype.log); | ||
sandbox.assert.calledWith( | ||
Logger.prototype.log, | ||
'kibana.keystore located in the data folder is deprecated. Future versions will use the config folder.' | ||
); | ||
}); | ||
}); |
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