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

feat(delete event): add functionality for delete event #520

Merged
merged 6 commits into from
Jan 25, 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
7 changes: 7 additions & 0 deletions action/repo/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func populateEvents(r *library.Repo, events []string) {
r.SetAllowComment(true)
comment.SetCreated(true)
comment.SetEdited(true)
case constants.EventDelete:
push.SetDeleteBranch(true)
push.SetDeleteTag(true)
case constants.EventPull + ":" + constants.ActionOpened:
pull.SetOpened(true)
case constants.EventPull + ":" + constants.ActionEdited:
Expand All @@ -134,6 +137,10 @@ func populateEvents(r *library.Repo, events []string) {
comment.SetCreated(true)
case constants.EventComment + ":" + constants.ActionEdited:
comment.SetEdited(true)
case constants.EventDelete + ":" + constants.ActionBranch:
push.SetDeleteBranch(true)
case constants.EventDelete + ":" + constants.ActionTag:
push.SetDeleteTag(true)
}
}

Expand Down
16 changes: 10 additions & 6 deletions action/repo/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func TestRepo_populateEvents(t *testing.T) {
}{
{
name: "happy path legacy events",
events: []string{"push", "pull_request", "tag", "deploy", "comment"},
events: []string{"push", "pull_request", "tag", "deploy", "comment", "delete"},
want: &library.Repo{
AllowPush: &tBool,
AllowPull: &tBool,
Expand All @@ -175,8 +175,10 @@ func TestRepo_populateEvents(t *testing.T) {
AllowComment: &tBool,
AllowEvents: &library.Events{
Push: &actions.Push{
Branch: &tBool,
Tag: &tBool,
Branch: &tBool,
Tag: &tBool,
DeleteBranch: &tBool,
DeleteTag: &tBool,
},
PullRequest: &actions.Pull{
Opened: &tBool,
Expand All @@ -195,7 +197,7 @@ func TestRepo_populateEvents(t *testing.T) {
},
{
name: "action specific",
events: []string{"push:branch", "push:tag", "pull_request:opened", "pull_request:edited", "deployment:created", "comment:created"},
events: []string{"push:branch", "push:tag", "pull_request:opened", "pull_request:edited", "deployment:created", "comment:created", "delete:branch", "delete:tag"},
want: &library.Repo{
AllowPush: &tBool,
AllowPull: &fBool,
Expand All @@ -204,8 +206,10 @@ func TestRepo_populateEvents(t *testing.T) {
AllowComment: &fBool,
AllowEvents: &library.Events{
Push: &actions.Push{
Branch: &tBool,
Tag: &tBool,
Branch: &tBool,
Tag: &tBool,
DeleteBranch: &tBool,
DeleteTag: &tBool,
},
PullRequest: &actions.Pull{
Opened: &tBool,
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/gin-gonic/gin v1.9.1
github.com/go-git/go-git/v5 v5.11.0
github.com/go-vela/sdk-go v0.22.1-0.20240110210525-4a16c9235b7a
github.com/go-vela/server v0.22.3-0.20240105215421-78eca514b01d
github.com/go-vela/types v0.22.1-0.20240111192144-0d0e22367796
github.com/go-vela/worker v0.22.0
github.com/go-vela/sdk-go v0.22.1-0.20240118151315-18ea1c51b5b2
github.com/go-vela/server v0.22.3-0.20240124164127-136cd544d576
github.com/go-vela/types v0.22.1-0.20240122175704-d058de26b401
github.com/go-vela/worker v0.22.1-0.20240118173944-724912db3b72
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/go-cmp v0.6.0
github.com/gosuri/uitable v0.0.4
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/go-vela/sdk-go v0.22.1-0.20240110210525-4a16c9235b7a h1:s95Qx5fPiK2eFJDu4vFudir57fWNt2MvcwP9+zzynTY=
github.com/go-vela/sdk-go v0.22.1-0.20240110210525-4a16c9235b7a/go.mod h1:EVAthIAXxYtP6I/AxbzTJngTtgvLwrNtRLZ39TBqZtg=
github.com/go-vela/server v0.22.3-0.20240105215421-78eca514b01d h1:cxFWuaKJEqn6yrgNTWiPIwwiYg+PvkFzvakJWSFL/rI=
github.com/go-vela/server v0.22.3-0.20240105215421-78eca514b01d/go.mod h1:whH2iqp3dZhBzo3z4AC/g9ChpDX/UO0ig+gZn24u58g=
github.com/go-vela/types v0.22.1-0.20240111192144-0d0e22367796 h1:fjma5QAoncoknvTOp2AL/qYDOt4liWkZS5+sUaCQKJw=
github.com/go-vela/types v0.22.1-0.20240111192144-0d0e22367796/go.mod h1:cax3mW1kVz/ioI8qltZE+wl9rOLgOPdwBIvCooL09e4=
github.com/go-vela/worker v0.22.0 h1:zmGiuykclbd0cfH6XKpCnoeIagYhYt7CJQ/y5HfqjZk=
github.com/go-vela/worker v0.22.0/go.mod h1:ErPzlBEBWgYcinlbscn5q+9iArIuajy1DO+Oe9Ya2NA=
github.com/go-vela/sdk-go v0.22.1-0.20240118151315-18ea1c51b5b2 h1:yM4z4PSY2Jr/edCIFjoQwKbr7W0WNnHAavp4LsHm+IA=
github.com/go-vela/sdk-go v0.22.1-0.20240118151315-18ea1c51b5b2/go.mod h1:EVAthIAXxYtP6I/AxbzTJngTtgvLwrNtRLZ39TBqZtg=
github.com/go-vela/server v0.22.3-0.20240124164127-136cd544d576 h1:GQgYRl6sUJAcSk2BuRcN8nd1uoWGFdZqRafph4Kzvp0=
github.com/go-vela/server v0.22.3-0.20240124164127-136cd544d576/go.mod h1:4fjiQD+7EAMxjJ1/qsnWpCrM7hrssY52aQr9o5T6UKA=
github.com/go-vela/types v0.22.1-0.20240122175704-d058de26b401 h1:LdqaHKseq6EUXIJU0h01p14J2rpXF2oFwKbJtsrdE2Y=
github.com/go-vela/types v0.22.1-0.20240122175704-d058de26b401/go.mod h1:cax3mW1kVz/ioI8qltZE+wl9rOLgOPdwBIvCooL09e4=
github.com/go-vela/worker v0.22.1-0.20240118173944-724912db3b72 h1:nW9WwRN7RMrvpG0VIhizEHlWErvUMbIlOb8K+hDlVzE=
github.com/go-vela/worker v0.22.1-0.20240118173944-724912db3b72/go.mod h1:ErPzlBEBWgYcinlbscn5q+9iArIuajy1DO+Oe9Ya2NA=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
Expand Down
Loading