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

Don't use filter to get default config & output #69088

Merged
merged 4 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ class AgentConfigService {
public async getDefaultAgentConfigId(soClient: SavedObjectsClientContract) {
const configs = await soClient.find({
type: AGENT_CONFIG_SAVED_OBJECT_TYPE,
filter: `${AGENT_CONFIG_SAVED_OBJECT_TYPE}.attributes.is_default:true`,
searchFields: ['is_default'],
search: 'true',
});

if (configs.saved_objects.length === 0) {
Expand Down
16 changes: 9 additions & 7 deletions x-pack/plugins/ingest_manager/server/services/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ const SAVED_OBJECT_TYPE = OUTPUT_SAVED_OBJECT_TYPE;
let cachedAdminUser: null | { username: string; password: string } = null;

class OutputService {
public async ensureDefaultOutput(soClient: SavedObjectsClientContract) {
const outputs = await soClient.find<Output>({
public async getDefaultOutput(soClient: SavedObjectsClientContract) {
return await soClient.find<Output>({
type: OUTPUT_SAVED_OBJECT_TYPE,
filter: `${OUTPUT_SAVED_OBJECT_TYPE}.attributes.is_default:true`,
searchFields: ['is_default'],
search: 'true',
});
}

public async ensureDefaultOutput(soClient: SavedObjectsClientContract) {
const outputs = await this.getDefaultOutput(soClient);
const cloud = appContextService.getCloud();
const cloudId = cloud?.isCloudEnabled && cloud.cloudId;
const cloudUrl = cloudId && decodeCloudId(cloudId)?.elasticsearchUrl;
Expand Down Expand Up @@ -50,10 +55,7 @@ class OutputService {
}

public async getDefaultOutputId(soClient: SavedObjectsClientContract) {
const outputs = await soClient.find({
type: OUTPUT_SAVED_OBJECT_TYPE,
filter: `${OUTPUT_SAVED_OBJECT_TYPE}.attributes.is_default:true`,
});
const outputs = await this.getDefaultOutput(soClient);

if (!outputs.saved_objects.length) {
return null;
Expand Down