mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
Add --ssl flag to make resolver generator use ssl with kbn and elasticsearch clients (#89873)
This commit is contained in:
parent
da28bd214c
commit
3c0d30cbfd
1 changed files with 35 additions and 11 deletions
|
@ -5,9 +5,10 @@
|
||||||
*/
|
*/
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
|
import fs from 'fs';
|
||||||
import { Client, ClientOptions } from '@elastic/elasticsearch';
|
import { Client, ClientOptions } from '@elastic/elasticsearch';
|
||||||
import { ResponseError } from '@elastic/elasticsearch/lib/errors';
|
import { ResponseError } from '@elastic/elasticsearch/lib/errors';
|
||||||
import { KbnClient, ToolingLog } from '@kbn/dev-utils';
|
import { KbnClient, ToolingLog, CA_CERT_PATH } from '@kbn/dev-utils';
|
||||||
import { AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
import { indexHostsAndAlerts } from '../../common/endpoint/index_data';
|
import { indexHostsAndAlerts } from '../../common/endpoint/index_data';
|
||||||
import { ANCESTRY_LIMIT, EndpointDocGenerator } from '../../common/endpoint/generate_data';
|
import { ANCESTRY_LIMIT, EndpointDocGenerator } from '../../common/endpoint/generate_data';
|
||||||
|
@ -202,15 +203,41 @@ async function main() {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
ssl: {
|
||||||
|
alias: 'ssl',
|
||||||
|
describe: 'Use https for elasticsearch and kbn clients',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
}).argv;
|
}).argv;
|
||||||
|
let ca: Buffer;
|
||||||
|
let kbnClient: KbnClientWithApiKeySupport;
|
||||||
|
let clientOptions: ClientOptions;
|
||||||
|
|
||||||
const kbnClient = new KbnClientWithApiKeySupport({
|
if (argv.ssl) {
|
||||||
log: new ToolingLog({
|
ca = fs.readFileSync(CA_CERT_PATH);
|
||||||
level: 'info',
|
const url = argv.kibana.replace('http:', 'https:');
|
||||||
writeTo: process.stdout,
|
const node = argv.node.replace('http:', 'https:');
|
||||||
}),
|
kbnClient = new KbnClientWithApiKeySupport({
|
||||||
url: argv.kibana,
|
log: new ToolingLog({
|
||||||
});
|
level: 'info',
|
||||||
|
writeTo: process.stdout,
|
||||||
|
}),
|
||||||
|
url,
|
||||||
|
certificateAuthorities: [ca],
|
||||||
|
});
|
||||||
|
clientOptions = { node, ssl: { ca: [ca] } };
|
||||||
|
} else {
|
||||||
|
kbnClient = new KbnClientWithApiKeySupport({
|
||||||
|
log: new ToolingLog({
|
||||||
|
level: 'info',
|
||||||
|
writeTo: process.stdout,
|
||||||
|
}),
|
||||||
|
url: argv.kibana,
|
||||||
|
});
|
||||||
|
clientOptions = { node: argv.node };
|
||||||
|
}
|
||||||
|
const client = new Client(clientOptions);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await doIngestSetup(kbnClient);
|
await doIngestSetup(kbnClient);
|
||||||
|
@ -219,9 +246,6 @@ async function main() {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const clientOptions: ClientOptions = { node: argv.node };
|
|
||||||
const client = new Client(clientOptions);
|
|
||||||
|
|
||||||
if (argv.delete) {
|
if (argv.delete) {
|
||||||
await deleteIndices(
|
await deleteIndices(
|
||||||
[argv.eventIndex, argv.metadataIndex, argv.policyIndex, argv.alertIndex],
|
[argv.eventIndex, argv.metadataIndex, argv.policyIndex, argv.alertIndex],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue