Skip to content

Commit

Permalink
Checkpoint.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
manchicken committed Jun 16, 2023
1 parent f0ab64e commit f9c130f
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 4 deletions.
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
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"]
}
}
}
6 changes: 3 additions & 3 deletions __tests__/lib/input-to-registry-document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const YAML = require('yaml')
const core = require('@actions/core')

const Ajv = require('ajv')
const ddSchema = require('../data/datadog-service-catalog-schema.json')
const ddSchema_v2 = require('../data/datadog-service-catalog-schema-v2.json')
const validate = new Ajv({ strict: false, validateFormats: false }).compile(
ddSchema,
ddSchema_v2,
)

const {
Expand All @@ -27,7 +27,7 @@ tags: |
- env:prod
- infrastructure:serverless
- language:nodejs
- other : value
- other : value
repos: |
- url: https://github.com/actions/toolkit
provider: Github
Expand Down
20 changes: 19 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ runs:
using: node16
main: dist/index.js
inputs:


github-token:
description: 'The GitHub token to use for the action; default is `secrets.GITHUB_TOKEN`'
required: false
Expand All @@ -25,12 +27,28 @@ inputs:
datadog-app-key:
description: 'The Datadog Application key'
required: true
schema-version:
description: 'The version of the Datadog Service Catalog Schema. The default is v2. Valid values are `v2` and `v2.1`.'
required: false
default: 'v2'
service-name:
description: 'The name of the service'
required: true
team:
description: 'The team responsible for the service'
required: true
application:
description: '(v2.1 only) The name of the application that the service belongs to.'
required: false
description:
description: '(v2.1 only) A description of the service.'
required: false
tier:
description: '(v2.1 only) A representation of how important this service is. You can use any string that conveys meaning for you or your organization.'
required: false
lifecycle:
description: '(v2.1 only) The current life cycle phase of the service. For example: sandbox, staging, production, deprecated'
required: false
email:
description: 'The email address of the team responsible for the service'
required: true
Expand All @@ -57,4 +75,4 @@ inputs:
required: false
integrations:
description: 'The integrations for the service'
required: false
required: false
9 changes: 9 additions & 0 deletions lib/input-expander.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* input-expander.js
* DDSCMP
* @desc This module contains all of the functions which expand scalar
* input from GitHub Actions into hydrated structures for the DD API.
*
* @author Michael D. Stemle, Jr
*/

const core = require('@actions/core')
const YAML = require('yaml')

Expand Down
12 changes: 12 additions & 0 deletions lib/schema-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const VersionDifferences = {
v2: {
uniqueFields: ['docs', 'repos'],
requiredFields: [],
},
'v2.1': {
uniqueFields: ['application', 'description', 'tier', 'lifecycle'],
requiredFields: [],
},
}

Object.freeze(VersionDifferences)

0 comments on commit f9c130f

Please sign in to comment.