From 27d130b232623d5577bed13b4d2e06872592f84e Mon Sep 17 00:00:00 2001 From: Matteo Silvestri Date: Tue, 5 Jul 2022 13:48:27 +0200 Subject: [PATCH] add comment explaining GitLab behaviour Signed-off-by: Matteo Silvestri --- .../src/scaffolder/actions/builtin/publish/gitlab.ts | 6 ++++++ 1 file changed, 6 insertions(+) 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 80d082bc4b..4fe55b77a2 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlab.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlab.ts @@ -171,6 +171,12 @@ export function createPublishGitlabAction(options: { visibility: repoVisibility, }); + // When setUserAsOwner is true the input token is expected to come from an unprivileged user GitLab + // OAuth flow. In this case GitLab works in a way that allows the unprivileged user to + // create the repository, but not to push the default protected branch (e.g. master). + // In order to set the user as owner of the newly created repository we need to check that the + // GitLab integration configuration for the matching host contains a token and use + // such token to bootstrap a new privileged client. if (setUserAsOwner && integrationConfig.config.token) { const adminClient = new Gitlab({ host: integrationConfig.config.baseUrl,