better description

This commit is contained in:
ston1th 2019-12-06 23:20:46 +01:00
commit 9ee2dc4d06

27
main.go
View file

@ -59,18 +59,18 @@ func mapGitAPI(s string) string {
return ""
}
func mapState(s string) string {
func mapState(s string) (state, description string) {
switch s {
case "Running":
return "pending"
return "pending", "Pending - Job triggered."
case "PipelineRunCancelled":
return "error"
return "error", "Job cancelled."
case "Failed":
return "failure"
return "failure", "Job failed."
case "Succeeded":
return "success"
return "success", "Job succeeded."
}
return ""
return "", ""
}
type Status struct {
@ -184,7 +184,7 @@ func statusUpdate(obj interface{}, s *StatusCache, sec typedcorev1.SecretInterfa
fin = (*f).Time
}
sha, url := getGit(pr)
if sha == "" {
if sha == "" || sha == "master" {
return
}
if !s.Set(sha, status, start, fin) {
@ -263,10 +263,15 @@ func postStatus(pr *PipelineRun, gitUrl, sha, status string, sec *corev1.Secret)
if tektonurl == "" {
log.Printf("missing tektonurl parameter for %s/%s", pr.Namespace, pr.Name)
}
pipeline := "tekton"
if pr.Spec.PipelineRef != nil {
pipeline += "-" + pr.Spec.PipelineRef.Name
}
state, desc := mapState(status)
s := &GitStatus{
Context: "tekton",
Description: pr.Name,
State: mapState(status),
Context: pipeline,
Description: desc,
State: state,
TargetURL: tektonurl,
}
buf := new(bytes.Buffer)
@ -401,7 +406,7 @@ func main() {
return
}
sha, _ := getGit(pr)
if sha != "" {
if sha != "" && sha != "master" {
s.Remove(sha)
}
},