Skip to content
Merged
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: 4 additions & 30 deletions applicationset/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"net/url"
"regexp"
"slices"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -234,7 +235,7 @@ func getPRGeneratorInfo(payload any) *prGeneratorInfo {
var info prGeneratorInfo
switch payload := payload.(type) {
case github.PullRequestPayload:
if !isAllowedGithubPullRequestAction(payload.Action) {
if !slices.Contains(githubAllowedPullRequestActions, payload.Action) {
return nil
}

Expand All @@ -250,7 +251,7 @@ func getPRGeneratorInfo(payload any) *prGeneratorInfo {
APIRegexp: apiRegexp,
}
case gitlab.MergeRequestEventPayload:
if !isAllowedGitlabPullRequestAction(payload.ObjectAttributes.Action) {
if !slices.Contains(gitlabAllowedPullRequestActions, payload.ObjectAttributes.Action) {
return nil
}

Expand All @@ -266,7 +267,7 @@ func getPRGeneratorInfo(payload any) *prGeneratorInfo {
APIHostname: urlObj.Hostname(),
}
case azuredevops.GitPullRequestEvent:
if !isAllowedAzureDevOpsPullRequestAction(string(payload.EventType)) {
if !slices.Contains(azuredevopsAllowedPullRequestActions, string(payload.EventType)) {
return nil
}

Expand Down Expand Up @@ -311,33 +312,6 @@ var azuredevopsAllowedPullRequestActions = []string{
"git.pullrequest.updated",
}

func isAllowedGithubPullRequestAction(action string) bool {
for _, allow := range githubAllowedPullRequestActions {
if allow == action {
return true
}
}
return false
}

func isAllowedGitlabPullRequestAction(action string) bool {
for _, allow := range gitlabAllowedPullRequestActions {
if allow == action {
return true
}
}
return false
}

func isAllowedAzureDevOpsPullRequestAction(action string) bool {
for _, allow := range azuredevopsAllowedPullRequestActions {
if allow == action {
return true
}
}
return false
}

func shouldRefreshGitGenerator(gen *v1alpha1.GitGenerator, info *gitGeneratorInfo) bool {
if gen == nil || info == nil {
return false
Expand Down
Loading