Skip to content

Commit 87007fb

Browse files
committed
Changing patterns for file and directory names.
- Renamed `schemaVersions` to `schema-versions` - Renamed `convenienceMappings` to `convenience-mappings` - Also added the ability to override convenience values with an optional second positional parameter
1 parent cb6116d commit 87007fb

18 files changed

+311
-46
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`lib/convenienceMappings.cjs #getConvenienceFieldValues() - full set 1`] = `
3+
exports[`lib/convenience-mappings.cjs #getConvenienceFieldValues() - full set 1`] = `
44
{
55
"email": "[email protected]",
66
"repo": "https://github.com/arcxp/datadog-service-catalog-metadata-provider",
@@ -9,10 +9,18 @@ exports[`lib/convenienceMappings.cjs #getConvenienceFieldValues() - full set 1`]
99
}
1010
`;
1111

12-
exports[`lib/convenienceMappings.cjs #getConvenienceFieldValues() - partial set 1`] = `
12+
exports[`lib/convenience-mappings.cjs #getConvenienceFieldValues() - partial set 1`] = `
1313
{
1414
"repo": "https://github.com/arcxp/datadog-service-catalog-metadata-provider",
1515
"slack": "https://fakeorg.slack.com/archives/A0000000000",
1616
"slack-support-channel": "https://fakeorg.slack.com/archives/A0000000001",
1717
}
1818
`;
19+
20+
exports[`lib/convenience-mappings.cjs #getConvenienceFieldValues() - partial set 2`] = `
21+
{
22+
"repo": "OVERRIDE!",
23+
"slack": "https://fakeorg.slack.com/archives/A0000000000",
24+
"slack-support-channel": "https://fakeorg.slack.com/archives/A0000000001",
25+
}
26+
`;

__tests__/lib/convenienceMappings.test.cjs renamed to __tests__/lib/convenience-mappings.test.cjs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const YAML = require('yaml')
22
const core = require('@actions/core')
3-
const subject = require('../../lib/convenienceMappings.cjs')
3+
const subject = require('../../lib/convenience-mappings.cjs')
44

5-
describe('lib/convenienceMappings.cjs', () => {
5+
describe('lib/convenience-mappings.cjs', () => {
66
test('#getConvenienceFieldValues() - full set', () => {
77
const testInput = `
88
---
@@ -33,4 +33,20 @@ repo: https://github.com/arcxp/datadog-service-catalog-metadata-provider
3333
expect(inputs).toMatchSnapshot()
3434
expect(inputs.email).toBeUndefined()
3535
})
36+
37+
test('#getConvenienceFieldValues() - partial set', () => {
38+
const testInput = `
39+
---
40+
slack: 'https://fakeorg.slack.com/archives/A0000000000'
41+
slack-support-channel: 'https://fakeorg.slack.com/archives/A0000000001'
42+
repo: https://github.com/arcxp/datadog-service-catalog-metadata-provider
43+
`
44+
// Full set of fields
45+
core.__setInputsObject(YAML.parse(testInput))
46+
const inputs = subject.getConvenienceFieldValues(core, {
47+
repo: 'OVERRIDE!',
48+
})
49+
expect(inputs).toMatchSnapshot()
50+
expect(inputs.repo).toEqual('OVERRIDE!')
51+
})
3652
})

__tests__/lib/schemaVersions.test.cjs renamed to __tests__/lib/schema-versions.test.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const subject = require('../../lib/schemaVersions.cjs')
1+
const subject = require('../../lib/schema-versions.cjs')
22

3-
describe('lib/schemaVersions.cjs#inputMapperByVersion()', () => {
3+
describe('lib/schema-versions.cjs#inputMapperByVersion()', () => {
44
test.each([{ version: 'v2' }, { version: 'v2.1' }, { version: 'v2.2' }])(
55
'$version mapper',
66
({ version }) => {

__tests__/lib/schemaVersions/__snapshots__/v2.1.test.cjs.snap renamed to __tests__/lib/schema-versions/__snapshots__/v2.1.test.cjs.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`lib/schemaVersions/v2.1.cjs#mapInputs() #mapInputs() - Merging in some convenience fields 1`] = `
3+
exports[`lib/schema-versions/v2.1.cjs#mapInputs() #mapInputs() - Merging in some convenience fields 1`] = `
44
{
55
"contacts": [
66
{
@@ -47,7 +47,7 @@ exports[`lib/schemaVersions/v2.1.cjs#mapInputs() #mapInputs() - Merging in some
4747
}
4848
`;
4949

50-
exports[`lib/schemaVersions/v2.1.cjs#mapSchemaFields() #mapSchemaFields() - Full schema fields set 1`] = `
50+
exports[`lib/schema-versions/v2.1.cjs#mapSchemaFields() #mapSchemaFields() - Full schema fields set 1`] = `
5151
{
5252
"application": "Schema Version v2.1 Test",
5353
"contacts": [
@@ -57,7 +57,7 @@ exports[`lib/schemaVersions/v2.1.cjs#mapSchemaFields() #mapSchemaFields() - Full
5757
"type": "email",
5858
},
5959
],
60-
"dd-service": "schemaVersions-v2.1-test",
60+
"dd-service": "schema-versions-v2.1-test",
6161
"description": "This is just a test",
6262
"integrations": {
6363
"opsgenie": {
@@ -99,7 +99,7 @@ exports[`lib/schemaVersions/v2.1.cjs#mapSchemaFields() #mapSchemaFields() - Full
9999
}
100100
`;
101101

102-
exports[`lib/schemaVersions/v2.1.cjs#mapSchemaFields() #mapSchemaFields() - Partial schema fields set 1`] = `
102+
exports[`lib/schema-versions/v2.1.cjs#mapSchemaFields() #mapSchemaFields() - Partial schema fields set 1`] = `
103103
{
104104
"contacts": [
105105
{

__tests__/lib/schemaVersions/__snapshots__/v2.2.test.cjs.snap renamed to __tests__/lib/schema-versions/__snapshots__/v2.2.test.cjs.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`lib/schemaVersions/v2.2.cjs#mapInputs() #mapInputs() - Merging in some convenience fields 1`] = `
3+
exports[`lib/schema-versions/v2.2.cjs#mapInputs() #mapInputs() - Merging in some convenience fields 1`] = `
44
{
55
"contacts": [
66
{
@@ -47,7 +47,7 @@ exports[`lib/schemaVersions/v2.2.cjs#mapInputs() #mapInputs() - Merging in some
4747
}
4848
`;
4949

50-
exports[`lib/schemaVersions/v2.2.cjs#mapSchemaFields() #mapSchemaFields() - Full schema fields set 1`] = `
50+
exports[`lib/schema-versions/v2.2.cjs#mapSchemaFields() #mapSchemaFields() - Full schema fields set 1`] = `
5151
{
5252
"application": "Schema Version v2.2 Test",
5353
"contacts": [
@@ -57,7 +57,7 @@ exports[`lib/schemaVersions/v2.2.cjs#mapSchemaFields() #mapSchemaFields() - Full
5757
"type": "email",
5858
},
5959
],
60-
"dd-service": "schemaVersions-v2.2-test",
60+
"dd-service": "schema-versions-v2.2-test",
6161
"description": "This is just a test",
6262
"integrations": {
6363
"opsgenie": {
@@ -104,7 +104,7 @@ exports[`lib/schemaVersions/v2.2.cjs#mapSchemaFields() #mapSchemaFields() - Full
104104
}
105105
`;
106106

107-
exports[`lib/schemaVersions/v2.2.cjs#mapSchemaFields() #mapSchemaFields() - Partial schema fields set 1`] = `
107+
exports[`lib/schema-versions/v2.2.cjs#mapSchemaFields() #mapSchemaFields() - Partial schema fields set 1`] = `
108108
{
109109
"contacts": [
110110
{

__tests__/lib/schemaVersions/__snapshots__/v2.test.cjs.snap renamed to __tests__/lib/schema-versions/__snapshots__/v2.test.cjs.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`lib/schemaVersions/v2.cjs#mapInputs() #mapInputs() - Merging in some convenience fields 1`] = `
3+
exports[`lib/schema-versions/v2.cjs#mapInputs() #mapInputs() - Merging in some convenience fields 1`] = `
44
{
55
"contacts": [
66
{
@@ -50,7 +50,7 @@ exports[`lib/schemaVersions/v2.cjs#mapInputs() #mapInputs() - Merging in some co
5050
}
5151
`;
5252

53-
exports[`lib/schemaVersions/v2.cjs#mapSchemaFields() #mapSchemaFields() - Full schema fields set 1`] = `
53+
exports[`lib/schema-versions/v2.cjs#mapSchemaFields() #mapSchemaFields() - Full schema fields set 1`] = `
5454
{
5555
"contacts": [
5656
{
@@ -59,7 +59,7 @@ exports[`lib/schemaVersions/v2.cjs#mapSchemaFields() #mapSchemaFields() - Full s
5959
"type": "email",
6060
},
6161
],
62-
"dd-service": "schemaVersions-v2-test",
62+
"dd-service": "schema-versions-v2-test",
6363
"docs": [
6464
{
6565
"name": "GitHub Actions!",
@@ -106,7 +106,7 @@ exports[`lib/schemaVersions/v2.cjs#mapSchemaFields() #mapSchemaFields() - Full s
106106
}
107107
`;
108108

109-
exports[`lib/schemaVersions/v2.cjs#mapSchemaFields() #mapSchemaFields() - Partial schema fields set 1`] = `
109+
exports[`lib/schema-versions/v2.cjs#mapSchemaFields() #mapSchemaFields() - Partial schema fields set 1`] = `
110110
{
111111
"contacts": [
112112
{

__tests__/lib/schemaVersions/v2.1.test.cjs renamed to __tests__/lib/schema-versions/v2.1.test.cjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const YAML = require('yaml')
22
const core = require('@actions/core')
3-
const subject = require('../../../lib/schemaVersions/v2.1.cjs')
3+
const subject = require('../../../lib/schema-versions/v2.1.cjs')
44

5-
describe('lib/schemaVersions/v2.1.cjs#mapSchemaFields()', () => {
5+
describe('lib/schema-versions/v2.1.cjs#mapSchemaFields()', () => {
66
test('#mapSchemaFields() - Full schema fields set', () => {
77
const testInput = `
88
---
99
schema-version: something-crazy-that-is-ignored
10-
service-name: schemaVersions-v2.1-test
10+
service-name: schema-versions-v2.1-test
1111
team: Team Name Here
1212
application: Schema Version v2.1 Test
1313
description: This is just a test
@@ -44,7 +44,7 @@ contacts: |
4444
core.__setInputsObject(YAML.parse(testInput))
4545
const inputs = subject._test.mapSchemaFields(core)
4646
expect(inputs).toMatchSnapshot()
47-
expect(inputs['dd-service']).toEqual('schemaVersions-v2.1-test')
47+
expect(inputs['dd-service']).toEqual('schema-versions-v2.1-test')
4848
})
4949

5050
test('#mapSchemaFields() - Partial schema fields set', () => {
@@ -87,7 +87,7 @@ contacts: |
8787
})
8888
})
8989

90-
describe('lib/schemaVersions/v2.1.cjs#mapInputs()', () => {
90+
describe('lib/schema-versions/v2.1.cjs#mapInputs()', () => {
9191
test('#mapInputs() - Merging in some convenience fields', () => {
9292
const testInput = `
9393
---

__tests__/lib/schemaVersions/v2.2.test.cjs renamed to __tests__/lib/schema-versions/v2.2.test.cjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const YAML = require('yaml')
22
const core = require('@actions/core')
3-
const subject = require('../../../lib/schemaVersions/v2.2.cjs')
3+
const subject = require('../../../lib/schema-versions/v2.2.cjs')
44

5-
describe('lib/schemaVersions/v2.2.cjs#mapSchemaFields()', () => {
5+
describe('lib/schema-versions/v2.2.cjs#mapSchemaFields()', () => {
66
test('#mapSchemaFields() - Full schema fields set', () => {
77
const testInput = `
88
---
99
schema-version: something-crazy-that-is-ignored
10-
service-name: schemaVersions-v2.2-test
10+
service-name: schema-versions-v2.2-test
1111
team: Team Name Here
1212
application: Schema Version v2.2 Test
1313
description: This is just a test
@@ -48,7 +48,7 @@ contacts: |
4848
core.__setInputsObject(YAML.parse(testInput))
4949
const inputs = subject._test.mapSchemaFields(core)
5050
expect(inputs).toMatchSnapshot()
51-
expect(inputs['dd-service']).toEqual('schemaVersions-v2.2-test')
51+
expect(inputs['dd-service']).toEqual('schema-versions-v2.2-test')
5252
})
5353

5454
test('#mapSchemaFields() - Partial schema fields set', () => {
@@ -91,7 +91,7 @@ contacts: |
9191
})
9292
})
9393

94-
describe('lib/schemaVersions/v2.2.cjs#mapInputs()', () => {
94+
describe('lib/schema-versions/v2.2.cjs#mapInputs()', () => {
9595
test('#mapInputs() - Merging in some convenience fields', () => {
9696
const testInput = `
9797
---

__tests__/lib/schemaVersions/v2.test.cjs renamed to __tests__/lib/schema-versions/v2.test.cjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const YAML = require('yaml')
22
const core = require('@actions/core')
3-
const subject = require('../../../lib/schemaVersions/v2.cjs')
3+
const subject = require('../../../lib/schema-versions/v2.cjs')
44

5-
describe('lib/schemaVersions/v2.cjs#mapSchemaFields()', () => {
5+
describe('lib/schema-versions/v2.cjs#mapSchemaFields()', () => {
66
test('#mapSchemaFields() - Full schema fields set', () => {
77
const testInput = `
88
---
99
schema-version: something-crazy-that-is-ignored
10-
service-name: schemaVersions-v2-test
10+
service-name: schema-versions-v2-test
1111
team: Team Name Here
1212
tags: |
1313
- 'application:GitHub Action Config Test'
@@ -44,7 +44,7 @@ extensions: |
4444
core.__setInputsObject(YAML.parse(testInput))
4545
const inputs = subject._test.mapSchemaFields(core)
4646
expect(inputs).toMatchSnapshot()
47-
expect(inputs['dd-service']).toEqual('schemaVersions-v2-test')
47+
expect(inputs['dd-service']).toEqual('schema-versions-v2-test')
4848
})
4949

5050
test('#mapSchemaFields() - Partial schema fields set', () => {
@@ -91,7 +91,7 @@ extensions: |
9191
})
9292
})
9393

94-
describe('lib/schemaVersions/v2.cjs#mapInputs()', () => {
94+
describe('lib/schema-versions/v2.cjs#mapInputs()', () => {
9595
test('#mapInputs() - Merging in some convenience fields', () => {
9696
const testInput = `
9797
---
File renamed without changes.

lib/input-to-registry-document.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
const core = require('@actions/core')
1212

13-
const { inputMapperByVersion } = require('./schemaVersions.cjs')
13+
const { inputMapperByVersion } = require('./schema-versions.cjs')
1414

1515
/**
1616
* This function takes the inputs from the Action and converts them into a registry document for Datadog.

lib/schemaVersions.cjs renamed to lib/schema-versions.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const mapperMatrix = {
2-
v2: require('./schemaVersions/v2.cjs').mapInputs,
3-
'v2.1': require('./schemaVersions/v2.1.cjs').mapInputs,
4-
'v2.2': require('./schemaVersions/v2.2.cjs').mapInputs,
2+
v2: require('./schema-versions/v2.cjs').mapInputs,
3+
'v2.1': require('./schema-versions/v2.1.cjs').mapInputs,
4+
'v2.2': require('./schema-versions/v2.2.cjs').mapInputs,
55
}
66

77
const defaultMapper = () => {

lib/schemaVersions/v2.1.cjs renamed to lib/schema-versions/v2.1.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file This file maps the GitHub Action's inputs to the v2 schema.
3-
* @module lib/schemaVersions/v2
3+
* @module lib/schema-versions/v2
44
* @author Mike Stemle
55
**/
66

@@ -15,7 +15,7 @@ const {
1515
combineValues,
1616
} = require('../input-expander.cjs')
1717

18-
const { getConvenienceFieldValues } = require('../convenienceMappings.cjs')
18+
const { getConvenienceFieldValues } = require('../convenience-mappings.cjs')
1919

2020
/**
2121
* This is function maps the inputs to the output schema version for the API.

lib/schemaVersions/v2.2.cjs renamed to lib/schema-versions/v2.2.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file This file maps the GitHub Action's inputs to the v2 schema.
3-
* @module lib/schemaVersions/v2
3+
* @module lib/schema-versions/v2
44
* @author Mike Stemle
55
**/
66

@@ -15,7 +15,7 @@ const {
1515
combineValues,
1616
} = require('../input-expander.cjs')
1717

18-
const { getConvenienceFieldValues } = require('../convenienceMappings.cjs')
18+
const { getConvenienceFieldValues } = require('../convenience-mappings.cjs')
1919

2020
/**
2121
* This is function maps the inputs to the output schema version for the API.

lib/schemaVersions/v2.cjs renamed to lib/schema-versions/v2.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file This file maps the GitHub Action's inputs to the v2 schema.
3-
* @module lib/schemaVersions/v2
3+
* @module lib/schema-versions/v2
44
* @author Mike Stemle
55
**/
66

@@ -15,7 +15,7 @@ const {
1515
combineValues,
1616
} = require('../input-expander.cjs')
1717

18-
const { getConvenienceFieldValues } = require('../convenienceMappings.cjs')
18+
const { getConvenienceFieldValues } = require('../convenience-mappings.cjs')
1919

2020
/**
2121
* This is function maps the inputs to the output schema version for the API.

0 commit comments

Comments
 (0)