本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.GetStatusTime方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.GetStatusTime方法的具體用法?Golang MungeObject.GetStatusTime怎麽用?Golang MungeObject.GetStatusTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.MungeObject
的用法示例。
在下文中一共展示了MungeObject.GetStatusTime方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Munge
// Munge is the workhorse the will actually make updates to the PR
func (StaleGreenCI) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if !obj.HasLabel(lgtmLabel) {
return
}
if mergeable, err := obj.IsMergeable(); !mergeable || err != nil {
return
}
if !obj.IsStatusSuccess(requiredContexts) {
return
}
for _, context := range requiredContexts {
statusTime := obj.GetStatusTime(context)
if statusTime == nil {
glog.Errorf("%d: unable to determine time %q context was set", *obj.Issue.Number, context)
return
}
if time.Since(*statusTime) > staleGreenCIHours*time.Hour {
obj.WriteComment(greenMsgBody)
err := obj.WaitForPending(requiredContexts)
if err != nil {
glog.Errorf("Failed waiting for PR to start testing: %v", err)
}
return
}
}
}
示例2: Munge
// Munge is the workhorse the will actually make updates to the PR
func (StalePendingCI) Munge(obj *github.MungeObject) {
requiredContexts := []string{jenkinsUnitContext, jenkinsE2EContext}
if !obj.IsPR() {
return
}
if !obj.HasLabel(lgtmLabel) {
return
}
if mergeable, err := obj.IsMergeable(); !mergeable || err != nil {
return
}
status := obj.GetStatusState(requiredContexts)
if status != "pending" {
return
}
for _, context := range requiredContexts {
statusTime := obj.GetStatusTime(context)
if statusTime == nil {
glog.Errorf("%d: unable to determine time %q context was set", *obj.Issue.Number, context)
return
}
if time.Since(*statusTime) > stalePendingCIHours*time.Hour {
obj.WriteComment(pendingMsgBody)
return
}
}
}
示例3: commentBeforeLastCI
func commentBeforeLastCI(obj *github.MungeObject, comment *githubapi.IssueComment) bool {
if !obj.IsStatusSuccess(requiredContexts) {
return false
}
if comment.CreatedAt == nil {
return false
}
commentTime := *comment.CreatedAt
for _, context := range requiredContexts {
statusTimeP := obj.GetStatusTime(context)
if statusTimeP == nil {
return false
}
statusTime := statusTimeP.Add(30 * time.Minute)
if commentTime.After(statusTime) {
return false
}
}
return true
}
示例4: Munge
// Munge is the workhorse the will actually make updates to the PR
func (StaleUnitTestMunger) Munge(obj *github.MungeObject) {
requiredContexts := []string{jenkinsUnitContext, jenkinsE2EContext}
if !obj.IsPR() {
return
}
if !obj.HasLabels([]string{"lgtm"}) {
return
}
if mergeable, err := obj.IsMergeable(); !mergeable || err != nil {
return
}
if !obj.IsStatusSuccess(requiredContexts) {
return
}
for _, context := range requiredContexts {
statusTime := obj.GetStatusTime(context)
if statusTime == nil {
glog.Errorf("%d: unable to determine time %q context was set", *obj.Issue.Number, context)
return
}
if time.Since(*statusTime) > staleHours*time.Hour {
msgFormat := `@k8s-bot test this
Tests are more than %d hours old. Re-running tests.`
msg := fmt.Sprintf(msgFormat, staleHours)
obj.WriteComment(msg)
err := obj.WaitForPending(requiredContexts)
if err != nil {
glog.Errorf("Failed waiting for PR to start testing: %v", err)
}
return
}
}
}
示例5: Munge
// Munge is the workhorse the will actually make updates to the PR
func (StalePendingCI) Munge(obj *github.MungeObject) {
requiredContexts := []string{jenkinsUnitContext, jenkinsE2EContext}
if !obj.IsPR() {
return
}
if !obj.HasLabel("lgtm") {
return
}
if mergeable, err := obj.IsMergeable(); !mergeable || err != nil {
return
}
status := obj.GetStatusState(requiredContexts)
if status != "pending" {
return
}
for _, context := range requiredContexts {
statusTime := obj.GetStatusTime(context)
if statusTime == nil {
glog.Errorf("%d: unable to determine time %q context was set", *obj.Issue.Number, context)
return
}
if time.Since(*statusTime) > stalePendingCIHours*time.Hour {
msgFormat := `@k8s-bot test this issue: #IGNORE
Tests have been pending for %d hours`
msg := fmt.Sprintf(msgFormat, stalePendingCIHours)
obj.WriteComment(msg)
return
}
}
}