[7.x] [Telemetry] schema check throw on missing schema (#75750) (#75767)

* [Telemetry] schema check throw on missing schema (#75750)

* update schema for 7.x
This commit is contained in:
Ahmad Bamieh 2020-08-24 21:22:36 +03:00 committed by GitHub
parent 512280336a
commit de32e9f8f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View file

@ -65,7 +65,8 @@ export function runTelemetryCheck() {
},
{
title: 'Checking Matching collector.schema against stored json files',
task: (context) => new Listr(checkMatchingSchemasTask(context), { exitOnError: true }),
task: (context) =>
new Listr(checkMatchingSchemasTask(context, !fix), { exitOnError: true }),
},
{
enabled: (_) => fix,

View file

@ -22,7 +22,7 @@ import { TaskContext } from './task_context';
import { checkMatchingMapping } from '../check_collector_integrity';
import { readFileAsync } from '../utils';
export function checkMatchingSchemasTask({ roots }: TaskContext) {
export function checkMatchingSchemasTask({ roots }: TaskContext, throwOnDiff: boolean) {
return roots.map((root) => ({
task: async () => {
const fullPath = path.resolve(process.cwd(), root.config.output);
@ -31,8 +31,16 @@ export function checkMatchingSchemasTask({ roots }: TaskContext) {
if (root.parsedCollections) {
const differences = checkMatchingMapping(root.parsedCollections, esMapping);
root.esMappingDiffs = Object.keys(differences);
if (root.esMappingDiffs.length && throwOnDiff) {
throw Error(
`The following changes must be persisted in ${fullPath} file. Use '--fix' to update.\n${JSON.stringify(
differences,
null,
2
)}`
);
}
}
},
title: `Checking in ${root.config.root}`,

View file

@ -48,6 +48,19 @@
}
}
},
"csp": {
"properties": {
"strict": {
"type": "boolean"
},
"warnLegacyBrowsers": {
"type": "boolean"
},
"rulesChangedFromDefault": {
"type": "boolean"
}
}
},
"telemetry": {
"properties": {
"opt_in_status": {