Skip to content

refactor codebase structure to allow for dependency injection

Jaime Nuche requested to merge T367782 into main

As a prerequisite to start injecting BDD mocks for our K8s backend dependencies, this commit restructures the Catalyst code to use singletons in a hierarchical package structure.

The singletons are necessary in order to be able to inject mocks for BDD tests. The reasons for the hierarchical packages are a bit more complicated, but they have to do with the fact that the new setup.go file will be used by the BDD test runner.

setup.go cannot be in the main package or else would not be accessible by the runner. But if setup.go is not in main, then it can't access the rest of the code that lived in main (router.go, catalyst.go, etc). All that other code then needs to be moved to its own packages as well.

Finally moving important pieces of the code out of main is a good improvement on its own though, since now any cycle dependencies between packages get exposed (cycle package deps being something normal in other languages but something Go frowns upon)

Bug: T367782

Merge request reports