forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In case of kubernetes integartion detected return manifest in standal…
…one agent layout instead of policy (elastic#114439) * In case of kubernetes integartion detected return manifest in standalone agent layout instead of policy
- Loading branch information
1 parent
8a643cc
commit 5cb33c2
Showing
11 changed files
with
568 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { safeDump } from 'js-yaml'; | ||
|
||
import type { FullAgentConfigMap } from '../types/models/agent_cm'; | ||
|
||
const CM_KEYS_ORDER = ['apiVersion', 'kind', 'metadata', 'data']; | ||
|
||
export const fullAgentConfigMapToYaml = ( | ||
policy: FullAgentConfigMap, | ||
toYaml: typeof safeDump | ||
): string => { | ||
return toYaml(policy, { | ||
skipInvalid: true, | ||
sortKeys: (keyA: string, keyB: string) => { | ||
const indexA = CM_KEYS_ORDER.indexOf(keyA); | ||
const indexB = CM_KEYS_ORDER.indexOf(keyB); | ||
if (indexA >= 0 && indexB < 0) { | ||
return -1; | ||
} | ||
|
||
if (indexA < 0 && indexB >= 0) { | ||
return 1; | ||
} | ||
|
||
return indexA - indexB; | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { FullAgentPolicy } from './agent_policy'; | ||
|
||
export interface FullAgentConfigMap { | ||
apiVersion: string; | ||
kind: string; | ||
metadata: Metadata; | ||
data: AgentYML; | ||
} | ||
|
||
interface Metadata { | ||
name: string; | ||
namespace: string; | ||
labels: Labels; | ||
} | ||
|
||
interface Labels { | ||
'k8s-app': string; | ||
} | ||
|
||
interface AgentYML { | ||
'agent.yml': FullAgentPolicy; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.