From 7aec28347cc2af3fae98c967f07c8030b6083883 Mon Sep 17 00:00:00 2001 From: Marcus Eide Date: Tue, 16 May 2023 09:47:42 +0200 Subject: [PATCH] Make options to getCredentials required Signed-off-by: Marcus Eide --- packages/integration/api-report.md | 2 +- .../SingleInstanceGitlabCredentialsProvider.ts | 12 ++++++++---- packages/integration/src/gitlab/types.ts | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/integration/api-report.md b/packages/integration/api-report.md index a1a14689ca..8939d24b20 100644 --- a/packages/integration/api-report.md +++ b/packages/integration/api-report.md @@ -501,7 +501,7 @@ export type GitlabCredentials = { // @public (undocumented) export interface GitlabCredentialsProvider { // (undocumented) - getCredentials(opts?: { url: string }): Promise; + getCredentials(opts: { url: string }): Promise; } // @public diff --git a/packages/integration/src/gitlab/SingleInstanceGitlabCredentialsProvider.ts b/packages/integration/src/gitlab/SingleInstanceGitlabCredentialsProvider.ts index 39f22ab9d5..76068a948e 100644 --- a/packages/integration/src/gitlab/SingleInstanceGitlabCredentialsProvider.ts +++ b/packages/integration/src/gitlab/SingleInstanceGitlabCredentialsProvider.ts @@ -28,11 +28,15 @@ export class SingleInstanceGitlabCredentialsProvider constructor(private readonly token?: string) {} - async getCredentials(): Promise { + async getCredentials(_opts: { url: string }): Promise { + if (!this.token) { + return {}; + } + return { - headers: this.token - ? { Authorization: `Bearer ${this.token}` } - : undefined, + headers: { + Authorization: `Bearer ${this.token}`, + }, token: this.token, }; } diff --git a/packages/integration/src/gitlab/types.ts b/packages/integration/src/gitlab/types.ts index ef8ccf8d6c..b980aaba7b 100644 --- a/packages/integration/src/gitlab/types.ts +++ b/packages/integration/src/gitlab/types.ts @@ -26,5 +26,5 @@ export type GitlabCredentials = { * @public */ export interface GitlabCredentialsProvider { - getCredentials(opts?: { url: string }): Promise; + getCredentials(opts: { url: string }): Promise; }