From 2bd5f240439f63a75a310b7627a55629f2309006 Mon Sep 17 00:00:00 2001 From: djamaile Date: Thu, 3 Feb 2022 22:14:29 +0100 Subject: [PATCH 1/2] fix(scaffolder-backend): use the right key when initializing a Gitlab client Signed-off-by: djamaile --- .changeset/seven-teachers-arrive.md | 5 +++++ .../src/scaffolder/actions/builtin/publish/gitlab.ts | 3 ++- .../scaffolder/actions/builtin/publish/gitlabMergeRequest.ts | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/seven-teachers-arrive.md diff --git a/.changeset/seven-teachers-arrive.md b/.changeset/seven-teachers-arrive.md new file mode 100644 index 0000000000..b9d6264576 --- /dev/null +++ b/.changeset/seven-teachers-arrive.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +fix for the gitlab:publish action to use the `oauthToken` key when creating a Gilab client. This only happens if ctx.input.token is provided else the key `token` will be used. diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlab.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlab.ts index a04766f941..48979306b1 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlab.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlab.ts @@ -112,10 +112,11 @@ export function createPublishGitlabAction(options: { } const token = ctx.input.token || integrationConfig.config.token!; + const tokenType = ctx.input.token ? 'oauthToken' : 'token'; const client = new Gitlab({ host: integrationConfig.config.baseUrl, - token, + [tokenType]: token, }); let { id: targetNamespace } = (await client.Namespaces.show(owner)) as { diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts index 281b72789f..bf687268c3 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts @@ -118,10 +118,11 @@ export const createPublishGitlabMergeRequestAction = (options: { } const token = ctx.input.token ?? integrationConfig.config.token!; + const tokenType = ctx.input.token ? 'oauthToken' : 'token'; const api = new Gitlab({ host: integrationConfig.config.baseUrl, - token, + [tokenType]: token, }); const fileRoot = ctx.workspacePath; From 1049a6d94924304ded900520823e0567b4f29134 Mon Sep 17 00:00:00 2001 From: djamaile Date: Thu, 3 Feb 2022 22:21:22 +0100 Subject: [PATCH 2/2] fix(scaffolder-backend): spelling mistakes Signed-off-by: djamaile --- .changeset/seven-teachers-arrive.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/seven-teachers-arrive.md b/.changeset/seven-teachers-arrive.md index b9d6264576..bdbbc33c44 100644 --- a/.changeset/seven-teachers-arrive.md +++ b/.changeset/seven-teachers-arrive.md @@ -2,4 +2,5 @@ '@backstage/plugin-scaffolder-backend': patch --- -fix for the gitlab:publish action to use the `oauthToken` key when creating a Gilab client. This only happens if ctx.input.token is provided else the key `token` will be used. +fix for the `gitlab:publish` action to use the `oauthToken` key when creating a +`Gitlab` client. This only happens if `ctx.input.token` is provided else the key `token` will be used.