@@ -16,7 +16,6 @@ package trustroot
16
16
17
17
import (
18
18
"context"
19
- "time"
20
19
21
20
"k8s.io/client-go/tools/cache"
22
21
kubeclient "knative.dev/pkg/client/injection/kube/client"
@@ -30,15 +29,14 @@ import (
30
29
"github.com/sigstore/policy-controller/pkg/apis/config"
31
30
trustrootinformer "github.com/sigstore/policy-controller/pkg/client/injection/informers/policy/v1alpha1/trustroot"
32
31
trustrootreconciler "github.com/sigstore/policy-controller/pkg/client/injection/reconciler/policy/v1alpha1/trustroot"
32
+ "github.com/sigstore/policy-controller/pkg/tuf"
33
33
cminformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/configmap"
34
34
)
35
35
36
36
// This is what the default finalizer name is, but make it explicit so we can
37
37
// use it in tests as well.
38
38
const FinalizerName = "trustroots.policy.sigstore.dev"
39
39
40
- type trustrootResyncPeriodKey struct {}
41
-
42
40
// NewController creates a Reconciler and returns the result of NewImpl.
43
41
func NewController (
44
42
ctx context.Context ,
@@ -78,22 +76,8 @@ func NewController(
78
76
pkgreconciler .NamespaceFilterFunc (system .Namespace ()),
79
77
pkgreconciler .NameFilterFunc (config .SigstoreKeysConfigName )),
80
78
Handler : controller .HandleAll (grCb ),
81
- }, FromContextOrDefaults (ctx )); err != nil {
79
+ }, tuf . FromContextOrDefaults (ctx )); err != nil {
82
80
logging .FromContext (ctx ).Warnf ("Failed configMapInformer AddEventHandlerWithResyncPeriod() %v" , err )
83
81
}
84
82
return impl
85
83
}
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