github.com/abayer/test-infra@v0.0.5/mungegithub/mungers/matchers/item.go (about) 1 /* 2 Copyright 2017 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package matchers 18 19 import ( 20 "time" 21 22 "github.com/google/go-github/github" 23 ) 24 25 type Item interface { 26 Match(matcher Matcher) bool 27 Date() *time.Time 28 AppendEvent(events []*github.IssueEvent) []*github.IssueEvent 29 AppendComment(comments []*github.IssueComment) []*github.IssueComment 30 AppendReviewComment(comments []*github.PullRequestComment) []*github.PullRequestComment 31 } 32 33 type Event github.IssueEvent 34 35 var _ Item = &Event{} 36 37 func (e *Event) Match(matcher Matcher) bool { 38 return matcher.MatchEvent((*github.IssueEvent)(e)) 39 } 40 41 func (e *Event) Date() *time.Time { 42 return e.CreatedAt 43 } 44 45 func (e *Event) AppendEvent(events []*github.IssueEvent) []*github.IssueEvent { 46 return append(events, (*github.IssueEvent)(e)) 47 } 48 49 func (e *Event) AppendComment(comments []*github.IssueComment) []*github.IssueComment { 50 return comments 51 } 52 53 func (e *Event) AppendReviewComment(reviews []*github.PullRequestComment) []*github.PullRequestComment { 54 return reviews 55 } 56 57 type Comment github.IssueComment 58 59 var _ Item = &Comment{} 60 61 func (c *Comment) Match(matcher Matcher) bool { 62 return matcher.MatchComment((*github.IssueComment)(c)) 63 } 64 65 func (c *Comment) Date() *time.Time { 66 return c.UpdatedAt 67 } 68 69 func (c *Comment) AppendEvent(events []*github.IssueEvent) []*github.IssueEvent { 70 return events 71 } 72 73 func (c *Comment) AppendComment(comments []*github.IssueComment) []*github.IssueComment { 74 return append(comments, (*github.IssueComment)(c)) 75 } 76 77 func (c *Comment) AppendReviewComment(reviews []*github.PullRequestComment) []*github.PullRequestComment { 78 return reviews 79 } 80 81 type ReviewComment github.PullRequestComment 82 83 var _ Item = &ReviewComment{} 84 85 func (r *ReviewComment) Match(matcher Matcher) bool { 86 return matcher.MatchReviewComment((*github.PullRequestComment)(r)) 87 } 88 89 func (r *ReviewComment) Date() *time.Time { 90 return r.UpdatedAt 91 } 92 93 func (r *ReviewComment) AppendEvent(events []*github.IssueEvent) []*github.IssueEvent { 94 return events 95 } 96 97 func (r *ReviewComment) AppendComment(comments []*github.IssueComment) []*github.IssueComment { 98 return comments 99 } 100 101 func (r *ReviewComment) AppendReviewComment(reviews []*github.PullRequestComment) []*github.PullRequestComment { 102 return append(reviews, (*github.PullRequestComment)(r)) 103 }