-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: builtin actions #537
Conversation
51d3968
to
bb32d6f
Compare
bb32d6f
to
d829fb9
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.
Is there a reason to use the __call__
internal method?
I'm concerned about the approach to using the internal method __call__
to run the logic of the action. I feel is not a good usage of this method and that method will be executed every time the object is called. It obfuscates the interface of the action, specially if we want to support pluggable actions. I feel the action should be executed through an ad-hoc "run" method. This seems to be the same pattern followed by plugins and modules in ansible.
This conflicts with having actions be simple functions. Functions are easier to test since they have no internal state. It also makes a plugin architecture harder since plugins have to inherit from a base class. I am generally against inheritance for code reuse. I prefer composition to inheritance using the delegation pattern: https://en.wikipedia.org/wiki/Delegation_pattern. |
37275ad
to
d80bf38
Compare
d80bf38
to
55c43dd
Compare
@benthomasson Please re-review I have used a Helper class to keep the shared code between the different actions. |
f99cbc1
to
3d8e4f8
Compare
9cb115e
to
7ae8041
Compare
7ae8041
to
78741cd
Compare
6a492b4
to
fddf8cf
Compare
a1f103c
to
170816d
Compare
05a6141
to
c649a9d
Compare
Each action is a separate class Allows for us to share code between actions
c649a9d
to
71b36ab
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.
Isn't this PR leaving dead code in the repo?
@Alex-Izquierdo Yes it will be removed in a different PR, since this PR was open for a while deleting the file and rebasing every time was a challenge. |
Since we have refactored actions we don't need the old builtin.py any more. Related to PR #537
Each action is a separate class
Allows for us to share code between different actions in a Helper class
Each action can be tested independently by injecting the required events