Skip to content

Commit

Permalink
nest agent_config within apm-server in the package policy input
Browse files Browse the repository at this point in the history
  • Loading branch information
ogupte committed Jun 2, 2021
1 parent a25497e commit 6129f4f
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,31 @@ function registerAgentConfigExternalCallback({
fleetPluginStart.registerExternalCallback(callbackName, callbackFn);
}

const APM_SERVER = 'apm-server';

// Immutable function applies the given package policy with a set of agent configurations
export function getPackagePolicyWithAgentConfigurations(
packagePolicy: PackagePolicy,
agentConfigurations: AgentConfiguration[]
) {
const [firstInput, ...restInputs] = packagePolicy.inputs;
const apmServer = firstInput?.config?.[APM_SERVER];
return {
...packagePolicy,
inputs: [
{
...firstInput,
config: {
agent_config: {
value: agentConfigurations.map((configuration) => ({
service: configuration.service,
config: configuration.settings,
etag: configuration.etag,
[AGENT_NAME]: configuration.agent_name,
})),
[APM_SERVER]: {
...apmServer,
agent_config: {
value: agentConfigurations.map((configuration) => ({
service: configuration.service,
config: configuration.settings,
etag: configuration.etag,
[AGENT_NAME]: configuration.agent_name,
})),
},
},
},
},
Expand Down

0 comments on commit 6129f4f

Please sign in to comment.