Skip to content

Commit

Permalink
fix: validation pathing
Browse files Browse the repository at this point in the history
* JSON schema validation was mistaking an install plan under a
  `/dashboards/` directory for an actual dashboard
* This adds a check for the quickstarts directory when evaluating
  related components
  • Loading branch information
aswanson-nr committed Feb 9, 2022
1 parent 67771c1 commit 0383b86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 6 additions & 6 deletions utils/__tests__/validate_quickstarts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jest.spyOn(global.console, 'error').mockImplementation(() => {});
const getTestFile = (schemaType) => {
const files = {
alert: {
path: '/alerts/',
path: '/quickstarts/testname/alerts/',
contents: [
{
name: 'fakealert',
Expand All @@ -23,7 +23,7 @@ const getTestFile = (schemaType) => {
],
},
dashboard: {
path: '/dashboards/',
path: '/quickstarts/testname/dashboards/',
contents: [
{
name: 'fakedashboard',
Expand All @@ -39,7 +39,7 @@ const getTestFile = (schemaType) => {
],
},
flex: {
path: '/instrumentation/flex/',
path: '/quickstarts/testname/instrumentation/flex/',
contents: [
{
name: 'fakeflexconfig',
Expand All @@ -50,23 +50,23 @@ const getTestFile = (schemaType) => {
],
},
synthetic: {
path: '/instrumentation/synthetics/',
path: '/quickstarts/testname/instrumentation/synthetics/',
contents: [
{
name: 'fakesynthetic',
},
],
},
main_config: {
path: '/main_config/', // this can be any path
path: '/quickstarts/testname/main_config/', // this can be any path
contents: [
{
title: 'Fake Quickstart',
name: 'fakequickstart',
description: 'fakeDescription',
authors: ['fakeAuthor'],
level: 'New Relic',
logo: 'logo.png'
logo: 'logo.png',
},
],
},
Expand Down
14 changes: 9 additions & 5 deletions utils/validate_quickstarts.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,26 @@ const validateFile = (file) => {

console.log(`Validating ${removeRepoPathPrefix(filePath)}`);
switch (true) {
case filePath.includes('/alerts/'): // validate using alert schema
case filePath.includes('/quickstarts/') && filePath.includes('/alerts/'): // validate using alert schema
errors = validateAgainstSchema(file.contents[0], alertSchema);
break;
case filePath.includes('/dashboards/'): // validate using dashboard schema
case filePath.includes('/quickstarts/') &&
filePath.includes('/dashboards/'): // validate using dashboard schema
errors = validateAgainstSchema(file.contents[0], dashboardSchema);
break;
case filePath.includes('/install/'): // validate using install schema
errors = validateAgainstSchema(file.contents[0], installSchema);
break;
case filePath.includes('/instrumentation/synthetics/'): // validate using synthetics schema
case filePath.includes('/quickstarts/') &&
filePath.includes('/instrumentation/synthetics/'): // validate using synthetics schema
errors = validateAgainstSchema(file.contents[0], syntheticSchema);
break;
case filePath.includes('/instrumentation/logging/'): // validate using logging schema
case filePath.includes('/quickstarts/') &&
filePath.includes('/instrumentation/logging/'): // validate using logging schema
errors = validateAgainstSchema(file.contents[0], loggingSchema);
break;
case filePath.includes('/instrumentation/flex/'): // validate using flex config schema.
case filePath.includes('/quickstarts/') &&
filePath.includes('/instrumentation/flex/'): // validate using flex config schema.
// The flex YAML is two documents, validate each of them
errors = [
...validateAgainstSchema(file.contents[0], flexConfigSchema),
Expand Down

0 comments on commit 0383b86

Please sign in to comment.