Skip to content

Commit

Permalink
fix(events): add action to deployment check (#1117)
Browse files Browse the repository at this point in the history
* fix(events): add action to deployment check

* fix compiler tests
  • Loading branch information
ecrupper authored May 3, 2024
1 parent 58ef7e8 commit 7693199
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (e *Events) Allowed(event, action string) bool {
allowed = e.GetComment().GetCreated()
case constants.EventComment + ":" + constants.ActionEdited:
allowed = e.GetComment().GetEdited()
case constants.EventDeploy:
case constants.EventDeploy + ":" + constants.ActionCreated:
allowed = e.GetDeployment().GetCreated()
case constants.EventSchedule:
allowed = e.GetSchedule().GetRun()
Expand Down
2 changes: 1 addition & 1 deletion api/types/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func TestTypes_Events_Allowed(t *testing.T) {
{event: "pull_request", action: "reopened", want: true},
{event: "pull_request", action: "labeled", want: false},
{event: "pull_request", action: "unlabeled", want: true},
{event: "deployment", want: false},
{event: "deployment", action: "created", want: false},
{event: "comment", action: "created", want: true},
{event: "comment", action: "edited", want: false},
{event: "schedule", want: true},
Expand Down
6 changes: 3 additions & 3 deletions compiler/native/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3317,7 +3317,7 @@ func Test_CompileLite(t *testing.T) {
Pull: "not_present",
Ruleset: yaml.Ruleset{
If: yaml.Rules{
Event: []string{"deployment"},
Event: []string{"deployment:created"},
Target: []string{"production"},
},
Matcher: "filepath",
Expand Down Expand Up @@ -3396,7 +3396,7 @@ func Test_CompileLite(t *testing.T) {
pipelineType: "",
substitute: true,
ruleData: &pipeline.RuleData{
Event: "deployment",
Event: "deployment:created",
Target: "production",
Path: []string{"README.md"},
},
Expand All @@ -3421,7 +3421,7 @@ func Test_CompileLite(t *testing.T) {
Pull: "not_present",
Ruleset: yaml.Ruleset{
If: yaml.Rules{
Event: []string{"deployment"},
Event: []string{"deployment:created"},
Target: []string{"production"},
},
Matcher: "filepath",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/ghodss/yaml v1.0.0
github.com/gin-gonic/gin v1.9.1
github.com/go-playground/assert/v2 v2.2.0
github.com/go-vela/types v0.23.4-0.20240405205548-f24f795ac0b7
github.com/go-vela/types v0.23.4-0.20240417135026-fb4a95c30338
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/go-cmp v0.6.0
github.com/google/go-github/v61 v61.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ 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-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw=
github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/go-vela/types v0.23.4-0.20240405205548-f24f795ac0b7 h1:3mN7ej69dMH3Vis3G/tPLzLL0Rfp8nR5qd0gpj5ejRM=
github.com/go-vela/types v0.23.4-0.20240405205548-f24f795ac0b7/go.mod h1:mEF9dLkk00rUXf/t39n2WvXZgJbxnPEEWy+DHqIlRUo=
github.com/go-vela/types v0.23.4-0.20240417135026-fb4a95c30338 h1:I0v47dOdAvjX7lOFN4s28uONChmluD6TNgFL1hpav60=
github.com/go-vela/types v0.23.4-0.20240417135026-fb4a95c30338/go.mod h1:vISsYDdjz9RPEK6qZ+MxtrdZEjTVU4K30NomB3826u8=
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

0 comments on commit 7693199

Please sign in to comment.