updated readme

This commit is contained in:
ston1th 2019-12-04 14:35:13 +01:00
commit 32eaa11037
2 changed files with 17 additions and 19 deletions

View file

@ -1,6 +1,6 @@
# status-reporter # status-reporter
The status reporter is a controller that watches pipelineruns for status cahnges. The status reporter is a controller that watches tekton `PipelineRuns` for status cahnges.
These are synced to the associated git commit hashes. These are synced to the associated git commit hashes.
For successful runs a preview environment comment will be added to the pull request. For successful runs a preview environment comment will be added to the pull request.
@ -13,11 +13,11 @@ Params:
* issue - pull request issue id * issue - pull request issue id
* scheme - `http://` or `https://` * scheme - `http://` or `https://`
* tektonurl - `http://tekton-dashboard.example.com` * tektonurl - `http://tekton-dashboard.example.com`
* previewurl - url to your deployed preview environment * previewurl - `my-preview-env.example.com`
Resources: Resources:
* git - revision: githash, url: clone_url * git - revision: git commit hash, url: `https://github.com/example/repo.git`
# Requirements # Requirements

30
main.go
View file

@ -21,12 +21,11 @@ import (
pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/client/clientset/versioned" "github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
extinf "github.com/tektoncd/pipeline/pkg/client/informers/externalversions" extinf "github.com/tektoncd/pipeline/pkg/client/informers/externalversions"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
//"k8s.io/apimachinery/pkg/types"
//"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
) )
@ -88,7 +87,7 @@ func NewStatusCache() *StatusCache {
return &StatusCache{cache: make(map[string]Status)} return &StatusCache{cache: make(map[string]Status)}
} }
func (sc *StatusCache) Set(sha, status string, st, fin time.Time) bool { func (sc *StatusCache) Set(sha, status string, st, fin time.Time) (ret bool) {
sc.Lock() sc.Lock()
defer sc.Unlock() defer sc.Unlock()
s, ok := sc.cache[sha] s, ok := sc.cache[sha]
@ -102,26 +101,25 @@ func (sc *StatusCache) Set(sha, status string, st, fin time.Time) bool {
return true return true
} }
if fin.After(s.Date) { if fin.After(s.Date) {
log.Printf("updating status in cache: %s %s", sha, status)
sc.cache[sha] = Status{status, fin} sc.cache[sha] = Status{status, fin}
return true ret = true
} }
if st.After(s.Date) { if !ret && st.After(s.Date) {
log.Printf("updating status in cache: %s %s", sha, status)
sc.cache[sha] = Status{status, st} sc.cache[sha] = Status{status, st}
return true ret = true
} }
if fin.Equal(s.Date) && s.Type != status { if !ret && fin.Equal(s.Date) && s.Type != status {
log.Printf("updating status in cache: %s %s", sha, status)
sc.cache[sha] = Status{status, fin} sc.cache[sha] = Status{status, fin}
return true ret = true
} }
if st.Equal(s.Date) && s.Type != status { if !ret && st.Equal(s.Date) && s.Type != status {
log.Printf("updating status in cache: %s %s", sha, status)
sc.cache[sha] = Status{status, st} sc.cache[sha] = Status{status, st}
return true ret = true
} }
return false if ret {
log.Printf("updating status in cache: %s %s", sha, status)
}
return ret
} }
func (sc *StatusCache) Remove(sha string) { func (sc *StatusCache) Remove(sha string) {