update
This commit is contained in:
@@ -18,115 +18,46 @@ export class GiteaProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
async getProjects(opts?: IListOptions): Promise<interfaces.data.IProject[]> {
|
||||
// Use org-scoped listing when groupFilterId is set
|
||||
const fetchFn = this.groupFilterId
|
||||
? (o: IListOptions) => this.client.getOrgRepos(this.groupFilterId!, o)
|
||||
: (o: IListOptions) => this.client.getRepos(o);
|
||||
|
||||
// If caller explicitly requests a specific page, respect it (no auto-pagination)
|
||||
if (opts?.page) {
|
||||
const repos = await fetchFn(opts);
|
||||
return repos.map((r) => this.mapProject(r));
|
||||
}
|
||||
|
||||
const allRepos: plugins.giteaClient.IGiteaRepository[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
|
||||
while (true) {
|
||||
const repos = await fetchFn({ ...opts, page, perPage });
|
||||
allRepos.push(...repos);
|
||||
if (repos.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
|
||||
return allRepos.map((r) => this.mapProject(r));
|
||||
const repos = this.groupFilterId
|
||||
? await (await this.client.getOrg(this.groupFilterId)).getRepos(opts)
|
||||
: await this.client.getRepos(opts);
|
||||
return repos.map((r) => this.mapProject(r));
|
||||
}
|
||||
|
||||
async getGroups(opts?: IListOptions): Promise<interfaces.data.IGroup[]> {
|
||||
// When groupFilterId is set, return only that single org
|
||||
if (this.groupFilterId) {
|
||||
const org = await this.client.getOrg(this.groupFilterId);
|
||||
return [this.mapGroup(org)];
|
||||
}
|
||||
|
||||
// If caller explicitly requests a specific page, respect it (no auto-pagination)
|
||||
if (opts?.page) {
|
||||
const orgs = await this.client.getOrgs(opts);
|
||||
return orgs.map((o) => this.mapGroup(o));
|
||||
}
|
||||
|
||||
const allOrgs: plugins.giteaClient.IGiteaOrganization[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
|
||||
while (true) {
|
||||
const orgs = await this.client.getOrgs({ ...opts, page, perPage });
|
||||
allOrgs.push(...orgs);
|
||||
if (orgs.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
|
||||
return allOrgs.map((o) => this.mapGroup(o));
|
||||
const orgs = await this.client.getOrgs(opts);
|
||||
return orgs.map((o) => this.mapGroup(o));
|
||||
}
|
||||
|
||||
async getGroupProjects(groupId: string, opts?: IListOptions): Promise<interfaces.data.IProject[]> {
|
||||
if (opts?.page) {
|
||||
const repos = await this.client.getOrgRepos(groupId, opts);
|
||||
return repos.map((r) => this.mapProject(r));
|
||||
}
|
||||
const allRepos: plugins.giteaClient.IGiteaRepository[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const repos = await this.client.getOrgRepos(groupId, { ...opts, page, perPage });
|
||||
allRepos.push(...repos);
|
||||
if (repos.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return allRepos.map((r) => this.mapProject(r));
|
||||
const org = await this.client.getOrg(groupId);
|
||||
const repos = await org.getRepos(opts);
|
||||
return repos.map((r) => this.mapProject(r));
|
||||
}
|
||||
|
||||
// --- Branches / Tags ---
|
||||
|
||||
async getBranches(projectFullPath: string, opts?: IListOptions): Promise<interfaces.data.IBranch[]> {
|
||||
if (opts?.page) {
|
||||
const branches = await this.client.getRepoBranches(projectFullPath, opts);
|
||||
return branches.map((b) => ({ name: b.name, commitSha: b.commit.id }));
|
||||
}
|
||||
const all: interfaces.data.IBranch[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const branches = await this.client.getRepoBranches(projectFullPath, { ...opts, page, perPage });
|
||||
all.push(...branches.map((b) => ({ name: b.name, commitSha: b.commit.id })));
|
||||
if (branches.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return all;
|
||||
const repo = await this.client.getRepo(projectFullPath);
|
||||
const branches = await repo.getBranches(opts);
|
||||
return branches.map((b) => ({ name: b.name, commitSha: b.commitSha }));
|
||||
}
|
||||
|
||||
async getTags(projectFullPath: string, opts?: IListOptions): Promise<interfaces.data.ITag[]> {
|
||||
if (opts?.page) {
|
||||
const tags = await this.client.getRepoTags(projectFullPath, opts);
|
||||
return tags.map((t) => ({ name: t.name, commitSha: t.commit.sha }));
|
||||
}
|
||||
const all: interfaces.data.ITag[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const tags = await this.client.getRepoTags(projectFullPath, { ...opts, page, perPage });
|
||||
all.push(...tags.map((t) => ({ name: t.name, commitSha: t.commit.sha })));
|
||||
if (tags.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return all;
|
||||
const repo = await this.client.getRepo(projectFullPath);
|
||||
const tags = await repo.getTags(opts);
|
||||
return tags.map((t) => ({ name: t.name, commitSha: t.commitSha }));
|
||||
}
|
||||
|
||||
// --- Project Secrets ---
|
||||
|
||||
async getProjectSecrets(projectId: string): Promise<interfaces.data.ISecret[]> {
|
||||
const secrets = await this.client.getRepoSecrets(projectId);
|
||||
const repo = await this.client.getRepo(projectId);
|
||||
const secrets = await repo.getSecrets();
|
||||
return secrets.map((s) => this.mapSecret(s, 'project', projectId));
|
||||
}
|
||||
|
||||
@@ -135,7 +66,8 @@ export class GiteaProvider extends BaseProvider {
|
||||
key: string,
|
||||
value: string,
|
||||
): Promise<interfaces.data.ISecret> {
|
||||
await this.client.setRepoSecret(projectId, key, value);
|
||||
const repo = await this.client.getRepo(projectId);
|
||||
await repo.setSecret(key, value);
|
||||
return { key, value: '***', protected: false, masked: true, scope: 'project', scopeId: projectId, scopeName: projectId, connectionId: this.connectionId, environment: '*' };
|
||||
}
|
||||
|
||||
@@ -148,13 +80,15 @@ export class GiteaProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
async deleteProjectSecret(projectId: string, key: string): Promise<void> {
|
||||
await this.client.deleteRepoSecret(projectId, key);
|
||||
const repo = await this.client.getRepo(projectId);
|
||||
await repo.deleteSecret(key);
|
||||
}
|
||||
|
||||
// --- Group Secrets ---
|
||||
|
||||
async getGroupSecrets(groupId: string): Promise<interfaces.data.ISecret[]> {
|
||||
const secrets = await this.client.getOrgSecrets(groupId);
|
||||
const org = await this.client.getOrg(groupId);
|
||||
const secrets = await org.getSecrets();
|
||||
return secrets.map((s) => this.mapSecret(s, 'group', groupId));
|
||||
}
|
||||
|
||||
@@ -163,7 +97,8 @@ export class GiteaProvider extends BaseProvider {
|
||||
key: string,
|
||||
value: string,
|
||||
): Promise<interfaces.data.ISecret> {
|
||||
await this.client.setOrgSecret(groupId, key, value);
|
||||
const org = await this.client.getOrg(groupId);
|
||||
await org.setSecret(key, value);
|
||||
return { key, value: '***', protected: false, masked: true, scope: 'group', scopeId: groupId, scopeName: groupId, connectionId: this.connectionId, environment: '*' };
|
||||
}
|
||||
|
||||
@@ -176,7 +111,8 @@ export class GiteaProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
async deleteGroupSecret(groupId: string, key: string): Promise<void> {
|
||||
await this.client.deleteOrgSecret(groupId, key);
|
||||
const org = await this.client.getOrg(groupId);
|
||||
await org.deleteSecret(key);
|
||||
}
|
||||
|
||||
// --- Pipelines (Action Runs) ---
|
||||
@@ -185,7 +121,8 @@ export class GiteaProvider extends BaseProvider {
|
||||
projectId: string,
|
||||
opts?: IPipelineListOptions,
|
||||
): Promise<interfaces.data.IPipeline[]> {
|
||||
const runs = await this.client.getActionRuns(projectId, {
|
||||
const repo = await this.client.getRepo(projectId);
|
||||
const runs = await repo.getActionRuns({
|
||||
page: opts?.page,
|
||||
perPage: opts?.perPage,
|
||||
status: opts?.status,
|
||||
@@ -199,90 +136,101 @@ export class GiteaProvider extends BaseProvider {
|
||||
projectId: string,
|
||||
pipelineId: string,
|
||||
): Promise<interfaces.data.IPipelineJob[]> {
|
||||
const jobs = await this.client.getActionRunJobs(projectId, Number(pipelineId));
|
||||
return jobs.map((j) => this.mapJob(j, pipelineId));
|
||||
// Use the client's internal method directly to avoid an extra getRepo call
|
||||
const jobs = await this.client.requestGetActionRunJobs(projectId, Number(pipelineId));
|
||||
return jobs.map((j) => {
|
||||
const resolvedStatus = plugins.giteaClient.resolveGiteaStatus(j.status, j.conclusion);
|
||||
return this.mapJob(resolvedStatus, j, pipelineId);
|
||||
});
|
||||
}
|
||||
|
||||
async getJobLog(projectId: string, jobId: string): Promise<string> {
|
||||
return this.client.getJobLog(projectId, Number(jobId));
|
||||
return this.client.requestGetJobLog(projectId, Number(jobId));
|
||||
}
|
||||
|
||||
async retryPipeline(projectId: string, pipelineId: string): Promise<void> {
|
||||
await this.client.rerunAction(projectId, Number(pipelineId));
|
||||
// Fetch the run to get its workflow path, then dispatch
|
||||
const run = await this.client.requestGetActionRun(projectId, Number(pipelineId));
|
||||
const wfId = plugins.giteaClient.extractWorkflowIdFromPath(run.path);
|
||||
const ref = run.head_branch || 'main';
|
||||
if (!wfId) {
|
||||
throw new Error(`Cannot retry: no workflow ID found in path "${run.path}"`);
|
||||
}
|
||||
await this.client.requestDispatchWorkflow(projectId, wfId, ref);
|
||||
}
|
||||
|
||||
async cancelPipeline(projectId: string, pipelineId: string): Promise<void> {
|
||||
await this.client.cancelAction(projectId, Number(pipelineId));
|
||||
async cancelPipeline(_projectId: string, _pipelineId: string): Promise<void> {
|
||||
throw new Error('Cancel is not supported by Gitea 1.25');
|
||||
}
|
||||
|
||||
// --- Mappers ---
|
||||
|
||||
private mapProject(r: plugins.giteaClient.IGiteaRepository): interfaces.data.IProject {
|
||||
private mapProject(r: plugins.giteaClient.GiteaRepository): interfaces.data.IProject {
|
||||
return {
|
||||
id: r.full_name || String(r.id),
|
||||
name: r.name || '',
|
||||
fullPath: r.full_name || '',
|
||||
description: r.description || '',
|
||||
defaultBranch: r.default_branch || 'main',
|
||||
webUrl: r.html_url || '',
|
||||
id: r.fullName || String(r.id),
|
||||
name: r.name,
|
||||
fullPath: r.fullName,
|
||||
description: r.description,
|
||||
defaultBranch: r.defaultBranch,
|
||||
webUrl: r.htmlUrl,
|
||||
connectionId: this.connectionId,
|
||||
visibility: r.private ? 'private' : 'public',
|
||||
topics: r.topics || [],
|
||||
lastActivity: r.updated_at || '',
|
||||
visibility: r.isPrivate ? 'private' : 'public',
|
||||
topics: r.topics,
|
||||
lastActivity: r.updatedAt,
|
||||
};
|
||||
}
|
||||
|
||||
private mapGroup(o: plugins.giteaClient.IGiteaOrganization): interfaces.data.IGroup {
|
||||
private mapGroup(o: plugins.giteaClient.GiteaOrganization): interfaces.data.IGroup {
|
||||
return {
|
||||
id: o.name || String(o.id),
|
||||
name: o.name || '',
|
||||
fullPath: o.name || '',
|
||||
description: o.description || '',
|
||||
name: o.name,
|
||||
fullPath: o.name,
|
||||
description: o.description,
|
||||
webUrl: `${this.baseUrl}/${o.name}`,
|
||||
connectionId: this.connectionId,
|
||||
visibility: o.visibility || 'public',
|
||||
projectCount: o.repo_count || 0,
|
||||
projectCount: o.repoCount,
|
||||
};
|
||||
}
|
||||
|
||||
private mapSecret(s: plugins.giteaClient.IGiteaSecret, scope: 'project' | 'group', scopeId: string, scopeName?: string): interfaces.data.ISecret {
|
||||
private mapSecret(s: plugins.giteaClient.GiteaSecret, scope: 'project' | 'group', scopeId: string): interfaces.data.ISecret {
|
||||
return {
|
||||
key: s.name || '',
|
||||
key: s.name,
|
||||
value: '***',
|
||||
protected: false,
|
||||
masked: true,
|
||||
scope,
|
||||
scopeId,
|
||||
scopeName: scopeName || scopeId,
|
||||
scopeName: scopeId,
|
||||
connectionId: this.connectionId,
|
||||
environment: '*',
|
||||
};
|
||||
}
|
||||
|
||||
private mapPipeline(r: plugins.giteaClient.IGiteaActionRun, projectId: string, projectName?: string): interfaces.data.IPipeline {
|
||||
private mapPipeline(r: plugins.giteaClient.GiteaActionRun, projectId: string): interfaces.data.IPipeline {
|
||||
return {
|
||||
id: String(r.id),
|
||||
projectId,
|
||||
projectName: projectName || projectId,
|
||||
projectName: projectId,
|
||||
connectionId: this.connectionId,
|
||||
status: this.mapStatus(r.status || r.conclusion),
|
||||
ref: r.head_branch || '',
|
||||
sha: r.head_sha || '',
|
||||
webUrl: r.html_url || '',
|
||||
duration: r.run_duration || 0,
|
||||
createdAt: r.created_at || '',
|
||||
status: this.mapStatus(r.resolvedStatus),
|
||||
ref: r.ref,
|
||||
sha: r.headSha,
|
||||
webUrl: r.htmlUrl,
|
||||
duration: r.duration,
|
||||
createdAt: r.startedAt,
|
||||
source: r.event || 'push',
|
||||
};
|
||||
}
|
||||
|
||||
private mapJob(j: plugins.giteaClient.IGiteaActionRunJob, pipelineId: string): interfaces.data.IPipelineJob {
|
||||
private mapJob(resolvedStatus: string, j: plugins.giteaClient.IGiteaActionRunJob, pipelineId: string): interfaces.data.IPipelineJob {
|
||||
return {
|
||||
id: String(j.id),
|
||||
pipelineId,
|
||||
name: j.name || '',
|
||||
stage: j.name || 'default',
|
||||
status: this.mapStatus(j.status || j.conclusion),
|
||||
duration: j.run_duration || 0,
|
||||
status: this.mapStatus(resolvedStatus),
|
||||
duration: plugins.giteaClient.computeDuration(j.started_at, j.completed_at),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -18,130 +18,47 @@ export class GitLabProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
async getProjects(opts?: IListOptions): Promise<interfaces.data.IProject[]> {
|
||||
if (this.groupFilterId) {
|
||||
// Auto-paginate group-scoped project listing
|
||||
if (opts?.page) {
|
||||
const projects = await this.client.getGroupProjects(this.groupFilterId, opts);
|
||||
return projects.map((p) => this.mapProject(p));
|
||||
}
|
||||
const allProjects: plugins.gitlabClient.IGitLabProject[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const projects = await this.client.getGroupProjects(this.groupFilterId, { ...opts, page, perPage });
|
||||
allProjects.push(...projects);
|
||||
if (projects.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return allProjects.map((p) => this.mapProject(p));
|
||||
}
|
||||
if (opts?.page) {
|
||||
const projects = await this.client.getProjects(opts);
|
||||
return projects.map((p) => this.mapProject(p));
|
||||
}
|
||||
const allProjects: plugins.gitlabClient.IGitLabProject[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const projects = await this.client.getProjects({ ...opts, page, perPage });
|
||||
allProjects.push(...projects);
|
||||
if (projects.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return allProjects.map((p) => this.mapProject(p));
|
||||
const projects = this.groupFilterId
|
||||
? await (await this.client.getGroup(this.groupFilterId)).getProjects(opts)
|
||||
: await this.client.getProjects(opts);
|
||||
return projects.map((p) => this.mapProject(p));
|
||||
}
|
||||
|
||||
async getGroups(opts?: IListOptions): Promise<interfaces.data.IGroup[]> {
|
||||
if (this.groupFilterId) {
|
||||
// Auto-paginate descendant groups listing
|
||||
if (opts?.page) {
|
||||
const groups = await this.client.getDescendantGroups(this.groupFilterId, opts);
|
||||
return groups.map((g) => this.mapGroup(g));
|
||||
}
|
||||
const allGroups: plugins.gitlabClient.IGitLabGroup[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const groups = await this.client.getDescendantGroups(this.groupFilterId, { ...opts, page, perPage });
|
||||
allGroups.push(...groups);
|
||||
if (groups.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return allGroups.map((g) => this.mapGroup(g));
|
||||
const group = await this.client.getGroup(this.groupFilterId);
|
||||
const descendants = await group.getDescendantGroups(opts);
|
||||
return descendants.map((g) => this.mapGroup(g));
|
||||
}
|
||||
if (opts?.page) {
|
||||
const groups = await this.client.getGroups(opts);
|
||||
return groups.map((g) => this.mapGroup(g));
|
||||
}
|
||||
const allGroups: plugins.gitlabClient.IGitLabGroup[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const groups = await this.client.getGroups({ ...opts, page, perPage });
|
||||
allGroups.push(...groups);
|
||||
if (groups.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return allGroups.map((g) => this.mapGroup(g));
|
||||
const groups = await this.client.getGroups(opts);
|
||||
return groups.map((g) => this.mapGroup(g));
|
||||
}
|
||||
|
||||
async getGroupProjects(groupId: string, opts?: IListOptions): Promise<interfaces.data.IProject[]> {
|
||||
if (opts?.page) {
|
||||
const projects = await this.client.getGroupProjects(groupId, opts);
|
||||
return projects.map((p) => this.mapProject(p));
|
||||
}
|
||||
const allProjects: plugins.gitlabClient.IGitLabProject[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const projects = await this.client.getGroupProjects(groupId, { ...opts, page, perPage });
|
||||
allProjects.push(...projects);
|
||||
if (projects.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return allProjects.map((p) => this.mapProject(p));
|
||||
const group = await this.client.getGroup(groupId);
|
||||
const projects = await group.getProjects(opts);
|
||||
return projects.map((p) => this.mapProject(p));
|
||||
}
|
||||
|
||||
// --- Branches / Tags ---
|
||||
|
||||
async getBranches(projectFullPath: string, opts?: IListOptions): Promise<interfaces.data.IBranch[]> {
|
||||
if (opts?.page) {
|
||||
const branches = await this.client.getRepoBranches(projectFullPath, opts);
|
||||
return branches.map((b) => ({ name: b.name, commitSha: b.commit.id }));
|
||||
}
|
||||
const all: interfaces.data.IBranch[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const branches = await this.client.getRepoBranches(projectFullPath, { ...opts, page, perPage });
|
||||
all.push(...branches.map((b) => ({ name: b.name, commitSha: b.commit.id })));
|
||||
if (branches.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return all;
|
||||
const project = await this.client.getProject(projectFullPath);
|
||||
const branches = await project.getBranches(opts);
|
||||
return branches.map((b) => ({ name: b.name, commitSha: b.commitSha }));
|
||||
}
|
||||
|
||||
async getTags(projectFullPath: string, opts?: IListOptions): Promise<interfaces.data.ITag[]> {
|
||||
if (opts?.page) {
|
||||
const tags = await this.client.getRepoTags(projectFullPath, opts);
|
||||
return tags.map((t) => ({ name: t.name, commitSha: t.commit.id }));
|
||||
}
|
||||
const all: interfaces.data.ITag[] = [];
|
||||
const perPage = opts?.perPage || 50;
|
||||
let page = 1;
|
||||
while (true) {
|
||||
const tags = await this.client.getRepoTags(projectFullPath, { ...opts, page, perPage });
|
||||
all.push(...tags.map((t) => ({ name: t.name, commitSha: t.commit.id })));
|
||||
if (tags.length < perPage) break;
|
||||
page++;
|
||||
}
|
||||
return all;
|
||||
const project = await this.client.getProject(projectFullPath);
|
||||
const tags = await project.getTags(opts);
|
||||
return tags.map((t) => ({ name: t.name, commitSha: t.commitSha }));
|
||||
}
|
||||
|
||||
// --- Project Secrets (CI/CD Variables) ---
|
||||
|
||||
async getProjectSecrets(projectId: string): Promise<interfaces.data.ISecret[]> {
|
||||
const vars = await this.client.getProjectVariables(projectId);
|
||||
const project = await this.client.getProject(projectId);
|
||||
const vars = await project.getVariables();
|
||||
return vars.map((v) => this.mapVariable(v, 'project', projectId));
|
||||
}
|
||||
|
||||
@@ -150,7 +67,8 @@ export class GitLabProvider extends BaseProvider {
|
||||
key: string,
|
||||
value: string,
|
||||
): Promise<interfaces.data.ISecret> {
|
||||
const v = await this.client.createProjectVariable(projectId, key, value);
|
||||
const project = await this.client.getProject(projectId);
|
||||
const v = await project.createVariable(key, value);
|
||||
return this.mapVariable(v, 'project', projectId);
|
||||
}
|
||||
|
||||
@@ -159,18 +77,21 @@ export class GitLabProvider extends BaseProvider {
|
||||
key: string,
|
||||
value: string,
|
||||
): Promise<interfaces.data.ISecret> {
|
||||
const v = await this.client.updateProjectVariable(projectId, key, value);
|
||||
const project = await this.client.getProject(projectId);
|
||||
const v = await project.updateVariable(key, value);
|
||||
return this.mapVariable(v, 'project', projectId);
|
||||
}
|
||||
|
||||
async deleteProjectSecret(projectId: string, key: string): Promise<void> {
|
||||
await this.client.deleteProjectVariable(projectId, key);
|
||||
const project = await this.client.getProject(projectId);
|
||||
await project.deleteVariable(key);
|
||||
}
|
||||
|
||||
// --- Group Secrets (CI/CD Variables) ---
|
||||
|
||||
async getGroupSecrets(groupId: string): Promise<interfaces.data.ISecret[]> {
|
||||
const vars = await this.client.getGroupVariables(groupId);
|
||||
const group = await this.client.getGroup(groupId);
|
||||
const vars = await group.getVariables();
|
||||
return vars.map((v) => this.mapVariable(v, 'group', groupId));
|
||||
}
|
||||
|
||||
@@ -179,7 +100,8 @@ export class GitLabProvider extends BaseProvider {
|
||||
key: string,
|
||||
value: string,
|
||||
): Promise<interfaces.data.ISecret> {
|
||||
const v = await this.client.createGroupVariable(groupId, key, value);
|
||||
const group = await this.client.getGroup(groupId);
|
||||
const v = await group.createVariable(key, value);
|
||||
return this.mapVariable(v, 'group', groupId);
|
||||
}
|
||||
|
||||
@@ -188,12 +110,14 @@ export class GitLabProvider extends BaseProvider {
|
||||
key: string,
|
||||
value: string,
|
||||
): Promise<interfaces.data.ISecret> {
|
||||
const v = await this.client.updateGroupVariable(groupId, key, value);
|
||||
const group = await this.client.getGroup(groupId);
|
||||
const v = await group.updateVariable(key, value);
|
||||
return this.mapVariable(v, 'group', groupId);
|
||||
}
|
||||
|
||||
async deleteGroupSecret(groupId: string, key: string): Promise<void> {
|
||||
await this.client.deleteGroupVariable(groupId, key);
|
||||
const group = await this.client.getGroup(groupId);
|
||||
await group.deleteVariable(key);
|
||||
}
|
||||
|
||||
// --- Pipelines ---
|
||||
@@ -202,7 +126,8 @@ export class GitLabProvider extends BaseProvider {
|
||||
projectId: string,
|
||||
opts?: IPipelineListOptions,
|
||||
): Promise<interfaces.data.IPipeline[]> {
|
||||
const pipelines = await this.client.getPipelines(projectId, {
|
||||
const project = await this.client.getProject(projectId);
|
||||
const pipelines = await project.getPipelines({
|
||||
page: opts?.page,
|
||||
perPage: opts?.perPage,
|
||||
status: opts?.status,
|
||||
@@ -216,83 +141,82 @@ export class GitLabProvider extends BaseProvider {
|
||||
projectId: string,
|
||||
pipelineId: string,
|
||||
): Promise<interfaces.data.IPipelineJob[]> {
|
||||
const jobs = await this.client.getPipelineJobs(projectId, Number(pipelineId));
|
||||
const jobs = await this.client.requestGetPipelineJobs(projectId, Number(pipelineId));
|
||||
return jobs.map((j) => this.mapJob(j, pipelineId));
|
||||
}
|
||||
|
||||
async getJobLog(projectId: string, jobId: string): Promise<string> {
|
||||
return this.client.getJobLog(projectId, Number(jobId));
|
||||
return this.client.requestGetJobLog(projectId, Number(jobId));
|
||||
}
|
||||
|
||||
async retryPipeline(projectId: string, pipelineId: string): Promise<void> {
|
||||
await this.client.retryPipeline(projectId, Number(pipelineId));
|
||||
await this.client.requestRetryPipeline(projectId, Number(pipelineId));
|
||||
}
|
||||
|
||||
async cancelPipeline(projectId: string, pipelineId: string): Promise<void> {
|
||||
await this.client.cancelPipeline(projectId, Number(pipelineId));
|
||||
await this.client.requestCancelPipeline(projectId, Number(pipelineId));
|
||||
}
|
||||
|
||||
// --- Mappers ---
|
||||
|
||||
private mapProject(p: plugins.gitlabClient.IGitLabProject): interfaces.data.IProject {
|
||||
private mapProject(p: plugins.gitlabClient.GitLabProject): interfaces.data.IProject {
|
||||
return {
|
||||
id: String(p.id),
|
||||
name: p.name || '',
|
||||
fullPath: p.path_with_namespace || '',
|
||||
description: p.description || '',
|
||||
defaultBranch: p.default_branch || 'main',
|
||||
webUrl: p.web_url || '',
|
||||
name: p.name,
|
||||
fullPath: p.fullPath,
|
||||
description: p.description,
|
||||
defaultBranch: p.defaultBranch,
|
||||
webUrl: p.webUrl,
|
||||
connectionId: this.connectionId,
|
||||
visibility: p.visibility || 'private',
|
||||
topics: p.topics || [],
|
||||
lastActivity: p.last_activity_at || '',
|
||||
visibility: p.visibility,
|
||||
topics: p.topics,
|
||||
lastActivity: p.lastActivityAt,
|
||||
};
|
||||
}
|
||||
|
||||
private mapGroup(g: plugins.gitlabClient.IGitLabGroup): interfaces.data.IGroup {
|
||||
private mapGroup(g: plugins.gitlabClient.GitLabGroup): interfaces.data.IGroup {
|
||||
return {
|
||||
id: String(g.id),
|
||||
name: g.name || '',
|
||||
fullPath: g.full_path || '',
|
||||
description: g.description || '',
|
||||
webUrl: g.web_url || '',
|
||||
name: g.name,
|
||||
fullPath: g.fullPath,
|
||||
description: g.description,
|
||||
webUrl: g.webUrl,
|
||||
connectionId: this.connectionId,
|
||||
visibility: g.visibility || 'private',
|
||||
visibility: g.visibility,
|
||||
projectCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
private mapVariable(
|
||||
v: plugins.gitlabClient.IGitLabVariable,
|
||||
v: plugins.gitlabClient.GitLabVariable,
|
||||
scope: 'project' | 'group',
|
||||
scopeId: string,
|
||||
scopeName?: string,
|
||||
): interfaces.data.ISecret {
|
||||
return {
|
||||
key: v.key || '',
|
||||
key: v.key,
|
||||
value: v.value || '***',
|
||||
protected: v.protected || false,
|
||||
masked: v.masked || false,
|
||||
protected: v.protected,
|
||||
masked: v.masked,
|
||||
scope,
|
||||
scopeId,
|
||||
scopeName: scopeName || scopeId,
|
||||
scopeName: scopeId,
|
||||
connectionId: this.connectionId,
|
||||
environment: v.environment_scope || '*',
|
||||
environment: v.environmentScope,
|
||||
};
|
||||
}
|
||||
|
||||
private mapPipeline(p: plugins.gitlabClient.IGitLabPipeline, projectId: string, projectName?: string): interfaces.data.IPipeline {
|
||||
private mapPipeline(p: plugins.gitlabClient.GitLabPipeline, projectId: string): interfaces.data.IPipeline {
|
||||
return {
|
||||
id: String(p.id),
|
||||
projectId,
|
||||
projectName: projectName || projectId,
|
||||
projectName: projectId,
|
||||
connectionId: this.connectionId,
|
||||
status: (p.status || 'pending') as interfaces.data.TPipelineStatus,
|
||||
ref: p.ref || '',
|
||||
sha: p.sha || '',
|
||||
webUrl: p.web_url || '',
|
||||
duration: p.duration || 0,
|
||||
createdAt: p.created_at || '',
|
||||
ref: p.ref,
|
||||
sha: p.sha,
|
||||
webUrl: p.webUrl,
|
||||
duration: p.duration,
|
||||
createdAt: p.createdAt,
|
||||
source: p.source || 'push',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user