diff --git a/apis/meta/annotations.go b/apis/meta/annotations.go index 4fd37c9c7..01d4612e7 100644 --- a/apis/meta/annotations.go +++ b/apis/meta/annotations.go @@ -17,36 +17,17 @@ limitations under the License. package meta const ( - // ReconcileAtAnnotation is the annotation used for triggering a reconciliation - // outside of the defined schedule. Despite the name, the value is not - // interpreted as a timestamp, and any change in value shall trigger a - // reconciliation. - // DEPRECATED: has been replaced by ReconcileRequestAnnotation. For - // backward-compatibility, use ReconcileAnnotationValue, which will account for - // both annotations. - ReconcileAtAnnotation string = "fluxcd.io/reconcileAt" - // ReconcileRequestAnnotation is the annotation used for triggering a reconciliation // outside of a defined schedule. The value is interpreted as a token, and any change // in value SHOULD trigger a reconciliation. ReconcileRequestAnnotation string = "reconcile.fluxcd.io/requestedAt" ) -// ReconcileAnnotationValue returns a value for the reconciliation request annotations, which can be used to detect -// changes; and, a boolean indicating whether either annotation was set. +// ReconcileAnnotationValue returns a value for the reconciliation request annotation, which can be used to detect +// changes; and, a boolean indicating whether the annotation was set. func ReconcileAnnotationValue(annotations map[string]string) (string, bool) { - reconcileAt, ok1 := annotations[ReconcileAtAnnotation] - requestedAt, ok2 := annotations[ReconcileRequestAnnotation] - // the values are concatenated; this means - // - a change in either will be detectable*, and - // - if one is set, the value will be just that; and, - // - if neither is set, it's a zero value. - // - // *unless the change is to shift a substring across the - // interstice between the strings; e.g., by swapping the value - // from one annotation to the other. Assuming a fresh timestamp is - // used each time, this caveat won't matter. - return reconcileAt + requestedAt, ok1 || ok2 + requestedAt, ok := annotations[ReconcileRequestAnnotation] + return requestedAt, ok } // ReconcileRequestStatus is a struct to embed in a status type, so that all types using the mechanism have the same diff --git a/apis/meta/annotations_test.go b/apis/meta/annotations_test.go index f923613df..9ee738ed3 100644 --- a/apis/meta/annotations_test.go +++ b/apis/meta/annotations_test.go @@ -41,8 +41,8 @@ func TestGetAnnotationValue(t *testing.T) { } obj.Status.SetLastHandledReconcileRequest(val) - // set one annotation: should detect a change - obj.Annotations[ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano) + // set annotation: should detect a change + obj.Annotations[ReconcileRequestAnnotation] = time.Now().Format(time.RFC3339Nano) val, ok = ReconcileAnnotationValue(obj.Annotations) if !ok { t.Error("expected ReconcileAnnotationValue to return true when an annotation is set") @@ -54,7 +54,7 @@ func TestGetAnnotationValue(t *testing.T) { obj.Status.SetLastHandledReconcileRequest(val) - // set the other annotation; should detect a change + // update annotation; should detect a change obj.Annotations[ReconcileRequestAnnotation] = time.Now().Format(time.RFC3339Nano) val, ok = ReconcileAnnotationValue(obj.Annotations) if !ok { diff --git a/runtime/predicates/reconcile_at_changed.go b/runtime/predicates/reconcile_at_changed.go deleted file mode 100644 index 4fbd66595..000000000 --- a/runtime/predicates/reconcile_at_changed.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright 2020 The Flux authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package predicates - -// ReconcilateAtChangedPredicate detects meta.ReconcileAtAnnotation changes. -// -// DEPRECATED: use ReconcileRequestedPredicate instead. -type ReconcilateAtChangedPredicate struct { - ReconcileRequestedPredicate -}