Skip to content

Commit

Permalink
Schema 2.1 update (#41)
Browse files Browse the repository at this point in the history
* Checkpoint.

- Reconciling the schemas
- Determining my path toward compatibility shifts

I need to be able to use another machine for this as well, so I'll be committing incomplete changes.

* Create devcontainer.json

Signed-off-by: Michael D. Stemle, Jr. <mike.stemle@washpost.com>

* Checkin
- Started work on versioning.
- Trying to get the Codespaces workflow going

* Update devcontainer.json

Signed-off-by: Michael D. Stemle, Jr. <mike.stemle@washpost.com>

* Container checkin.

* Checkpoint.

* Got a bunch of field mappings done.

* Got integrations and application in.
- Also added some safeties

* Primary fields are in the mapping now
- Got the fields in
- Got the tests working
- Time to add convenience fields

* Some convenience mappings added.

* Tidying up some internal constants.

* Mappings with versions are working now!
- Org rule files are broken still
- Documentation still needs to be updated

* Tests are passing!
- Still need to work on org-rules file functionality
- Still need to update documentation

* Massive documentation updates.
- Added info about schema versions
- Added examples showing the differences in schema versions
- Still need to think about org rules file more

* I think org rules files are done!

* Version bump and docs.

* Fixing versions in docs.

---------

Signed-off-by: Michael D. Stemle, Jr. <mike.stemle@washpost.com>
  • Loading branch information
manchicken committed Jun 29, 2023
1 parent f0ab64e commit 3ad03a5
Show file tree
Hide file tree
Showing 26 changed files with 5,710 additions and 1,624 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"image": "mcr.microsoft.com/devcontainers/typescript-node:20-buster",
"features": {
"ghcr.io/devcontainers-contrib/features/prettier:1": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/jest:2": { "version": "latest" }
},
"customizations": {
"vscode": {
"extensions": ["Orta.vscode-jest", "esbenp.prettier-vscode"]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
tags
node_modules/*
coverage
.nova
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog],
and this project adheres to [Semantic Versioning].

## [2.0.0] - 2023-06-29

### Added

- Support for the Datadog Service Catalog v2.1 schema version.

### Changed

- Version updates to dependencies.
- Corrected a bunch of documentation problems.

## [1.1.2] - 2023-03-16

### Fixed
Expand Down
401 changes: 315 additions & 86 deletions README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions __mocks__/@actions/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ const core = require('@actions/core')
let inputs = {}
core.__setInputsObject = (obj) => (inputs = obj)
core.__resetInputsObject = () => (inputs = {})
core.__dumpInputsObject = () => console.debug({ CORE_INPUTS: inputs })

core.getInput = jest.fn().mockImplementation((name) => {
return inputs[name]
})

core.setFailed = jest.fn()

module.exports = core
212 changes: 212 additions & 0 deletions __tests__/data/datadog-service-catalog-schema-v2.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://github.com/DataDog/schema/tree/main/service-catalog/v2.1/schema.json",
"title": "Service Definition Schema v2.1",
"description": "A service definition for providing additional service metadata and integrations v2.1",
"type": "object",
"properties": {
"schema-version": {
"description": "Schema version being used",
"examples": ["v2.1"],
"type": "string",
"default": "v2.1",
"enum": ["v2.1"]
},
"dd-service": {
"description": "Unique identifier of the service. Must be unique across all services, and is used to match with a service in Datadog",
"examples": ["my-service"],
"type": "string"
},
"team": {
"description": "Team that owns the service. It is used to locate a team defined in Datadog Teams if it exists",
"examples": ["my-team"],
"type": "string"
},
"application": {
"description": "Identifier for a group of related services serving a product feature, which the service is a part of",
"examples": ["my-app"],
"type": "string"
},
"description": {
"description": "A short description of the service",
"examples": ["My app description"],
"type": "string"
},
"tier": {
"description": "Importance of the service",
"examples": ["1", "High"],
"type": "string"
},
"lifecycle": {
"description": "The current life cycle phase of the service.",
"examples": ["sandbox", "staging", "production", "deprecated"],
"type": "string"
},
"contacts": {
"description": "A list of contacts related to the services. ",
"type": "array",
"items": {
"$ref": "#/$defs/contact"
}
},
"links": {
"description": "A list of links related to the services. ",
"type": "array",
"items": {
"$ref": "#/$defs/link"
}
},
"tags": {
"description": "A set of custom tags",
"examples": [["my:tag"]],
"type": "array",
"items": {
"type": "string"
}
},
"integrations": {
"description": "Third party integrations that Datadog supports",
"type": "object",
"properties": {
"pagerduty": {
"description": "Pagerduty integration for the service",
"type": "object",
"properties": {
"service-url": {
"description": "Pagerduty Service URL",
"examples": [
"https://my-org.pagerduty.com/service-directory/PMyService"
],
"type": "string",
"pattern": "^(https?://)?[a-zA-Z\\d_\\-.]+\\.pagerduty\\.com/service-directory/(P[a-zA-Z\\d_\\-]+)/?$"
}
},
"required": ["service-url"],
"additionalProperties": false
},
"opsgenie": {
"description": "Opsgenie integration for the service",
"type": "object",
"properties": {
"service-url": {
"description": "Opsgenie Service URL",
"examples": [
"https://www.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"
],
"type": "string",
"pattern": "^(https?://)?[a-zA-Z\\d_\\-.]+\\.opsgenie\\.com/service/([a-zA-Z\\d_\\-]+)/?$"
},
"region": {
"description": "Opsgenie Instance Region",
"type": "string",
"examples": ["US", "EU"],
"enum": ["US", "EU"]
}
},
"required": ["service-url"],
"additionalProperties": false
}
},
"additionalProperties": false
},
"extensions": {
"description": "Custom extensions",
"type": "object",
"additionalProperties": true
}
},
"additionalProperties": false,
"required": ["schema-version", "dd-service"],
"$defs": {
"link": {
"additionalProperties": false,
"type": "object",
"properties": {
"name": {
"description": "Link name",
"examples": ["Runbook", "Dashboard"],
"type": "string"
},
"type": {
"description": "Link type",
"examples": ["runbook", "doc"],
"type": "string",
"enum": ["doc", "runbook", "repo", "dashboard", "other"]
},
"url": {
"description": "Link url",
"examples": ["https://my-runbook"],
"type": "string",
"format": "uri"
},
"provider": {
"description": "Link provider",
"examples": ["Github", "Confluence"],
"type": "string"
}
},
"required": ["name", "type", "url"]
},
"contact": {
"additionalProperties": false,
"type": "object",
"properties": {
"name": {
"description": "Contact name",
"examples": ["Oncall Slack", "Team Email"],
"type": "string",
"minLength": 2
},
"type": {
"description": "Contact type",
"examples": ["email", "slack", "microsoft-teams"],
"type": "string",
"enum": ["email", "slack", "microsoft-teams"]
},
"contact": {
"description": "Contact value",
"examples": [
"contact@datadoghq.com",
"https://my-org.slack.com/archives/my-channel"
],
"type": "string"
}
},
"allOf": [
{
"if": {
"properties": {
"type": {
"const": "email"
}
}
},
"then": {
"properties": {
"contact": {
"format": "email"
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "slack"
}
}
},
"then": {
"properties": {
"contact": {
"pattern": "https://[a-zA-Z0-9_\\-]+.slack\\.com/archives/[a-zA-Z0-9_\\-]+"
}
}
}
}
],
"required": ["type", "contact"]
}
}
}
87 changes: 87 additions & 0 deletions __tests__/lib/__snapshots__/fieldMappings-schema.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`constants convenienceFields 1`] = `
[
"email",
"slack",
"repo",
"opsgenie",
"pagerduty",
"slack-support-channel",
]
`;

exports[`constants mappings 1`] = `
{
"application": {
"v2": [Function],
"v2.1": [Function],
},
"contacts": {
"v2": [Function],
"v2.1": [Function],
},
"description": {
"v2": [Function],
"v2.1": [Function],
},
"docs": {
"v2": [Function],
"v2.1": [Function],
},
"integrations": {
"v2": [Function],
"v2.1": [Function],
},
"lifecycle": {
"v2": [Function],
"v2.1": [Function],
},
"links": {
"v2": [Function],
"v2.1": [Function],
},
"repos": {
"v2": [Function],
"v2.1": [Function],
},
"schema-version": {
"v2": [Function],
"v2.1": [Function],
},
"service-name": {
"v2": [Function],
"v2.1": [Function],
},
"tags": {
"v2": [Function],
"v2.1": [Function],
},
"team": {
"v2": [Function],
"v2.1": [Function],
},
"tier": {
"v2": [Function],
"v2.1": [Function],
},
}
`;

exports[`constants schemaFields 1`] = `
[
"schema-version",
"service-name",
"team",
"contacts",
"tags",
"links",
"integrations",
"docs",
"repos",
"application",
"description",
"tier",
"lifecycle",
]
`;
Loading

0 comments on commit 3ad03a5

Please sign in to comment.