Skip to content

Commit

Permalink
feat(schema): add schema validation for install plans
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeveland27 committed Sep 8, 2021
1 parent 930a52a commit ffde666
Show file tree
Hide file tree
Showing 2 changed files with 358 additions and 0 deletions.
353 changes: 353 additions & 0 deletions utils/schemas/install_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,353 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "install_config.json",
"type": "object",
"title": "The root schema",
"description": "The root schema comprises the entire JSON document.",
"default": {},
"examples": [
{
"id": "infra-agent-standard",
"title": "Infrastructure Agent Install",
"description": "New Relic's infrastructure monitoring agent is a lightweight executable file that collects data about your hosts. It also forwards data from infrastructure integrations to New Relic, as well as log data for log analytics.",
"target": {
"type": "agent",
"destination": "host",
"os": [
"darwin",
"linux",
"windows"
],
"context": "markdown content"
},
"install": {
"mode": "targetedInstall",
"destination": {
"recipeName": "infrastructure-agent-installer",
"nerdletId": "setup-nerdlets.setup-python-integration",
"url": "https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/#install"
}
},
"fallback": {
"mode": "targetedInstall",
"destination": {
"recipeName": "infrastructure-agent-installer",
"nerdletId": "setup-nerdlets.setup-python-integration",
"url": "https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/#install"
}
}
}
],
"required": [
"id",
"target",
"install"
],
"properties": {
"id": {
"$id": "#/properties/id",
"type": "string",
"title": "The id schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"infra-agent-standard"
]
},
"title": {
"$id": "#/properties/title",
"type": "string",
"title": "The title schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"Infrastructure Agent Install"
]
},
"description": {
"$id": "#/properties/description",
"type": "string",
"title": "The description schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"New Relic's infrastructure monitoring agent is a lightweight executable file that collects data about your hosts. It also forwards data from infrastructure integrations to New Relic, as well as log data for log analytics."
]
},
"target": {
"$id": "#/properties/target",
"type": "object",
"title": "The target schema",
"description": "An explanation about the purpose of this instance.",
"default": {},
"examples": [
{
"type": "agent",
"destination": "host",
"os": [
"darwin",
"linux",
"windows"
],
"context": "markdown content"
}
],
"required": [
"type",
"destination"
],
"properties": {
"type": {
"$id": "#/properties/target/properties/type",
"type": "string",
"title": "The type schema",
"description": "An explanation about the purpose of this instance.",
"enum": [
"agent",
"integration",
"on-host-integration",
"pixie",
"unknown"
],
"default": "",
"examples": [
"agent"
]
},
"destination": {
"$id": "#/properties/target/properties/destination",
"type": "string",
"title": "The destination schema",
"description": "An explanation about the purpose of this instance.",
"enum": [
"application",
"cloud",
"host",
"kubernetes",
"unknown"
],
"default": "",
"examples": [
"host"
]
},
"os": {
"$id": "#/properties/target/properties/os",
"type": "array",
"title": "The os schema",
"description": "An explanation about the purpose of this instance.",
"default": [],
"examples": [
[
"darwin",
"linux"
]
],
"items": {
"$id": "#/properties/target/properties/os/items",
"anyOf": [
{
"$id": "#/properties/target/properties/os/items/anyOf/0",
"type": "string",
"title": "The first anyOf schema",
"description": "An explanation about the purpose of this instance.",
"enum": [
"darwin",
"linux",
"windows"
],
"default": "",
"examples": [
"darwin",
"linux"
]
}
]
}
},
"context": {
"$id": "#/properties/target/properties/context",
"type": "string",
"title": "The context schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"markdown content"
]
}
}
},
"install": {
"$id": "#/properties/install",
"type": "object",
"title": "The install schema",
"description": "An explanation about the purpose of this instance.",
"default": {},
"examples": [
{
"mode": "targetedInstall",
"destination": {
"recipeName": "infrastructure-agent-installer",
"nerdletId": "setup-nerdlets.setup-python-integration",
"url": "https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/#install"
}
}
],
"required": [
"mode",
"destination"
],
"properties": {
"mode": {
"$id": "#/properties/install/properties/mode",
"type": "string",
"title": "The mode schema",
"description": "An explanation about the purpose of this instance.",
"enum": [
"guidedInstall",
"targetedInstall",
"nerdlet",
"link"
],
"default": "",
"examples": [
"targetedInstall"
]
},
"destination": {
"$id": "#/properties/install/properties/destination",
"type": "object",
"title": "The destination schema",
"description": "An explanation about the purpose of this instance.",
"default": {},
"examples": [
{
"recipeName": "infrastructure-agent-installer",
"nerdletId": "setup-nerdlets.setup-python-integration",
"url": "https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/#install"
}
],
"required": [],
"properties": {
"recipeName": {
"$id": "#/properties/install/properties/destination/properties/recipeName",
"type": "string",
"title": "The recipeName schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"infrastructure-agent-installer"
]
},
"nerdletId": {
"$id": "#/properties/install/properties/destination/properties/nerdletId",
"type": "string",
"title": "The nerdletId schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"setup-nerdlets.setup-python-integration"
]
},
"url": {
"$id": "#/properties/install/properties/destination/properties/url",
"type": "string",
"title": "The url schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/#install"
]
}
}
}
}
},
"fallback": {
"$id": "#/properties/fallback",
"type": "object",
"title": "The fallback schema",
"description": "An explanation about the purpose of this instance.",
"default": {},
"examples": [
{
"mode": "targetedInstall",
"destination": {
"recipeName": "infrastructure-agent-installer",
"nerdletId": "setup-nerdlets.setup-python-integration",
"url": "https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/#install"
}
}
],
"required": [
"mode",
"destination"
],
"properties": {
"mode": {
"$id": "#/properties/fallback/properties/mode",
"type": "string",
"title": "The mode schema",
"description": "An explanation about the purpose of this instance.",
"enum": [
"guidedInstall",
"targetedInstall",
"nerdlet",
"link"
],
"default": "",
"examples": [
"targetedInstall"
]
},
"destination": {
"$id": "#/properties/fallback/properties/destination",
"type": "object",
"title": "The destination schema",
"description": "An explanation about the purpose of this instance.",
"default": {},
"examples": [
{
"recipeName": "infrastructure-agent-installer",
"nerdletId": "setup-nerdlets.setup-python-integration",
"url": "https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/#install"
}
],
"required": [],
"properties": {
"recipeName": {
"$id": "#/properties/fallback/properties/destination/properties/recipeName",
"type": "string",
"title": "The recipeName schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"infrastructure-agent-installer"
]
},
"nerdletId": {
"$id": "#/properties/fallback/properties/destination/properties/nerdletId",
"type": "string",
"title": "The nerdletId schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"setup-nerdlets.setup-python-integration"
]
},
"url": {
"$id": "#/properties/fallback/properties/destination/properties/url",
"type": "string",
"title": "The url schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install/#install"
]
}
}
}
}
}
}
}
5 changes: 5 additions & 0 deletions utils/validate_packs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const alertSchema = require('./schemas/alert_config.json');
const dashboardSchema = require('./schemas/dashboard_config.json');
const flexConfigSchema = require('./schemas/flex_config.json');
const flexIntegrationsSchema = require('./schemas/flex_integrations.json');
const installSchema = require('./schemas/install_config.json');
const syntheticSchema = require('./schemas/synthetic_config.json');
const loggingSchema = require('./schemas/logging_config.json');

Expand Down Expand Up @@ -82,6 +83,9 @@ const validateFile = (file) => {
case 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
errors = validateAgainstSchema(file.contents[0], syntheticSchema);
break;
Expand Down Expand Up @@ -117,6 +121,7 @@ const getPackFilePaths = (basePath) => {
const yamlFilePaths = [
...glob.sync(path.resolve(basePath, '../packs/**/*.yaml'), options),
...glob.sync(path.resolve(basePath, '../packs/**/*.yml'), options),
...glob.sync(path.resolve(basePath, '../install/**/*.yml'), options),
];

const jsonFilePaths = glob.sync(
Expand Down

0 comments on commit ffde666

Please sign in to comment.