-
Notifications
You must be signed in to change notification settings - Fork 134
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 k8s_service to use new module_utils code #327
Refactor k8s_service to use new module_utils code #327
Conversation
Signed-off-by: Alina Buzachis <[email protected]>
recheck |
Signed-off-by: Alina Buzachis <[email protected]>
ea04d2a
to
d4012b5
Compare
Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
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.
Unfortunately, we can't use run_module()
here as it's currently written. The selector
, type
, and ports
parameters get lost. We should also force the kind
value. I'll need to think about whether we want to change that function and how. It may be easiest for now to just replicate what you need from run_module()
here. We don't need the continue on error functionality because this module currently only works with a single resource definition.
fdd3251
to
4852313
Compare
Signed-off-by: Alina Buzachis <[email protected]>
4852313
to
b6df034
Compare
recheck |
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.
It may be worth adding one or two tests for this module at the very least just as a smoke test.
plugins/modules/k8s_service.py
Outdated
if module.params["validate"] is not None: | ||
module.warnings = validate(svc.client, module, definition) |
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.
This module does not support the validate
param. I was a bit surprised to see that this passed CI since it should throw an AttributeError
exception. Upon further investigation, I found that there is only a single test for this module and it uses ignore_errors: yes
. 😱
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.
😭I wanted to replicate some things from the runner... but I didn't pay attention at the naming and the other things... my fault!
I also noticed k8s_service
is not fully covered with integration tests.
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.
@gravesm Can we open some issues for the modules that are not fully covered by integration tests?
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.
Yes, definitely.
plugins/modules/k8s_service.py
Outdated
except CoreException as e: | ||
if module.warnings: | ||
e["msg"] += "\n" + "\n ".join(module.warnings) | ||
module.fail_json(msg=e) |
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.
I think msg
needs to be a string.
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.
Yes, it needs. Thanks!
plugins/modules/k8s_service.py
Outdated
|
||
try: | ||
result = perform_action(svc, definition, module.params) |
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.
This function is infinitely recursive as it just keeps calling itself. Did you mean to import the perform_action()
function from runner.py
?
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.
It should replicate perform_action()
from runner. But I did it wrong and trying to check if possible.
33a81e9
to
43c4f7f
Compare
Signed-off-by: Alina Buzachis <[email protected]>
43c4f7f
to
a0fdae2
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.
LGTM!
recheck |
1 similar comment
recheck |
recheck |
1 similar comment
recheck |
…s#327) Refactor k8s_service to use new module_utils code SUMMARY Refactor k8s_service to use new module_utils code ISSUE TYPE Feature Pull Request COMPONENT NAME k8s_service Reviewed-by: Mike Graves <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: None <None>
SUMMARY
Refactor k8s_service to use new module_utils code
ISSUE TYPE
COMPONENT NAME
k8s_service