Skip to content

Commit

Permalink
New way to check if serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Nov 22, 2024
1 parent 06de7b8 commit 2aa31e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions x-pack/plugins/alerting/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@
"usageCollection",
"security",
"monitoringCollection",
"spaces",
"serverless"
"spaces"
],
"extraPublicDirs": [
"common",
"common/parse_duration"
]
}
}
}
18 changes: 9 additions & 9 deletions x-pack/plugins/alerting/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export interface AlertingPluginsSetup {
data: DataPluginSetup;
features: FeaturesPluginSetup;
unifiedSearch: UnifiedSearchServerPluginSetup;
serverless?: ServerlessPluginSetup;
}

export interface AlertingPluginsStart {
Expand All @@ -213,7 +212,6 @@ export interface AlertingPluginsStart {
data: DataPluginStart;
dataViews: DataViewsPluginStart;
share: SharePluginStart;
serverless?: ServerlessPluginSetup;
}

export class AlertingPlugin {
Expand All @@ -239,6 +237,7 @@ export class AlertingPlugin {
private pluginStop$: Subject<void>;
private dataStreamAdapter?: DataStreamAdapter;
private backfillClient?: BackfillClient;
private readonly isServerless: boolean;
private nodeRoles: PluginInitializerContext['node']['roles'];
private readonly connectorAdapterRegistry = new ConnectorAdapterRegistry();

Expand All @@ -256,6 +255,7 @@ export class AlertingPlugin {
this.kibanaVersion = initializerContext.env.packageInfo.version;
this.inMemoryMetrics = new InMemoryMetrics(initializerContext.logger.get('in_memory_metrics'));
this.pluginStop$ = new ReplaySubject(1);
this.isServerless = initializerContext.env.packageInfo.buildFlavor === 'serverless';
}

public setup(
Expand All @@ -268,7 +268,7 @@ export class AlertingPlugin {

const elasticsearchAndSOAvailability$ = getElasticsearchAndSOAvailability(core.status.core$);

const useDataStreamForAlerts = !!plugins.serverless;
const useDataStreamForAlerts = this.isServerless;
this.dataStreamAdapter = getDataStreamAdapter({ useDataStreamForAlerts });

core.capabilities.registerProvider(() => {
Expand All @@ -282,7 +282,7 @@ export class AlertingPlugin {
};
});

plugins.features.registerKibanaFeature(getRulesSettingsFeature(!!plugins.serverless));
plugins.features.registerKibanaFeature(getRulesSettingsFeature(this.isServerless));

plugins.features.registerKibanaFeature(maintenanceWindowFeature);

Expand Down Expand Up @@ -330,7 +330,7 @@ export class AlertingPlugin {
.getStartServices()
.then(([{ elasticsearch }]) => elasticsearch.client.asInternalUser),
elasticsearchAndSOAvailability$,
isServerless: !!plugins.serverless,
isServerless: this.isServerless,
});
}
}
Expand Down Expand Up @@ -411,7 +411,7 @@ export class AlertingPlugin {
getAlertIndicesAlias: createGetAlertIndicesAliasFn(this.ruleTypeRegistry!),
encryptedSavedObjects: plugins.encryptedSavedObjects,
config$: plugins.unifiedSearch.autocomplete.getInitializerContextConfig().create(),
isServerless: !!plugins.serverless,
isServerless: this.isServerless,
});

return {
Expand Down Expand Up @@ -562,7 +562,7 @@ export class AlertingPlugin {
logger: this.logger,
savedObjectsService: core.savedObjects,
securityService: core.security,
isServerless: !!plugins.serverless,
isServerless: this.isServerless,
});

maintenanceWindowClientFactory.initialize({
Expand Down Expand Up @@ -620,7 +620,7 @@ export class AlertingPlugin {
rulesSettingsService: new RulesSettingsService({
cacheInterval: this.config.rulesSettings.cacheInterval,
getRulesSettingsClientWithRequest,
isServerless: !!plugins.serverless,
isServerless: this.isServerless,
logger,
}),
savedObjects: core.savedObjects,
Expand All @@ -629,7 +629,7 @@ export class AlertingPlugin {
supportsEphemeralTasks: plugins.taskManager.supportsEphemeralTasks(),
uiSettings: core.uiSettings,
usageCounter: this.usageCounter,
isServerless: !!plugins.serverless,
isServerless: this.isServerless,
});

this.eventLogService!.registerSavedObjectProvider(RULE_SAVED_OBJECT_TYPE, (request) => {
Expand Down

0 comments on commit 2aa31e6

Please sign in to comment.