@@ -53,46 +53,46 @@ var _ = Describe("controller", func() {
53
53
Describe ("controller" , func () {
54
54
// TODO(directxman12): write a whole suite of controller-client interaction tests
55
55
56
- // Since all tests are run in parallel and share the same testenv, we namespace the objects
57
- // created by using a namespace per entry, and adding a watch predicate that filters by
58
- // namespace.
56
+ // Since all tests are run in parallel and share the same testenv, we namespace the objects
57
+ // created by using a namespace per entry, and adding a watch predicate that filters by
58
+ // namespace.
59
59
DescribeTable ("should reconcile" , func (enableWarmup bool ) {
60
60
By ("Creating the Manager" )
61
61
cm , err := manager .New (cfg , manager.Options {})
62
62
Expect (err ).NotTo (HaveOccurred ())
63
63
64
64
By ("Creating the Controller" )
65
65
instance , err := controller .New (
66
- fmt .Sprintf ("foo-controller-%t" , enableWarmup ),
67
- cm ,
68
- controller.Options {
69
- Reconciler : reconcile .Func (
70
- func (_ context.Context , request reconcile.Request ) (reconcile.Result , error ) {
71
- reconciled <- request
72
- return reconcile.Result {}, nil
73
- }),
74
- EnableWarmup : ptr .To (enableWarmup ),
75
- },
76
- )
66
+ fmt .Sprintf ("foo-controller-%t" , enableWarmup ),
67
+ cm ,
68
+ controller.Options {
69
+ Reconciler : reconcile .Func (
70
+ func (_ context.Context , request reconcile.Request ) (reconcile.Result , error ) {
71
+ reconciled <- request
72
+ return reconcile.Result {}, nil
73
+ }),
74
+ EnableWarmup : ptr .To (enableWarmup ),
75
+ },
76
+ )
77
77
Expect (err ).NotTo (HaveOccurred ())
78
78
79
- testNamespace := strconv .FormatBool (enableWarmup )
79
+ testNamespace := strconv .FormatBool (enableWarmup )
80
80
81
81
By ("Watching Resources" )
82
82
err = instance .Watch (
83
83
source .Kind (cm .GetCache (), & appsv1.ReplicaSet {},
84
84
handler .TypedEnqueueRequestForOwner [* appsv1.ReplicaSet ](cm .GetScheme (), cm .GetRESTMapper (), & appsv1.Deployment {}),
85
- makeNamespacePredicate [* appsv1.ReplicaSet ](testNamespace ),
85
+ makeNamespacePredicate [* appsv1.ReplicaSet ](testNamespace ),
86
86
),
87
87
)
88
88
Expect (err ).NotTo (HaveOccurred ())
89
89
90
90
err = instance .Watch (
91
- source .Kind (cm .GetCache (), & appsv1.Deployment {},
92
- & handler.TypedEnqueueRequestForObject [* appsv1.Deployment ]{},
93
- makeNamespacePredicate [* appsv1.Deployment ](testNamespace ),
94
- ),
95
- )
91
+ source .Kind (cm .GetCache (), & appsv1.Deployment {},
92
+ & handler.TypedEnqueueRequestForObject [* appsv1.Deployment ]{},
93
+ makeNamespacePredicate [* appsv1.Deployment ](testNamespace ),
94
+ ),
95
+ )
96
96
Expect (err ).NotTo (HaveOccurred ())
97
97
98
98
err = cm .GetClient ().Get (ctx , types.NamespacedName {Name : "foo" }, & corev1.Namespace {})
@@ -135,11 +135,11 @@ var _ = Describe("controller", func() {
135
135
Name : "deployment-name" ,
136
136
}}
137
137
138
- By ("Creating the test namespace" )
139
- _ , err = clientset .CoreV1 ().Namespaces ().Create (ctx , & corev1.Namespace {
140
- ObjectMeta : metav1.ObjectMeta { Name : testNamespace },
141
- }, metav1.CreateOptions {})
142
- Expect (err ).NotTo (HaveOccurred ())
138
+ By ("Creating the test namespace" )
139
+ _ , err = clientset .CoreV1 ().Namespaces ().Create (ctx , & corev1.Namespace {
140
+ ObjectMeta : metav1.ObjectMeta {Name : testNamespace },
141
+ }, metav1.CreateOptions {})
142
+ Expect (err ).NotTo (HaveOccurred ())
143
143
144
144
By ("Invoking Reconciling for Create" )
145
145
deployment , err = clientset .AppsV1 ().Deployments (testNamespace ).Create (ctx , deployment , metav1.CreateOptions {})
@@ -202,11 +202,11 @@ var _ = Describe("controller", func() {
202
202
By ("Invoking Reconciling for a pod when it is created when adding watcher dynamically" )
203
203
// Add new watcher dynamically
204
204
err = instance .Watch (
205
- source .Kind (cm .GetCache (), & corev1.Pod {},
206
- & handler.TypedEnqueueRequestForObject [* corev1.Pod ]{},
207
- makeNamespacePredicate [* corev1.Pod ](testNamespace ),
208
- ),
209
- )
205
+ source .Kind (cm .GetCache (), & corev1.Pod {},
206
+ & handler.TypedEnqueueRequestForObject [* corev1.Pod ]{},
207
+ makeNamespacePredicate [* corev1.Pod ](testNamespace ),
208
+ ),
209
+ )
210
210
Expect (err ).NotTo (HaveOccurred ())
211
211
212
212
pod := & corev1.Pod {
@@ -242,9 +242,9 @@ var _ = Describe("controller", func() {
242
242
// makeNamespacePredicate returns a predicate that filters out all objects not in the passed in
243
243
// namespace.
244
244
func makeNamespacePredicate [object client.Object ](namespace string ) predicate.TypedPredicate [object ] {
245
- return predicate.NewTypedPredicateFuncs [object ](func (obj object ) bool {
246
- return obj .GetNamespace () == namespace
247
- })
245
+ return predicate.NewTypedPredicateFuncs [object ](func (obj object ) bool {
246
+ return obj .GetNamespace () == namespace
247
+ })
248
248
}
249
249
250
250
func truePtr () * bool {
0 commit comments