Skip to content

Commit

Permalink
[7.x] [Telemetry] schema check throw on missing schema (elastic#75750) (
Browse files Browse the repository at this point in the history
elastic#75767)

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

* update schema for 7.x
  • Loading branch information
Bamieh authored Aug 24, 2020
1 parent 5122803 commit de32e9f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/kbn-telemetry-tools/src/cli/run_telemetry_check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}`,
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@
}
}
},
"csp": {
"properties": {
"strict": {
"type": "boolean"
},
"warnLegacyBrowsers": {
"type": "boolean"
},
"rulesChangedFromDefault": {
"type": "boolean"
}
}
},
"telemetry": {
"properties": {
"opt_in_status": {
Expand Down

0 comments on commit de32e9f

Please sign in to comment.