Skip to content

Commit

Permalink
fix: Private pipelines are not displayed in the list of pipelines tha…
Browse files Browse the repository at this point in the history
…t use job templates. (#633)
  • Loading branch information
yk634 authored Nov 21, 2024
1 parent ff446ae commit 49e6390
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/templateFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,13 @@ class TemplateFactory extends BaseFactory {
const eventFactory = EventFactory.getInstance();

const pipelineData = await pipelineFactory.list(pipelineConfig);
const eventIds = pipelineData.filter(p => p.lastEventId !== null).map(p => p.lastEventId);
const publicPipelineData = pipelineData.filter(p => {
const privatePipeline = p.scmRepo && p.scmRepo.private;
const setToPublic = p.settings && p.settings.public;

return !privatePipeline || setToPublic;
});
const eventIds = publicPipelineData.filter(p => p.lastEventId !== null).map(p => p.lastEventId);
const eventConfig = {
params: { id: eventIds },
readOnly: true
Expand All @@ -395,7 +401,7 @@ class TemplateFactory extends BaseFactory {
return map;
}, {});

return pipelineData.map(p => {
return publicPipelineData.map(p => {
return {
id: p.id,
name: p.name,
Expand Down
22 changes: 20 additions & 2 deletions test/lib/templateFactory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ describe('Template Factory', () => {
name: 'nathom/sd-uses-template',
url: 'https://github.com/test/repo/tree/main/pipe3',
rootDir: 'pipe3',
private: false
private: true
},
lastRun: '2023-08-31T18:18:37.501Z',
admins: { nathom: true }
Expand Down Expand Up @@ -1461,11 +1461,29 @@ describe('Template Factory', () => {
name: 'nathom/sd-uses-template',
url: 'https://github.com/test/repo/tree/main/pipe3',
rootDir: 'pipe3',
private: false
private: true
},
settings: { public: true },
createTime: '2023-08-17T18:18:37.501Z',
admins: { nathom: true },
lastEventId: 1
},

{
id: 3,
name: 'nathom/sd-uses-template',
scmUri: 'github.com:672032066:main:pipe4',
scmContext: 'github:github.com',
scmRepo: {
branch: 'main',
name: 'nathom/sd-uses-template',
url: 'https://github.com/test/repo/tree/main/pipe4',
rootDir: 'pipe4',
private: true
},
createTime: '2023-08-17T18:18:37.501Z',
admins: { nathom: true },
lastEventId: 3
}
];

Expand Down

0 comments on commit 49e6390

Please sign in to comment.