mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.12`: - [[doclinks] propagate build flavor to `getDocLinks` (#172358)](https://github.com/elastic/kibana/pull/172358) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Pierre Gayvallet","email":"pierre.gayvallet@elastic.co"},"sourceCommit":{"committedDate":"2023-12-12T09:59:41Z","message":"[doclinks] propagate build flavor to `getDocLinks` (#172358)\n\n## Summary\r\n\r\nFix https://github.com/elastic/kibana/issues/167088\r\n\r\nAdd a new `buildFlavor` (`traditional` | `serverless`) parameter to\r\n`getDocLinks` and `getDocLinksMeta` so that the doc links generator\r\nlogic can leverage the information\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"c50f3d749ed9071bf4c0974ed4f71399627f088a","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Docs","Team:Core","release_note:skip","v8.12.0","v8.13.0"],"number":172358,"url":"https://github.com/elastic/kibana/pull/172358","mergeCommit":{"message":"[doclinks] propagate build flavor to `getDocLinks` (#172358)\n\n## Summary\r\n\r\nFix https://github.com/elastic/kibana/issues/167088\r\n\r\nAdd a new `buildFlavor` (`traditional` | `serverless`) parameter to\r\n`getDocLinks` and `getDocLinksMeta` so that the doc links generator\r\nlogic can leverage the information\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"c50f3d749ed9071bf4c0974ed4f71399627f088a"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/172358","number":172358,"mergeCommit":{"message":"[doclinks] propagate build flavor to `getDocLinks` (#172358)\n\n## Summary\r\n\r\nFix https://github.com/elastic/kibana/issues/167088\r\n\r\nAdd a new `buildFlavor` (`traditional` | `serverless`) parameter to\r\n`getDocLinks` and `getDocLinksMeta` so that the doc links generator\r\nlogic can leverage the information\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"c50f3d749ed9071bf4c0974ed4f71399627f088a"}}]}] BACKPORT--> Co-authored-by: Pierre Gayvallet <pierre.gayvallet@elastic.co>
This commit is contained in:
parent
2ea119b97f
commit
76e8e9a89f
21 changed files with 83 additions and 37 deletions
|
@ -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(() => {
|
||||
|
@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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/**/*",
|
||||
|
|
|
@ -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<DocLinksService>;
|
||||
|
|
|
@ -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/**/*",
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 }),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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$(),
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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/');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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/',
|
||||
|
|
|
@ -633,3 +633,5 @@ export interface DocLinks {
|
|||
readonly settings: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type BuildFlavor = 'serverless' | 'traditional';
|
||||
|
|
|
@ -125,7 +125,12 @@ export const AutocompleteFieldListsComponent: React.FC<AutocompleteFieldListsPro
|
|||
<EuiLink
|
||||
external
|
||||
target="_blank"
|
||||
href={getDocLinks({ kibanaBranch: 'main' }).securitySolution.exceptions.value_lists}
|
||||
href={
|
||||
getDocLinks({
|
||||
kibanaBranch: 'main',
|
||||
buildFlavor: 'traditional',
|
||||
}).securitySolution.exceptions.value_lists
|
||||
}
|
||||
>
|
||||
{i18n.SEE_DOCUMENTATION}
|
||||
</EuiLink>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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.`;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue