From b8744e53ff393b17f6b833d20ad0489b5c736da3 Mon Sep 17 00:00:00 2001 From: Adam Letizia Date: Wed, 17 May 2023 10:02:19 -0500 Subject: [PATCH] chore: return undefined when entity is missing url location annotation Signed-off-by: Adam Letizia --- plugins/github-actions/src/api/GithubActionsClient.ts | 4 +--- .../github-actions/src/components/getHostnameFromEntity.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/github-actions/src/api/GithubActionsClient.ts b/plugins/github-actions/src/api/GithubActionsClient.ts index d1ff689f2e..e427c343e2 100644 --- a/plugins/github-actions/src/api/GithubActionsClient.ts +++ b/plugins/github-actions/src/api/GithubActionsClient.ts @@ -46,9 +46,7 @@ export class GithubActionsClient implements GithubActionsApi { const configs = readGithubIntegrationConfigs( this.configApi.getOptionalConfigArray('integrations.github') ?? [], ); - const githubIntegrationConfig = configs.find( - v => v.host === hostname ?? 'github.com', - ); + const githubIntegrationConfig = configs.find(v => v.host === hostname); const baseUrl = githubIntegrationConfig?.apiBaseUrl; return new Octokit({ auth: token, baseUrl }); } diff --git a/plugins/github-actions/src/components/getHostnameFromEntity.ts b/plugins/github-actions/src/components/getHostnameFromEntity.ts index 27e3213d32..836fd22860 100644 --- a/plugins/github-actions/src/components/getHostnameFromEntity.ts +++ b/plugins/github-actions/src/components/getHostnameFromEntity.ts @@ -26,7 +26,7 @@ export const getHostnameFromEntity = (entity: Entity) => { entity?.metadata.annotations?.[ANNOTATION_SOURCE_LOCATION] ?? entity?.metadata.annotations?.[ANNOTATION_LOCATION]; - return location && location.startsWith('url:') + return location?.startsWith('url:') ? gitUrlParse(location.slice(4)).resource - : ''; + : undefined; };