controller: Move SyncAt annotation to API

This commit is contained in:
stefanprodan 2020-04-20 10:51:33 +03:00
parent fce046f440
commit 61d49cab5e
2 changed files with 9 additions and 6 deletions

View File

@ -11,3 +11,8 @@ type Source interface {
// GetInterval returns the interval at which the source is updated.
GetInterval() metav1.Duration
}
const (
// SyncAtAnnotation is the timestamp corresponding to an on-demand source sync.
SyncAtAnnotation string = "source.fluxcd.io/syncAt"
)

View File

@ -24,6 +24,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
)
type SourceChangePredicate struct {
@ -43,8 +45,8 @@ func (SourceChangePredicate) Update(e event.UpdateEvent) bool {
}
// handle force sync
if val, ok := e.MetaNew.GetAnnotations()[ForceSyncAnnotation]; ok {
if valOld, okOld := e.MetaOld.GetAnnotations()[ForceSyncAnnotation]; okOld {
if val, ok := e.MetaNew.GetAnnotations()[sourcev1.SyncAtAnnotation]; ok {
if valOld, okOld := e.MetaOld.GetAnnotations()[sourcev1.SyncAtAnnotation]; okOld {
if val != valOld {
return true
}
@ -56,10 +58,6 @@ func (SourceChangePredicate) Update(e event.UpdateEvent) bool {
return false
}
const (
ForceSyncAnnotation string = "source.fluxcd.io/syncAt"
)
type GarbageCollectPredicate struct {
predicate.Funcs
Scheme *runtime.Scheme