From 61d49cab5e87f81ec6d4cdabb288a996d85c8e5b Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Mon, 20 Apr 2020 10:51:33 +0300 Subject: [PATCH] controller: Move SyncAt annotation to API --- api/v1alpha1/source.go | 5 +++++ controllers/predicate.go | 10 ++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api/v1alpha1/source.go b/api/v1alpha1/source.go index d98acd26..f82254a4 100644 --- a/api/v1alpha1/source.go +++ b/api/v1alpha1/source.go @@ -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" +) diff --git a/controllers/predicate.go b/controllers/predicate.go index 47826465..4f6ce208 100644 --- a/controllers/predicate.go +++ b/controllers/predicate.go @@ -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