mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
secret event can be empty
This commit is contained in:
parent
108e3fe93b
commit
3f3abe88f6
@ -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
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user