From 35422cec8fc7da9e94dcb3e0f28c9fa195c62223 Mon Sep 17 00:00:00 2001 From: "miriam.aparicio" Date: Tue, 6 Jun 2023 16:40:53 +0100 Subject: [PATCH 1/6] add feature flags to apm config and serverless.oblt.yml --- config/serverless.oblt.yml | 10 +++ .../templates/apm_service_template/index.tsx | 1 - .../templates/settings_template.stories.tsx | 15 +++- .../apm_plugin/mock_apm_plugin_context.tsx | 11 +++ .../apm/public/hooks/use_apm_feature_flag.ts | 11 +-- x-pack/plugins/apm/public/index.ts | 11 +++ x-pack/plugins/apm/server/index.ts | 75 +++++++++++++++++++ x-pack/plugins/apm/server/plugin.ts | 3 +- 8 files changed, 125 insertions(+), 12 deletions(-) diff --git a/config/serverless.oblt.yml b/config/serverless.oblt.yml index 0195414203d8f..0c2dba8ee7212 100644 --- a/config/serverless.oblt.yml +++ b/config/serverless.oblt.yml @@ -27,3 +27,13 @@ xpack.apm.serverlessOnboarding: true xpack.fleet.packages: - name: apm version: latest +## Disable APM UI components and API calls +xpack.apm.featureFlags.agentConfigurationAvailable: false +xpack.apm.featureFlags.configurableIndicesAvailable: false +xpack.apm.featureFlags.infrastructureTabAvailable: false +xpack.apm.featureFlags.infraUiAvailable: false +xpack.apm.featureFlags.migrationToFleetAvailable: false +xpack.apm.featureFlags.sourcemapApiAvailable: false +xpack.apm.featureFlags.spacesAvailable: false +xpack.apm.featureFlags.schemaAvailable: false +xpack.apm.featureFlags.storageExplorerAvailable: false diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx index c0c2c83e331ce..6400365aa87a1 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx @@ -217,7 +217,6 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) { ); const router = useApmRouter(); - const isInfraTabAvailable = useApmFeatureFlag( ApmFeatureFlagName.InfrastructureTabAvailable ); diff --git a/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx b/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx index b214a79b7a1f8..c0d70d72f9ef7 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx @@ -25,6 +25,14 @@ const coreMock = { }, } as unknown as Partial; +const configMock = { + featureFlags: { + agentConfigurationAvailable: true, + schemaAvailable: true, + indicesAvailable: true, + }, +}; + const stories: Meta = { title: 'routing/templates/SettingsTemplate', component: SettingsTemplate, @@ -36,7 +44,12 @@ const stories: Meta = { return ( diff --git a/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx b/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx index 559e66437cda0..8c80a14218c31 100644 --- a/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx +++ b/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx @@ -71,6 +71,17 @@ const mockConfig: ConfigSchema = { latestAgentVersionsUrl: '', serverlessOnboarding: false, managedServiceUrl: '', + featureFlags: { + agentConfigurationAvailable: true, + configurableIndicesAvailable: true, + infrastructureTabAvailable: true, + infraUiAvailable: true, + migrationToFleetAvailable: true, + sourcemapApiAvailable: true, + spacesAvailable: true, + schemaAvailable: true, + storageExplorerAvailable: true, + }, }; const urlService = new UrlService({ diff --git a/x-pack/plugins/apm/public/hooks/use_apm_feature_flag.ts b/x-pack/plugins/apm/public/hooks/use_apm_feature_flag.ts index e78ec26985cdd..f644aa3ae2eab 100644 --- a/x-pack/plugins/apm/public/hooks/use_apm_feature_flag.ts +++ b/x-pack/plugins/apm/public/hooks/use_apm_feature_flag.ts @@ -5,22 +5,17 @@ * 2.0. */ -import { useMemo } from 'react'; import { ApmFeatureFlagName, - getApmFeatureFlags, ValueOfApmFeatureFlag, } from '../../common/apm_feature_flags'; +import { useApmPluginContext } from '../context/apm_plugin/use_apm_plugin_context'; export function useApmFeatureFlag< TApmFeatureFlagName extends ApmFeatureFlagName >( featureFlag: TApmFeatureFlagName ): ValueOfApmFeatureFlag { - const featureFlags = useMemo(() => { - // this should be replaced with an API call - return getApmFeatureFlags(); - }, []); - - return featureFlags[featureFlag]; + const { config } = useApmPluginContext(); + return config.featureFlags[featureFlag]; } diff --git a/x-pack/plugins/apm/public/index.ts b/x-pack/plugins/apm/public/index.ts index 1dea751371137..b61f950074a74 100644 --- a/x-pack/plugins/apm/public/index.ts +++ b/x-pack/plugins/apm/public/index.ts @@ -16,6 +16,17 @@ export interface ConfigSchema { latestAgentVersionsUrl: string; serverlessOnboarding: boolean; managedServiceUrl: string; + featureFlags: { + agentConfigurationAvailable: boolean; + configurableIndicesAvailable: boolean; + infrastructureTabAvailable: boolean; + infraUiAvailable: boolean; + migrationToFleetAvailable: boolean; + sourcemapApiAvailable: boolean; + spacesAvailable: boolean; + schemaAvailable: boolean; + storageExplorerAvailable: boolean; + }; } export const plugin: PluginInitializer = ( diff --git a/x-pack/plugins/apm/server/index.ts b/x-pack/plugins/apm/server/index.ts index 42327cb1d636e..1076689aef92b 100644 --- a/x-pack/plugins/apm/server/index.ts +++ b/x-pack/plugins/apm/server/index.ts @@ -69,6 +69,80 @@ const configSchema = schema.object({ schema.string({ defaultValue: '' }), schema.never() ), + featureFlags: schema.object({ + agentConfigurationAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + configurableIndicesAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + infrastructureTabAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + infraUiAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + migrationToFleetAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + sourcemapApiAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + spacesAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + schemaAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + storageExplorerAvailable: schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) + ), + }), }); // plugin config @@ -129,6 +203,7 @@ export const config: PluginConfigDescriptor = { latestAgentVersionsUrl: true, managedServiceUrl: true, serverlessOnboarding: true, + featureFlags: true, }, schema: configSchema, }; diff --git a/x-pack/plugins/apm/server/plugin.ts b/x-pack/plugins/apm/server/plugin.ts index f91afd4ece8ed..618c1b388bfab 100644 --- a/x-pack/plugins/apm/server/plugin.ts +++ b/x-pack/plugins/apm/server/plugin.ts @@ -55,7 +55,6 @@ import { migrateLegacyAPMIndicesToSpaceAware } from './saved_objects/migrations/ import { scheduleSourceMapMigration } from './routes/source_maps/schedule_source_map_migration'; import { createApmSourceMapIndexTemplate } from './routes/source_maps/create_apm_source_map_index_template'; import { addApiKeysToEveryPackagePolicyIfMissing } from './routes/fleet/api_keys/add_api_keys_to_policies_if_missing'; -import { getApmFeatureFlags } from '../common/apm_feature_flags'; import { apmTutorialCustomIntegration } from '../common/tutorial/tutorials'; export class APMPlugin @@ -183,7 +182,7 @@ export class APMPlugin }, logger: this.logger, config: currentConfig, - featureFlags: getApmFeatureFlags(), + featureFlags: currentConfig.featureFlags, repository: getGlobalApmServerRouteRepository(), ruleDataClient, plugins: resourcePlugins, From cc554c2e01b614680d8181a90d1541613e2838f4 Mon Sep 17 00:00:00 2001 From: "miriam.aparicio" Date: Mon, 12 Jun 2023 10:56:03 +0100 Subject: [PATCH 2/6] fix incorrent feature flag value --- .../components/routing/templates/settings_template.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx b/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx index c0d70d72f9ef7..7e57ce021e993 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx @@ -29,7 +29,7 @@ const configMock = { featureFlags: { agentConfigurationAvailable: true, schemaAvailable: true, - indicesAvailable: true, + configurableIndicesAvailable: true, }, }; From 3c8b9680754ae398310d7758a621a12a67973ae8 Mon Sep 17 00:00:00 2001 From: "miriam.aparicio" Date: Mon, 12 Jun 2023 16:13:35 +0100 Subject: [PATCH 3/6] fix plugin functional tests --- .../test_suites/core_plugins/rendering.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/plugin_functional/test_suites/core_plugins/rendering.ts b/test/plugin_functional/test_suites/core_plugins/rendering.ts index 935495c362ab5..4d39e61e8e209 100644 --- a/test/plugin_functional/test_suites/core_plugins/rendering.ts +++ b/test/plugin_functional/test_suites/core_plugins/rendering.ts @@ -180,6 +180,15 @@ export default function ({ getService }: PluginFunctionalProviderContext) { 'xpack.apm.managedServiceUrl (any)', 'xpack.apm.serverlessOnboarding (any)', 'xpack.apm.latestAgentVersionsUrl (string)', + 'xpack.apm.featureFlags.agentConfigurationAvailable (any)', + 'xpack.apm.featureFlags.configurableIndicesAvailable (any)', + 'xpack.apm.featureFlags.infrastructureTabAvailable (any)', + 'xpack.apm.featureFlags.infraUiAvailable (any)', + 'xpack.apm.featureFlags.migrationToFleetAvailable (any)', + 'xpack.apm.featureFlags.sourcemapApiAvailable (any)', + 'xpack.apm.featureFlags.spacesAvailable (any)', + 'xpack.apm.featureFlags.schemaAvailable (any)', + 'xpack.apm.featureFlags.storageExplorerAvailable (any)', 'xpack.cases.files.allowedMimeTypes (array)', 'xpack.cases.files.maxSize (number)', 'xpack.cases.markdownPlugins.lens (boolean)', From eca126ce3d4c6463b6219b7c84c524e92a88da97 Mon Sep 17 00:00:00 2001 From: "miriam.aparicio" Date: Tue, 13 Jun 2023 14:56:31 +0100 Subject: [PATCH 4/6] remove schemaAvailable flag --- config/serverless.oblt.yml | 1 - .../test_suites/core_plugins/rendering.ts | 1 - x-pack/plugins/apm/common/apm_feature_flags.ts | 5 ----- .../routing/templates/settings_template.stories.tsx | 1 - .../components/routing/templates/settings_template.tsx | 10 +++++----- .../context/apm_plugin/mock_apm_plugin_context.tsx | 1 - x-pack/plugins/apm/public/index.ts | 1 - x-pack/plugins/apm/server/index.ts | 8 -------- 8 files changed, 5 insertions(+), 23 deletions(-) diff --git a/config/serverless.oblt.yml b/config/serverless.oblt.yml index 0c2dba8ee7212..294ef37eaaa18 100644 --- a/config/serverless.oblt.yml +++ b/config/serverless.oblt.yml @@ -35,5 +35,4 @@ xpack.apm.featureFlags.infraUiAvailable: false xpack.apm.featureFlags.migrationToFleetAvailable: false xpack.apm.featureFlags.sourcemapApiAvailable: false xpack.apm.featureFlags.spacesAvailable: false -xpack.apm.featureFlags.schemaAvailable: false xpack.apm.featureFlags.storageExplorerAvailable: false diff --git a/test/plugin_functional/test_suites/core_plugins/rendering.ts b/test/plugin_functional/test_suites/core_plugins/rendering.ts index 4d39e61e8e209..0798622592294 100644 --- a/test/plugin_functional/test_suites/core_plugins/rendering.ts +++ b/test/plugin_functional/test_suites/core_plugins/rendering.ts @@ -187,7 +187,6 @@ export default function ({ getService }: PluginFunctionalProviderContext) { 'xpack.apm.featureFlags.migrationToFleetAvailable (any)', 'xpack.apm.featureFlags.sourcemapApiAvailable (any)', 'xpack.apm.featureFlags.spacesAvailable (any)', - 'xpack.apm.featureFlags.schemaAvailable (any)', 'xpack.apm.featureFlags.storageExplorerAvailable (any)', 'xpack.cases.files.allowedMimeTypes (array)', 'xpack.cases.files.maxSize (number)', diff --git a/x-pack/plugins/apm/common/apm_feature_flags.ts b/x-pack/plugins/apm/common/apm_feature_flags.ts index c928c8a0dec6a..f63eb7425dba8 100644 --- a/x-pack/plugins/apm/common/apm_feature_flags.ts +++ b/x-pack/plugins/apm/common/apm_feature_flags.ts @@ -16,7 +16,6 @@ export enum ApmFeatureFlagName { MigrationToFleetAvailable = 'migrationToFleetAvailable', SourcemapApiAvailable = 'sourcemapApiAvailable', SpacesAvailable = 'spacesAvailable', - SchemaAvailable = 'schemaAvailable', StorageExplorerAvailable = 'storageExplorerAvailable', } @@ -49,10 +48,6 @@ const apmFeatureFlagMap = { default: true, type: t.boolean, }, - [ApmFeatureFlagName.SchemaAvailable]: { - default: true, - type: t.boolean, - }, [ApmFeatureFlagName.StorageExplorerAvailable]: { default: true, type: t.boolean, diff --git a/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx b/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx index 7e57ce021e993..e3604e67ebf5b 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/settings_template.stories.tsx @@ -28,7 +28,6 @@ const coreMock = { const configMock = { featureFlags: { agentConfigurationAvailable: true, - schemaAvailable: true, configurableIndicesAvailable: true, }, }; diff --git a/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx b/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx index 7337be6c3d40e..11b81003f4ef4 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx @@ -46,7 +46,7 @@ export function SettingsTemplate({ children, selectedTab }: Props) { const agentConfigurationAvailable = useApmFeatureFlag( ApmFeatureFlagName.AgentConfigurationAvailable ); - const schemaTabAvailable = useApmFeatureFlag( + const migrationToFleetAvailable = useApmFeatureFlag( ApmFeatureFlagName.MigrationToFleetAvailable ); const indicesAvailable = useApmFeatureFlag( @@ -59,7 +59,7 @@ export function SettingsTemplate({ children, selectedTab }: Props) { router, defaultEnvironment, agentConfigurationAvailable, - schemaTabAvailable, + migrationToFleetAvailable, indicesAvailable, }); @@ -84,7 +84,7 @@ function getTabs({ router, defaultEnvironment, agentConfigurationAvailable, - schemaTabAvailable, + migrationToFleetAvailable, indicesAvailable, }: { core: CoreStart; @@ -92,7 +92,7 @@ function getTabs({ router: ApmRouter; defaultEnvironment: Environment; agentConfigurationAvailable: boolean; - schemaTabAvailable: boolean; + migrationToFleetAvailable: boolean; indicesAvailable: boolean; }) { const canReadMlJobs = !!core.application.capabilities.ml?.canGetJobs; @@ -171,7 +171,7 @@ function getTabs({ ] : []), - ...(schemaTabAvailable + ...(migrationToFleetAvailable ? [ { key: 'schema' as const, diff --git a/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx b/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx index 8c80a14218c31..a4a8eb888ea02 100644 --- a/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx +++ b/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx @@ -79,7 +79,6 @@ const mockConfig: ConfigSchema = { migrationToFleetAvailable: true, sourcemapApiAvailable: true, spacesAvailable: true, - schemaAvailable: true, storageExplorerAvailable: true, }, }; diff --git a/x-pack/plugins/apm/public/index.ts b/x-pack/plugins/apm/public/index.ts index b61f950074a74..a90c433db6a3a 100644 --- a/x-pack/plugins/apm/public/index.ts +++ b/x-pack/plugins/apm/public/index.ts @@ -24,7 +24,6 @@ export interface ConfigSchema { migrationToFleetAvailable: boolean; sourcemapApiAvailable: boolean; spacesAvailable: boolean; - schemaAvailable: boolean; storageExplorerAvailable: boolean; }; } diff --git a/x-pack/plugins/apm/server/index.ts b/x-pack/plugins/apm/server/index.ts index 1076689aef92b..4f9b501337de4 100644 --- a/x-pack/plugins/apm/server/index.ts +++ b/x-pack/plugins/apm/server/index.ts @@ -126,14 +126,6 @@ const configSchema = schema.object({ }), schema.oneOf([schema.literal(true)], { defaultValue: true }) ), - schemaAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), storageExplorerAvailable: schema.conditional( schema.contextRef('serverless'), true, From 33ad69ee5bcb488ce7d20194c5262873670d9146 Mon Sep 17 00:00:00 2001 From: "miriam.aparicio" Date: Tue, 13 Jun 2023 15:59:38 +0100 Subject: [PATCH 5/6] remove spacesAvailable flag --- config/serverless.oblt.yml | 1 - .../test_suites/core_plugins/rendering.ts | 1 - x-pack/plugins/apm/common/apm_feature_flags.ts | 5 ----- .../public/context/apm_plugin/mock_apm_plugin_context.tsx | 1 - x-pack/plugins/apm/public/index.ts | 1 - x-pack/plugins/apm/server/index.ts | 8 -------- 6 files changed, 17 deletions(-) diff --git a/config/serverless.oblt.yml b/config/serverless.oblt.yml index 294ef37eaaa18..023824e1c5611 100644 --- a/config/serverless.oblt.yml +++ b/config/serverless.oblt.yml @@ -34,5 +34,4 @@ xpack.apm.featureFlags.infrastructureTabAvailable: false xpack.apm.featureFlags.infraUiAvailable: false xpack.apm.featureFlags.migrationToFleetAvailable: false xpack.apm.featureFlags.sourcemapApiAvailable: false -xpack.apm.featureFlags.spacesAvailable: false xpack.apm.featureFlags.storageExplorerAvailable: false diff --git a/test/plugin_functional/test_suites/core_plugins/rendering.ts b/test/plugin_functional/test_suites/core_plugins/rendering.ts index 0798622592294..47408b0131477 100644 --- a/test/plugin_functional/test_suites/core_plugins/rendering.ts +++ b/test/plugin_functional/test_suites/core_plugins/rendering.ts @@ -186,7 +186,6 @@ export default function ({ getService }: PluginFunctionalProviderContext) { 'xpack.apm.featureFlags.infraUiAvailable (any)', 'xpack.apm.featureFlags.migrationToFleetAvailable (any)', 'xpack.apm.featureFlags.sourcemapApiAvailable (any)', - 'xpack.apm.featureFlags.spacesAvailable (any)', 'xpack.apm.featureFlags.storageExplorerAvailable (any)', 'xpack.cases.files.allowedMimeTypes (array)', 'xpack.cases.files.maxSize (number)', diff --git a/x-pack/plugins/apm/common/apm_feature_flags.ts b/x-pack/plugins/apm/common/apm_feature_flags.ts index f63eb7425dba8..0685555d02c1e 100644 --- a/x-pack/plugins/apm/common/apm_feature_flags.ts +++ b/x-pack/plugins/apm/common/apm_feature_flags.ts @@ -15,7 +15,6 @@ export enum ApmFeatureFlagName { InfraUiAvailable = 'infraUiAvailable', MigrationToFleetAvailable = 'migrationToFleetAvailable', SourcemapApiAvailable = 'sourcemapApiAvailable', - SpacesAvailable = 'spacesAvailable', StorageExplorerAvailable = 'storageExplorerAvailable', } @@ -44,10 +43,6 @@ const apmFeatureFlagMap = { default: true, type: t.boolean, }, - [ApmFeatureFlagName.SpacesAvailable]: { - default: true, - type: t.boolean, - }, [ApmFeatureFlagName.StorageExplorerAvailable]: { default: true, type: t.boolean, diff --git a/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx b/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx index a4a8eb888ea02..78ad49f465ed4 100644 --- a/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx +++ b/x-pack/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx @@ -78,7 +78,6 @@ const mockConfig: ConfigSchema = { infraUiAvailable: true, migrationToFleetAvailable: true, sourcemapApiAvailable: true, - spacesAvailable: true, storageExplorerAvailable: true, }, }; diff --git a/x-pack/plugins/apm/public/index.ts b/x-pack/plugins/apm/public/index.ts index a90c433db6a3a..b6aa22dab272a 100644 --- a/x-pack/plugins/apm/public/index.ts +++ b/x-pack/plugins/apm/public/index.ts @@ -23,7 +23,6 @@ export interface ConfigSchema { infraUiAvailable: boolean; migrationToFleetAvailable: boolean; sourcemapApiAvailable: boolean; - spacesAvailable: boolean; storageExplorerAvailable: boolean; }; } diff --git a/x-pack/plugins/apm/server/index.ts b/x-pack/plugins/apm/server/index.ts index 4f9b501337de4..e4664553c41b5 100644 --- a/x-pack/plugins/apm/server/index.ts +++ b/x-pack/plugins/apm/server/index.ts @@ -118,14 +118,6 @@ const configSchema = schema.object({ }), schema.oneOf([schema.literal(true)], { defaultValue: true }) ), - spacesAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), storageExplorerAvailable: schema.conditional( schema.contextRef('serverless'), true, From 42fb17af987e4672cfd20f82f74cbcfca4970c18 Mon Sep 17 00:00:00 2001 From: "miriam.aparicio" Date: Wed, 14 Jun 2023 11:02:16 +0100 Subject: [PATCH 6/6] improve readability in config for feature flags --- x-pack/plugins/apm/server/index.ts | 72 +++++++----------------------- 1 file changed, 16 insertions(+), 56 deletions(-) diff --git a/x-pack/plugins/apm/server/index.ts b/x-pack/plugins/apm/server/index.ts index e4664553c41b5..880a9d5e83a79 100644 --- a/x-pack/plugins/apm/server/index.ts +++ b/x-pack/plugins/apm/server/index.ts @@ -14,6 +14,15 @@ import { maxSuggestions } from '@kbn/observability-plugin/common'; import { SearchAggregatedTransactionSetting } from '../common/aggregated_transactions'; import { APMPlugin } from './plugin'; +const disabledOnServerless = schema.conditional( + schema.contextRef('serverless'), + true, + schema.boolean({ + defaultValue: false, + }), + schema.oneOf([schema.literal(true)], { defaultValue: true }) +); + // All options should be documented in the APM configuration settings: https://github.com/elastic/kibana/blob/main/docs/settings/apm-settings.asciidoc // and be included on cloud allow list unless there are specific reasons not to const configSchema = schema.object({ @@ -70,62 +79,13 @@ const configSchema = schema.object({ schema.never() ), featureFlags: schema.object({ - agentConfigurationAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), - configurableIndicesAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), - infrastructureTabAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), - infraUiAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), - migrationToFleetAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), - sourcemapApiAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), - storageExplorerAvailable: schema.conditional( - schema.contextRef('serverless'), - true, - schema.boolean({ - defaultValue: false, - }), - schema.oneOf([schema.literal(true)], { defaultValue: true }) - ), + agentConfigurationAvailable: disabledOnServerless, + configurableIndicesAvailable: disabledOnServerless, + infrastructureTabAvailable: disabledOnServerless, + infraUiAvailable: disabledOnServerless, + migrationToFleetAvailable: disabledOnServerless, + sourcemapApiAvailable: disabledOnServerless, + storageExplorerAvailable: disabledOnServerless, }), });