in x-pack/platform/plugins/shared/fleet/server/services/preconfiguration/outputs.ts [282:386]
async function isPreconfiguredOutputDifferentFromCurrent(
existingOutput: Output,
preconfiguredOutput: Partial<Output>
): Promise<boolean> {
// ssl fields are common to all output types
const sslKeyHashIsDifferent = await isSecretDifferent(
preconfiguredOutput.secrets?.ssl?.key,
existingOutput.secrets?.ssl?.key
);
const kafkaFieldsAreDifferent = async (): Promise<boolean> => {
if (existingOutput.type !== 'kafka' || preconfiguredOutput.type !== 'kafka') {
return false;
}
const passwordHashIsDifferent = await isSecretDifferent(
preconfiguredOutput.secrets?.password,
existingOutput.secrets?.password
);
return (
isDifferent(existingOutput.client_id, preconfiguredOutput.client_id) ||
isDifferent(existingOutput.version, preconfiguredOutput.version) ||
isDifferent(existingOutput.key, preconfiguredOutput.key) ||
isDifferent(existingOutput.compression, preconfiguredOutput.compression) ||
isDifferent(existingOutput.compression_level, preconfiguredOutput.compression_level) ||
isDifferent(existingOutput.auth_type, preconfiguredOutput.auth_type) ||
isDifferent(existingOutput.connection_type, preconfiguredOutput.connection_type) ||
isDifferent(existingOutput.username, preconfiguredOutput.username) ||
isDifferent(existingOutput.password, preconfiguredOutput.password) ||
isDifferent(existingOutput.sasl, preconfiguredOutput.sasl) ||
isDifferent(existingOutput.partition, preconfiguredOutput.partition) ||
isDifferent(existingOutput.random, preconfiguredOutput.random) ||
isDifferent(existingOutput.round_robin, preconfiguredOutput.round_robin) ||
isDifferent(existingOutput.hash, preconfiguredOutput.hash) ||
isDifferent(existingOutput.topic, preconfiguredOutput.topic) ||
isDifferent(existingOutput.headers, preconfiguredOutput.headers) ||
isDifferent(existingOutput.timeout, preconfiguredOutput.timeout) ||
isDifferent(existingOutput.broker_timeout, preconfiguredOutput.broker_timeout) ||
isDifferent(existingOutput.required_acks, preconfiguredOutput.required_acks) ||
passwordHashIsDifferent
);
};
const logstashFieldsAreDifferent = async () => {
if (existingOutput.type !== 'logstash' || preconfiguredOutput.type !== 'logstash') {
return false;
}
};
const remoteESFieldsAreDifferent = async (): Promise<boolean> => {
if (
existingOutput.type !== 'remote_elasticsearch' ||
preconfiguredOutput.type !== 'remote_elasticsearch'
) {
return false;
}
const serviceTokenIsDifferent =
(await isSecretDifferent(
preconfiguredOutput.secrets?.service_token,
existingOutput.secrets?.service_token
)) ||
isDifferent(existingOutput.kibana_url, preconfiguredOutput.kibana_url) ||
isDifferent(existingOutput.sync_integrations, preconfiguredOutput.sync_integrations) ||
isDifferent(
existingOutput.sync_uninstalled_integrations,
preconfiguredOutput.sync_uninstalled_integrations
);
return serviceTokenIsDifferent;
};
return (
!existingOutput.is_preconfigured ||
isDifferent(existingOutput.is_default, preconfiguredOutput.is_default) ||
isDifferent(existingOutput.is_default_monitoring, preconfiguredOutput.is_default_monitoring) ||
isDifferent(existingOutput.name, preconfiguredOutput.name) ||
isDifferent(existingOutput.type, preconfiguredOutput.type) ||
(preconfiguredOutput.hosts &&
!isEqual(
existingOutput?.type === 'elasticsearch'
? existingOutput.hosts?.map(normalizeHostsForAgents)
: existingOutput.hosts,
preconfiguredOutput.type === 'elasticsearch'
? preconfiguredOutput.hosts.map(normalizeHostsForAgents)
: preconfiguredOutput.hosts
)) ||
isDifferent(preconfiguredOutput.ssl, existingOutput.ssl) ||
isDifferent(existingOutput.ca_sha256, preconfiguredOutput.ca_sha256) ||
isDifferent(
existingOutput.ca_trusted_fingerprint,
preconfiguredOutput.ca_trusted_fingerprint
) ||
isDifferent(existingOutput.config_yaml, preconfiguredOutput.config_yaml) ||
isDifferent(existingOutput.proxy_id, preconfiguredOutput.proxy_id) ||
isDifferent(existingOutput.allow_edit ?? [], preconfiguredOutput.allow_edit ?? []) ||
(preconfiguredOutput.preset &&
isDifferent(existingOutput.preset, preconfiguredOutput.preset)) ||
isDifferent(existingOutput.is_internal, preconfiguredOutput.is_internal) ||
sslKeyHashIsDifferent ||
(await kafkaFieldsAreDifferent()) ||
(await logstashFieldsAreDifferent()) ||
(await remoteESFieldsAreDifferent())
);
}