[serverless] Add ability to disable certain plugins for Serverless. (#155583)

> Derived from https://github.com/elastic/kibana/pull/153274

## Summary

This PR extracts configuration settings for enabling/disabling plugins
in Serverless projects based on current requirements.

It seemed prudent to create an independent PR to K.I.S.S, rather than
include in PRs with more ornate changes, (e.g.
https://github.com/elastic/kibana/pull/155582)
This commit is contained in:
Clint Andrew Hall 2023-04-26 13:44:31 -04:00 committed by GitHub
parent f6b010c45f
commit 6690c445e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 87 additions and 8 deletions

View file

@ -1,2 +1,17 @@
newsfeed.enabled: false
xpack.fleet.enableExperimental: ['fleetServerStandalone']
xpack.fleet.internal.disableILMPolicies: true
# Management team plugins
xpack.upgrade_assistant.enabled: false
xpack.rollup.enabled: false
xpack.watcher.enabled: false
xpack.ccr.enabled: false
xpack.ilm.enabled: false
xpack.remote_clusters.enabled: false
xpack.snapshot_restore.enabled: false
xpack.license_management.enabled: false
# Other disabled plugins
xpack.canvas.enabled: false
xpack.reporting.enabled: false

View file

@ -56,6 +56,7 @@ const configSchema = schema.object({
latestAgentVersionsUrl: schema.string({
defaultValue: 'https://apm-agent-versions.elastic.co/versions.json',
}),
enabled: schema.boolean({ defaultValue: true }),
});
// plugin config

View file

@ -22,6 +22,11 @@ const schemaLatest = schema.object(
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
/**
* Disables the plugin.
* Added back in 8.8.
*/
enabled: schema.boolean({ defaultValue: true }),
},
{ defaultValue: undefined }
);

View file

@ -24,13 +24,13 @@ export const mockKibanaValues = {
),
} as unknown as ApplicationStart,
capabilities: {} as Capabilities,
config: { host: 'http://localhost:3002' },
charts: chartPluginMock.createStartContract(),
cloud: {
...cloudMock.createSetup(),
isCloudEnabled: false,
deployment_url: 'https://cloud.elastic.co/deployments/some-id',
isCloudEnabled: false,
},
config: { host: 'http://localhost:3002' },
data: dataPluginMock.createStartContract(),
guidedOnboarding: {},
history: mockHistory,
@ -50,12 +50,12 @@ export const mockKibanaValues = {
hasNativeConnectors: true,
hasWebCrawler: true,
},
uiSettings: uiSettingsServiceMock.createStartContract(),
renderHeaderActions: jest.fn(),
security: securityMock.createStart(),
setBreadcrumbs: jest.fn(),
setChromeIsVisible: jest.fn(),
setDocTitle: jest.fn(),
renderHeaderActions: jest.fn(),
uiSettings: uiSettingsServiceMock.createStartContract(),
};
jest.mock('../../shared/kibana', () => ({

View file

@ -67,9 +67,9 @@ export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
reducers: ({ props }) => ({
application: [props.application || {}, {}],
capabilities: [props.capabilities || {}, {}],
config: [props.config || {}, {}],
charts: [props.charts, {}],
cloud: [props.cloud || {}, {}],
config: [props.config || {}, {}],
data: [props.data, {}],
guidedOnboarding: [props.guidedOnboarding, {}],
history: [props.history, {}],

View file

@ -19,6 +19,7 @@ export const configSchema = schema.object({
accessCheckTimeoutWarning: schema.number({ defaultValue: 300 }),
canDeployEntSearch: schema.boolean({ defaultValue: true }),
customHeaders: schema.maybe(schema.object({}, { unknowns: 'allow' })),
enabled: schema.boolean({ defaultValue: true }),
hasConnectors: schema.boolean({ defaultValue: true }),
hasDefaultIngestPipeline: schema.boolean({ defaultValue: true }),
hasNativeConnectors: schema.boolean({ defaultValue: true }),

View file

@ -107,7 +107,7 @@ export function calculatePackagePrivilegesFromCapabilities(
return {
...acc,
[privilege]: {
executePackageAction: capabilities.siem[privilegeName] || false,
executePackageAction: (capabilities.siem && capabilities.siem[privilegeName]) || false,
},
};
},

View file

@ -166,6 +166,7 @@ export const config: PluginConfigDescriptor = {
}),
})
),
enabled: schema.boolean({ defaultValue: true }),
}),
};

View file

@ -24,6 +24,11 @@ const schemaLatest = schema.object(
}),
// Cloud requires the ability to hide internal node attributes from users.
filteredNodeAttributes: schema.arrayOf(schema.string(), { defaultValue: [] }),
/**
* Disables the plugin.
* Added back in 8.8.
*/
enabled: schema.boolean({ defaultValue: true }),
},
{ defaultValue: undefined }
);

View file

@ -22,6 +22,11 @@ const schemaLatest = schema.object(
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
/**
* Disables the plugin.
* Added back in 8.8.
*/
enabled: schema.boolean({ defaultValue: true }),
},
{ defaultValue: undefined }
);

View file

@ -41,6 +41,7 @@ const configSchema = schema.object({
}),
}),
}),
enabled: schema.boolean({ defaultValue: true }),
});
export const config: PluginConfigDescriptor = {

View file

@ -22,6 +22,11 @@ const schemaLatest = schema.object(
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
/**
* Disables the plugin.
* Added back in 8.8.
*/
enabled: schema.boolean({ defaultValue: true }),
},
{ defaultValue: undefined }
);

View file

@ -22,6 +22,11 @@ const schemaLatest = schema.object(
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
/**
* Disables the plugin.
* Added back in 8.8.
*/
enabled: schema.boolean({ defaultValue: true }),
},
{ defaultValue: undefined }
);

View file

@ -31,6 +31,7 @@ export const createMockConfig = (): ConfigType => {
alertIgnoreFields: [],
experimentalFeatures: parseExperimentalConfigValue(enableExperimental),
enabled: true,
};
};

View file

@ -122,6 +122,7 @@ export const configSchema = schema.object({
* the package is not already installed.
*/
prebuiltRulesPackageVersion: schema.maybe(schema.string()),
enabled: schema.boolean({ defaultValue: true }),
});
export type ConfigSchema = TypeOf<typeof configSchema>;

View file

@ -25,6 +25,11 @@ const schemaLatest = schema.object(
slm_ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
/**
* Disables the plugin.
* Added back in 8.8.
*/
enabled: schema.boolean({ defaultValue: true }),
},
{ defaultValue: undefined }
);

View file

@ -23,6 +23,7 @@ const serviceConfig = schema.object({
const uptimeConfig = schema.object({
index: schema.maybe(schema.string()),
service: schema.maybe(serviceConfig),
enabled: schema.boolean({ defaultValue: true }),
});
export const config: PluginConfigDescriptor = {

View file

@ -12,6 +12,8 @@
"actions",
"alerting",
"cases",
"data",
"fleet",
"embeddable",
"discover",
"dataViews",
@ -44,4 +46,4 @@
"indexLifecycleManagement"
]
}
}
}

View file

@ -50,6 +50,7 @@ describe('getServiceLocations', function () {
manifestUrl: 'http://local.dev',
showExperimentalLocations: false,
},
enabled: true,
},
// @ts-ignore
logger: {
@ -101,6 +102,7 @@ describe('getServiceLocations', function () {
manifestUrl: 'http://local.dev',
showExperimentalLocations: false,
},
enabled: true,
},
// @ts-ignore
logger: {
@ -138,6 +140,7 @@ describe('getServiceLocations', function () {
manifestUrl: 'http://local.dev',
showExperimentalLocations: true,
},
enabled: true,
},
// @ts-ignore
logger: {

View file

@ -80,6 +80,7 @@ describe('SyntheticsService', () => {
password: '12345',
manifestUrl: 'http://localhost:8080/api/manifest',
},
enabled: true,
},
coreStart: mockCoreStart,
encryptedSavedObjects: mockEncryptedSO(),
@ -101,7 +102,11 @@ describe('SyntheticsService', () => {
};
});
serverMock.config = {
service: { devUrl: 'http://localhost', manifestUrl: 'https://test-manifest.com' },
service: {
devUrl: 'http://localhost',
manifestUrl: 'https://test-manifest.com',
},
enabled: true,
};
if (serverMock.savedObjectsClient) {
serverMock.savedObjectsClient.find = jest.fn().mockResolvedValue({
@ -165,6 +170,7 @@ describe('SyntheticsService', () => {
username: 'dev',
password: '12345',
},
enabled: true,
};
const service = new SyntheticsService(serverMock);

View file

@ -12,6 +12,11 @@ import { PluginConfigDescriptor } from '@kbn/core/server';
// even for minor releases.
// -------------------------------
const configSchema = schema.object({
/**
* Disables the plugin.
*/
enabled: schema.boolean({ defaultValue: true }),
featureSet: schema.object({
/**
* Ml Snapshot should only be enabled for major version upgrades. Currently this
@ -39,6 +44,9 @@ const configSchema = schema.object({
*/
reindexCorrectiveActions: schema.boolean({ defaultValue: false }),
}),
/**
* This config allows to hide the UI without disabling the plugin.
*/
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),

View file

@ -6,6 +6,14 @@
*/
import { PluginInitializerContext } from '@kbn/core/server';
import { schema } from '@kbn/config-schema';
import { WatcherServerPlugin } from './plugin';
export const plugin = (ctx: PluginInitializerContext) => new WatcherServerPlugin(ctx);
export const config = {
schema: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
};