Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP. Strawman for doing setup in plugin#start #62709

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/plugins/endpoint/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"kibanaVersion": "kibana",
"configPath": ["xpack", "endpoint"],
"requiredPlugins": ["features", "embeddable", "data", "dataEnhanced"],
"requiredPlugins": ["features", "embeddable", "data", "dataEnhanced", "ingestManager"],
"server": true,
"ui": true
}
4 changes: 3 additions & 1 deletion x-pack/plugins/endpoint/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Plugin, CoreSetup, AppMountParameters, CoreStart } from 'kibana/public'
import { EmbeddableSetup } from 'src/plugins/embeddable/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { i18n } from '@kbn/i18n';
import { IngestManagerStart } from '../../ingest_manager/public';
import { ResolverEmbeddableFactory } from './embeddables/resolver';

export type EndpointPluginStart = void;
Expand All @@ -18,6 +19,7 @@ export interface EndpointPluginSetupDependencies {
}
export interface EndpointPluginStartDependencies {
data: DataPublicPluginStart;
ingestManager: IngestManagerStart;
}

/**
Expand Down Expand Up @@ -63,7 +65,7 @@ export class EndpointPlugin
);
}

public start() {}
public start(/* core: CoreStart, deps: EndpointPluginStartDependencies*/) {}

public stop() {}
}
2 changes: 2 additions & 0 deletions x-pack/plugins/ingest_manager/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import { PluginInitializerContext } from 'src/core/public';
import { IngestManagerPlugin } from './plugin';

export { IngestManagerSetup, IngestManagerStart } from './plugin';

export const plugin = (initializerContext: PluginInitializerContext) => {
return new IngestManagerPlugin(initializerContext);
};
10 changes: 8 additions & 2 deletions x-pack/plugins/ingest_manager/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import { IngestManagerConfigType } from '../common/types';
export { IngestManagerConfigType } from '../common/types';

export type IngestManagerSetup = void;
export type IngestManagerStart = void;
export interface IngestManagerStart {
isInitialized: boolean;
}

export interface IngestManagerSetupDeps {
licensing: LicensingPluginSetup;
Expand Down Expand Up @@ -61,7 +63,11 @@ export class IngestManagerPlugin
});
}

public start(core: CoreStart) {}
public async start(core: CoreStart): Promise<IngestManagerStart> {
const { isInitialized } = await core.http.post('/api/ingest_manager/setup');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious on how the app is going to react if this call throw an error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally. I will explicitly handle it and return false for now and we can talk more about other options (retry then, later, etc)


return { isInitialized };
}

public stop() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const createFleetSetupHandler: RequestHandler = async (context, request,
try {
const soClient = context.core.savedObjects.client;
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
await setupIngestManager(soClient, callCluster);
await setupFleet(soClient, callCluster);

return response.ok({
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ingest_manager/server/services/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export async function setupFleet(
],
},
});

const password = generateRandomPassword();
// Create fleet enroll user
await callCluster('transport.request', {
Expand Down