Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
Signed-off-by: everettraven <everettraven@gmail.com>
  • Loading branch information
everettraven committed May 16, 2024
1 parent ddde5f8 commit d73c922
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 51 deletions.
4 changes: 2 additions & 2 deletions pkg/reconciler/internal/hook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ func (d *dependentResourceWatcher) Exec(owner *unstructured.Unstructured, rel re
&sdkhandler.EnqueueRequestForAnnotation[*unstructured.Unstructured]{
Type: owner.GetObjectKind().GroupVersionKind().GroupKind(),
},
dependentPredicate,
dependentPredicate,
),
); err != nil {
); err != nil {
return err
}
}
Expand Down
28 changes: 14 additions & 14 deletions pkg/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,11 +954,11 @@ func (r *Reconciler) setupWatches(mgr ctrl.Manager, c controller.Controller) err

if err := c.Watch(
source.Kind(
mgr.GetCache(),
client.Object(obj),
&sdkhandler.InstrumentedEnqueueRequestForObject[client.Object]{},
preds...,
),
mgr.GetCache(),
client.Object(obj),
&sdkhandler.InstrumentedEnqueueRequestForObject[client.Object]{},
preds...,
),
); err != nil {
return err
}
Expand All @@ -972,15 +972,15 @@ func (r *Reconciler) setupWatches(mgr ctrl.Manager, c controller.Controller) err

if err := c.Watch(
source.Kind(
mgr.GetCache(),
secret,
handler.TypedEnqueueRequestForOwner[*corev1.Secret](
mgr.GetScheme(),
mgr.GetRESTMapper(),
obj,
handler.OnlyControllerOwner(),
),
),
mgr.GetCache(),
secret,
handler.TypedEnqueueRequestForOwner[*corev1.Secret](
mgr.GetScheme(),
mgr.GetRESTMapper(),
obj,
handler.OnlyControllerOwner(),
),
),
); err != nil {
return err
}
Expand Down
65 changes: 30 additions & 35 deletions pkg/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type reconcilerTestSuiteOpts struct {
}

var _ = Describe("Reconciler", func() {
var _ = Describe("New", func() {
_ = Describe("New", func() {
It("should fail without a GVK", func() {
r, err := New(WithChart(chart.Chart{}))
Expect(r).To(BeNil())
Expand All @@ -125,54 +125,54 @@ var _ = Describe("Reconciler", func() {
})
})

var _ = Describe("Option", func() {
_ = Describe("Option", func() {
var r *Reconciler
BeforeEach(func() {
r = &Reconciler{}
})
var _ = Describe("WithClient", func() {
_ = Describe("WithClient", func() {
It("should set the reconciler client", func() {
client := fake.NewClientBuilder().Build()
Expect(WithClient(client)(r)).To(Succeed())
Expect(r.client).To(Equal(client))
})
})
var _ = Describe("WithActionClientGetter", func() {
_ = Describe("WithActionClientGetter", func() {
It("should set the reconciler action client getter", func() {
fakeActionClientGetter := helmfake.NewActionClientGetter(nil, nil)
Expect(WithActionClientGetter(fakeActionClientGetter)(r)).To(Succeed())
Expect(r.actionClientGetter).To(Equal(fakeActionClientGetter))
})
})
var _ = Describe("WithEventRecorder", func() {
_ = Describe("WithEventRecorder", func() {
It("should set the reconciler event recorder", func() {
rec := record.NewFakeRecorder(0)
Expect(WithEventRecorder(rec)(r)).To(Succeed())
Expect(r.eventRecorder).To(Equal(rec))
})
})
var _ = Describe("WithLog", func() {
_ = Describe("WithLog", func() {
It("should set the reconciler log", func() {
log := logr.Discard()
Expect(WithLog(log)(r)).To(Succeed())
Expect(r.log).To(Equal(log))
})
})
var _ = Describe("WithGroupVersionKind", func() {
_ = Describe("WithGroupVersionKind", func() {
It("should set the reconciler GVK", func() {
gvk := schema.GroupVersionKind{Group: "mygroup", Version: "v1", Kind: "MyApp"}
Expect(WithGroupVersionKind(gvk)(r)).To(Succeed())
Expect(r.gvk).To(Equal(&gvk))
})
})
var _ = Describe("WithChart", func() {
_ = Describe("WithChart", func() {
It("should set the reconciler chart", func() {
chrt := chart.Chart{Metadata: &chart.Metadata{Name: "my-chart"}}
Expect(WithChart(chrt)(r)).To(Succeed())
Expect(r.chrt).To(Equal(&chrt))
})
})
var _ = Describe("WithOverrideValues", func() {
_ = Describe("WithOverrideValues", func() {
It("should succeed with valid overrides", func() {
overrides := map[string]string{"foo": "bar"}
Expect(WithOverrideValues(overrides)(r)).To(Succeed())
Expand All @@ -184,7 +184,7 @@ var _ = Describe("Reconciler", func() {
Expect(WithOverrideValues(overrides)(r)).NotTo(Succeed())
})
})
var _ = Describe("SkipDependentWatches", func() {
_ = Describe("SkipDependentWatches", func() {
It("should set to false", func() {
Expect(SkipDependentWatches(false)(r)).To(Succeed())
Expect(r.skipDependentWatches).To(BeFalse())
Expand All @@ -194,7 +194,7 @@ var _ = Describe("Reconciler", func() {
Expect(r.skipDependentWatches).To(BeTrue())
})
})
var _ = Describe("WithMaxConcurrentReconciles", func() {
_ = Describe("WithMaxConcurrentReconciles", func() {
It("should set the reconciler max concurrent reconciled", func() {
Expect(WithMaxConcurrentReconciles(1)(r)).To(Succeed())
Expect(r.maxConcurrentReconciles).To(Equal(1))
Expand All @@ -204,7 +204,7 @@ var _ = Describe("Reconciler", func() {
Expect(WithMaxConcurrentReconciles(-1)(r)).NotTo(Succeed())
})
})
var _ = Describe("WithReconcilePeriod", func() {
_ = Describe("WithReconcilePeriod", func() {
It("should set the reconciler reconcile period", func() {
Expect(WithReconcilePeriod(0)(r)).To(Succeed())
Expect(r.reconcilePeriod).To(Equal(time.Duration(0)))
Expand All @@ -213,7 +213,7 @@ var _ = Describe("Reconciler", func() {
Expect(WithReconcilePeriod(-time.Nanosecond)(r)).NotTo(Succeed())
})
})
var _ = Describe("WithMaxReleaseHistory", func() {
_ = Describe("WithMaxReleaseHistory", func() {
It("should set the max history size", func() {
Expect(WithMaxReleaseHistory(10)(r)).To(Succeed())
Expect(r.maxHistory).To(Equal(10))
Expand All @@ -226,7 +226,7 @@ var _ = Describe("Reconciler", func() {
Expect(WithMaxReleaseHistory(-1)(r)).NotTo(Succeed())
})
})
var _ = Describe("WithInstallAnnotations", func() {
_ = Describe("WithInstallAnnotations", func() {
It("should set multiple reconciler install annotations", func() {
a1 := annotation.InstallDisableHooks{CustomName: "my.domain/custom-name1"}
a2 := annotation.InstallDisableHooks{CustomName: "my.domain/custom-name2"}
Expand Down Expand Up @@ -276,7 +276,7 @@ var _ = Describe("Reconciler", func() {
}))
})
})
var _ = Describe("WithUpgradeAnnotations", func() {
_ = Describe("WithUpgradeAnnotations", func() {
It("should set multiple reconciler upgrade annotations", func() {
a1 := annotation.UpgradeDisableHooks{CustomName: "my.domain/custom-name1"}
a2 := annotation.UpgradeDisableHooks{CustomName: "my.domain/custom-name2"}
Expand Down Expand Up @@ -326,7 +326,7 @@ var _ = Describe("Reconciler", func() {
}))
})
})
var _ = Describe("WithUninstallAnnotations", func() {
_ = Describe("WithUninstallAnnotations", func() {
It("should set multiple reconciler uninstall annotations", func() {
a1 := annotation.UninstallDisableHooks{CustomName: "my.domain/custom-name1"}
a2 := annotation.UninstallDisableHooks{CustomName: "my.domain/custom-name2"}
Expand Down Expand Up @@ -376,7 +376,7 @@ var _ = Describe("Reconciler", func() {
}))
})
})
var _ = Describe("WithPreHook", func() {
_ = Describe("WithPreHook", func() {
It("should set a reconciler prehook", func() {
called := false
preHook := hook.PreHookFunc(func(*unstructured.Unstructured, chartutil.Values, logr.Logger) error {
Expand All @@ -389,7 +389,7 @@ var _ = Describe("Reconciler", func() {
Expect(called).To(BeTrue())
})
})
var _ = Describe("WithPostHook", func() {
_ = Describe("WithPostHook", func() {
It("should set a reconciler posthook", func() {
called := false
postHook := hook.PostHookFunc(func(*unstructured.Unstructured, release.Release, logr.Logger) error {
Expand All @@ -402,7 +402,7 @@ var _ = Describe("Reconciler", func() {
Expect(called).To(BeTrue())
})
})
var _ = Describe("WithValueMapper", func() {
_ = Describe("WithValueMapper", func() {
It("should set the reconciler value mapper", func() {
mapper := values.MapperFunc(func(chartutil.Values) chartutil.Values {
return chartutil.Values{"mapped": true}
Expand All @@ -412,7 +412,7 @@ var _ = Describe("Reconciler", func() {
Expect(r.valueMapper.Map(chartutil.Values{})).To(Equal(chartutil.Values{"mapped": true}))
})
})
var _ = Describe("WithValueTranslator", func() {
_ = Describe("WithValueTranslator", func() {
It("should set the reconciler value translator", func() {
translator := values.TranslatorFunc(func(ctx context.Context, u *unstructured.Unstructured) (chartutil.Values, error) {
return chartutil.Values{"translated": true}, nil
Expand All @@ -422,7 +422,7 @@ var _ = Describe("Reconciler", func() {
Expect(r.valueTranslator.Translate(context.Background(), &unstructured.Unstructured{})).To(Equal(chartutil.Values{"translated": true}))
})
})
var _ = Describe("WithSelector", func() {
_ = Describe("WithSelector", func() {
It("should set the reconciler selector", func() {
objUnlabeled := &unstructured.Unstructured{}

Expand All @@ -447,7 +447,7 @@ var _ = Describe("Reconciler", func() {
})
})

var _ = Describe("Reconcile", func() {
_ = Describe("Reconcile", func() {
var (
obj *unstructured.Unstructured
objKey types.NamespacedName
Expand All @@ -470,7 +470,6 @@ var _ = Describe("Reconciler", func() {
obj = testutil.BuildTestCR(gvk)
objKey = types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}
req = reconcile.Request{NamespacedName: objKey}

})

AfterEach(func() {
Expand Down Expand Up @@ -806,9 +805,7 @@ var _ = Describe("Reconciler", func() {
})
})
When("requested CR release is present", func() {
var (
currentRelease *release.Release
)
var currentRelease *release.Release
BeforeEach(func() {
// Reconcile once to get the release installed and finalizers added
var err error
Expand Down Expand Up @@ -1319,7 +1316,6 @@ var _ = Describe("Reconciler", func() {
})
})
})

}

When("generic GVK scheme setup", func() {
Expand All @@ -1329,10 +1325,9 @@ var _ = Describe("Reconciler", func() {
When("custom type GVK scheme setup ", func() {
parameterizedReconcilerTests(reconcilerTestSuiteOpts{customGVKSchemeSetup: true})
})

})

var _ = Describe("Test custom controller setup", func() {
_ = Describe("Test custom controller setup", func() {
var (
mgr manager.Manager
r *Reconciler
Expand All @@ -1345,12 +1340,12 @@ var _ = Describe("Reconciler", func() {
u := &unstructured.Unstructured{}
u.SetGroupVersionKind(additionalGVK)
return c.Watch(
source.Kind(
mgr.GetCache(),
u,
&sdkhandler.InstrumentedEnqueueRequestForObject[*unstructured.Unstructured]{},
),
)
source.Kind(
mgr.GetCache(),
u,
&sdkhandler.InstrumentedEnqueueRequestForObject[*unstructured.Unstructured]{},
),
)
}

It("Registering builder setup function for reconciler works", func() {
Expand Down

0 comments on commit d73c922

Please sign in to comment.