From 3d61f61fc74a4f4ae88e5c1ae06ba8a9d02daee3 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Fri, 23 Oct 2020 18:53:34 +1300 Subject: [PATCH] Fixes naming error for default fallbacks in harbor scanner matchers --- services/api/src/resources/problem/resolvers.ts | 4 ++-- services/api/src/resources/problem/sql.ts | 2 +- .../src/handlers/problems/harborScanningCompleted.ts | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/services/api/src/resources/problem/resolvers.ts b/services/api/src/resources/problem/resolvers.ts index b7aa959af3..c448c01db7 100644 --- a/services/api/src/resources/problem/resolvers.ts +++ b/services/api/src/resources/problem/resolvers.ts @@ -199,7 +199,7 @@ export const addProblemHarborScanMatch = async ( description, defaultLagoonProject, defaultLagoonEnvironment, - defaultLagoonServiceName, + defaultLagoonService, regex }, }, @@ -219,7 +219,7 @@ export const addProblemHarborScanMatch = async ( description, default_lagoon_project: defaultLagoonProject, default_lagoon_environment: defaultLagoonEnvironment, - default_lagoon_service_name: defaultLagoonServiceName, + default_lagoon_service_name: defaultLagoonService, regex } ), diff --git a/services/api/src/resources/problem/sql.ts b/services/api/src/resources/problem/sql.ts index 65e1a79081..e20dcd28ef 100644 --- a/services/api/src/resources/problem/sql.ts +++ b/services/api/src/resources/problem/sql.ts @@ -24,7 +24,7 @@ const standardProblemHarborScanMatchReturn = { description: 'description', default_lagoon_project: 'defaultLagoonProject', default_lagoon_environment: 'defaultLagoonEnvironment', - default_lagoon_service_name: 'defaultLagoonServiceName', + default_lagoon_service: 'defaultLagoonServiceName', regex: 'regex' }; diff --git a/services/webhooks2tasks/src/handlers/problems/harborScanningCompleted.ts b/services/webhooks2tasks/src/handlers/problems/harborScanningCompleted.ts index ef068f6913..3117a15a7f 100644 --- a/services/webhooks2tasks/src/handlers/problems/harborScanningCompleted.ts +++ b/services/webhooks2tasks/src/handlers/problems/harborScanningCompleted.ts @@ -175,11 +175,10 @@ const matchRepositoryAgainstPatterns = (repoFullName, matchPatterns = []) => { } const matchPatternDetails = matchingRes.pop() || DEFAULT_REPO_DETAILS_MATCHER; - const { - lagoonProjectName = matchPatternDetails.defaultProjectName, - lagoonEnvironmentName = matchPatternDetails.defaultEnvironmentName, - lagoonServiceName = matchPatternDetails.defaultServiceName, + lagoonProjectName = matchPatternDetails.defaultLagoonProject, + lagoonEnvironmentName = matchPatternDetails.defaultLagoonEnvironment, + lagoonServiceName = matchPatternDetails.defaultLagoonService, } = extractRepositoryDetailsGivenRegex(repoFullName, matchPatternDetails.regex); return {lagoonProjectName, lagoonEnvironmentName, lagoonServiceName}; @@ -190,7 +189,7 @@ const generateRegex = R.memoizeWith(R.identity, re => new RegExp(re)); const extractRepositoryDetailsGivenRegex = (repoFullName, pattern = DEFAULT_REPO_DETAILS_REGEX) => { const re = generateRegex(pattern); const match = re.exec(repoFullName); - return match.groups; + return match.groups || {}; } const generateWebhookData = (