diff --git a/util/consistencydetector/data_consistency_detector.go b/util/consistencydetector/data_consistency_detector.go index 32ee2c76..06f172d8 100644 --- a/util/consistencydetector/data_consistency_detector.go +++ b/util/consistencydetector/data_consistency_detector.go @@ -19,8 +19,10 @@ package consistencydetector import ( "context" "fmt" + "os" "reflect" "sort" + "strconv" "time" "k8s.io/apimachinery/pkg/api/meta" @@ -31,6 +33,18 @@ import ( "k8s.io/klog/v2" ) +var dataConsistencyDetectionForWatchListEnabled = false + +func init() { + dataConsistencyDetectionForWatchListEnabled, _ = strconv.ParseBool(os.Getenv("KUBE_WATCHLIST_INCONSISTENCY_DETECTOR")) +} + +// IsDataConsistencyDetectionForWatchListEnabled returns true when +// the KUBE_WATCHLIST_INCONSISTENCY_DETECTOR environment variable was set during a binary startup. +func IsDataConsistencyDetectionForWatchListEnabled() bool { + return dataConsistencyDetectionForWatchListEnabled +} + type RetrieveItemsFunc[U any] func() []U type ListFunc[T runtime.Object] func(ctx context.Context, options metav1.ListOptions) (T, error) diff --git a/util/consistencydetector/watch_list_data_consistency_detector.go b/util/consistencydetector/watch_list_data_consistency_detector.go deleted file mode 100644 index 67b5a511..00000000 --- a/util/consistencydetector/watch_list_data_consistency_detector.go +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright 2024 The Kubernetes 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 consistencydetector - -import ( - "os" - "strconv" -) - -var dataConsistencyDetectionForWatchListEnabled = false - -func init() { - dataConsistencyDetectionForWatchListEnabled, _ = strconv.ParseBool(os.Getenv("KUBE_WATCHLIST_INCONSISTENCY_DETECTOR")) -} - -// IsDataConsistencyDetectionForWatchListEnabled returns true when -// the KUBE_WATCHLIST_INCONSISTENCY_DETECTOR environment variable was set during a binary startup. -func IsDataConsistencyDetectionForWatchListEnabled() bool { - return dataConsistencyDetectionForWatchListEnabled -}