From 3f3abe88f6a35136445ae942e343fc90eea28f8b Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sat, 20 May 2017 01:01:30 +0200 Subject: [PATCH] secret event can be empty --- model/secret.go | 3 +++ model/secret_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/model/secret.go b/model/secret.go index 159fba5d5..1cfd8a108 100644 --- a/model/secret.go +++ b/model/secret.go @@ -44,6 +44,9 @@ type Secret struct { // Match returns true if an image and event match the restricted list. func (s *Secret) Match(event string) bool { + if len(s.Events) == 0 { + return true + } for _, pattern := range s.Events { if match, _ := filepath.Match(pattern, event); match { return true diff --git a/model/secret_test.go b/model/secret_test.go index b2f39149b..16e1e6594 100644 --- a/model/secret_test.go +++ b/model/secret_test.go @@ -21,6 +21,10 @@ func TestSecret(t *testing.T) { secret.Events = []string{"pull_request"} g.Assert(secret.Match("push")).IsFalse() }) + g.It("should match when no event filters defined", func() { + secret := Secret{} + g.Assert(secret.Match("pull_request")).IsTrue() + }) g.It("should pass validation") g.Describe("should fail validation", func() { g.It("when no image")