diff --git a/packages/core/apps/core-apps-server-internal/src/bundle_routes/register_bundle_routes.test.ts b/packages/core/apps/core-apps-server-internal/src/bundle_routes/register_bundle_routes.test.ts index 7f444d3221a3..e6550f6e86cb 100644 --- a/packages/core/apps/core-apps-server-internal/src/bundle_routes/register_bundle_routes.test.ts +++ b/packages/core/apps/core-apps-server-internal/src/bundle_routes/register_bundle_routes.test.ts @@ -15,13 +15,14 @@ import { registerBundleRoutes } from './register_bundle_routes'; import { FileHashCache } from './file_hash_cache'; const createPackageInfo = (parts: Partial = {}): PackageInfo => ({ - ...parts, buildNum: 42, buildSha: 'sha', dist: true, branch: 'master', version: '8.0.0', buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'traditional', + ...parts, }); const createUiPlugins = (...ids: string[]): UiPlugins => ({ diff --git a/packages/core/base/core-base-browser-mocks/src/core_context.mock.ts b/packages/core/base/core-base-browser-mocks/src/core_context.mock.ts index 4de9ca33e0ee..53933d4146df 100644 --- a/packages/core/base/core-base-browser-mocks/src/core_context.mock.ts +++ b/packages/core/base/core-base-browser-mocks/src/core_context.mock.ts @@ -26,6 +26,7 @@ function createCoreContext({ production = false }: { production?: boolean } = {} buildSha: 'buildSha', dist: false, buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'traditional', }, }, }; diff --git a/packages/core/plugins/core-plugins-browser-internal/src/test_helpers/mocks.ts b/packages/core/plugins/core-plugins-browser-internal/src/test_helpers/mocks.ts index aea293345175..787a7d767819 100644 --- a/packages/core/plugins/core-plugins-browser-internal/src/test_helpers/mocks.ts +++ b/packages/core/plugins/core-plugins-browser-internal/src/test_helpers/mocks.ts @@ -25,6 +25,7 @@ export const createPluginInitializerContextMock = (config: unknown = {}) => { buildSha: 'buildSha', dist: false, buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'traditional', }, }, logger: loggerMock.create(), diff --git a/packages/core/plugins/core-plugins-browser-mocks/src/plugins_service.mock.ts b/packages/core/plugins/core-plugins-browser-mocks/src/plugins_service.mock.ts index 45154fa0165d..56ea09aed483 100644 --- a/packages/core/plugins/core-plugins-browser-mocks/src/plugins_service.mock.ts +++ b/packages/core/plugins/core-plugins-browser-mocks/src/plugins_service.mock.ts @@ -43,6 +43,7 @@ const createPluginInitializerContextMock = (config: unknown = {}) => { buildSha: 'buildSha', dist: false, buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'serverless', }, }, logger: loggerMock.create(), diff --git a/packages/core/plugins/core-plugins-server-internal/src/discovery/plugin_manifest_parser.test.ts b/packages/core/plugins/core-plugins-server-internal/src/discovery/plugin_manifest_parser.test.ts index 9f2cd298adfb..35cff51f820f 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/discovery/plugin_manifest_parser.test.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/discovery/plugin_manifest_parser.test.ts @@ -8,20 +8,21 @@ import { mockReadFile } from './plugin_manifest_parser.test.mocks'; -import { PluginDiscoveryErrorType } from './plugin_discovery_error'; - import { resolve } from 'path'; +import type { PackageInfo } from '@kbn/config'; +import { PluginDiscoveryErrorType } from './plugin_discovery_error'; import { parseManifest } from './plugin_manifest_parser'; const pluginPath = resolve('path', 'existent-dir'); const pluginManifestPath = resolve(pluginPath, 'kibana.json'); -const packageInfo = { +const packageInfo: PackageInfo = { branch: 'master', buildNum: 1, buildSha: '', version: '7.0.0-alpha1', dist: false, buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'traditional', }; afterEach(() => { diff --git a/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap b/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap index 84f58863363a..3428f9842d44 100644 --- a/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap +++ b/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap @@ -20,6 +20,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -82,6 +83,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -148,6 +150,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -210,6 +213,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -272,6 +276,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -338,6 +343,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -400,6 +406,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -462,6 +469,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -528,6 +536,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -598,6 +607,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -660,6 +670,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -726,6 +737,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -796,6 +808,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, @@ -862,6 +875,7 @@ Object { "packageInfo": Object { "branch": Any, "buildDate": "2023-05-15T23:12:09.000Z", + "buildFlavor": Any, "buildNum": Any, "buildSha": Any, "dist": Any, diff --git a/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.ts index 5140891d1eee..df9589b043d2 100644 --- a/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.ts @@ -28,6 +28,7 @@ const createPackageInfo = (parts: Partial = {}): PackageInfo => ({ buildDate: new Date('2023-05-15T23:12:09.000Z'), dist: false, version: '8.0.0', + buildFlavor: 'traditional', ...parts, }); diff --git a/packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.ts b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.ts index 81a1cea933f1..193ad54918d9 100644 --- a/packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.ts @@ -45,6 +45,7 @@ const INJECTED_METADATA = { dist: expect.any(Boolean), version: expect.any(String), buildDate: new Date(BUILD_DATE).toISOString(), + buildFlavor: expect.any(String), }, }, }; diff --git a/packages/kbn-config/src/__snapshots__/env.test.ts.snap b/packages/kbn-config/src/__snapshots__/env.test.ts.snap index 39aae1dd9b2f..e5d5a3816ced 100644 --- a/packages/kbn-config/src/__snapshots__/env.test.ts.snap +++ b/packages/kbn-config/src/__snapshots__/env.test.ts.snap @@ -29,6 +29,7 @@ Env { "packageInfo": Object { "branch": "feature-v1", "buildDate": 2023-05-15T23:12:09.000Z, + "buildFlavor": "traditional", "buildNum": 9007199254740991, "buildSha": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "dist": false, @@ -71,6 +72,7 @@ Env { "packageInfo": Object { "branch": "feature-v1", "buildDate": 2023-05-15T23:12:09.000Z, + "buildFlavor": "traditional", "buildNum": 9007199254740991, "buildSha": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "dist": false, @@ -112,6 +114,7 @@ Env { "packageInfo": Object { "branch": "some-branch", "buildDate": 2023-05-15T23:12:09.000Z, + "buildFlavor": "traditional", "buildNum": 9007199254740991, "buildSha": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "dist": false, @@ -153,6 +156,7 @@ Env { "packageInfo": Object { "branch": "feature-v1", "buildDate": 2023-05-15T23:12:09.000Z, + "buildFlavor": "traditional", "buildNum": 100, "buildSha": "feature-v1-build-sha", "dist": true, @@ -194,6 +198,7 @@ Env { "packageInfo": Object { "branch": "feature-v1", "buildDate": 2023-05-15T23:12:09.000Z, + "buildFlavor": "traditional", "buildNum": 9007199254740991, "buildSha": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "dist": false, @@ -235,6 +240,7 @@ Env { "packageInfo": Object { "branch": "feature-v1", "buildDate": 2023-05-15T23:12:09.000Z, + "buildFlavor": "traditional", "buildNum": 100, "buildSha": "feature-v1-build-sha", "dist": true, diff --git a/packages/kbn-config/src/env.test.ts b/packages/kbn-config/src/env.test.ts index 5203c34b7321..7c301ff83e6f 100644 --- a/packages/kbn-config/src/env.test.ts +++ b/packages/kbn-config/src/env.test.ts @@ -208,3 +208,43 @@ test('pluginSearchPaths only includes kibana-extra, regardless of plugin filters expect(env4.pluginSearchPaths).toEqual(['/some/home/kibana-extra', '/some/home/dir/plugins']); }); + +describe('packageInfo.buildFlavor', () => { + it('is set to `serverless` when the `serverless` cli flag is `true`', () => { + mockPackage.raw = { + branch: 'some-branch', + version: 'some-version', + }; + + const env = Env.createDefault( + REPO_ROOT, + getEnvOptions({ + configs: ['/test/cwd/config/kibana.yml'], + cliArgs: { + serverless: true, + }, + }) + ); + + expect(env.packageInfo.buildFlavor).toEqual('serverless'); + }); + + it('is set to `traditional` when the `serverless` cli flag is `false`', () => { + mockPackage.raw = { + branch: 'some-branch', + version: 'some-version', + }; + + const env = Env.createDefault( + REPO_ROOT, + getEnvOptions({ + configs: ['/test/cwd/config/kibana.yml'], + cliArgs: { + serverless: false, + }, + }) + ); + + expect(env.packageInfo.buildFlavor).toEqual('traditional'); + }); +}); diff --git a/packages/kbn-config/src/env.ts b/packages/kbn-config/src/env.ts index 64d147d9a4a8..99728f0dfc41 100644 --- a/packages/kbn-config/src/env.ts +++ b/packages/kbn-config/src/env.ts @@ -124,6 +124,7 @@ export class Env { version: pkg.version, dist: isKibanaDistributable, buildDate: isKibanaDistributable ? new Date(pkg.build.date) : new Date(), + buildFlavor: this.cliArgs.serverless ? 'serverless' : 'traditional', }); } } diff --git a/packages/kbn-config/src/types.ts b/packages/kbn-config/src/types.ts index dcb959f30cd0..f9038a1a7fd2 100644 --- a/packages/kbn-config/src/types.ts +++ b/packages/kbn-config/src/types.ts @@ -15,6 +15,7 @@ export interface PackageInfo { buildNum: number; buildSha: string; buildDate: Date; + buildFlavor: BuildFlavor; dist: boolean; } @@ -26,3 +27,5 @@ export interface EnvironmentMode { dev: boolean; prod: boolean; } + +export type BuildFlavor = 'serverless' | 'traditional'; diff --git a/src/core/server/integration_tests/status/routes/status.test.ts b/src/core/server/integration_tests/status/routes/status.test.ts index 41d1342090d7..0d7d6a84e249 100644 --- a/src/core/server/integration_tests/status/routes/status.test.ts +++ b/src/core/server/integration_tests/status/routes/status.test.ts @@ -86,6 +86,7 @@ describe('GET /api/status', () => { dist: true, version: '9.9.9-SNAPSHOT', buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'traditional', }, serverName: 'xkibana', uuid: 'xxxx-xxxxx', diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts index 00f2497ab1dd..62dd66f63ec6 100644 --- a/src/core/server/mocks.ts +++ b/src/core/server/mocks.ts @@ -100,6 +100,7 @@ function pluginInitializerContextMock(config: T = {} as T) { buildSha: 'buildSha', dist: false, buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'traditional', }, instanceUuid: 'instance-uuid', configs: ['/some/path/to/config/kibana.yml'], diff --git a/x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/integration_tests/pdfmaker.test.ts b/x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/integration_tests/pdfmaker.test.ts index cdd8350c0ae9..2243f68b7ad7 100644 --- a/x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/integration_tests/pdfmaker.test.ts +++ b/x-pack/plugins/screenshotting/server/formats/pdf/pdf_maker/integration_tests/pdfmaker.test.ts @@ -36,6 +36,7 @@ describe('PdfMaker', () => { dist: false, version: '1000.0.0', buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'traditional', }; pdf = new PdfMaker(layout, undefined, packageInfo, logger); }); diff --git a/x-pack/plugins/screenshotting/server/screenshots/index.test.ts b/x-pack/plugins/screenshotting/server/screenshots/index.test.ts index bdaf96e710f7..8208d7e2c451 100644 --- a/x-pack/plugins/screenshotting/server/screenshots/index.test.ts +++ b/x-pack/plugins/screenshotting/server/screenshots/index.test.ts @@ -58,6 +58,7 @@ describe('Screenshot Observable Pipeline', () => { dist: false, version: '5000.0.0', buildDate: new Date('2023-05-15T23:12:09.000Z'), + buildFlavor: 'traditional', }; options = { browserTimezone: 'UTC',