chore: return undefined when entity is missing url location annotation

Signed-off-by: Adam Letizia <LetiziaAdam@JohnDeere.com>
This commit is contained in:
Adam Letizia
2023-05-17 10:02:19 -05:00
parent a13d939781
commit b8744e53ff
2 changed files with 3 additions and 5 deletions
@@ -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 });
}
@@ -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;
};