mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
(cherry picked from commit e794156efb
)
Co-authored-by: Josh Dover <1813008+joshdover@users.noreply.github.com>
This commit is contained in:
parent
a946a4e331
commit
0fbe4e065b
3 changed files with 25 additions and 10 deletions
|
@ -95,10 +95,13 @@ export interface Agent extends AgentBase {
|
|||
access_api_key?: string;
|
||||
// @deprecated
|
||||
default_api_key_history?: FleetServerAgent['default_api_key_history'];
|
||||
outputs?: Array<{
|
||||
api_key_id: string;
|
||||
to_retire_api_key_ids?: FleetServerAgent['default_api_key_history'];
|
||||
}>;
|
||||
outputs?: Record<
|
||||
string,
|
||||
{
|
||||
api_key_id: string;
|
||||
to_retire_api_key_ids?: FleetServerAgent['default_api_key_history'];
|
||||
}
|
||||
>;
|
||||
status?: AgentStatus;
|
||||
packages: string[];
|
||||
sort?: Array<number | string | null>;
|
||||
|
|
|
@ -331,15 +331,22 @@ describe('invalidateAPIKeysForAgents', () => {
|
|||
id: 'defaultApiKeyHistory2',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
outputs: {
|
||||
output1: {
|
||||
api_key_id: 'outputApiKey1',
|
||||
to_retire_api_key_ids: [{ id: 'outputApiKeyRetire1' }, { id: 'outputApiKeyRetire2' }],
|
||||
},
|
||||
{
|
||||
output2: {
|
||||
api_key_id: 'outputApiKey2',
|
||||
},
|
||||
],
|
||||
output3: {
|
||||
api_key_id: 'outputApiKey3',
|
||||
to_retire_api_key_ids: [
|
||||
// Somes Fleet Server agents don't have an id here (probably a bug)
|
||||
{ retired_at: 'foo' },
|
||||
],
|
||||
},
|
||||
},
|
||||
} as any,
|
||||
]);
|
||||
|
||||
|
@ -353,6 +360,7 @@ describe('invalidateAPIKeysForAgents', () => {
|
|||
'outputApiKeyRetire1',
|
||||
'outputApiKeyRetire2',
|
||||
'outputApiKey2',
|
||||
'outputApiKey3',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -216,12 +216,16 @@ export async function invalidateAPIKeysForAgents(agents: Agent[]) {
|
|||
agent.default_api_key_history.forEach((apiKey) => keys.push(apiKey.id));
|
||||
}
|
||||
if (agent.outputs) {
|
||||
agent.outputs.forEach((output) => {
|
||||
Object.values(agent.outputs).forEach((output) => {
|
||||
if (output.api_key_id) {
|
||||
keys.push(output.api_key_id);
|
||||
}
|
||||
if (output.to_retire_api_key_ids) {
|
||||
output.to_retire_api_key_ids.forEach((apiKey) => keys.push(apiKey.id));
|
||||
Object.values(output.to_retire_api_key_ids).forEach((apiKey) => {
|
||||
if (apiKey?.id) {
|
||||
keys.push(apiKey.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue