@@ -16,7 +16,6 @@ package trustroot
1616
1717import (
1818 "context"
19- "time"
2019
2120 "k8s.io/client-go/tools/cache"
2221 kubeclient "knative.dev/pkg/client/injection/kube/client"
@@ -30,15 +29,14 @@ import (
3029 "github.com/sigstore/policy-controller/pkg/apis/config"
3130 trustrootinformer "github.com/sigstore/policy-controller/pkg/client/injection/informers/policy/v1alpha1/trustroot"
3231 trustrootreconciler "github.com/sigstore/policy-controller/pkg/client/injection/reconciler/policy/v1alpha1/trustroot"
32+ "github.com/sigstore/policy-controller/pkg/tuf"
3333 cminformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/configmap"
3434)
3535
3636// This is what the default finalizer name is, but make it explicit so we can
3737// use it in tests as well.
3838const FinalizerName = "trustroots.policy.sigstore.dev"
3939
40- type trustrootResyncPeriodKey struct {}
41-
4240// NewController creates a Reconciler and returns the result of NewImpl.
4341func NewController (
4442 ctx context.Context ,
@@ -78,22 +76,8 @@ func NewController(
7876 pkgreconciler .NamespaceFilterFunc (system .Namespace ()),
7977 pkgreconciler .NameFilterFunc (config .SigstoreKeysConfigName )),
8078 Handler : controller .HandleAll (grCb ),
81- }, FromContextOrDefaults (ctx )); err != nil {
79+ }, tuf . FromContextOrDefaults (ctx )); err != nil {
8280 logging .FromContext (ctx ).Warnf ("Failed configMapInformer AddEventHandlerWithResyncPeriod() %v" , err )
8381 }
8482 return impl
8583}
86-
87- func ToContext (ctx context.Context , duration time.Duration ) context.Context {
88- return context .WithValue (ctx , trustrootResyncPeriodKey {}, duration )
89- }
90-
91- // FromContextOrDefaults returns a stored trustrootResyncPeriod if attached.
92- // If not found, it returns a default duration
93- func FromContextOrDefaults (ctx context.Context ) time.Duration {
94- x , ok := ctx .Value (trustrootResyncPeriodKey {}).(time.Duration )
95- if ok {
96- return x
97- }
98- return controller .DefaultResyncPeriod
99- }
0 commit comments