Skip to content

Commit

Permalink
fix: correct new template create logic (#1803)
Browse files Browse the repository at this point in the history
  • Loading branch information
DekusDenial authored Oct 18, 2019
1 parent 54ca3b4 commit ab63fd4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions plugins/templates/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,10 @@ module.exports = () => ({
labels: config.template.labels || []
});

// If template name doesn't exist yet, just create a new entry
if (templates.length === 0) {
return templateFactory.create(templateConfig);
}

// If template name exists, but this build's pipelineId is not the same as template's pipelineId
// Then this build does not have permission to publish
if (pipeline.id !== templates[0].pipelineId || isPR) {
if (isPR ||
(templates.length !== 0 && pipeline.id !== templates[0].pipelineId)) {
throw boom.forbidden('Not allowed to publish this template');
}

Expand Down

0 comments on commit ab63fd4

Please sign in to comment.