mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[APM] Add feature flag to sourcemap endpoints (#157997)
Part of https://github.com/elastic/kibana/issues/153776 Disallow uploading source maps endpoints to make it clear that it won't work by returning 501 Not Implemented status code
This commit is contained in:
parent
8a081dc308
commit
97e6c84f82
1 changed files with 21 additions and 2 deletions
|
@ -9,6 +9,7 @@ import { SavedObjectsClientContract } from '@kbn/core/server';
|
|||
import { Artifact } from '@kbn/fleet-plugin/server';
|
||||
import { jsonRt, toNumberRt } from '@kbn/io-ts-utils';
|
||||
import * as t from 'io-ts';
|
||||
import { ApmFeatureFlags } from '../../../common/apm_feature_flags';
|
||||
import { getInternalSavedObjectsClient } from '../../lib/helpers/get_internal_saved_objects_client';
|
||||
import { stringFromBufferRt } from '../../utils/string_from_buffer_rt';
|
||||
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
|
||||
|
@ -40,6 +41,14 @@ export const sourceMapRt = t.intersection([
|
|||
|
||||
export type SourceMap = t.TypeOf<typeof sourceMapRt>;
|
||||
|
||||
function throwNotImplementedIfSourceMapNotAvailable(
|
||||
featureFlags: ApmFeatureFlags
|
||||
): void {
|
||||
if (!featureFlags.sourcemapApiAvailable) {
|
||||
throw Boom.notImplemented();
|
||||
}
|
||||
}
|
||||
|
||||
const listSourceMapRoute = createApmServerRoute({
|
||||
endpoint: 'GET /api/apm/sourcemaps',
|
||||
options: { tags: ['access:apm'] },
|
||||
|
@ -52,7 +61,10 @@ const listSourceMapRoute = createApmServerRoute({
|
|||
async handler({
|
||||
params,
|
||||
plugins,
|
||||
featureFlags,
|
||||
}): Promise<ListSourceMapArtifactsResponse | undefined> {
|
||||
throwNotImplementedIfSourceMapNotAvailable(featureFlags);
|
||||
|
||||
const { page, perPage } = params.query;
|
||||
|
||||
try {
|
||||
|
@ -97,7 +109,10 @@ const uploadSourceMapRoute = createApmServerRoute({
|
|||
plugins,
|
||||
core,
|
||||
logger,
|
||||
featureFlags,
|
||||
}): Promise<Artifact | undefined> => {
|
||||
throwNotImplementedIfSourceMapNotAvailable(featureFlags);
|
||||
|
||||
const {
|
||||
service_name: serviceName,
|
||||
service_version: serviceVersion,
|
||||
|
@ -162,7 +177,9 @@ const deleteSourceMapRoute = createApmServerRoute({
|
|||
id: t.string,
|
||||
}),
|
||||
}),
|
||||
handler: async ({ params, plugins, core }): Promise<void> => {
|
||||
handler: async ({ params, plugins, core, featureFlags }): Promise<void> => {
|
||||
throwNotImplementedIfSourceMapNotAvailable(featureFlags);
|
||||
|
||||
const fleetPluginStart = await plugins.fleet?.start();
|
||||
const { id } = params.path;
|
||||
const coreStart = await core.start();
|
||||
|
@ -192,7 +209,9 @@ const deleteSourceMapRoute = createApmServerRoute({
|
|||
const migrateFleetArtifactsSourceMapRoute = createApmServerRoute({
|
||||
endpoint: 'POST /internal/apm/sourcemaps/migrate_fleet_artifacts',
|
||||
options: { tags: ['access:apm', 'access:apm_write'] },
|
||||
handler: async ({ plugins, core, logger }): Promise<void> => {
|
||||
handler: async ({ plugins, core, logger, featureFlags }): Promise<void> => {
|
||||
throwNotImplementedIfSourceMapNotAvailable(featureFlags);
|
||||
|
||||
const fleet = await plugins.fleet?.start();
|
||||
const coreStart = await core.start();
|
||||
const internalESClient = coreStart.elasticsearch.client.asInternalUser;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue