Skip to content

Commit

Permalink
Merge pull request #56 from RedHatInsights/psav/tech_debt
Browse files Browse the repository at this point in the history
Simplify some functions
  • Loading branch information
psav authored Sep 6, 2022
2 parents 7754223 + 83ed23b commit 0fea023
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 250 deletions.
12 changes: 11 additions & 1 deletion controllers/frontend_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,17 @@ func (r *FrontendReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c

cache := resCache.NewObjectCache(ctx, r.Client, cacheConfig)

err = runReconciliation(ctx, r.Client, &frontend, fe, &cache)
reconciliation := FrontendReconciliation{
Log: log,
Recorder: r.Recorder,
Cache: cache,
FRE: r,
FrontendEnvironment: fe,
Ctx: ctx,
Frontend: &frontend,
}

err = reconciliation.run()

if err != nil {
SetFrontendConditions(ctx, r.Client, &frontend, crd.ReconciliationFailed, err)
Expand Down
9 changes: 6 additions & 3 deletions controllers/frontend_controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ var _ = Describe("Frontend controller with image", func() {
ctx := context.Background()

var customConfig apiextensions.JSON
customConfig.UnmarshalJSON([]byte(`{"apple": "pie"}`))
customConfig.UnmarshalJSON([]byte(`{"apple":"pie"}`))

var customConfig2 apiextensions.JSON
customConfig2.UnmarshalJSON([]byte(`{"cheese":"pasty"}`))

frontend := &crd.Frontend{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -114,7 +117,7 @@ var _ = Describe("Frontend controller with image", func() {
}},
}},
},
CustomConfig: &customConfig,
CustomConfig: &customConfig2,
},
}
Expect(k8sClient.Create(ctx, frontend2)).Should(Succeed())
Expand Down Expand Up @@ -197,7 +200,7 @@ var _ = Describe("Frontend controller with image", func() {
}, timeout, interval).Should(BeTrue())
Expect(createdConfigMap.Name).Should(Equal(FrontendEnvName))
Expect(createdConfigMap.Data).Should(Equal(map[string]string{
"fed-modules.json": "{\"testFrontend\":{\"manifestLocation\":\"/apps/inventory/fed-mods.json\",\"modules\":[{\"id\":\"test\",\"module\":\"./RootApp\",\"routes\":[{\"pathname\":\"/test/href\"}]}],\"config\":{\"apple\":\"pie\"}},\"testFrontend2\":{\"manifestLocation\":\"/apps/inventory/fed-mods.json\",\"modules\":[{\"id\":\"test\",\"module\":\"./RootApp\",\"routes\":[{\"pathname\":\"/test/href\"}]}],\"config\":{\"apple\":\"pie\"}}}",
"fed-modules.json": "{\"testFrontend\":{\"manifestLocation\":\"/apps/inventory/fed-mods.json\",\"modules\":[{\"id\":\"test\",\"module\":\"./RootApp\",\"routes\":[{\"pathname\":\"/test/href\"}]}],\"config\":{\"apple\":\"pie\"}},\"testFrontend2\":{\"manifestLocation\":\"/apps/inventory/fed-mods.json\",\"modules\":[{\"id\":\"test\",\"module\":\"./RootApp\",\"routes\":[{\"pathname\":\"/test/href\"}]}],\"config\":{\"cheese\":\"pasty\"}}}",
"test-env.json": "{\"id\":\"test-bundle\",\"title\":\"\",\"navItems\":[{\"title\":\"Test\",\"href\":\"/test/href\"},{\"title\":\"Test\",\"href\":\"/test/href\"}]}",
}))
Expect(createdConfigMap.ObjectMeta.OwnerReferences[0].Name).Should(Equal(FrontendEnvName))
Expand Down
Loading

0 comments on commit 0fea023

Please sign in to comment.