@backstage/plugin-scaffolder-backend-module-gitlab 0.11.3 → 0.11.4-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +1 -0
- package/dist/actions/gitlab.cjs.js +4 -1
- package/dist/actions/gitlab.cjs.js.map +1 -1
- package/dist/actions/gitlabGroupAccessAction.cjs.js +177 -0
- package/dist/actions/gitlabGroupAccessAction.cjs.js.map +1 -0
- package/dist/actions/gitlabGroupAccessAction.examples.cjs.js +103 -0
- package/dist/actions/gitlabGroupAccessAction.examples.cjs.js.map +1 -0
- package/dist/actions/gitlabProjectVariableCreate.cjs.js +5 -0
- package/dist/actions/gitlabProjectVariableCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectVariableCreate.examples.cjs.js +20 -0
- package/dist/actions/gitlabProjectVariableCreate.examples.cjs.js.map +1 -1
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +25 -1
- package/dist/module.cjs.js +2 -0
- package/dist/module.cjs.js.map +1 -1
- package/package.json +12 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.11.4-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c1726a: Added new `gitlab:group:access` scaffolder action to add or remove users and groups as members of GitLab groups. The action supports specifying members via `userIds` and/or `groupIds` array parameters, configurable access levels (Guest, Reporter, Developer, Maintainer, Owner), and defaults to the 'add' action when not specified.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/integration@2.0.0-next.1
|
|
10
|
+
- @backstage/plugin-scaffolder-node@0.13.0-next.1
|
|
11
|
+
- @backstage/backend-plugin-api@1.7.1-next.0
|
|
12
|
+
- @backstage/config@1.3.6
|
|
13
|
+
- @backstage/errors@1.2.7
|
|
14
|
+
|
|
15
|
+
## 0.11.4-next.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 5730c8e: Added `maskedAndHidden` option to `gitlab:projectVariable:create` and `publish:gitlab` action to support creating GitLab project variables that are both masked and hidden. Updated gitbeaker to version 43.8.0 for proper type support.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/integration@1.21.0-next.0
|
|
22
|
+
- @backstage/backend-plugin-api@1.7.1-next.0
|
|
23
|
+
- @backstage/config@1.3.6
|
|
24
|
+
- @backstage/errors@1.2.7
|
|
25
|
+
- @backstage/plugin-scaffolder-node@0.12.6-next.0
|
|
26
|
+
|
|
3
27
|
## 0.11.3
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -100,6 +100,7 @@ function createPublishGitlabAction(options) {
|
|
|
100
100
|
variable_type: z.enum(["env_var", "file"]).optional(),
|
|
101
101
|
protected: z.boolean().optional(),
|
|
102
102
|
masked: z.boolean().optional(),
|
|
103
|
+
masked_and_hidden: z.boolean().optional(),
|
|
103
104
|
raw: z.boolean().optional(),
|
|
104
105
|
environment_scope: z.string().optional()
|
|
105
106
|
})
|
|
@@ -197,7 +198,7 @@ function createPublishGitlabAction(options) {
|
|
|
197
198
|
host: integrationConfig.config.baseUrl,
|
|
198
199
|
token: integrationConfig.config.token
|
|
199
200
|
});
|
|
200
|
-
await adminClient.ProjectMembers.add(projectId,
|
|
201
|
+
await adminClient.ProjectMembers.add(projectId, 50, { userId });
|
|
201
202
|
}
|
|
202
203
|
const remoteUrl = http_url_to_repo.replace(/\.git$/, "");
|
|
203
204
|
const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;
|
|
@@ -273,6 +274,7 @@ function createPublishGitlabAction(options) {
|
|
|
273
274
|
variable_type: variable.variable_type ?? "env_var",
|
|
274
275
|
protected: variable.protected ?? false,
|
|
275
276
|
masked: variable.masked ?? false,
|
|
277
|
+
masked_and_hidden: variable.masked_and_hidden ?? false,
|
|
276
278
|
raw: variable.raw ?? false,
|
|
277
279
|
environment_scope: variable.environment_scope ?? "*"
|
|
278
280
|
});
|
|
@@ -285,6 +287,7 @@ function createPublishGitlabAction(options) {
|
|
|
285
287
|
variableType: variableWithDefaults.variable_type,
|
|
286
288
|
protected: variableWithDefaults.protected,
|
|
287
289
|
masked: variableWithDefaults.masked,
|
|
290
|
+
masked_and_hidden: variableWithDefaults.masked_and_hidden,
|
|
288
291
|
environmentScope: variableWithDefaults.environment_scope,
|
|
289
292
|
description: variableWithDefaults.description,
|
|
290
293
|
raw: variableWithDefaults.raw
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.cjs.js","sources":["../../src/actions/gitlab.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Gitlab, VariableType } from '@gitbeaker/rest';\nimport { Config } from '@backstage/config';\nimport { examples } from './gitlab.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitLab.\n *\n * @public\n */\nexport function createPublishGitlabAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:gitlab',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to GitLab.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n repoVisibility: z =>\n z\n .enum(['private', 'public', 'internal'], {\n description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`,\n })\n .optional(),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'master'`,\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the default author email for the commit.`,\n })\n .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n sourcePath: z =>\n z\n .union([z.string(), z.boolean()], {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted or set to true, the entire workspace will be published as the repository. If set to false, the created repository will be empty.',\n })\n .optional(),\n skipExisting: z =>\n z\n .boolean({\n description:\n 'Do not publish the repository if it already exists. The default value is false.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n setUserAsOwner: z =>\n z\n .boolean({\n description:\n 'Set the token user as owner of the newly created repository. Requires a token authorized to do the edit in the integration configuration for the matching host',\n })\n .optional(),\n topics: z =>\n z\n .array(z.string(), {\n description:\n 'Topic labels to apply on the repository. (deprecated, use settings.topics instead)',\n })\n .optional(),\n settings: z =>\n z\n .object({\n path: z\n .string({\n description:\n 'Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes).',\n })\n .optional(),\n auto_devops_enabled: z\n .boolean({\n description: 'Enable Auto DevOps for this project',\n })\n .optional(),\n ci_config_path: z\n .string({\n description: 'Custom CI config path for this project',\n })\n .optional(),\n description: z\n .string({\n description: 'Short project description',\n })\n .optional(),\n merge_method: z\n .enum(['merge', 'rebase_merge', 'ff'], {\n description: 'Merge Methods (merge, rebase_merge, ff)',\n })\n .optional(),\n squash_option: z\n .enum(['default_off', 'default_on', 'never', 'always'], {\n description:\n 'Set squash option for the project (never, always, default_on, default_off)',\n })\n .optional(),\n topics: z\n .array(z.string(), {\n description: 'Topic labels to apply on the repository',\n })\n .optional(),\n visibility: z\n .enum(['private', 'public', 'internal'], {\n description:\n 'The visibility of the project. Can be private, internal, or public. The default value is private.',\n })\n .optional(),\n only_allow_merge_if_all_discussions_are_resolved: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged when all the discussions are resolved.',\n })\n .optional(),\n only_allow_merge_if_pipeline_succeeds: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged with successful pipelines. This setting is named Pipelines must succeed in the project settings.',\n })\n .optional(),\n allow_merge_on_skipped_pipeline: z\n .boolean({\n description:\n 'Set whether or not merge requests can be merged with skipped jobs.',\n })\n .optional(),\n })\n .optional(),\n branches: z =>\n z\n .array(\n z.object({\n name: z.string(),\n protect: z.boolean().optional(),\n create: z.boolean().optional(),\n ref: z.string().optional(),\n }),\n )\n .optional(),\n projectVariables: z =>\n z\n .array(\n z.object({\n key: z.string(),\n value: z.string(),\n description: z.string().optional(),\n variable_type: z.enum(['env_var', 'file']).optional(),\n protected: z.boolean().optional(),\n masked: z.boolean().optional(),\n raw: z.boolean().optional(),\n environment_scope: z.string().optional(),\n }),\n )\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z.string({\n description: 'A URL to the repository with the provider',\n }),\n repoContentsUrl: z =>\n z.string({\n description: 'A URL to the root of the repository',\n }),\n projectId: z =>\n z.number({\n description: 'The ID of the project',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the initial commit',\n }),\n created: z =>\n z.boolean({\n description: 'Whether the repository was created or not',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n repoVisibility = 'private',\n defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n setUserAsOwner = false,\n topics = [],\n settings = {},\n branches = [],\n projectVariables = [],\n skipExisting = false,\n signCommit,\n } = ctx.input;\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !ctx.input.token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = ctx.input.token || integrationConfig.config.token!;\n const tokenType = ctx.input.token ? 'oauthToken' : 'token';\n\n const client = new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n\n let targetNamespaceId;\n let targetNamespaceKind;\n try {\n const namespaceResponse = (await client.Namespaces.show(owner)) as {\n id: number;\n kind: string;\n };\n\n targetNamespaceId = namespaceResponse.id;\n targetNamespaceKind = namespaceResponse.kind;\n } catch (e) {\n if (e.cause?.response?.status === 404) {\n throw new InputError(\n `The namespace ${owner} is not found or the user doesn't have permissions to access it`,\n );\n }\n throw e;\n }\n\n const { id: userId } = (await client.Users.showCurrentUser()) as {\n id: number;\n };\n\n if (!targetNamespaceId) {\n targetNamespaceId = userId;\n targetNamespaceKind = 'user';\n }\n\n const existingProjects =\n targetNamespaceKind === 'user'\n ? await client.Users.allProjects(owner, { search: repo })\n : await client.Groups.allProjects(owner, { search: repo });\n\n const existingProject = existingProjects.find(\n project => project.path === repo,\n );\n\n if (!skipExisting || (skipExisting && !existingProject)) {\n ctx.logger.info(`Creating repo ${repo} in namespace ${owner}.`);\n const { id: projectId, http_url_to_repo } =\n await client.Projects.create({\n namespaceId: targetNamespaceId,\n name: repo,\n visibility: repoVisibility,\n ...(topics.length ? { topics } : {}),\n ...(Object.keys(settings).length ? { ...settings } : {}),\n });\n\n // When setUserAsOwner is true the input token is expected to come from an unprivileged user GitLab\n // OAuth flow. In this case GitLab works in a way that allows the unprivileged user to\n // create the repository, but not to push the default protected branch (e.g. master).\n // In order to set the user as owner of the newly created repository we need to check that the\n // GitLab integration configuration for the matching host contains a token and use\n // such token to bootstrap a new privileged client.\n if (setUserAsOwner && integrationConfig.config.token) {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n await adminClient.ProjectMembers.add(projectId, userId, 50);\n }\n\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const shouldSkipPublish =\n typeof ctx.input.sourcePath === 'boolean' && !ctx.input.sourcePath;\n if (!shouldSkipPublish) {\n const commitResult = await initRepoAndPush({\n dir:\n typeof ctx.input.sourcePath === 'boolean'\n ? ctx.workspacePath\n : getRepoSourceDirectory(\n ctx.workspacePath,\n ctx.input.sourcePath,\n ),\n remoteUrl: http_url_to_repo as string,\n defaultBranch,\n auth: {\n username: 'oauth2',\n password: token,\n },\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n if (branches) {\n for (const branch of branches) {\n const {\n name,\n protect = false,\n create = false,\n ref = 'master',\n } = branch;\n\n if (create) {\n try {\n await client.Branches.create(projectId, name, ref);\n } catch (e) {\n throw new InputError(\n `Branch creation failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(\n `Branch ${name} created for ${projectId} with ref ${ref}`,\n );\n }\n\n if (protect) {\n try {\n await client.ProtectedBranches.protect(projectId, name);\n } catch (e) {\n throw new InputError(\n `Branch protection failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(`Branch ${name} protected for ${projectId}`);\n }\n }\n }\n ctx.output('commitHash', commitResult?.commitHash);\n }\n\n if (projectVariables) {\n for (const variable of projectVariables) {\n const variableWithDefaults = Object.assign(variable, {\n variable_type: (variable.variable_type ??\n 'env_var') as VariableType,\n protected: variable.protected ?? false,\n masked: variable.masked ?? false,\n raw: variable.raw ?? false,\n environment_scope: variable.environment_scope ?? '*',\n });\n\n try {\n await client.ProjectVariables.create(\n projectId,\n variableWithDefaults.key,\n variableWithDefaults.value,\n {\n variableType: variableWithDefaults.variable_type,\n protected: variableWithDefaults.protected,\n masked: variableWithDefaults.masked,\n environmentScope: variableWithDefaults.environment_scope,\n description: variableWithDefaults.description,\n raw: variableWithDefaults.raw,\n },\n );\n } catch (e) {\n throw new InputError(\n `Environment variable creation failed for ${\n variableWithDefaults.key\n }. ${printGitlabError(e)}`,\n );\n }\n }\n }\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('projectId', projectId);\n ctx.output('created', true);\n } else if (existingProject) {\n ctx.logger.info(`Repo ${repo} already exists in namespace ${owner}.`);\n const {\n id: projectId,\n http_url_to_repo,\n default_branch,\n } = existingProject;\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', `${remoteUrl}/-/blob/${default_branch}`);\n ctx.output('projectId', projectId);\n ctx.output('created', false);\n }\n },\n });\n}\n\nfunction printGitlabError(error: any): string {\n return JSON.stringify({ code: error.code, message: error.description });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Gitlab","initRepoAndPush","getRepoSourceDirectory"],"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,KAAA,EAAoB;AAC5C,EAAA,OAAO,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,MAAM,IAAA,EAAM,OAAA,EAAS,KAAA,CAAM,WAAA,EAAa,CAAA;AACxE;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlab.cjs.js","sources":["../../src/actions/gitlab.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Gitlab, VariableType } from '@gitbeaker/rest';\nimport { Config } from '@backstage/config';\nimport { examples } from './gitlab.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitLab.\n *\n * @public\n */\nexport function createPublishGitlabAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:gitlab',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to GitLab.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n repoVisibility: z =>\n z\n .enum(['private', 'public', 'internal'], {\n description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`,\n })\n .optional(),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'master'`,\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the default author email for the commit.`,\n })\n .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n sourcePath: z =>\n z\n .union([z.string(), z.boolean()], {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted or set to true, the entire workspace will be published as the repository. If set to false, the created repository will be empty.',\n })\n .optional(),\n skipExisting: z =>\n z\n .boolean({\n description:\n 'Do not publish the repository if it already exists. The default value is false.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n setUserAsOwner: z =>\n z\n .boolean({\n description:\n 'Set the token user as owner of the newly created repository. Requires a token authorized to do the edit in the integration configuration for the matching host',\n })\n .optional(),\n topics: z =>\n z\n .array(z.string(), {\n description:\n 'Topic labels to apply on the repository. (deprecated, use settings.topics instead)',\n })\n .optional(),\n settings: z =>\n z\n .object({\n path: z\n .string({\n description:\n 'Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes).',\n })\n .optional(),\n auto_devops_enabled: z\n .boolean({\n description: 'Enable Auto DevOps for this project',\n })\n .optional(),\n ci_config_path: z\n .string({\n description: 'Custom CI config path for this project',\n })\n .optional(),\n description: z\n .string({\n description: 'Short project description',\n })\n .optional(),\n merge_method: z\n .enum(['merge', 'rebase_merge', 'ff'], {\n description: 'Merge Methods (merge, rebase_merge, ff)',\n })\n .optional(),\n squash_option: z\n .enum(['default_off', 'default_on', 'never', 'always'], {\n description:\n 'Set squash option for the project (never, always, default_on, default_off)',\n })\n .optional(),\n topics: z\n .array(z.string(), {\n description: 'Topic labels to apply on the repository',\n })\n .optional(),\n visibility: z\n .enum(['private', 'public', 'internal'], {\n description:\n 'The visibility of the project. Can be private, internal, or public. The default value is private.',\n })\n .optional(),\n only_allow_merge_if_all_discussions_are_resolved: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged when all the discussions are resolved.',\n })\n .optional(),\n only_allow_merge_if_pipeline_succeeds: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged with successful pipelines. This setting is named Pipelines must succeed in the project settings.',\n })\n .optional(),\n allow_merge_on_skipped_pipeline: z\n .boolean({\n description:\n 'Set whether or not merge requests can be merged with skipped jobs.',\n })\n .optional(),\n })\n .optional(),\n branches: z =>\n z\n .array(\n z.object({\n name: z.string(),\n protect: z.boolean().optional(),\n create: z.boolean().optional(),\n ref: z.string().optional(),\n }),\n )\n .optional(),\n projectVariables: z =>\n z\n .array(\n z.object({\n key: z.string(),\n value: z.string(),\n description: z.string().optional(),\n variable_type: z.enum(['env_var', 'file']).optional(),\n protected: z.boolean().optional(),\n masked: z.boolean().optional(),\n masked_and_hidden: z.boolean().optional(),\n raw: z.boolean().optional(),\n environment_scope: z.string().optional(),\n }),\n )\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z.string({\n description: 'A URL to the repository with the provider',\n }),\n repoContentsUrl: z =>\n z.string({\n description: 'A URL to the root of the repository',\n }),\n projectId: z =>\n z.number({\n description: 'The ID of the project',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the initial commit',\n }),\n created: z =>\n z.boolean({\n description: 'Whether the repository was created or not',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n repoVisibility = 'private',\n defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n setUserAsOwner = false,\n topics = [],\n settings = {},\n branches = [],\n projectVariables = [],\n skipExisting = false,\n signCommit,\n } = ctx.input;\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !ctx.input.token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = ctx.input.token || integrationConfig.config.token!;\n const tokenType = ctx.input.token ? 'oauthToken' : 'token';\n\n const client = new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n\n let targetNamespaceId;\n let targetNamespaceKind;\n try {\n const namespaceResponse = (await client.Namespaces.show(owner)) as {\n id: number;\n kind: string;\n };\n\n targetNamespaceId = namespaceResponse.id;\n targetNamespaceKind = namespaceResponse.kind;\n } catch (e) {\n if (e.cause?.response?.status === 404) {\n throw new InputError(\n `The namespace ${owner} is not found or the user doesn't have permissions to access it`,\n );\n }\n throw e;\n }\n\n const { id: userId } = (await client.Users.showCurrentUser()) as {\n id: number;\n };\n\n if (!targetNamespaceId) {\n targetNamespaceId = userId;\n targetNamespaceKind = 'user';\n }\n\n const existingProjects =\n targetNamespaceKind === 'user'\n ? await client.Users.allProjects(owner, { search: repo })\n : await client.Groups.allProjects(owner, { search: repo });\n\n const existingProject = existingProjects.find(\n project => project.path === repo,\n );\n\n if (!skipExisting || (skipExisting && !existingProject)) {\n ctx.logger.info(`Creating repo ${repo} in namespace ${owner}.`);\n const { id: projectId, http_url_to_repo } =\n await client.Projects.create({\n namespaceId: targetNamespaceId,\n name: repo,\n visibility: repoVisibility,\n ...(topics.length ? { topics } : {}),\n ...(Object.keys(settings).length ? { ...settings } : {}),\n });\n\n // When setUserAsOwner is true the input token is expected to come from an unprivileged user GitLab\n // OAuth flow. In this case GitLab works in a way that allows the unprivileged user to\n // create the repository, but not to push the default protected branch (e.g. master).\n // In order to set the user as owner of the newly created repository we need to check that the\n // GitLab integration configuration for the matching host contains a token and use\n // such token to bootstrap a new privileged client.\n if (setUserAsOwner && integrationConfig.config.token) {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n await adminClient.ProjectMembers.add(projectId, 50, { userId });\n }\n\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const shouldSkipPublish =\n typeof ctx.input.sourcePath === 'boolean' && !ctx.input.sourcePath;\n if (!shouldSkipPublish) {\n const commitResult = await initRepoAndPush({\n dir:\n typeof ctx.input.sourcePath === 'boolean'\n ? ctx.workspacePath\n : getRepoSourceDirectory(\n ctx.workspacePath,\n ctx.input.sourcePath,\n ),\n remoteUrl: http_url_to_repo as string,\n defaultBranch,\n auth: {\n username: 'oauth2',\n password: token,\n },\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n if (branches) {\n for (const branch of branches) {\n const {\n name,\n protect = false,\n create = false,\n ref = 'master',\n } = branch;\n\n if (create) {\n try {\n await client.Branches.create(projectId, name, ref);\n } catch (e) {\n throw new InputError(\n `Branch creation failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(\n `Branch ${name} created for ${projectId} with ref ${ref}`,\n );\n }\n\n if (protect) {\n try {\n await client.ProtectedBranches.protect(projectId, name);\n } catch (e) {\n throw new InputError(\n `Branch protection failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(`Branch ${name} protected for ${projectId}`);\n }\n }\n }\n ctx.output('commitHash', commitResult?.commitHash);\n }\n\n if (projectVariables) {\n for (const variable of projectVariables) {\n const variableWithDefaults = Object.assign(variable, {\n variable_type: (variable.variable_type ??\n 'env_var') as VariableType,\n protected: variable.protected ?? false,\n masked: variable.masked ?? false,\n masked_and_hidden: variable.masked_and_hidden ?? false,\n raw: variable.raw ?? false,\n environment_scope: variable.environment_scope ?? '*',\n });\n\n try {\n await client.ProjectVariables.create(\n projectId,\n variableWithDefaults.key,\n variableWithDefaults.value,\n {\n variableType: variableWithDefaults.variable_type,\n protected: variableWithDefaults.protected,\n masked: variableWithDefaults.masked,\n masked_and_hidden: variableWithDefaults.masked_and_hidden,\n environmentScope: variableWithDefaults.environment_scope,\n description: variableWithDefaults.description,\n raw: variableWithDefaults.raw,\n },\n );\n } catch (e) {\n throw new InputError(\n `Environment variable creation failed for ${\n variableWithDefaults.key\n }. ${printGitlabError(e)}`,\n );\n }\n }\n }\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('projectId', projectId);\n ctx.output('created', true);\n } else if (existingProject) {\n ctx.logger.info(`Repo ${repo} already exists in namespace ${owner}.`);\n const {\n id: projectId,\n http_url_to_repo,\n default_branch,\n } = existingProject;\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', `${remoteUrl}/-/blob/${default_branch}`);\n ctx.output('projectId', projectId);\n ctx.output('created', false);\n }\n },\n });\n}\n\nfunction printGitlabError(error: any): string {\n return JSON.stringify({ code: error.code, message: error.description });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Gitlab","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AAkCO,SAAS,0BAA0B,OAAA,EAGvC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAA,EAAO,GAAI,OAAA;AAEjC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAA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A,OAAO,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,MAAM,IAAA,EAAM,OAAA,EAAS,KAAA,CAAM,WAAA,EAAa,CAAA;AACxE;;;;"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var errors = require('@backstage/errors');
|
|
4
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
5
|
+
var util = require('../util.cjs.js');
|
|
6
|
+
var gitlabGroupAccessAction_examples = require('./gitlabGroupAccessAction.examples.cjs.js');
|
|
7
|
+
|
|
8
|
+
const accessLevelMapping = {
|
|
9
|
+
no_access: 0,
|
|
10
|
+
minimal_access: 5,
|
|
11
|
+
guest: 10,
|
|
12
|
+
planner: 15,
|
|
13
|
+
reporter: 20,
|
|
14
|
+
developer: 30,
|
|
15
|
+
maintainer: 40,
|
|
16
|
+
owner: 50
|
|
17
|
+
};
|
|
18
|
+
function resolveAccessLevel(level) {
|
|
19
|
+
if (typeof level === "number") return level;
|
|
20
|
+
const resolved = accessLevelMapping[level.toLocaleLowerCase("en-US")];
|
|
21
|
+
if (resolved === void 0) {
|
|
22
|
+
throw new errors.InputError(
|
|
23
|
+
`Invalid access level: "${level}". Valid values are: ${Object.keys(
|
|
24
|
+
accessLevelMapping
|
|
25
|
+
).join(", ")} or a numeric GitLab access level`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return resolved;
|
|
29
|
+
}
|
|
30
|
+
const createGitlabGroupAccessAction = (options) => {
|
|
31
|
+
const { integrations } = options;
|
|
32
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
33
|
+
id: "gitlab:group:access",
|
|
34
|
+
description: "Adds or removes users and groups from a GitLab group",
|
|
35
|
+
supportsDryRun: true,
|
|
36
|
+
examples: gitlabGroupAccessAction_examples.examples,
|
|
37
|
+
schema: {
|
|
38
|
+
input: {
|
|
39
|
+
repoUrl: (z) => z.string({
|
|
40
|
+
description: "The host of the GitLab instance, for example 'gitlab.com' or 'gitlab.my-company.com'."
|
|
41
|
+
}),
|
|
42
|
+
token: (z) => z.string({
|
|
43
|
+
description: "The token to use for authorization to GitLab"
|
|
44
|
+
}).optional(),
|
|
45
|
+
path: (z) => z.union([z.number(), z.string()], {
|
|
46
|
+
description: "The ID or path of the group to add/remove members from"
|
|
47
|
+
}),
|
|
48
|
+
userIds: (z) => z.array(z.number(), {
|
|
49
|
+
description: "The IDs of the users to add/remove"
|
|
50
|
+
}).optional(),
|
|
51
|
+
groupIds: (z) => z.array(z.number(), {
|
|
52
|
+
description: "The IDs of the groups to share with or unshare from the target group"
|
|
53
|
+
}).optional(),
|
|
54
|
+
action: (z) => z.enum(["add", "remove"], {
|
|
55
|
+
description: 'The action to perform: add or remove the members. Defaults to "add".'
|
|
56
|
+
}).default("add").optional(),
|
|
57
|
+
accessLevel: (z) => z.union([z.number(), z.string()], {
|
|
58
|
+
description: 'The access level for the members. Can be a number (0=No access, 5=Minimal access, 10=Guest, 15=Planner, 20=Reporter, 30=Developer, 40=Maintainer, 50=Owner) or a string (e.g., "guest", "developer"). Defaults to 30 (Developer).'
|
|
59
|
+
}).default(30).optional()
|
|
60
|
+
},
|
|
61
|
+
output: {
|
|
62
|
+
userIds: (z) => z.array(z.number(), {
|
|
63
|
+
description: "The IDs of the users that were added or removed"
|
|
64
|
+
}).optional(),
|
|
65
|
+
groupIds: (z) => z.array(z.number(), {
|
|
66
|
+
description: "The IDs of the groups that were shared with or unshared from"
|
|
67
|
+
}).optional(),
|
|
68
|
+
path: (z) => z.union([z.number(), z.string()], {
|
|
69
|
+
description: "The ID or path of the group the members were added to or removed from"
|
|
70
|
+
}).optional(),
|
|
71
|
+
accessLevel: (z) => z.number({
|
|
72
|
+
description: "The access level granted to the members (only for add action)"
|
|
73
|
+
}).optional()
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
async handler(ctx) {
|
|
77
|
+
const {
|
|
78
|
+
token,
|
|
79
|
+
repoUrl,
|
|
80
|
+
path,
|
|
81
|
+
userIds = [],
|
|
82
|
+
groupIds = [],
|
|
83
|
+
accessLevel: rawAccessLevel = 30,
|
|
84
|
+
action = "add"
|
|
85
|
+
} = ctx.input;
|
|
86
|
+
if (userIds.length === 0 && groupIds.length === 0) {
|
|
87
|
+
throw new errors.InputError(
|
|
88
|
+
"At least one of userIds or groupIds must be provided and non-empty"
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const accessLevel = resolveAccessLevel(rawAccessLevel);
|
|
92
|
+
if (ctx.isDryRun) {
|
|
93
|
+
if (userIds.length > 0) {
|
|
94
|
+
ctx.output("userIds", userIds);
|
|
95
|
+
}
|
|
96
|
+
if (groupIds.length > 0) {
|
|
97
|
+
ctx.output("groupIds", groupIds);
|
|
98
|
+
}
|
|
99
|
+
ctx.output("path", path);
|
|
100
|
+
if (action === "add") {
|
|
101
|
+
ctx.output("accessLevel", accessLevel);
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const host = util.parseRepoHost(repoUrl);
|
|
106
|
+
const api = util.getClient({ host, integrations, token });
|
|
107
|
+
for (const userId of userIds) {
|
|
108
|
+
ctx.logger.info(
|
|
109
|
+
`${action === "add" ? "Adding" : "Removing"} user ${userId} ${action === "add" ? "to" : "from"} group ${path}`
|
|
110
|
+
);
|
|
111
|
+
await ctx.checkpoint({
|
|
112
|
+
key: `gitlab.group.member.user.${action}.${path}.${userId}`,
|
|
113
|
+
fn: async () => {
|
|
114
|
+
if (action === "add") {
|
|
115
|
+
try {
|
|
116
|
+
await api.GroupMembers.add(
|
|
117
|
+
path,
|
|
118
|
+
accessLevel,
|
|
119
|
+
{ userId }
|
|
120
|
+
);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error.cause?.response?.status === 409) {
|
|
123
|
+
await api.GroupMembers.edit(
|
|
124
|
+
path,
|
|
125
|
+
userId,
|
|
126
|
+
accessLevel
|
|
127
|
+
);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
await api.GroupMembers.remove(path, userId);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
for (const sharedGroupId of groupIds) {
|
|
139
|
+
ctx.logger.info(
|
|
140
|
+
`${action === "add" ? "Adding" : "Removing"} group ${sharedGroupId} ${action === "add" ? "to" : "from"} group ${path}`
|
|
141
|
+
);
|
|
142
|
+
await ctx.checkpoint({
|
|
143
|
+
key: `gitlab.group.member.group.${action}.${path}.${sharedGroupId}`,
|
|
144
|
+
fn: async () => {
|
|
145
|
+
if (action === "add") {
|
|
146
|
+
try {
|
|
147
|
+
await api.Groups.share(path, sharedGroupId, accessLevel, {});
|
|
148
|
+
} catch (error) {
|
|
149
|
+
if (error.cause?.response?.status === 409) {
|
|
150
|
+
await api.Groups.unshare(path, sharedGroupId, {});
|
|
151
|
+
await api.Groups.share(path, sharedGroupId, accessLevel, {});
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
await api.Groups.unshare(path, sharedGroupId, {});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
ctx.output("path", path);
|
|
163
|
+
if (userIds.length > 0) {
|
|
164
|
+
ctx.output("userIds", userIds);
|
|
165
|
+
}
|
|
166
|
+
if (groupIds.length > 0) {
|
|
167
|
+
ctx.output("groupIds", groupIds);
|
|
168
|
+
}
|
|
169
|
+
if (action === "add") {
|
|
170
|
+
ctx.output("accessLevel", accessLevel);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
exports.createGitlabGroupAccessAction = createGitlabGroupAccessAction;
|
|
177
|
+
//# sourceMappingURL=gitlabGroupAccessAction.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitlabGroupAccessAction.cjs.js","sources":["../../src/actions/gitlabGroupAccessAction.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { AccessLevel } from '@gitbeaker/core';\nimport { getClient, parseRepoHost } from '../util';\nimport { examples } from './gitlabGroupAccessAction.examples';\n\ntype NonAdminAccessLevel = Exclude<AccessLevel, AccessLevel.ADMIN>;\n\nconst accessLevelMapping: Record<string, number> = {\n no_access: 0,\n minimal_access: 5,\n guest: 10,\n planner: 15,\n reporter: 20,\n developer: 30,\n maintainer: 40,\n owner: 50,\n};\n\nfunction resolveAccessLevel(level: string | number): number {\n if (typeof level === 'number') return level;\n const resolved = accessLevelMapping[level.toLocaleLowerCase('en-US')];\n if (resolved === undefined) {\n throw new InputError(\n `Invalid access level: \"${level}\". Valid values are: ${Object.keys(\n accessLevelMapping,\n ).join(', ')} or a numeric GitLab access level`,\n );\n }\n return resolved;\n}\n\n/**\n * Creates a `gitlab:group:access` Scaffolder action.\n *\n * @public\n */\nexport const createGitlabGroupAccessAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:access',\n description: 'Adds or removes users and groups from a GitLab group',\n supportsDryRun: true,\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n \"The host of the GitLab instance, for example 'gitlab.com' or 'gitlab.my-company.com'.\",\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n path: z =>\n z.union([z.number(), z.string()], {\n description:\n 'The ID or path of the group to add/remove members from',\n }),\n userIds: z =>\n z\n .array(z.number(), {\n description: 'The IDs of the users to add/remove',\n })\n .optional(),\n groupIds: z =>\n z\n .array(z.number(), {\n description:\n 'The IDs of the groups to share with or unshare from the target group',\n })\n .optional(),\n action: z =>\n z\n .enum(['add', 'remove'], {\n description:\n 'The action to perform: add or remove the members. Defaults to \"add\".',\n })\n .default('add')\n .optional(),\n accessLevel: z =>\n z\n .union([z.number(), z.string()], {\n description:\n 'The access level for the members. Can be a number (0=No access, 5=Minimal access, 10=Guest, 15=Planner, 20=Reporter, 30=Developer, 40=Maintainer, 50=Owner) or a string (e.g., \"guest\", \"developer\"). Defaults to 30 (Developer).',\n })\n .default(30)\n .optional(),\n },\n output: {\n userIds: z =>\n z\n .array(z.number(), {\n description: 'The IDs of the users that were added or removed',\n })\n .optional(),\n groupIds: z =>\n z\n .array(z.number(), {\n description:\n 'The IDs of the groups that were shared with or unshared from',\n })\n .optional(),\n path: z =>\n z\n .union([z.number(), z.string()], {\n description:\n 'The ID or path of the group the members were added to or removed from',\n })\n .optional(),\n accessLevel: z =>\n z\n .number({\n description:\n 'The access level granted to the members (only for add action)',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n token,\n repoUrl,\n path,\n userIds = [],\n groupIds = [],\n accessLevel: rawAccessLevel = 30,\n action = 'add',\n } = ctx.input;\n\n if (userIds.length === 0 && groupIds.length === 0) {\n throw new InputError(\n 'At least one of userIds or groupIds must be provided and non-empty',\n );\n }\n\n const accessLevel = resolveAccessLevel(rawAccessLevel);\n\n if (ctx.isDryRun) {\n if (userIds.length > 0) {\n ctx.output('userIds', userIds);\n }\n if (groupIds.length > 0) {\n ctx.output('groupIds', groupIds);\n }\n ctx.output('path', path);\n if (action === 'add') {\n ctx.output('accessLevel', accessLevel);\n }\n return;\n }\n\n const host = parseRepoHost(repoUrl);\n\n const api = getClient({ host, integrations, token });\n\n // Process users\n for (const userId of userIds) {\n ctx.logger.info(\n `${action === 'add' ? 'Adding' : 'Removing'} user ${userId} ${\n action === 'add' ? 'to' : 'from'\n } group ${path}`,\n );\n await ctx.checkpoint({\n key: `gitlab.group.member.user.${action}.${path}.${userId}`,\n fn: async () => {\n if (action === 'add') {\n try {\n await api.GroupMembers.add(\n path,\n accessLevel as NonAdminAccessLevel,\n { userId },\n );\n } catch (error: any) {\n // If member already exists, try to edit instead\n if (error.cause?.response?.status === 409) {\n await api.GroupMembers.edit(\n path,\n userId,\n accessLevel as NonAdminAccessLevel,\n );\n return;\n }\n throw error;\n }\n } else {\n await api.GroupMembers.remove(path, userId);\n }\n },\n });\n }\n\n // Process groups\n for (const sharedGroupId of groupIds) {\n ctx.logger.info(\n `${action === 'add' ? 'Adding' : 'Removing'} group ${sharedGroupId} ${\n action === 'add' ? 'to' : 'from'\n } group ${path}`,\n );\n await ctx.checkpoint({\n key: `gitlab.group.member.group.${action}.${path}.${sharedGroupId}`,\n fn: async () => {\n if (action === 'add') {\n try {\n await api.Groups.share(path, sharedGroupId, accessLevel, {});\n } catch (error: any) {\n // If group is already shared, unshare and re-share\n if (error.cause?.response?.status === 409) {\n await api.Groups.unshare(path, sharedGroupId, {});\n await api.Groups.share(path, sharedGroupId, accessLevel, {});\n return;\n }\n throw error;\n }\n } else {\n await api.Groups.unshare(path, sharedGroupId, {});\n }\n },\n });\n }\n\n ctx.output('path', path);\n\n if (userIds.length > 0) {\n ctx.output('userIds', userIds);\n }\n if (groupIds.length > 0) {\n ctx.output('groupIds', groupIds);\n }\n\n if (action === 'add') {\n ctx.output('accessLevel', accessLevel);\n }\n },\n });\n};\n"],"names":["InputError","createTemplateAction","examples","parseRepoHost","getClient"],"mappings":";;;;;;;AAyBA,MAAM,kBAAA,GAA6C;AAAA,EACjD,SAAA,EAAW,CAAA;AAAA,EACX,cAAA,EAAgB,CAAA;AAAA,EAChB,KAAA,EA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|
4
|
+
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
8
|
+
|
|
9
|
+
const examples = [
|
|
10
|
+
{
|
|
11
|
+
description: "Add users to a group using numeric group ID",
|
|
12
|
+
example: yaml__default.default.stringify({
|
|
13
|
+
steps: [
|
|
14
|
+
{
|
|
15
|
+
id: "gitlabGroupAccess",
|
|
16
|
+
name: "Add Users to Group",
|
|
17
|
+
action: "gitlab:group:access",
|
|
18
|
+
input: {
|
|
19
|
+
repoUrl: "gitlab.com",
|
|
20
|
+
path: 123,
|
|
21
|
+
userIds: [456, 789],
|
|
22
|
+
accessLevel: 30
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
description: "Add users to a group using string path",
|
|
30
|
+
example: yaml__default.default.stringify({
|
|
31
|
+
steps: [
|
|
32
|
+
{
|
|
33
|
+
id: "gitlabGroupAccess",
|
|
34
|
+
name: "Add Users to Group",
|
|
35
|
+
action: "gitlab:group:access",
|
|
36
|
+
input: {
|
|
37
|
+
repoUrl: "gitlab.com",
|
|
38
|
+
path: "group1",
|
|
39
|
+
userIds: [456],
|
|
40
|
+
accessLevel: "developer"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
description: "Remove users from a group",
|
|
48
|
+
example: yaml__default.default.stringify({
|
|
49
|
+
steps: [
|
|
50
|
+
{
|
|
51
|
+
id: "gitlabGroupAccess",
|
|
52
|
+
name: "Remove Users from Group",
|
|
53
|
+
action: "gitlab:group:access",
|
|
54
|
+
input: {
|
|
55
|
+
repoUrl: "gitlab.com",
|
|
56
|
+
path: 123,
|
|
57
|
+
userIds: [456, 789],
|
|
58
|
+
action: "remove"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
description: "Share a group with another group",
|
|
66
|
+
example: yaml__default.default.stringify({
|
|
67
|
+
steps: [
|
|
68
|
+
{
|
|
69
|
+
id: "gitlabGroupAccess",
|
|
70
|
+
name: "Share Group",
|
|
71
|
+
action: "gitlab:group:access",
|
|
72
|
+
input: {
|
|
73
|
+
repoUrl: "gitlab.com",
|
|
74
|
+
path: 123,
|
|
75
|
+
groupIds: [456],
|
|
76
|
+
accessLevel: 30
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
description: "Unshare a group",
|
|
84
|
+
example: yaml__default.default.stringify({
|
|
85
|
+
steps: [
|
|
86
|
+
{
|
|
87
|
+
id: "gitlabGroupAccess",
|
|
88
|
+
name: "Unshare Group",
|
|
89
|
+
action: "gitlab:group:access",
|
|
90
|
+
input: {
|
|
91
|
+
repoUrl: "gitlab.com",
|
|
92
|
+
path: 123,
|
|
93
|
+
groupIds: [456],
|
|
94
|
+
action: "remove"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
exports.examples = examples;
|
|
103
|
+
//# sourceMappingURL=gitlabGroupAccessAction.examples.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitlabGroupAccessAction.examples.cjs.js","sources":["../../src/actions/gitlabGroupAccessAction.examples.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Add users to a group using numeric group ID',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroupAccess',\n name: 'Add Users to Group',\n action: 'gitlab:group:access',\n input: {\n repoUrl: 'gitlab.com',\n path: 123,\n userIds: [456, 789],\n accessLevel: 30,\n },\n },\n ],\n }),\n },\n {\n description: 'Add users to a group using string path',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroupAccess',\n name: 'Add Users to Group',\n action: 'gitlab:group:access',\n input: {\n repoUrl: 'gitlab.com',\n path: 'group1',\n userIds: [456],\n accessLevel: 'developer',\n },\n },\n ],\n }),\n },\n {\n description: 'Remove users from a group',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroupAccess',\n name: 'Remove Users from Group',\n action: 'gitlab:group:access',\n input: {\n repoUrl: 'gitlab.com',\n path: 123,\n userIds: [456, 789],\n action: 'remove',\n },\n },\n ],\n }),\n },\n {\n description: 'Share a group with another group',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroupAccess',\n name: 'Share Group',\n action: 'gitlab:group:access',\n input: {\n repoUrl: 'gitlab.com',\n path: 123,\n groupIds: [456],\n accessLevel: 30,\n },\n },\n ],\n }),\n },\n {\n description: 'Unshare a group',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroupAccess',\n name: 'Unshare Group',\n action: 'gitlab:group:access',\n input: {\n repoUrl: 'gitlab.com',\n path: 123,\n groupIds: [456],\n action: 'remove',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,6CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,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AA,UACE,EAAA,EAAI,mBAAA;AAAA,UACJ,IAAA,EAAM,aAAA;AAAA,UACN,MAAA,EAAQ,qBAAA;AAAA,UACR,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,YAAA;AAAA,YACT,IAAA,EAAM,GAAA;AAAA,YACN,QAAA,EAAU,CAAC,GAAG,CAAA;AAAA,YACd,WAAA,EAAa;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,iBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,mBAAA;AAAA,UACJ,IAAA,EAAM,eAAA;AAAA,UACN,MAAA,EAAQ,qBAAA;AAAA,UACR,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,YAAA;AAAA,YACT,IAAA,EAAM,GAAA;AAAA,YACN,QAAA,EAAU,CAAC,GAAG,CAAA;AAAA,YACd,MAAA,EAAQ;AAAA;AACV;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -35,6 +35,9 @@ const createGitlabProjectVariableAction = (options) => {
|
|
|
35
35
|
masked: (z) => z.boolean({
|
|
36
36
|
description: "Whether the variable is masked"
|
|
37
37
|
}).default(false).optional(),
|
|
38
|
+
maskedAndHidden: (z) => z.boolean({
|
|
39
|
+
description: "Whether the variable is masked and hidden"
|
|
40
|
+
}).default(false).optional(),
|
|
38
41
|
raw: (z) => z.boolean({
|
|
39
42
|
description: "Whether the variable is expandable"
|
|
40
43
|
}).default(false).optional(),
|
|
@@ -52,6 +55,7 @@ const createGitlabProjectVariableAction = (options) => {
|
|
|
52
55
|
variableType,
|
|
53
56
|
variableProtected = false,
|
|
54
57
|
masked = false,
|
|
58
|
+
maskedAndHidden = false,
|
|
55
59
|
raw = false,
|
|
56
60
|
environmentScope = "*",
|
|
57
61
|
token
|
|
@@ -65,6 +69,7 @@ const createGitlabProjectVariableAction = (options) => {
|
|
|
65
69
|
variableType,
|
|
66
70
|
protected: variableProtected,
|
|
67
71
|
masked,
|
|
72
|
+
masked_and_hidden: maskedAndHidden,
|
|
68
73
|
raw,
|
|
69
74
|
environmentScope
|
|
70
75
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectVariableCreate.cjs.js","sources":["../../src/actions/gitlabProjectVariableCreate.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { VariableType } from '@gitbeaker/rest';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabProjectVariableCreate.examples';\n\n/**\n * Creates a `gitlab:projectVariable:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectVariableAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectVariable:create',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: z =>\n z\n .string({\n description:\n 'The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed',\n })\n .regex(/^[A-Za-z0-9_]{1,255}$/),\n value: z =>\n z.string({\n description: 'The value of a variable',\n }),\n variableType: z =>\n z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z =>\n z\n .boolean({\n description: 'Whether the variable is protected',\n })\n .default(false)\n .optional(),\n masked: z =>\n z\n .boolean({\n description: 'Whether the variable is masked',\n })\n .default(false)\n .optional(),\n raw: z =>\n z\n .boolean({\n description: 'Whether the variable is expandable',\n })\n .default(false)\n .optional(),\n environmentScope: z =>\n z\n .string({\n description: 'The environment_scope of the variable',\n })\n .default('*')\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n projectId,\n key,\n value,\n variableType,\n variableProtected = false,\n masked = false,\n raw = false,\n environmentScope = '*',\n token,\n } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const api = getClient({ host, integrations, token });\n\n await ctx.checkpoint({\n key: `create.project.variables.${projectId}.${key}.${value}`,\n fn: async () => {\n await api.ProjectVariables.create(projectId, key, value, {\n variableType: variableType as VariableType,\n protected: variableProtected,\n masked,\n raw,\n environmentScope,\n });\n },\n });\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","getClient"],"mappings":";;;;;;AA4BO,MAAM,iCAAA,GAAoC,CAAC,OAAA,KAE5C;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,+BAAA;AAAA,cACJC,6CAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,KAAA,CAAM,CA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MAAA,GAAS,KAAA;AAAA,QACT,GAAA,GAAM,KAAA;AAAA,QACN,gBAAA,GAAmB,GAAA;AAAA,QACnB;AAAA,UACE,GAAA,CAAI,KAAA;AAER,MAAA,MAAM,EAAE,IAAA,EAAK,GAAIC,iBAAA,CAAa,SAAS,YAAY,CAAA;AAEnD,MAAA,MAAM,MAAMC,cAAA,CAAU,EAAE,IAAA,EAAM,YAAA,EAAc,OAAO,CAAA;AAEnD,MAAA,MAAM,IAAI,UAAA,CAAW;AAAA,QACnB,KAAK,CAAA,yBAAA,EAA4B,SAAS,CAAA,CAAA,EAAI,GAAG,IAAI,KAAK,CAAA,CAAA;AAAA,QAC1D,IAAI,YAAY;AACd,UAAA,MAAM,GAAA,CAAI,gBAAA,CAAiB,MAAA,CAAO,SAAA,EAAW,KAAK,KAAA,EAAO;AAAA,YACvD,YAAA;AAAA,YACA,SAAA,EAAW,iBAAA;AAAA,YACX,MAAA;AAAA,YACA,GAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlabProjectVariableCreate.cjs.js","sources":["../../src/actions/gitlabProjectVariableCreate.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { VariableType } from '@gitbeaker/rest';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabProjectVariableCreate.examples';\n\n/**\n * Creates a `gitlab:projectVariable:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectVariableAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectVariable:create',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: z =>\n z\n .string({\n description:\n 'The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed',\n })\n .regex(/^[A-Za-z0-9_]{1,255}$/),\n value: z =>\n z.string({\n description: 'The value of a variable',\n }),\n variableType: z =>\n z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z =>\n z\n .boolean({\n description: 'Whether the variable is protected',\n })\n .default(false)\n .optional(),\n masked: z =>\n z\n .boolean({\n description: 'Whether the variable is masked',\n })\n .default(false)\n .optional(),\n maskedAndHidden: z =>\n z\n .boolean({\n description: 'Whether the variable is masked and hidden',\n })\n .default(false)\n .optional(),\n raw: z =>\n z\n .boolean({\n description: 'Whether the variable is expandable',\n })\n .default(false)\n .optional(),\n environmentScope: z =>\n z\n .string({\n description: 'The environment_scope of the variable',\n })\n .default('*')\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n projectId,\n key,\n value,\n variableType,\n variableProtected = false,\n masked = false,\n maskedAndHidden = false,\n raw = false,\n environmentScope = '*',\n token,\n } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const api = getClient({ host, integrations, token });\n\n await ctx.checkpoint({\n key: `create.project.variables.${projectId}.${key}.${value}`,\n fn: async () => {\n await api.ProjectVariables.create(projectId, key, value, {\n variableType: variableType as VariableType,\n protected: variableProtected,\n masked,\n masked_and_hidden: maskedAndHidden,\n raw,\n environmentScope,\n });\n },\n });\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","getClient"],"mappings":";;;;;;AA4BO,MAAM,iCAAA,GAAoC,CAAC,OAAA,KAE5C;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,+BAAA;AAAA,cACJC,6CAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CAAE,MAAA,EAAO,EAAG,CAAA,CAAE,MAAA,EAAQ,CAAA,EAAG;AAAA,UAChC,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,CAAA,CACA,KAAA,CAAM,uBAAuB,CAAA;AAAA,QAClC,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,YAAA,EAAc,CAAA,CAAA,KACZ,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,iBAAA,EAAmB,CAAA,CAAA,KACjB,CAAA,CACG,OAAA,CAAQ;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA,CACA,OAAA,CAAQ,KAAK,EACb,QAA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IAAI,YAAY;AACd,UAAA,MAAM,GAAA,CAAI,gBAAA,CAAiB,MAAA,CAAO,SAAA,EAAW,KAAK,KAAA,EAAO;AAAA,YACvD,YAAA;AAAA,YACA,SAAA,EAAW,iBAAA;AAAA,YACX,MAAA;AAAA,YACA,iBAAA,EAAmB,eAAA;AAAA,YACnB,GAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -144,6 +144,26 @@ const examples = [
|
|
|
144
144
|
}
|
|
145
145
|
]
|
|
146
146
|
})
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
description: "Create a GitLab project variable that is masked and hidden.",
|
|
150
|
+
example: yaml__default.default.stringify({
|
|
151
|
+
steps: [
|
|
152
|
+
{
|
|
153
|
+
id: "createVariable",
|
|
154
|
+
action: "gitlab:projectVariable:create",
|
|
155
|
+
name: "Create GitLab Project Variable",
|
|
156
|
+
input: {
|
|
157
|
+
repoUrl: "gitlab.com?repo=repo&owner=owner",
|
|
158
|
+
projectId: "999",
|
|
159
|
+
key: "SECRET_TOKEN",
|
|
160
|
+
value: "super-secret-token",
|
|
161
|
+
variableType: "env_var",
|
|
162
|
+
maskedAndHidden: true
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
})
|
|
147
167
|
}
|
|
148
168
|
];
|
|
149
169
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectVariableCreate.examples.cjs.js","sources":["../../src/actions/gitlabProjectVariableCreate.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Creating a GitLab project variable of type env_var',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n },\n },\n ],\n }),\n },\n {\n description: 'Creating a GitLab project variable of type file',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my-file-content',\n variableType: 'file',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is protected.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n variableProtected: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable with masked flag as true',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n key: 'DB_PASSWORD',\n value: 'password123',\n variableType: 'env_var',\n masked: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is expandable.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n raw: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project variable with a specific environment scope.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n environmentScope: 'production',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project variable with a wildcard environment scope.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n environmentScope: '*',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,oDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,gBAAA;AAAA,UACJ,MAAA,EAAQ,0CAAA;AAAA,UACR,IAAA,EAAM,gCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,GAAA,EAAK,aAAA;AAAA,YACL,KAAA,EAAO,UAAA;AAAA,YACP,YAAA,EAAc;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE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ACF,KACD;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlabProjectVariableCreate.examples.cjs.js","sources":["../../src/actions/gitlabProjectVariableCreate.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Creating a GitLab project variable of type env_var',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n },\n },\n ],\n }),\n },\n {\n description: 'Creating a GitLab project variable of type file',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my-file-content',\n variableType: 'file',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is protected.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n variableProtected: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable with masked flag as true',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n key: 'DB_PASSWORD',\n value: 'password123',\n variableType: 'env_var',\n masked: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is expandable.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n raw: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project variable with a specific environment scope.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n environmentScope: 'production',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project variable with a wildcard environment scope.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n environmentScope: '*',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is masked and hidden.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '999',\n key: 'SECRET_TOKEN',\n value: 'super-secret-token',\n variableType: 'env_var',\n maskedAndHidden: true,\n },\n },\n ],\n }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CAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,GAAA,EAAK,aAAA;AAAA,YACL,KAAA,EAAO,UAAA;AAAA,YACP,YAAA,EAAc,SAAA;AAAA,YACd,gBAAA,EAAkB;AAAA;AACpB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,qEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,gBAAA;AAAA,UACJ,MAAA,EAAQ,+BAAA;AAAA,UACR,IAAA,EAAM,gCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,GAAA,EAAK,aAAA;AAAA,YACL,KAAA,EAAO,UAAA;AAAA,YACP,YAAA,EAAc,SAAA;AAAA,YACd,gBAAA,EAAkB;AAAA;AACpB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,6DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,gBAAA;AAAA,UACJ,MAAA,EAAQ,+BAAA;AAAA,UACR,IAAA,EAAM,gCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,GAAA,EAAK,cAAA;AAAA,YACL,KAAA,EAAO,oBAAA;AAAA,YACP,YAAA,EAAc,SAAA;AAAA,YACd,eAAA,EAAiB;AAAA;AACnB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var gitlab = require('./actions/gitlab.cjs.js');
|
|
6
6
|
var gitlabGroupEnsureExists = require('./actions/gitlabGroupEnsureExists.cjs.js');
|
|
7
|
+
var gitlabGroupAccessAction = require('./actions/gitlabGroupAccessAction.cjs.js');
|
|
7
8
|
var gitlabIssueCreate = require('./actions/gitlabIssueCreate.cjs.js');
|
|
8
9
|
var gitlabIssueEdit = require('./actions/gitlabIssueEdit.cjs.js');
|
|
9
10
|
var gitlabMergeRequest = require('./actions/gitlabMergeRequest.cjs.js');
|
|
@@ -20,6 +21,7 @@ var module$1 = require('./module.cjs.js');
|
|
|
20
21
|
|
|
21
22
|
exports.createPublishGitlabAction = gitlab.createPublishGitlabAction;
|
|
22
23
|
exports.createGitlabGroupEnsureExistsAction = gitlabGroupEnsureExists.createGitlabGroupEnsureExistsAction;
|
|
24
|
+
exports.createGitlabGroupAccessAction = gitlabGroupAccessAction.createGitlabGroupAccessAction;
|
|
23
25
|
exports.createGitlabIssueAction = gitlabIssueCreate.createGitlabIssueAction;
|
|
24
26
|
exports.editGitlabIssueAction = gitlabIssueEdit.editGitlabIssueAction;
|
|
25
27
|
exports.createPublishGitlabMergeRequestAction = gitlabMergeRequest.createPublishGitlabMergeRequestAction;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ declare function createPublishGitlabAction(options: {
|
|
|
53
53
|
variable_type?: "file" | "env_var" | undefined;
|
|
54
54
|
masked?: boolean | undefined;
|
|
55
55
|
environment_scope?: string | undefined;
|
|
56
|
+
masked_and_hidden?: boolean | undefined;
|
|
56
57
|
}[] | undefined;
|
|
57
58
|
}, {
|
|
58
59
|
remoteUrl: string;
|
|
@@ -81,6 +82,28 @@ declare const createGitlabGroupEnsureExistsAction: (options: {
|
|
|
81
82
|
groupId?: number | undefined;
|
|
82
83
|
}, "v2">;
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Creates a `gitlab:group:access` Scaffolder action.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
declare const createGitlabGroupAccessAction: (options: {
|
|
91
|
+
integrations: ScmIntegrationRegistry;
|
|
92
|
+
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
93
|
+
repoUrl: string;
|
|
94
|
+
path: string | number;
|
|
95
|
+
token?: string | undefined;
|
|
96
|
+
userIds?: number[] | undefined;
|
|
97
|
+
groupIds?: number[] | undefined;
|
|
98
|
+
action?: "add" | "remove" | undefined;
|
|
99
|
+
accessLevel?: string | number | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
userIds?: number[] | undefined;
|
|
102
|
+
groupIds?: number[] | undefined;
|
|
103
|
+
path?: string | number | undefined;
|
|
104
|
+
accessLevel?: number | undefined;
|
|
105
|
+
}, "v2">;
|
|
106
|
+
|
|
84
107
|
/**
|
|
85
108
|
* Creates a `gitlab:issues:create` Scaffolder action.
|
|
86
109
|
*
|
|
@@ -256,6 +279,7 @@ declare const createGitlabProjectVariableAction: (options: {
|
|
|
256
279
|
token?: string | undefined;
|
|
257
280
|
variableProtected?: boolean | undefined;
|
|
258
281
|
masked?: boolean | undefined;
|
|
282
|
+
maskedAndHidden?: boolean | undefined;
|
|
259
283
|
raw?: boolean | undefined;
|
|
260
284
|
environmentScope?: string | undefined;
|
|
261
285
|
}, {
|
|
@@ -357,4 +381,4 @@ declare namespace IssueStateEvent {
|
|
|
357
381
|
*/
|
|
358
382
|
declare const gitlabModule: _backstage_backend_plugin_api.BackendFeature;
|
|
359
383
|
|
|
360
|
-
export { IssueStateEvent, IssueType, createGitlabGroupEnsureExistsAction, createGitlabIssueAction, createGitlabProjectAccessTokenAction, createGitlabProjectDeployTokenAction, createGitlabProjectVariableAction, createGitlabRepoPushAction, createGitlabUserInfoAction, createPublishGitlabAction, createPublishGitlabMergeRequestAction, createTriggerGitlabPipelineAction, gitlabModule as default, editGitlabIssueAction };
|
|
384
|
+
export { IssueStateEvent, IssueType, createGitlabGroupAccessAction, createGitlabGroupEnsureExistsAction, createGitlabIssueAction, createGitlabProjectAccessTokenAction, createGitlabProjectDeployTokenAction, createGitlabProjectVariableAction, createGitlabRepoPushAction, createGitlabUserInfoAction, createPublishGitlabAction, createPublishGitlabMergeRequestAction, createTriggerGitlabPipelineAction, gitlabModule as default, editGitlabIssueAction };
|
package/dist/module.cjs.js
CHANGED
|
@@ -5,6 +5,7 @@ var integration = require('@backstage/integration');
|
|
|
5
5
|
var alpha = require('@backstage/plugin-scaffolder-node/alpha');
|
|
6
6
|
var gitlab = require('./actions/gitlab.cjs.js');
|
|
7
7
|
var gitlabGroupEnsureExists = require('./actions/gitlabGroupEnsureExists.cjs.js');
|
|
8
|
+
var gitlabGroupAccessAction = require('./actions/gitlabGroupAccessAction.cjs.js');
|
|
8
9
|
var gitlabIssueCreate = require('./actions/gitlabIssueCreate.cjs.js');
|
|
9
10
|
var gitlabIssueEdit = require('./actions/gitlabIssueEdit.cjs.js');
|
|
10
11
|
var gitlabMergeRequest = require('./actions/gitlabMergeRequest.cjs.js');
|
|
@@ -33,6 +34,7 @@ const gitlabModule = backendPluginApi.createBackendModule({
|
|
|
33
34
|
const integrations = integration.ScmIntegrations.fromConfig(config);
|
|
34
35
|
scaffolder.addActions(
|
|
35
36
|
gitlabGroupEnsureExists.createGitlabGroupEnsureExistsAction({ integrations }),
|
|
37
|
+
gitlabGroupAccessAction.createGitlabGroupAccessAction({ integrations }),
|
|
36
38
|
gitlabProjectMigrate.createGitlabProjectMigrateAction({ integrations }),
|
|
37
39
|
gitlabIssueCreate.createGitlabIssueAction({ integrations }),
|
|
38
40
|
gitlabProjectAccessTokenCreate.createGitlabProjectAccessTokenAction({ integrations }),
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { scaffolderAutocompleteExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createGitlabGroupEnsureExistsAction,\n createGitlabIssueAction,\n createGitlabProjectAccessTokenAction,\n createGitlabProjectDeployTokenAction,\n createGitlabProjectVariableAction,\n createGitlabRepoPushAction,\n createGitlabUserInfoAction,\n createPublishGitlabAction,\n createPublishGitlabMergeRequestAction,\n createTriggerGitlabPipelineAction,\n editGitlabIssueAction,\n} from './actions';\nimport { createGitlabProjectMigrateAction } from './actions/gitlabProjectMigrate';\nimport { createHandleAutocompleteRequest } from './autocomplete/autocomplete';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node';\n\n/**\n * @public\n * The GitLab Module for the Scaffolder Backend\n */\nexport const gitlabModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'gitlab',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, autocomplete, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createGitlabGroupEnsureExistsAction({ integrations }),\n createGitlabProjectMigrateAction({ integrations }),\n createGitlabIssueAction({ integrations }),\n createGitlabProjectAccessTokenAction({ integrations }),\n createGitlabProjectDeployTokenAction({ integrations }),\n createGitlabProjectVariableAction({ integrations }),\n createGitlabRepoPushAction({ integrations }),\n createGitlabUserInfoAction({ integrations }),\n editGitlabIssueAction({ integrations }),\n createPublishGitlabAction({ config, integrations }),\n createPublishGitlabMergeRequestAction({ integrations }),\n createTriggerGitlabPipelineAction({ integrations }),\n );\n\n autocomplete.addAutocompleteProvider({\n id: 'gitlab',\n handler: createHandleAutocompleteRequest({ integrations }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createGitlabGroupEnsureExistsAction","createGitlabProjectMigrateAction","createGitlabIssueAction","createGitlabProjectAccessTokenAction","createGitlabProjectDeployTokenAction","createGitlabProjectVariableAction","createGitlabRepoPushAction","createGitlabUserInfoAction","editGitlabIssueAction","createPublishGitlabAction","createPublishGitlabMergeRequestAction","createTriggerGitlabPipelineAction","createHandleAutocompleteRequest"],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { scaffolderAutocompleteExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createGitlabGroupEnsureExistsAction,\n createGitlabGroupAccessAction,\n createGitlabIssueAction,\n createGitlabProjectAccessTokenAction,\n createGitlabProjectDeployTokenAction,\n createGitlabProjectVariableAction,\n createGitlabRepoPushAction,\n createGitlabUserInfoAction,\n createPublishGitlabAction,\n createPublishGitlabMergeRequestAction,\n createTriggerGitlabPipelineAction,\n editGitlabIssueAction,\n} from './actions';\nimport { createGitlabProjectMigrateAction } from './actions/gitlabProjectMigrate';\nimport { createHandleAutocompleteRequest } from './autocomplete/autocomplete';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node';\n\n/**\n * @public\n * The GitLab Module for the Scaffolder Backend\n */\nexport const gitlabModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'gitlab',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, autocomplete, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createGitlabGroupEnsureExistsAction({ integrations }),\n createGitlabGroupAccessAction({ integrations }),\n createGitlabProjectMigrateAction({ integrations }),\n createGitlabIssueAction({ integrations }),\n createGitlabProjectAccessTokenAction({ integrations }),\n createGitlabProjectDeployTokenAction({ integrations }),\n createGitlabProjectVariableAction({ integrations }),\n createGitlabRepoPushAction({ integrations }),\n createGitlabUserInfoAction({ integrations }),\n editGitlabIssueAction({ integrations }),\n createPublishGitlabAction({ config, integrations }),\n createPublishGitlabMergeRequestAction({ integrations }),\n createTriggerGitlabPipelineAction({ integrations }),\n );\n\n autocomplete.addAutocompleteProvider({\n id: 'gitlab',\n handler: createHandleAutocompleteRequest({ integrations }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createGitlabGroupEnsureExistsAction","createGitlabGroupAccessAction","createGitlabProjectMigrateAction","createGitlabIssueAction","createGitlabProjectAccessTokenAction","createGitlabProjectDeployTokenAction","createGitlabProjectVariableAction","createGitlabRepoPushAction","createGitlabUserInfoAction","editGitlabIssueAction","createPublishGitlabAction","createPublishGitlabMergeRequestAction","createTriggerGitlabPipelineAction","createHandleAutocompleteRequest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2CO,MAAM,eAAeA,oCAAA,CAAoB;AAAA,EAC9C,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,QAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAa,EAAG;AACzB,IAAA,YAAA,CAAa;AAAA,MACX,IAAA,EAAM;AAAA,QACJ,UAAA,EAAYC,oDAAA;AAAA,QACZ,YAAA,EAAcC,0CAAA;AAAA,QACd,QAAQC,6BAAA,CAAa;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,gBAAYC,cAAA,EAAc,QAAO,EAAG;AAC/C,QAAA,MAAM,YAAA,GAAeC,2BAAA,CAAgB,UAAA,CAAW,MAAM,CAAA;AAEtD,QAAA,UAAA,CAAW,UAAA;AAAA,UACTC,2DAAA,CAAoC,EAAE,YAAA,EAAc,CAAA;AAAA,UACpDC,qDAAA,CAA8B,EAAE,YAAA,EAAc,CAAA;AAAA,UAC9CC,qDAAA,CAAiC,EAAE,YAAA,EAAc,CAAA;AAAA,UACjDC,yCAAA,CAAwB,EAAE,YAAA,EAAc,CAAA;AAAA,UACxCC,mEAAA,CAAqC,EAAE,YAAA,EAAc,CAAA;AAAA,UACrDC,mEAAA,CAAqC,EAAE,YAAA,EAAc,CAAA;AAAA,UACrDC,6DAAA,CAAkC,EAAE,YAAA,EAAc,CAAA;AAAA,UAClDC,yCAAA,CAA2B,EAAE,YAAA,EAAc,CAAA;AAAA,UAC3CC,yCAAA,CAA2B,EAAE,YAAA,EAAc,CAAA;AAAA,UAC3CC,qCAAA,CAAsB,EAAE,YAAA,EAAc,CAAA;AAAA,UACtCC,gCAAA,CAA0B,EAAE,MAAA,EAAQ,YAAA,EAAc,CAAA;AAAA,UAClDC,wDAAA,CAAsC,EAAE,YAAA,EAAc,CAAA;AAAA,UACtDC,uDAAA,CAAkC,EAAE,YAAA,EAAc;AAAA,SACpD;AAEA,QAAAd,cAAA,CAAa,uBAAA,CAAwB;AAAA,UACnC,EAAA,EAAI,QAAA;AAAA,UACJ,OAAA,EAASe,4CAAA,CAAgC,EAAE,YAAA,EAAc;AAAA,SAC1D,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-gitlab",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4-next.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin-module",
|
|
6
6
|
"pluginId": "scaffolder",
|
|
@@ -53,20 +53,21 @@
|
|
|
53
53
|
"test": "backstage-cli package test"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@backstage/backend-plugin-api": "
|
|
57
|
-
"@backstage/config": "
|
|
58
|
-
"@backstage/errors": "
|
|
59
|
-
"@backstage/integration": "
|
|
60
|
-
"@backstage/plugin-scaffolder-node": "
|
|
61
|
-
"@gitbeaker/
|
|
62
|
-
"@gitbeaker/
|
|
56
|
+
"@backstage/backend-plugin-api": "1.7.1-next.0",
|
|
57
|
+
"@backstage/config": "1.3.6",
|
|
58
|
+
"@backstage/errors": "1.2.7",
|
|
59
|
+
"@backstage/integration": "2.0.0-next.1",
|
|
60
|
+
"@backstage/plugin-scaffolder-node": "0.13.0-next.1",
|
|
61
|
+
"@gitbeaker/core": "^43.8.0",
|
|
62
|
+
"@gitbeaker/requester-utils": "^43.8.0",
|
|
63
|
+
"@gitbeaker/rest": "^43.8.0",
|
|
63
64
|
"luxon": "^3.0.0",
|
|
64
65
|
"yaml": "^2.0.0",
|
|
65
66
|
"zod": "^3.25.76"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@backstage/backend-test-utils": "
|
|
69
|
-
"@backstage/cli": "
|
|
70
|
-
"@backstage/plugin-scaffolder-node-test-utils": "
|
|
69
|
+
"@backstage/backend-test-utils": "1.11.1-next.1",
|
|
70
|
+
"@backstage/cli": "0.36.0-next.1",
|
|
71
|
+
"@backstage/plugin-scaffolder-node-test-utils": "0.3.9-next.1"
|
|
71
72
|
}
|
|
72
73
|
}
|