Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove legacy event code from repo and secret #1098

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 All @@ -223,7 +195,7 @@

return
}
r.SetPipelineType(input.GetPipelineType())

Check failure on line 198 in api/repo/create.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] api/repo/create.go#L198

expressions should not be cuddled with blocks (wsl)
Raw output
api/repo/create.go:198:3: expressions should not be cuddled with blocks (wsl)
		r.SetPipelineType(input.GetPipelineType())
		^
}

// create unique id for the repo
Expand Down Expand Up @@ -275,11 +247,7 @@

// 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
Loading