kibana/packages/kbn-test/kbn_test_config.ts
Spencer 1b85815402
[packages] migrate all plugins to packages (#148130)
Fixes https://github.com/elastic/kibana/issues/149344

This PR migrates all plugins to packages automatically. It does this
using `node scripts/lint_packages` to automatically migrate
`kibana.json` files to `kibana.jsonc` files. By doing this automatically
we can simplify many build and testing procedures to only support
packages, and not both "packages" and "synthetic packages" (basically
pointers to plugins).

The majority of changes are in operations related code, so we'll be
having operations review this before marking it ready for review. The
vast majority of the code owners are simply pinged because we deleted
all `kibana.json` files and replaced them with `kibana.jsonc` files, so
we plan on leaving the PR ready-for-review for about 24 hours before
merging (after feature freeze), assuming we don't have any blockers
(especially from @elastic/kibana-core since there are a few core
specific changes, though the majority were handled in #149370).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-02-08 21:06:50 -06:00

51 lines
1.8 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import url from 'url';
import { kibanaTestUser } from './src/kbn/users';
export interface UrlParts {
protocol?: string;
hostname?: string;
port?: number;
auth?: string;
username?: string;
password?: string;
}
export const kbnTestConfig = new (class KbnTestConfig {
getPort() {
return this.getUrlParts().port;
}
getUrlParts(): UrlParts {
// allow setting one complete TEST_KIBANA_URL for ES like https://elastic:changeme@example.com:9200
if (process.env.TEST_KIBANA_URL) {
const testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL);
return {
protocol: testKibanaUrl.protocol?.slice(0, -1),
hostname: testKibanaUrl.hostname === null ? undefined : testKibanaUrl.hostname,
port: testKibanaUrl.port ? parseInt(testKibanaUrl.port, 10) : undefined,
auth: testKibanaUrl.auth === null ? undefined : testKibanaUrl.auth,
username: testKibanaUrl.auth?.split(':')[0],
password: testKibanaUrl.auth?.split(':')[1],
};
}
const username = process.env.TEST_KIBANA_USERNAME || kibanaTestUser.username;
const password = process.env.TEST_KIBANA_PASSWORD || kibanaTestUser.password;
return {
protocol: process.env.TEST_KIBANA_PROTOCOL || 'http',
hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost',
port: process.env.TEST_KIBANA_PORT ? parseInt(process.env.TEST_KIBANA_PORT, 10) : 5620,
auth: `${username}:${password}`,
username,
password,
};
}
})();