Skip to content

Commit

Permalink
feat: add feature flag for team creation (#12)
Browse files Browse the repository at this point in the history
* feat: add feature flag for team creation

Current behaviour creates a secret team if a team doesn't exist. This
adds a feature flag to prevent creating teams unless the feature flag is
set

* fixup! feat: add feature flag for team creation
  • Loading branch information
maxflintoff-tomtom authored Sep 12, 2024
1 parent 7184b1a commit 1a9e70a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ module.exports = {
DEPLOYMENT_CONFIG_FILE: process.env.DEPLOYMENT_CONFIG_FILE || 'deployment-settings.yml',
CREATE_PR_COMMENT: process.env.CREATE_PR_COMMENT || 'true',
CREATE_ERROR_ISSUE: process.env.CREATE_ERROR_ISSUE || 'true',
BLOCK_REPO_RENAME_BY_HUMAN: process.env.BLOCK_REPO_RENAME_BY_HUMAN || 'false'
BLOCK_REPO_RENAME_BY_HUMAN: process.env.BLOCK_REPO_RENAME_BY_HUMAN || 'false',
// If set to true, then when a team is defined in the settings file, it will be created if it does not exist.
FEATURE_CREATE_TEAMS_IF_NOT_EXIST: process.env.FEATURE_CREATE_TEAMS_IF_NOT_EXIST || 'false'
}
5 changes: 5 additions & 0 deletions lib/plugins/teams.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Diffable = require('./diffable')
const NopCommand = require('../nopcommand')
const env = require('../env')

const teamRepoEndpoint = '/orgs/:owner/teams/:team_slug/repos/:owner/:repo'
module.exports = class Teams extends Diffable {
Expand Down Expand Up @@ -43,6 +44,10 @@ module.exports = class Teams extends Diffable {
})
}).catch(e => {
if (e.status === 404) {
if (env.FEATURE_CREATE_TEAMS_IF_NOT_EXIST == 'false') {
this.log.info(`Feature to create teams is disabled. Team ${attrs.name} not found`)
return
}
const createParam = {
org: this.repo.owner,
name: attrs.name
Expand Down

0 comments on commit 1a9e70a

Please sign in to comment.