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

[Fleet] Fix fleet_server_hosts value in fleet/settings API #144898

Merged
merged 6 commits into from
Nov 10, 2022
Merged
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion x-pack/plugins/fleet/server/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { GLOBAL_SETTINGS_SAVED_OBJECT_TYPE, GLOBAL_SETTINGS_ID } from '../../com
import type { SettingsSOAttributes, Settings, BaseSettings } from '../../common/types';

import { appContextService } from './app_context';
import { listFleetServerHosts } from './fleet_server_host';

export async function getSettings(soClient: SavedObjectsClientContract): Promise<Settings> {
const res = await soClient.find<SettingsSOAttributes>({
Expand All @@ -23,10 +24,12 @@ export async function getSettings(soClient: SavedObjectsClientContract): Promise
throw Boom.notFound('Global settings not found');
}
const settingsSo = res.saved_objects[0];
const fleetServerHosts = await listFleetServerHosts(soClient);

return {
id: settingsSo.id,
...settingsSo.attributes,
fleet_server_hosts: settingsSo.attributes.fleet_server_hosts || [],
fleet_server_hosts: fleetServerHosts.items.flatMap((item) => item.host_urls),
preconfigured_fields: getConfigFleetServerHosts() ? ['fleet_server_hosts'] : [],
};
}
Expand Down