Skip to content

Commit

Permalink
Merge pull request #5 from LeakIX/develop
Browse files Browse the repository at this point in the history
Added optional tags filtering to plugin interface
  • Loading branch information
gboddin authored Jul 8, 2021
2 parents b5ed754 + 2e87fb5 commit 100930c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions l9plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type WebPluginRequest struct {
Headers map[string]string
Body []byte
hashCache string
Tags []string
}

type WebPluginResponse struct {
Expand Down Expand Up @@ -145,4 +146,35 @@ func (request *WebPluginRequest) EqualAny(testRequests []WebPluginRequest) bool
}
}
return false
}

func (request *WebPluginRequest) HasTag(tag string) bool {
for _, eventTag := range request.Tags {
if eventTag == tag {
return true
}
}
return false
}

func (request *WebPluginRequest) HasAnyTags(tags []string) bool {
for _, tag := range tags {
if request.HasTag(tag) {
return true
}
}
return false
}

func (request *WebPluginRequest) AddTags(tags []string) {
for _, tag := range tags {
request.AddTag(tag)
}
}


func (request *WebPluginRequest) AddTag(tag string) {
if !request.HasTag(tag) {
request.Tags = append(request.Tags, tag)
}
}

0 comments on commit 100930c

Please sign in to comment.