From 8b3dc2636fec6b37e451e8dbff91e17060c05ed9 Mon Sep 17 00:00:00 2001 From: Mike Stemle Date: Wed, 20 Dec 2023 19:48:58 -0500 Subject: [PATCH] building, and adding debug. --- dist/index.cjs | 110 +++++++++++++++++++++++++++--------------- lib/fieldMappings.cjs | 2 + 2 files changed, 72 insertions(+), 40 deletions(-) diff --git a/dist/index.cjs b/dist/index.cjs index 6fdde8e..b6cdc9f 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -30605,7 +30605,7 @@ var require_fieldMappings = __commonJS({ useSharedMappings(["v2.1", "v2.2"], mapToUsing("lifecycle", passThru)) ), // New in v2.2 - type: { + type2: { v2: versionCompatibilityError("type", "v2", ["v2.2"]), "v2.1": versionCompatibilityError("type", "v2.1", ["v2.2"]), "v2.2": mapToUsing("type", passThru) @@ -30620,17 +30620,21 @@ var require_fieldMappings = __commonJS({ ["v2", "v2.1", "v2.2"], mapToUsing("contacts", arrayYamlParse) ), - links: { - v2: (input) => ({ - links: forceArray(expandObjectInputs(input)).map( - (x) => ( - // v2 doesn't have a provider field - _.omit(x, ["provider"]) + links: Object.assign( + { + v2: (input) => ({ + links: forceArray(expandObjectInputs(input)).map( + (x) => ( + // v2 doesn't have a provider field + _.omit(x, ["provider"]) + ) ) - ) - }), - "v2.1": (input) => ({ links: forceArray(expandObjectInputs(input)) }) - }, + }) + }, + useSharedMappings(["v2.1", "v2.2"], (input) => ({ + links: forceArray(expandObjectInputs(input)) + })) + ), // This tags setup is a little hairy, but the biggest thing // to keep in mind is that we want a list of strings, made up // of colon-separated values. Mercifully, this is the same @@ -30653,14 +30657,24 @@ var require_fieldMappings = __commonJS({ ["v2", "v2.1", "v2.2"], mapToUsing("integrations", objectYamlParse) ), - docs: { - v2: mapToUsing("docs", arrayYamlParse), - "v2.1": versionCompatibilityError("docs", "v2.1", ["v2"]) - }, - repos: { - v2: mapToUsing("repos", arrayYamlParse), - "v2.1": versionCompatibilityError("repos", "v2.1", ["v2"]) - }, + docs: Object.assign( + { + v2: mapToUsing("docs", arrayYamlParse) + }, + useSharedMappings( + ["v2.1", "v2.2"], + versionCompatibilityError("docs", "v2.1", ["v2"]) + ) + ), + repos: Object.assign( + { + v2: mapToUsing("repos", arrayYamlParse) + }, + useSharedMappings( + ["v2.1", "v2.2"], + versionCompatibilityError("repos", "v2.1", ["v2"]) + ) + ), "ci-pipeline-fingerprints": { v2: versionCompatibilityError("ci-pipeline-fingerprints", "v2", ["v2.2"]), "v2.1": versionCompatibilityError("ci-pipeline-fingerprints", "v2.1", [ @@ -30685,7 +30699,7 @@ var require_fieldMappings = __commonJS({ var convenienceMappings = { // These fields map into `contacts` in the registry document. email: useSharedMappings( - ["v2", "v2.1"], + ["v2", "v2.1", "v2.2"], (input, doc) => incorporateConvenienceMapping( { contact: input, type: "email" }, doc, @@ -30693,7 +30707,7 @@ var require_fieldMappings = __commonJS({ ) ), slack: useSharedMappings( - ["v2", "v2.1"], + ["v2", "v2.1", "v2.2"], (input, doc) => incorporateConvenienceMapping( { contact: input, type: "slack" }, doc, @@ -30701,38 +30715,53 @@ var require_fieldMappings = __commonJS({ ) ), // These fields map into `repos` list in the registry document for v2, and into the `links` list in the registry document for v2.1. - repo: { - v2: (input, doc) => incorporateConvenienceMapping({ name: "Repo", url: input }, doc, "repos"), - "v2.1": (input, doc) => incorporateConvenienceMapping( - { name: "Repo", type: "repo", url: input }, - doc, - "links" + repo: Object.assign( + { + v2: (input, doc) => incorporateConvenienceMapping( + { name: "Repo", url: input }, + doc, + "repos" + ) + }, + useSharedMappings( + ["v2.1", "v2.2"], + (input, doc) => incorporateConvenienceMapping( + { name: "Repo", type: "repo", url: input }, + doc, + "links" + ) ) - }, + ), // These fields map into `integrations` in the registry document. opsgenie: useSharedMappings( - ["v2", "v2.1"], + ["v2", "v2.1", "v2.2"], (input, doc) => incorporateConvenienceMappingToObject( { opsgenie: { "service-url": input } }, doc, "integrations" ) ), - pagerduty: { - v2: (input, doc) => incorporateConvenienceMappingToObject( - { pagerduty: input }, - doc, - "integrations" - ), - "v2.1": (input, doc) => incorporateConvenienceMappingToObject( - { pagerduty: { "service-url": input } }, - doc, - "integrations" + pagerduty: Object.assign( + { + v2: (input, doc) => incorporateConvenienceMappingToObject( + { pagerduty: input }, + doc, + "integrations" + ) + }, + useSharedMappings( + ["v2.1", "v2.2"], + (input, doc) => incorporateConvenienceMappingToObject( + { pagerduty: { "service-url": input } }, + doc, + "integrations" + ) ) - } + ) }; convenienceMappings["slack-support-channel"] = convenienceMappings.slack; Object.freeze(convenienceMappings); + core2.debug({ mappings, convenienceMappings }); var convenienceFields = _.keys(convenienceMappings); Object.freeze(convenienceFields); var mapField = (field, version2) => (input, doc = void 0) => (mappings?.[field]?.[version2] ?? convenienceMappings?.[field]?.[version2] ?? ((_2) => core2.setFailed(`Unknown field: ${field}`)))(input, doc); @@ -35083,6 +35112,7 @@ var require_org_rules = __commonJS({ return true; }; var determineRuleCompliance = (rule, serviceDescription) => { + core2.debug({ rule, serviceDescription }); if (!rule || !serviceDescription) { throw new Error("Both rule and service description are required."); } diff --git a/lib/fieldMappings.cjs b/lib/fieldMappings.cjs index 415fdf6..c9f28bc 100644 --- a/lib/fieldMappings.cjs +++ b/lib/fieldMappings.cjs @@ -316,6 +316,8 @@ const convenienceMappings = { convenienceMappings['slack-support-channel'] = convenienceMappings.slack Object.freeze(convenienceMappings) +core.debug({ mappings, convenienceMappings }) + /** * This is the list of fields which are convenience fields, which are mapped to other fields in the registry document. * @type {string[]}