Skip to content

Commit

Permalink
Merge branch 'main' of github.com:arcxp/datadog-service-catalog-metad…
Browse files Browse the repository at this point in the history
…ata-provider
  • Loading branch information
manchicken committed Oct 24, 2024
2 parents 022b4da + 2f1839e commit e909e37
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/v2-automated-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: echo "date=$(date +'%Y-%m-%d -- %s')" >> $GITHUB_OUTPUT

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run CI Tests
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v2.1-automated-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: echo "date=$(date +'%Y-%m-%d -- %s')" >> $GITHUB_OUTPUT

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run CI Tests
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v2.2-automated-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: echo "date=$(date +'%Y-%m-%d -- %s')" >> $GITHUB_OUTPUT

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run CI Tests
env:
Expand Down
1 change: 1 addition & 0 deletions __tests__/lib/input-expander.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ describe('input-expander.cjs - utilities', () => {
{ value: 0, outcome: false },
{ value: 1, outcome: false },
{ value: { a: undefined }, outcome: false },
{ value: '', outcome: true },
])('#isNothing($value) should be $outcome', ({ value, outcome }) => {
expect(isNothing(value)).toBe(outcome)
})
Expand Down
6 changes: 3 additions & 3 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32033,7 +32033,7 @@ var require_input_expander = __commonJS({
":"
) : entry
);
var isNothing = (testValue) => !_.isDate(testValue) && (_.isObject(testValue) || _.isArray(testValue)) ? _.isEmpty(testValue) : _.isNil(testValue);
var isNothing = (testValue) => !_.isDate(testValue) && (_.isObject(testValue) || _.isArray(testValue) || _.isString(testValue)) ? _.isEmpty(testValue) : _.isNil(testValue);
var combineValues = (value, key, target) => {
if (isNothing(value)) {
return target;
Expand Down Expand Up @@ -36832,7 +36832,7 @@ var { validateDatadogHostname } = require_input_validation();
var { fetchAndApplyOrgRules } = require_org_rules();
var registerWithDataDog = async (apiKey, appKey, ddHost, configJsonStr) => {
DatadogPostGovernor.increment();
core.debug(`JSON: ${configJsonStr}`);
core.debug(`JSON: \xAB${configJsonStr}\xBB`);
const client = new HttpClient(
"nodejs - GitHub Actions - arcxp/datadog-service-catalog-metadata-provider"
);
Expand Down Expand Up @@ -36875,7 +36875,7 @@ var run = async (configs) => {
}
};
core.debug("STARTING THE PARSE");
inputsToRegistryDocument().then((configs) => {
Promise.resolve().then(() => inputsToRegistryDocument()).then((configs) => {
core.debug(`Input schema version is \xAB${core.getInput("schema-version")}\xBB`);
core.debug(
`Inputs coming off of configs: ${JSON.stringify(configs, void 0, 2)}`
Expand Down
15 changes: 8 additions & 7 deletions index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const { fetchAndApplyOrgRules } = require('./lib/org-rules')
const registerWithDataDog = async (apiKey, appKey, ddHost, configJsonStr) => {
DatadogPostGovernor.increment()

core.debug(`JSON: ${configJsonStr}`)
core.debug(`JSON: «${configJsonStr}»`)
// Prep the auth
const client = new HttpClient(
'nodejs - GitHub Actions - arcxp/datadog-service-catalog-metadata-provider'
'nodejs - GitHub Actions - arcxp/datadog-service-catalog-metadata-provider',
)

const response = await client.post(
Expand All @@ -27,15 +27,15 @@ const registerWithDataDog = async (apiKey, appKey, ddHost, configJsonStr) => {
'DD-API-KEY': apiKey,
'DD-APPLICATION-KEY': appKey,
'Content-Type': 'application/json',
}
},
)
const statusCode = response.message.statusCode
const body = await response.readBody()
core.debug(`Response status code: ${statusCode}, with body: ${body}`)

if (statusCode !== 200) {
core.setFailed(
`Failed to register service with DataDog. Status Code: ${statusCode} Body: ${body}`
`Failed to register service with DataDog. Status Code: ${statusCode} Body: ${body}`,
)
}
}
Expand All @@ -51,7 +51,7 @@ const run = async (configs) => {

if (!apiKey || !appKey) {
return core.setFailed(
'Both `datadog-key` and `datadog-app-key` are required.'
'Both `datadog-key` and `datadog-app-key` are required.',
)
}

Expand All @@ -74,11 +74,12 @@ const run = async (configs) => {

// Grab the inputs and then run with them!
core.debug('STARTING THE PARSE')
inputsToRegistryDocument()
Promise.resolve()
.then(() => inputsToRegistryDocument())
.then((configs) => {
core.debug(`Input schema version is «${core.getInput('schema-version')}»`)
core.debug(
`Inputs coming off of configs: ${JSON.stringify(configs, undefined, 2)}`
`Inputs coming off of configs: ${JSON.stringify(configs, undefined, 2)}`,
)

return configs
Expand Down
3 changes: 2 additions & 1 deletion lib/input-expander.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ const parseYamlExpectDatadogTags = (str) =>
* @function
**/
const isNothing = (testValue) =>
!_.isDate(testValue) && (_.isObject(testValue) || _.isArray(testValue))
!_.isDate(testValue) &&
(_.isObject(testValue) || _.isArray(testValue) || _.isString(testValue))
? _.isEmpty(testValue)
: _.isNil(testValue)

Expand Down
25 changes: 10 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,27 @@
"type": "git",
"url": "git+https://github.com/arcxp/datadog-service-catalog-metadata-provider.git"
},
"keywords": [
"github",
"action",
"datadog",
"service-catalog"
],
"keywords": ["github", "action", "datadog", "service-catalog"],
"author": "Mike Stemle <mike.stemle@washpost.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/arcxp/datadog-service-catalog-metadata-provider/issues"
},
"homepage": "https://github.com/arcxp/datadog-service-catalog-metadata-provider#readme",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.0",
"@actions/http-client": "^2.2.1",
"@octokit/rest": "^20.1.0",
"@actions/http-client": "^2.2.3",
"@octokit/rest": "^21.0.2",
"lodash": "^4.17.21",
"uuid": "^9.0.1",
"yaml": "^2.4.1"
"uuid": "^10.0.0",
"yaml": "^2.6.0"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"ajv": "^8.12.0",
"esbuild": "0.20.2",
"@types/jest": "^29.5.14",
"ajv": "^8.17.1",
"esbuild": "0.24.0",
"jest": "^29.7.0",
"prettier": "^3.2.5"
"prettier": "^3.3.3"
}
}

0 comments on commit e909e37

Please sign in to comment.