Skip to content

Commit

Permalink
chore: remove legacy event code from repo and secret (#1098)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Apr 1, 2024
1 parent c5813f6 commit f591935
Show file tree
Hide file tree
Showing 53 changed files with 396 additions and 670 deletions.
34 changes: 1 addition & 33 deletions api/repo/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,34 +182,6 @@ func CreateRepo(c *gin.Context) {
r.SetAllowEvents(defaultAllowedEvents(defaultRepoEvents, defaultRepoEventsMask))
}

// -- DEPRECATED SECTION --
// set default events if no events are passed in
if !input.GetAllowPull() && !input.GetAllowPush() &&
!input.GetAllowDeploy() && !input.GetAllowTag() &&
!input.GetAllowComment() {
for _, event := range defaultRepoEvents {
switch event {
case constants.EventPull:
r.SetAllowPull(true)
case constants.EventPush:
r.SetAllowPush(true)
case constants.EventDeploy:
r.SetAllowDeploy(true)
case constants.EventTag:
r.SetAllowTag(true)
case constants.EventComment:
r.SetAllowComment(true)
}
}
} else {
r.SetAllowComment(input.GetAllowComment())
r.SetAllowDeploy(input.GetAllowDeploy())
r.SetAllowPull(input.GetAllowPull())
r.SetAllowPush(input.GetAllowPush())
r.SetAllowTag(input.GetAllowTag())
}
// -- END DEPRECATED SECTION --

if len(input.GetPipelineType()) == 0 {
r.SetPipelineType(constants.PipelineTypeYAML)
} else {
Expand Down Expand Up @@ -275,11 +247,7 @@ func CreateRepo(c *gin.Context) {

// make sure our record of the repo allowed events matches what we send to SCM
// what the dbRepo has should override default events on enable
r.SetAllowComment(dbRepo.GetAllowComment())
r.SetAllowDeploy(dbRepo.GetAllowDeploy())
r.SetAllowPull(dbRepo.GetAllowPull())
r.SetAllowPush(dbRepo.GetAllowPush())
r.SetAllowTag(dbRepo.GetAllowTag())
r.SetAllowEvents(dbRepo.GetAllowEvents())
}

// check if we should create the webhook
Expand Down
45 changes: 0 additions & 45 deletions api/repo/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,51 +191,6 @@ func UpdateRepo(c *gin.Context) {
eventsChanged = true
}

// -- DEPRECATED SECTION --
if input.AllowPull != nil {
// update allow_pull if set
r.SetAllowPull(input.GetAllowPull())

eventsChanged = true
}

if input.AllowPush != nil {
// update allow_push if set
r.SetAllowPush(input.GetAllowPush())

eventsChanged = true
}

if input.AllowDeploy != nil {
// update allow_deploy if set
r.SetAllowDeploy(input.GetAllowDeploy())

eventsChanged = true
}

if input.AllowTag != nil {
// update allow_tag if set
r.SetAllowTag(input.GetAllowTag())

eventsChanged = true
}

if input.AllowComment != nil {
// update allow_comment if set
r.SetAllowComment(input.GetAllowComment())

eventsChanged = true
}

// set default events if no events are enabled
if !r.GetAllowPull() && !r.GetAllowPush() &&
!r.GetAllowDeploy() && !r.GetAllowTag() &&
!r.GetAllowComment() {
r.SetAllowPull(true)
r.SetAllowPush(true)
}
// -- END DEPRECATED SECTION --

// set default events if no events are enabled
if r.GetAllowEvents().ToDatabase() == 0 {
r.SetAllowEvents(defaultAllowedEvents(defaultRepoEvents, defaultRepoEventsMask))
Expand Down
5 changes: 0 additions & 5 deletions api/secret/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,6 @@ func CreateSecret(c *gin.Context) {
input.SetAllowEvents(e)
}

if len(input.GetEvents()) == 0 {
// set default events to enable for the secret
input.SetEvents([]string{constants.EventPush, constants.EventTag, constants.EventDeploy})
}

if input.AllowCommand == nil {
input.SetAllowCommand(true)
}
Expand Down
4 changes: 0 additions & 4 deletions api/secret/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ func UpdateSecret(c *gin.Context) {
input.SetImages(util.Unique(input.GetImages()))
}

if len(input.GetEvents()) > 0 {
input.SetEvents(util.Unique(input.GetEvents()))
}

if input.AllowCommand != nil {
// update allow_command if set
input.SetAllowCommand(input.GetAllowCommand())
Expand Down
Loading

0 comments on commit f591935

Please sign in to comment.