diff --git a/packages/core/doc-links/core-doc-links-browser-internal/src/doc_links_service.test.ts b/packages/core/doc-links/core-doc-links-browser-internal/src/doc_links_service.test.ts index b30082e62c653..30e8188dd6af9 100644 --- a/packages/core/doc-links/core-doc-links-browser-internal/src/doc_links_service.test.ts +++ b/packages/core/doc-links/core-doc-links-browser-internal/src/doc_links_service.test.ts @@ -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; + let coreContext: ReturnType; let service: DocLinksService; beforeEach(() => { @@ -26,7 +28,8 @@ describe('DocLinksService', () => { settings: 'http://settings.test.url', }); - service = new DocLinksService(); + coreContext = coreContextMock.create(); + service = new DocLinksService(coreContext); }); afterEach(() => { @@ -43,6 +46,7 @@ describe('DocLinksService', () => { expect(getDocLinksMetaMock).toHaveBeenCalledTimes(1); expect(getDocLinksMetaMock).toHaveBeenCalledWith({ kibanaBranch: 'test-branch', + buildFlavor: coreContext.env.packageInfo.buildFlavor, }); }); @@ -64,6 +68,7 @@ describe('DocLinksService', () => { expect(getDocLinksMock).toHaveBeenCalledTimes(1); expect(getDocLinksMock).toHaveBeenCalledWith({ kibanaBranch: 'test-branch', + buildFlavor: coreContext.env.packageInfo.buildFlavor, }); }); diff --git a/packages/core/doc-links/core-doc-links-browser-internal/src/doc_links_service.ts b/packages/core/doc-links/core-doc-links-browser-internal/src/doc_links_service.ts index 115d41e1ee930..a5d6fe17ddf63 100644 --- a/packages/core/doc-links/core-doc-links-browser-internal/src/doc_links_service.ts +++ b/packages/core/doc-links/core-doc-links-browser-internal/src/doc_links_service.ts @@ -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'; @@ -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, diff --git a/packages/core/doc-links/core-doc-links-browser-internal/tsconfig.json b/packages/core/doc-links/core-doc-links-browser-internal/tsconfig.json index dda4c975120d7..45980da56c3da 100644 --- a/packages/core/doc-links/core-doc-links-browser-internal/tsconfig.json +++ b/packages/core/doc-links/core-doc-links-browser-internal/tsconfig.json @@ -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/**/*", diff --git a/packages/core/doc-links/core-doc-links-browser-mocks/src/doc_links_service.mock.ts b/packages/core/doc-links/core-doc-links-browser-mocks/src/doc_links_service.mock.ts index 03c394aa926e8..ef62bd97eca19 100644 --- a/packages/core/doc-links/core-doc-links-browser-mocks/src/doc_links_service.mock.ts +++ b/packages/core/doc-links/core-doc-links-browser-mocks/src/doc_links_service.mock.ts @@ -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'; @@ -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; diff --git a/packages/core/doc-links/core-doc-links-browser-mocks/tsconfig.json b/packages/core/doc-links/core-doc-links-browser-mocks/tsconfig.json index 473ae750e67ee..e60609b94a11b 100644 --- a/packages/core/doc-links/core-doc-links-browser-mocks/tsconfig.json +++ b/packages/core/doc-links/core-doc-links-browser-mocks/tsconfig.json @@ -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/**/*", diff --git a/packages/core/doc-links/core-doc-links-server-internal/src/doc_links_service.test.ts b/packages/core/doc-links/core-doc-links-server-internal/src/doc_links_service.test.ts index 6b7c7d3b33f3a..13c75fa0f6d25 100644 --- a/packages/core/doc-links/core-doc-links-server-internal/src/doc_links_service.test.ts +++ b/packages/core/doc-links/core-doc-links-server-internal/src/doc_links_service.test.ts @@ -41,6 +41,7 @@ describe('DocLinksService', () => { expect(getDocLinksMetaMock).toHaveBeenCalledTimes(1); expect(getDocLinksMetaMock).toHaveBeenCalledWith({ kibanaBranch: coreContext.env.packageInfo.branch, + buildFlavor: coreContext.env.packageInfo.buildFlavor, }); }); @@ -62,6 +63,7 @@ describe('DocLinksService', () => { expect(getDocLinksMock).toHaveBeenCalledTimes(1); expect(getDocLinksMock).toHaveBeenCalledWith({ kibanaBranch: coreContext.env.packageInfo.branch, + buildFlavor: coreContext.env.packageInfo.buildFlavor, }); }); diff --git a/packages/core/doc-links/core-doc-links-server-internal/src/doc_links_service.ts b/packages/core/doc-links/core-doc-links-server-internal/src/doc_links_service.ts index 3201bcd0256a4..ae11657666864 100644 --- a/packages/core/doc-links/core-doc-links-server-internal/src/doc_links_service.ts +++ b/packages/core/doc-links/core-doc-links-server-internal/src/doc_links_service.ts @@ -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, diff --git a/packages/core/doc-links/core-doc-links-server-mocks/src/doc_links_service.mock.ts b/packages/core/doc-links/core-doc-links-server-mocks/src/doc_links_service.mock.ts index d43c14c7fe8c3..b0ed04298dd1c 100644 --- a/packages/core/doc-links/core-doc-links-server-mocks/src/doc_links_service.mock.ts +++ b/packages/core/doc-links/core-doc-links-server-mocks/src/doc_links_service.mock.ts @@ -15,9 +15,10 @@ type DocLinksServiceContract = PublicMethodsOf; 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 }), }; }; diff --git a/packages/core/root/core-root-browser-internal/src/core_system.ts b/packages/core/root/core-root-browser-internal/src/core_system.ts index 3dcef6e3858cd..4c50aaf640e2a 100644 --- a/packages/core/root/core-root-browser-internal/src/core_system.ts +++ b/packages/core/root/core-root-browser-internal/src/core_system.ts @@ -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(); diff --git a/packages/core/test-helpers/core-test-helpers-model-versions/src/test_bed/test_kit.ts b/packages/core/test-helpers/core-test-helpers-model-versions/src/test_bed/test_kit.ts index 93517ea3b33a6..ee33208d793c2 100644 --- a/packages/core/test-helpers/core-test-helpers-model-versions/src/test_bed/test_kit.ts +++ b/packages/core/test-helpers/core-test-helpers-model-versions/src/test_bed/test_kit.ts @@ -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'; @@ -216,6 +216,7 @@ const getMigrator = async ({ loggerFactory, kibanaVersion, kibanaBranch, + buildFlavor = 'traditional', nodeRoles, }: { configService: ConfigService; @@ -226,6 +227,7 @@ const getMigrator = async ({ loggerFactory: LoggerFactory; kibanaVersion: string; kibanaBranch: string; + buildFlavor?: BuildFlavor; nodeRoles: NodeRoles; }) => { const savedObjectsConf = await firstValueFrom( @@ -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); diff --git a/packages/kbn-config/index.ts b/packages/kbn-config/index.ts index 4950e3f68beed..1b4c66702d9e8 100644 --- a/packages/kbn-config/index.ts +++ b/packages/kbn-config/index.ts @@ -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'; diff --git a/packages/kbn-config/src/config_service.ts b/packages/kbn-config/src/config_service.ts index e1c4ccfb55fbe..56b6f1b7887cf 100644 --- a/packages/kbn-config/src/config_service.ts +++ b/packages/kbn-config/src/config_service.ts @@ -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$(), diff --git a/packages/kbn-doc-links/src/get_doc_links.test.ts b/packages/kbn-doc-links/src/get_doc_links.test.ts index 0fff33ebd3fe4..60ce89266afc4 100644 --- a/packages/kbn-doc-links/src/get_doc_links.test.ts +++ b/packages/kbn-doc-links/src/get_doc_links.test.ts @@ -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).settings = 'override'; diff --git a/packages/kbn-doc-links/src/get_doc_links.ts b/packages/kbn-doc-links/src/get_doc_links.ts index a55fcde870efe..c5c253af7717a 100644 --- a/packages/kbn-doc-links/src/get_doc_links.ts +++ b/packages/kbn-doc-links/src/get_doc_links.ts @@ -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; diff --git a/packages/kbn-doc-links/src/get_doc_meta.test.ts b/packages/kbn-doc-links/src/get_doc_meta.test.ts index ec98fc5345a06..28685ee654a18 100644 --- a/packages/kbn-doc-links/src/get_doc_meta.test.ts +++ b/packages/kbn-doc-links/src/get_doc_meta.test.ts @@ -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/'); }); }); diff --git a/packages/kbn-doc-links/src/get_doc_meta.ts b/packages/kbn-doc-links/src/get_doc_meta.ts index 10e144166d39f..6e36aef20471f 100644 --- a/packages/kbn-doc-links/src/get_doc_meta.ts +++ b/packages/kbn-doc-links/src/get_doc_meta.ts @@ -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/', diff --git a/packages/kbn-doc-links/src/types.ts b/packages/kbn-doc-links/src/types.ts index f9e8699a06375..3b3b26be0426e 100644 --- a/packages/kbn-doc-links/src/types.ts +++ b/packages/kbn-doc-links/src/types.ts @@ -633,3 +633,5 @@ export interface DocLinks { readonly settings: string; }; } + +export type BuildFlavor = 'serverless' | 'traditional'; diff --git a/packages/kbn-securitysolution-autocomplete/src/field_value_lists/index.tsx b/packages/kbn-securitysolution-autocomplete/src/field_value_lists/index.tsx index 8a57f90e75ecc..a7b621979a5a8 100644 --- a/packages/kbn-securitysolution-autocomplete/src/field_value_lists/index.tsx +++ b/packages/kbn-securitysolution-autocomplete/src/field_value_lists/index.tsx @@ -125,7 +125,12 @@ export const AutocompleteFieldListsComponent: React.FC {i18n.SEE_DOCUMENTATION} diff --git a/src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_test_kit.ts b/src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_test_kit.ts index 1f6e9a7a58c77..e88a876edbc63 100644 --- a/src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_test_kit.ts +++ b/src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_test_kit.ts @@ -12,7 +12,7 @@ import { SemVer } from 'semver'; 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'; @@ -278,6 +278,7 @@ interface GetMigratorParams { loggerFactory: LoggerFactory; kibanaVersion: string; kibanaBranch: string; + buildFlavor?: BuildFlavor; nodeRoles: NodeRoles; } @@ -290,6 +291,7 @@ const getMigrator = async ({ loggerFactory, kibanaVersion, kibanaBranch, + buildFlavor = 'traditional', nodeRoles, }: GetMigratorParams) => { const savedObjectsConf = await firstValueFrom( @@ -301,8 +303,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); diff --git a/src/core/server/integration_tests/saved_objects/migrations/test_utils.ts b/src/core/server/integration_tests/saved_objects/migrations/test_utils.ts index 610981bab56ab..85e2d7b318fc6 100644 --- a/src/core/server/integration_tests/saved_objects/migrations/test_utils.ts +++ b/src/core/server/integration_tests/saved_objects/migrations/test_utils.ts @@ -17,12 +17,18 @@ import JSON5 from 'json5'; export const getDocVersion = () => { const env = Env.createDefault(REPO_ROOT, getEnvOptions()); - return getDocLinksMeta({ kibanaBranch: env.packageInfo.branch }).version; + return getDocLinksMeta({ + kibanaBranch: env.packageInfo.branch, + buildFlavor: env.packageInfo.buildFlavor, + }).version; }; export const getMigrationDocLink = () => { const env = Env.createDefault(REPO_ROOT, getEnvOptions()); - const docLinks = getDocLinks({ kibanaBranch: env.packageInfo.branch }); + const docLinks = getDocLinks({ + kibanaBranch: env.packageInfo.branch, + buildFlavor: env.packageInfo.buildFlavor, + }); return docLinks.kibanaUpgradeSavedObjects; }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/deprecation.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/deprecation.ts index 8e956e0e48aa6..46a9af76da4f0 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/deprecation.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/deprecation.ts @@ -16,7 +16,8 @@ import { DETECTION_ENGINE_RULES_BULK_ACTION } from '../../../../../common/consta * @returns string */ export const buildDeprecatedBulkEndpointMessage = (path: string) => { - const docsLink = getDocLinks({ kibanaBranch: 'main' }).siem.ruleApiOverview; + const docsLink = getDocLinks({ kibanaBranch: 'main', buildFlavor: 'traditional' }).siem + .ruleApiOverview; return `Deprecated endpoint: ${path} API is deprecated since v8.2. Please use the ${DETECTION_ENGINE_RULES_BULK_ACTION} API instead. See ${docsLink} for more detail.`; };