Skip to content

Commit

Permalink
Merge branch 'main' into eui-v91.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen authored Dec 12, 2023
2 parents 89c3731 + 156c8f2 commit 1f94a5b
Show file tree
Hide file tree
Showing 215 changed files with 5,313 additions and 6,243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
*/

import { getDocLinksMock, getDocLinksMetaMock } from './doc_links_service.test.mocks';
import { coreContextMock } from '@kbn/core-base-browser-mocks';
import { DocLinksService } from './doc_links_service';
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';

describe('DocLinksService', () => {
let injectedMetadata: ReturnType<typeof injectedMetadataServiceMock.createStartContract>;
let coreContext: ReturnType<typeof coreContextMock.create>;
let service: DocLinksService;

beforeEach(() => {
Expand All @@ -26,7 +28,8 @@ describe('DocLinksService', () => {
settings: 'http://settings.test.url',
});

service = new DocLinksService();
coreContext = coreContextMock.create();
service = new DocLinksService(coreContext);
});

afterEach(() => {
Expand All @@ -43,6 +46,7 @@ describe('DocLinksService', () => {
expect(getDocLinksMetaMock).toHaveBeenCalledTimes(1);
expect(getDocLinksMetaMock).toHaveBeenCalledWith({
kibanaBranch: 'test-branch',
buildFlavor: coreContext.env.packageInfo.buildFlavor,
});
});

Expand All @@ -64,6 +68,7 @@ describe('DocLinksService', () => {
expect(getDocLinksMock).toHaveBeenCalledTimes(1);
expect(getDocLinksMock).toHaveBeenCalledWith({
kibanaBranch: 'test-branch',
buildFlavor: coreContext.env.packageInfo.buildFlavor,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { getDocLinks, getDocLinksMeta } from '@kbn/doc-links';
import type { CoreContext } from '@kbn/core-base-browser-internal';
import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal';
import type { DocLinksStart } from '@kbn/core-doc-links-browser';

Expand All @@ -17,12 +18,15 @@ export interface DocLinksServiceStartDeps {

/** @internal */
export class DocLinksService {
constructor(private readonly coreContext: CoreContext) {}

public setup() {}

public start({ injectedMetadata }: DocLinksServiceStartDeps): DocLinksStart {
const kibanaBranch = injectedMetadata.getKibanaBranch();
const docMeta = getDocLinksMeta({ kibanaBranch });
const docLinks = getDocLinks({ kibanaBranch });
const buildFlavor = this.coreContext.env.packageInfo.buildFlavor;
const docMeta = getDocLinksMeta({ kibanaBranch, buildFlavor });
const docLinks = getDocLinks({ kibanaBranch, buildFlavor });

return {
DOC_LINK_VERSION: docMeta.version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"@kbn/core-injected-metadata-browser-internal",
"@kbn/core-doc-links-browser",
"@kbn/core-injected-metadata-browser-mocks",
"@kbn/core-base-browser-mocks",
"@kbn/core-base-browser-internal",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type { PublicMethodsOf } from '@kbn/utility-types';
import { coreContextMock } from '@kbn/core-base-browser-mocks';
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import type { DocLinksStart } from '@kbn/core-doc-links-browser';
import { DocLinksService } from '@kbn/core-doc-links-browser-internal';
Expand All @@ -15,7 +16,7 @@ const createStartContractMock = (): DocLinksStart => {
// This service is so simple that we actually use the real implementation
const injectedMetadata = injectedMetadataServiceMock.createStartContract();
injectedMetadata.getKibanaBranch.mockReturnValue('mocked-test-branch');
return new DocLinksService().start({ injectedMetadata });
return new DocLinksService(coreContextMock.create()).start({ injectedMetadata });
};

type DocLinksServiceContract = PublicMethodsOf<DocLinksService>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"@kbn/utility-types",
"@kbn/core-injected-metadata-browser-mocks",
"@kbn/core-doc-links-browser",
"@kbn/core-doc-links-browser-internal"
"@kbn/core-doc-links-browser-internal",
"@kbn/core-base-browser-mocks"
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('DocLinksService', () => {
expect(getDocLinksMetaMock).toHaveBeenCalledTimes(1);
expect(getDocLinksMetaMock).toHaveBeenCalledWith({
kibanaBranch: coreContext.env.packageInfo.branch,
buildFlavor: coreContext.env.packageInfo.buildFlavor,
});
});

Expand All @@ -62,6 +63,7 @@ describe('DocLinksService', () => {
expect(getDocLinksMock).toHaveBeenCalledTimes(1);
expect(getDocLinksMock).toHaveBeenCalledWith({
kibanaBranch: coreContext.env.packageInfo.branch,
buildFlavor: coreContext.env.packageInfo.buildFlavor,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import type { DocLinksServiceSetup, DocLinksServiceStart } from '@kbn/core-doc-l

/** @internal */
export class DocLinksService {
private readonly kibanaBranch: string;
private docLinks?: DocLinksServiceSetup;

constructor(core: CoreContext) {
this.kibanaBranch = core.env.packageInfo.branch;
}
constructor(private readonly coreContext: CoreContext) {}

public setup(): DocLinksServiceSetup {
const docMeta = getDocLinksMeta({ kibanaBranch: this.kibanaBranch });
const docLinks = getDocLinks({ kibanaBranch: this.kibanaBranch });
const kibanaBranch = this.coreContext.env.packageInfo.branch;
const buildFlavor = this.coreContext.env.packageInfo.buildFlavor;

const docMeta = getDocLinksMeta({ kibanaBranch, buildFlavor });
const docLinks = getDocLinks({ kibanaBranch, buildFlavor });
this.docLinks = {
...docMeta,
links: docLinks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ type DocLinksServiceContract = PublicMethodsOf<DocLinksService>;

const createSetupMock = (): DocLinksServiceSetup => {
const branch = 'test-branch';
const buildFlavor = 'traditional';
return {
...getDocLinksMeta({ kibanaBranch: branch }),
links: getDocLinks({ kibanaBranch: branch }),
...getDocLinksMeta({ kibanaBranch: branch, buildFlavor }),
links: getDocLinks({ kibanaBranch: branch, buildFlavor }),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class CoreSystem {
browserSupportsCsp,
kibanaVersion: injectedMetadata.version,
});
this.docLinks = new DocLinksService();
this.docLinks = new DocLinksService(this.coreContext);
this.rendering = new RenderingService();
this.application = new ApplicationService();
this.integrations = new IntegrationsService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import fs from 'fs/promises';
import { defaultsDeep } from 'lodash';
import { BehaviorSubject, firstValueFrom, map } from 'rxjs';
import { ConfigService, Env } from '@kbn/config';
import { ConfigService, Env, BuildFlavor } from '@kbn/config';
import { getEnvOptions } from '@kbn/config-mocks';
import { REPO_ROOT } from '@kbn/repo-info';
import { KibanaMigrator } from '@kbn/core-saved-objects-migration-server-internal';
Expand Down Expand Up @@ -216,6 +216,7 @@ const getMigrator = async ({
loggerFactory,
kibanaVersion,
kibanaBranch,
buildFlavor = 'traditional',
nodeRoles,
}: {
configService: ConfigService;
Expand All @@ -226,6 +227,7 @@ const getMigrator = async ({
loggerFactory: LoggerFactory;
kibanaVersion: string;
kibanaBranch: string;
buildFlavor?: BuildFlavor;
nodeRoles: NodeRoles;
}) => {
const savedObjectsConf = await firstValueFrom(
Expand All @@ -237,8 +239,8 @@ const getMigrator = async ({
const soConfig = new SavedObjectConfig(savedObjectsConf, savedObjectsMigrationConf);

const docLinks: DocLinksServiceStart = {
...getDocLinksMeta({ kibanaBranch }),
links: getDocLinks({ kibanaBranch }),
...getDocLinksMeta({ kibanaBranch, buildFlavor }),
links: getDocLinks({ kibanaBranch, buildFlavor }),
};

const esCapabilities = await getCapabilitiesFromClient(client);
Expand Down
20 changes: 18 additions & 2 deletions packages/kbn-apm-synthtrace/src/cli/run_synthtrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@
import datemath from '@kbn/datemath';
import { Argv } from 'yargs';
import yargs from 'yargs/yargs';
import { readdirSync } from 'fs';
import path from 'path';
import { intervalToMs } from './utils/interval_to_ms';
import { parseRunCliFlags } from './utils/parse_run_cli_flags';
import { startHistoricalDataUpload } from './utils/start_historical_data_upload';
import { startLiveDataUpload } from './utils/start_live_data_upload';

function getBuiltinScenarios() {
return readdirSync(path.resolve(__dirname, '../scenarios')).map((s) => s.replace(/\.ts$/, ''));
}

function options(y: Argv) {
return y
.usage('$0 <file>')
.positional('file', {
describe: 'File that contains the trace scenario',
describe: 'Name of scenario',
demandOption: true,
string: true,
choices: getBuiltinScenarios(),
})
.option('target', {
describe: 'Elasticsearch target',
Expand Down Expand Up @@ -54,6 +62,7 @@ function options(y: Argv) {
})
.option('logLevel', {
describe: 'Log level',
choices: ['trace', 'debug', 'info', 'error'],
default: 'info',
})
.option('scenarioOpts', {
Expand All @@ -66,7 +75,14 @@ function options(y: Argv) {
describe: 'Assumes passed package version to avoid calling Fleet API to install',
string: true,
})
.showHelpOnFail(false);
.example(
'$0 simple_logs --target=http://admin:changeme@localhost:9200',
'Ingest data to specific Elasticsearch cluster'
)
.example('$0 simple_logs --live', 'Continuously ingest data to local development cluster')
.example('$0 simple_logs --from=now-24h --to=now', 'Ingest data for a fixed time window')
.showHelpOnFail(false)
.wrap(null);
}

async function run(argv: RunCliFlags) {
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-check-mappings-update-cli/current_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,8 @@
"indicator.params",
"indicator.type",
"name",
"tags"
"tags",
"version"
],
"threshold-explorer-view": [],
"observability-onboarding-state": [
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-check-mappings-update-cli/current_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,9 @@
},
"tags": {
"type": "keyword"
},
"version": {
"type": "long"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export { isConfigPath, hasConfigPathIntersection } from './src/config';
export { ObjectToConfigAdapter } from './src/object_to_config_adapter';
export type { CliArgs, RawPackageInfo, EnvOptions } from './src/env';
export { Env } from './src/env';
export type { EnvironmentMode, PackageInfo } from './src/types';
export type { EnvironmentMode, PackageInfo, BuildFlavor } from './src/types';
5 changes: 4 additions & 1 deletion packages/kbn-config/src/config_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export class ConfigService {
) {
this.log = logger.get('config');
this.deprecationLog = logger.get('config', 'deprecation');
this.docLinks = getDocLinks({ kibanaBranch: env.packageInfo.branch });
this.docLinks = getDocLinks({
kibanaBranch: env.packageInfo.branch,
buildFlavor: env.packageInfo.buildFlavor,
});

this.config$ = combineLatest([
this.rawConfigProvider.getConfig$(),
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-doc-links/src/get_doc_links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getDocLinks } from './get_doc_links';

describe('getDocLinks', () => {
it('returns an immutable object', () => {
const links = getDocLinks({ kibanaBranch: 'test.branch' });
const links = getDocLinks({ kibanaBranch: 'test.branch', buildFlavor: 'traditional' });

expect(() => {
(links as unknown as Record<string, unknown>).settings = 'override';
Expand Down
7 changes: 4 additions & 3 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
*/

import { deepFreeze } from '@kbn/std';
import type { DocLinks } from './types';
import type { DocLinks, BuildFlavor } from './types';
import { getDocLinksMeta } from './get_doc_meta';

export interface GetDocLinkOptions {
kibanaBranch: string;
buildFlavor: BuildFlavor;
}

export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
const meta = getDocLinksMeta({ kibanaBranch });
export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): DocLinks => {
const meta = getDocLinksMeta({ kibanaBranch, buildFlavor });

const DOC_LINK_VERSION = meta.version;
const ELASTIC_WEBSITE_URL = meta.elasticWebsiteUrl;
Expand Down
14 changes: 9 additions & 5 deletions packages/kbn-doc-links/src/get_doc_meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ import { getDocLinksMeta } from './get_doc_meta';

describe('getDocLinksMeta', () => {
it('returns the correct version for the `main` branch', () => {
expect(getDocLinksMeta({ kibanaBranch: 'main' }).version).toEqual('master');
expect(getDocLinksMeta({ kibanaBranch: 'main', buildFlavor: 'traditional' }).version).toEqual(
'master'
);
});

it('returns the correct version for other branches', () => {
expect(getDocLinksMeta({ kibanaBranch: '7.x' }).version).toEqual('7.x');
expect(getDocLinksMeta({ kibanaBranch: '7.x', buildFlavor: 'traditional' }).version).toEqual(
'7.x'
);
});

it('returns the correct website url', () => {
expect(getDocLinksMeta({ kibanaBranch: '7.x' }).elasticWebsiteUrl).toEqual(
'https://www.elastic.co/'
);
expect(
getDocLinksMeta({ kibanaBranch: '7.x', buildFlavor: 'traditional' }).elasticWebsiteUrl
).toEqual('https://www.elastic.co/');
});
});
8 changes: 6 additions & 2 deletions packages/kbn-doc-links/src/get_doc_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
* Side Public License, v 1.
*/

import { DocLinksMeta } from './types';
import { DocLinksMeta, BuildFlavor } from './types';

export interface GetDocLinksMetaOptions {
kibanaBranch: string;
buildFlavor: BuildFlavor;
}

export const getDocLinksMeta = ({ kibanaBranch }: GetDocLinksMetaOptions): DocLinksMeta => {
export const getDocLinksMeta = ({
kibanaBranch,
buildFlavor,
}: GetDocLinksMetaOptions): DocLinksMeta => {
return {
version: kibanaBranch === 'main' ? 'master' : kibanaBranch,
elasticWebsiteUrl: 'https://www.elastic.co/',
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,3 +633,5 @@ export interface DocLinks {
readonly settings: string;
};
}

export type BuildFlavor = 'serverless' | 'traditional';
13 changes: 13 additions & 0 deletions packages/kbn-monaco/src/esql/lib/ast/definitions/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ export const evalFunctionsDefinitions: FunctionDefinition[] = [
},
],
},
{
name: 'to_geopoint',
description: i18n.translate('monaco.esql.definitions.toGeopointDoc', {
defaultMessage: 'Converts to geo_point.',
}),
signatures: [
{
params: [{ name: 'field', type: 'any' }],
returnType: 'geo_point',
examples: [`from index | EVAL geopoint = to_geopoint(field)`],
},
],
},
{
name: 'to_integer',
alias: ['to_int'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function getCallbackMocks() {
name: `${type}Field`,
type,
})),
{ name: 'geoPointField', type: 'geo_point' },
{ name: 'any#Char$ field', type: 'number' },
{ name: 'kubernetes.something.something', type: 'number' },
{
Expand Down
Loading

0 comments on commit 1f94a5b

Please sign in to comment.