mirror of
https://github.com/harness/drone.git
synced 2025-05-19 02:20:03 +08: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.
|
// Match returns true if an image and event match the restricted list.
|
||||||
func (s *Secret) Match(event string) bool {
|
func (s *Secret) Match(event string) bool {
|
||||||
|
if len(s.Events) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
for _, pattern := range s.Events {
|
for _, pattern := range s.Events {
|
||||||
if match, _ := filepath.Match(pattern, event); match {
|
if match, _ := filepath.Match(pattern, event); match {
|
||||||
return true
|
return true
|
||||||
|
@ -21,6 +21,10 @@ func TestSecret(t *testing.T) {
|
|||||||
secret.Events = []string{"pull_request"}
|
secret.Events = []string{"pull_request"}
|
||||||
g.Assert(secret.Match("push")).IsFalse()
|
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.It("should pass validation")
|
||||||
g.Describe("should fail validation", func() {
|
g.Describe("should fail validation", func() {
|
||||||
g.It("when no image")
|
g.It("when no image")
|
||||||
|
Loading…
Reference in New Issue
Block a user