Skip to content

Commit

Permalink
feat(logs): adjust implementation to unuse legacy config
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Antonio Ghiani committed Nov 27, 2024
1 parent 2457615 commit ed4c923
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export const configSchema = schema.object({

export const config: PluginConfigDescriptor<LogsSharedConfig> = {
schema: configSchema,
deprecations: ({ unused }) => [unused('savedObjects.logView.enabled', { level: 'warning' })],
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export interface LogsSharedBackendLibs extends LogsSharedDomainLibs {
getStartServices: LogsSharedPluginStartServicesAccessor;
getUsageCollector: () => UsageCollector;
logger: Logger;
isServerless: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class LogsSharedPlugin
private logViews: LogViewsService;
private usageCollector: UsageCollector;

constructor(context: PluginInitializerContext<LogsSharedConfig>) {
constructor(private readonly context: PluginInitializerContext<LogsSharedConfig>) {
this.config = context.config.get();
this.logger = context.logger.get();
this.usageCollector = {};
Expand All @@ -51,11 +51,13 @@ export class LogsSharedPlugin
}

public setup(core: LogsSharedPluginCoreSetup, plugins: LogsSharedServerPluginSetupDeps) {
const isServerless = this.context.env.packageInfo.buildFlavor === 'serverless';

const framework = new KibanaFramework(core, plugins);

const logViews = this.logViews.setup();

if (this.config.savedObjects.logView.enabled) {
if (!isServerless) {
// Conditionally register log view saved objects
core.savedObjects.registerType(logViewSavedObjectType);
} else {
Expand All @@ -78,6 +80,7 @@ export class LogsSharedPlugin
getStartServices: () => core.getStartServices(),
getUsageCollector: () => this.usageCollector,
logger: this.logger,
isServerless,
};

// Register server side APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const initGetLogViewRoute = ({
config,
framework,
getStartServices,
isServerless,
}: LogsSharedBackendLibs) => {
framework
.registerVersionedRoute({
Expand Down Expand Up @@ -41,7 +42,7 @@ export const initGetLogViewRoute = ({
* - if the log view saved object is correctly registered, perform a lookup for retrieving it
* - else, skip the saved object lookup and immediately get the internal log view if exists.
*/
const logView = config.savedObjects.logView.enabled
const logView = !isServerless
? await logViewsClient.getLogView(logViewId)
: await logViewsClient.getInternalLogView(logViewId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const initLogViewRoutes = (libs: LogsSharedBackendLibs) => {
initGetLogViewRoute(libs);

// Register the log view update endpoint only when the Saved object is correctly registered
if (libs.config.savedObjects.logView.enabled) {
if (!libs.isServerless) {
initPutLogViewRoute(libs);
}
};

0 comments on commit ed4c923

Please sign in to comment.