secret event can be empty

This commit is contained in:
Brad Rydzewski 2017-05-20 01:01:30 +02:00
parent 108e3fe93b
commit 3f3abe88f6
2 changed files with 7 additions and 0 deletions

View file

@ -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

View file

@ -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")