Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rename] Refactored src/cli_keystore/* #76

Merged
merged 2 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/cli_keystore/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function add(keystore, key, options = {}) {
let value;

if (!keystore.exists()) {
return logger.error("ERROR: Kibana keystore not found. Use 'create' command to create one.");
return logger.error("ERROR: OpenSearch Dashboards keystore not found. Use 'create' command to create one.");
}

if (!options.force && keystore.has(key)) {
Expand Down
8 changes: 4 additions & 4 deletions src/cli_keystore/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { add } from './add';
import { Logger } from '../cli_plugin/lib/logger';
import * as prompt from './utils/prompt';

describe('Kibana keystore', () => {
describe('OpenSearch Dashboards keystore', () => {
describe('add', () => {
const sandbox = sinon.createSandbox();

Expand All @@ -62,7 +62,7 @@ describe('Kibana keystore', () => {

it('returns an error for a nonexistent keystore', async () => {
const keystore = new Keystore('/data/nonexistent.keystore');
const message = "ERROR: Kibana keystore not found. Use 'create' command to create one.";
const message = "ERROR: OpenSearch Dashboards keystore not found. Use 'create' command to create one.";

await add(keystore, 'foo');

Expand Down Expand Up @@ -157,13 +157,13 @@ describe('Kibana keystore', () => {

const stdin = new PassThrough();
process.nextTick(() => {
stdin.write('kibana\n');
stdin.write('opensearch-dashboards\n');
stdin.end();
});

await add(keystore, 'foo', { stdin: true, stdinStream: stdin });

expect(keystore.data.foo).toEqual('kibana');
expect(keystore.data.foo).toEqual('opensearch-dashboards');
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/cli_keystore/cli_keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import { addCli } from './add';
import { removeCli } from './remove';
import { getKeystore } from './get_keystore';

const argv = process.env.kbnWorkerArgv
? JSON.parse(process.env.kbnWorkerArgv)
const argv = process.env.osdWorkerArgv
? JSON.parse(process.env.osdWorkerArgv)
: process.argv.slice();
const program = new Command('bin/kibana-keystore');
const program = new Command('bin/opensearch-dashboards-keystore');

program
.version(pkg.version)
.description('A tool for managing settings stored in the Kibana keystore');
.description('A tool for managing settings stored in the OpenSearch Dashboards keystore');

const keystore = new Keystore(getKeystore());

Expand Down
6 changes: 3 additions & 3 deletions src/cli_keystore/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function create(keystore, command, options) {
const logger = new Logger(options);

if (keystore.exists()) {
const overwrite = await confirm('A Kibana keystore already exists. Overwrite?');
const overwrite = await confirm('A OpenSearch Dashboards keystore already exists. Overwrite?');

if (!overwrite) {
return logger.log('Exiting without modifying keystore.');
Expand All @@ -34,13 +34,13 @@ export async function create(keystore, command, options) {
keystore.reset();
keystore.save();

logger.log(`Created Kibana keystore in ${keystore.path}`);
logger.log(`Created OpenSearch Dashboards keystore in ${keystore.path}`);
}

export function createCli(program, keystore) {
program
.command('create')
.description('Creates a new Kibana keystore')
.description('Creates a new OpenSearch Dashboards keystore')
.option('-s, --silent', 'prevent all logging')
.action(create.bind(null, keystore));
}
6 changes: 3 additions & 3 deletions src/cli_keystore/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { create } from './create';
import { Logger } from '../cli_plugin/lib/logger';
import * as prompt from './utils/prompt';

describe('Kibana keystore', () => {
describe('OpenSearch Dashboards keystore', () => {
describe('create', () => {
const sandbox = sinon.createSandbox();

Expand Down Expand Up @@ -72,7 +72,7 @@ describe('Kibana keystore', () => {
await create(keystore);

sinon.assert.calledOnce(Logger.prototype.log);
sinon.assert.calledWith(Logger.prototype.log, `Created Kibana keystore in ${path}`);
sinon.assert.calledWith(Logger.prototype.log, `Created OpenSearch Dashboards keystore in ${path}`);
});

it('prompts for overwrite', async () => {
Expand All @@ -84,7 +84,7 @@ describe('Kibana keystore', () => {
sinon.assert.calledOnce(prompt.confirm);
const { args } = prompt.confirm.getCall(0);

expect(args[0]).toEqual('A Kibana keystore already exists. Overwrite?');
expect(args[0]).toEqual('A OpenSearch Dashboards keystore already exists. Overwrite?');
mihirsoni marked this conversation as resolved.
Show resolved Hide resolved
});

it('aborts if overwrite is denied', async () => {
Expand Down
8 changes: 4 additions & 4 deletions src/cli_keystore/get_keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import { existsSync } from 'fs';
import { join } from 'path';

import { Logger } from '../cli_plugin/lib/logger';
import { getConfigDirectory, getDataPath } from '@kbn/utils';
import { getConfigDirectory, getDataPath } from '@osd/utils';

export function getKeystore() {
const configKeystore = join(getConfigDirectory(), 'kibana.keystore');
const dataKeystore = join(getDataPath(), 'kibana.keystore');
const configKeystore = join(getConfigDirectory(), 'opensearchDashboards.keystore');
const dataKeystore = join(getDataPath(), 'opensearchDashboards.keystore');
mihirsoni marked this conversation as resolved.
Show resolved Hide resolved
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.`
`opensearchDashboards.keystore located in the data folder is deprecated. Future versions will use the config folder.`
mihirsoni marked this conversation as resolved.
Show resolved Hide resolved
);
keystorePath = dataKeystore;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/get_keystore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('get_keystore', () => {
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.'
'opensearchDashboards.keystore located in the data folder is deprecated. Future versions will use the config folder.'
mihirsoni marked this conversation as resolved.
Show resolved Hide resolved
);
});
});
2 changes: 1 addition & 1 deletion src/cli_keystore/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function list(keystore, command, options = {}) {
const logger = new Logger(options);

if (!keystore.exists()) {
return logger.error("ERROR: Kibana keystore not found. Use 'create' command to create one.");
return logger.error("ERROR: OpenSearch Dashboards keystore not found. Use 'create' command to create one.");
}

const keys = keystore.keys();
Expand Down
4 changes: 2 additions & 2 deletions src/cli_keystore/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { Keystore } from '../legacy/server/keystore';
import { list } from './list';
import { Logger } from '../cli_plugin/lib/logger';

describe('Kibana keystore', () => {
describe('OpenSearch Dashboards keystore', () => {
describe('list', () => {
const sandbox = sinon.createSandbox();

Expand Down Expand Up @@ -68,7 +68,7 @@ describe('Kibana keystore', () => {
sinon.assert.calledOnce(Logger.prototype.error);
sinon.assert.calledWith(
Logger.prototype.error,
"ERROR: Kibana keystore not found. Use 'create' command to create one."
"ERROR: OpenSearch Dashboards keystore not found. Use 'create' command to create one."
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/remove.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import sinon from 'sinon';
import { Keystore } from '../legacy/server/keystore';
import { remove } from './remove';

describe('Kibana keystore', () => {
describe('OpenSearch Dashboards keystore', () => {
describe('remove', () => {
const sandbox = sinon.createSandbox();

Expand Down