-
Notifications
You must be signed in to change notification settings - Fork 48
Don't use globals for platforms and components registration #1147
Conversation
63cc1eb
to
1876094
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work 🥳 . Some suggestions.
59913f6
to
d15d4d4
Compare
d15d4d4
to
0614654
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to parallelize the tests.
@@ -88,9 +88,14 @@ type config struct { | |||
KubeAPIServerExtraFlags []string | |||
} | |||
|
|||
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit as doing different things. One is exposing things, other is adding new exported const. Both commit still do one thing each, just in multiple contexts. I think I prefer to keep them separate.
0614654
to
03c19bb
Compare
Which ones? I'm almost sure this is out of scope of this (already large) PR. If you talk about the unit tests using configuration, I think we should fix them either on the way OR in a separate PR as part of other issue. @surajssd addressed remaining review comments, please have a look again. |
The promise of this change is that tests could be parallelised which weren't because we were extracting the same object from global store. So how do we confirm that promise is fullfilled with this change? |
There is no global registry anymore and it's up to the package itself to ensure immutability, as |
I need to rebase. |
03c19bb
to
297530c
Compare
As a preparation for solving #992. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
As a preparation for #992. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
As a preparation to #992, so platform name from the configuration don't need to be duplicated. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
This commit moves platforms registration logic from using globals to single function in cli/cmd/cluster package, as this is the only user of old GetPlatforms() function. For platform unit tests, NewConfig() function exported by each platform package should be used instead. Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
We no longer rely on the init function call registration method for all platform packages, so anonymous imports are no longer needed. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
As a preparation for #992. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
To make it consistent with pkg/platform/* packages and to make it available outside of package, so we can avoid using globals and init() functions for collecting available components default configurations. Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
To be consistent with other components. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
So no globals or HCL parsing is involved in testing. Also components.Get() is now deprecated, as we want to avoid relying on globals and init() functions. Part of #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
So we don't rely on other packages while running unit tests. Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
Instead, add few helper functions, which will also replace components.Get(). Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
As a next step of not using globals and init() functions across our code. Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
They are not used anymore, so can be removed. Refs #992. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
To be consistent with platform and component packages. Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
To be consistent with platform and component packages. Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
Import all available backends locally instead, to avoid using globals. Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
No other packages really need backend.Backend interface, so we can move it to cli/cmd/cluster package where it is actually consumed, which is an recommendation in Go. This way we can further reduce exported API of the codebase. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
We no longer use registration pattern for backends, as it is using globals and init() which we want to avoid using. We also moved the interface to cli/cmd/cluster package, as it was the only consumer of it, so actually the entire package can be now removed, as it no longer has any use. Refs #992 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
We no longer rely on the init function call registration method for all backend packages, so anonymous imports are no longer needed. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
297530c
to
f728c60
Compare
Rebased to also adapt Tinkerbell platform for introduced changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for getting rid of all those terrible init()
functions!
This pull request includes commits from #1098, please do not review commits from #1098 in this pull requestCloses #992
Closes #597
See commit messages for details.