changed to older Gitbeaker version
Signed-off-by: Thomas Troschke <thomas.troschke@deutschebahn.com>
This commit is contained in:
@@ -62,6 +62,7 @@ export const createGitlabProjectAccessTokenAction: (options: {
|
||||
name?: string | undefined;
|
||||
accessLevel?: number | undefined;
|
||||
scopes?: string[] | undefined;
|
||||
expiresAt?: string | undefined;
|
||||
},
|
||||
{
|
||||
access_token: string;
|
||||
|
||||
+13
-11
@@ -17,7 +17,6 @@
|
||||
import { InputError } from '@backstage/errors';
|
||||
import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
import { AccessTokenScopes } from '@gitbeaker/core';
|
||||
import { Gitlab } from '@gitbeaker/rest';
|
||||
import { DateTime } from 'luxon';
|
||||
import { z } from 'zod';
|
||||
@@ -31,8 +30,6 @@ import { examples } from './createGitlabProjectAccessTokenAction.examples';
|
||||
* @public
|
||||
*/
|
||||
|
||||
const gitbeakerAccessTokenScopesType: z.ZodType<AccessTokenScopes[]> = z.any();
|
||||
|
||||
export const createGitlabProjectAccessTokenAction = (options: {
|
||||
integrations: ScmIntegrationRegistry;
|
||||
}) => {
|
||||
@@ -42,9 +39,14 @@ export const createGitlabProjectAccessTokenAction = (options: {
|
||||
examples,
|
||||
schema: {
|
||||
input: z.object({
|
||||
projectId: z.number({
|
||||
projectId: z.union([z.number(), z.string()], {
|
||||
description: 'Project ID/Name(slug) of the Gitlab Project',
|
||||
}),
|
||||
token: z
|
||||
.string({
|
||||
description: 'The token to use for authorization to GitLab',
|
||||
})
|
||||
.optional(),
|
||||
name: z.string({ description: 'Name of Access Key' }).optional(),
|
||||
repoUrl: z.string({ description: 'URL to gitlab instance' }),
|
||||
accessLevel: z
|
||||
@@ -53,18 +55,18 @@ export const createGitlabProjectAccessTokenAction = (options: {
|
||||
'Access Level of the Token, 10 (Guest), 20 (Reporter), 30 (Developer), 40 (Maintainer), and 50 (Owner)',
|
||||
})
|
||||
.optional(),
|
||||
scopes: gitbeakerAccessTokenScopesType,
|
||||
scopes: z
|
||||
.string({
|
||||
description: 'Scopes for a project access token',
|
||||
})
|
||||
.array()
|
||||
.optional(),
|
||||
expiresAt: z
|
||||
.string({
|
||||
description:
|
||||
'Expiration date of the access token in ISO format (YYYY-MM-DD). If Empty, it will set to the maximum of 365 days.',
|
||||
})
|
||||
.optional(),
|
||||
token: z
|
||||
.string({
|
||||
description: 'The token to use for authorization to GitLab',
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
output: z.object({
|
||||
access_token: z.string({ description: 'Access Token' }),
|
||||
@@ -107,7 +109,7 @@ export const createGitlabProjectAccessTokenAction = (options: {
|
||||
const response = await api.ProjectAccessTokens.create(
|
||||
projectId,
|
||||
name,
|
||||
scopes,
|
||||
scopes as any,
|
||||
{
|
||||
expiresAt:
|
||||
expiresAt || DateTime.now().plus({ days: 365 }).toISODate()!,
|
||||
|
||||
@@ -19,9 +19,9 @@ import {
|
||||
GitLabIntegration,
|
||||
ScmIntegrationRegistry,
|
||||
} from '@backstage/integration';
|
||||
import { Gitlab, GroupSchema } from '@gitbeaker/rest';
|
||||
import { z } from 'zod';
|
||||
import commonGitlabConfig from './commonGitlabConfig';
|
||||
import { Gitlab, GroupSchema } from '@gitbeaker/rest';
|
||||
import * as util from './util';
|
||||
|
||||
export const parseRepoHost = (repoUrl: string): string => {
|
||||
@@ -50,11 +50,6 @@ export const getToken = (
|
||||
}
|
||||
|
||||
const token = config.token || integrationConfig.config.token!;
|
||||
const tokenType = config.token ? 'oauthToken' : 'token';
|
||||
|
||||
if (tokenType === 'oauthToken') {
|
||||
throw new InputError(`OAuth Token is currently not supported`);
|
||||
}
|
||||
|
||||
return { token: token, integrationConfig: integrationConfig };
|
||||
};
|
||||
|
||||
@@ -8381,7 +8381,7 @@ __metadata:
|
||||
"@backstage/errors": "workspace:^"
|
||||
"@backstage/integration": "workspace:^"
|
||||
"@backstage/plugin-scaffolder-node": "workspace:^"
|
||||
"@gitbeaker/core": ^39.25.0
|
||||
"@gitbeaker/core": ^35.8.0
|
||||
"@gitbeaker/node": ^35.8.0
|
||||
"@gitbeaker/rest": ^39.25.0
|
||||
jest-date-mock: ^1.0.8
|
||||
@@ -11260,7 +11260,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@gitbeaker/core@npm:^35.6.0, @gitbeaker/core@npm:^35.8.1":
|
||||
"@gitbeaker/core@npm:^35.6.0, @gitbeaker/core@npm:^35.8.0, @gitbeaker/core@npm:^35.8.1":
|
||||
version: 35.8.1
|
||||
resolution: "@gitbeaker/core@npm:35.8.1"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user