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
Feature request: import custom code module in generated modular input scripts. #331
Comments
Thanks for this feature request, I agree that I think that your approach is good enough for this use case. I can't think of anything better. |
This feature could be really usefull, it could allow to use custom code without having to maintain the get_scheme() manually after some changes in the globalConfig.json... |
Is there any plan to add this functionality ? |
I read the ask one more time, you are actually referring to the actual modular input code, not the rest handlers created by What you are referring to, may be an actually interesting feature request. I have limited capacity this quarter, I can keep this in mind during our next quarter planning. |
@Jalkar FYI to get around this issue, I create the customizations I need to the rest handler in a separate module, extending The advantage here being I don't need to understand if UCC will try to overwrite my customizations or not, and don't need to manually implement get_scheme(). I let UCC do as much of the work as possible. My opinion, if I understand @Jalkar - I'm a bit happier without UCC trying to modify code I've already written. It makes debugging easier when modules I've authored don't change during build process, but maybe others feel differently, or it decreases the scope of work for UCC PR to something that is doable. HTH IE:
UCC-GEN generates TA_inputname_rh_inputname.py:
additional_packaging adds/modifies TA_inputname_rh_inputname.py:
|
So in the end you need to change the generated file after each ucc-gen exec ? |
If you have an input called As far as I understand, we are talking here about 2 different but similar use cases:
Both of them are valid feature requests, but should be tracked differently. |
My issue is currently when i'm adding a new parameter for an existing input, I need to manually edit the "scheme" of the existing package/bin/my_mod_input.py |
re-reading your last comments, i just catch the diff rest handler/modular inputs :) |
FYI @Jalkar RE: "So in the end you need to change the generated file after each ucc-gen exec ?" >> YES. I added code in additional_packaging.py to open the generated rest handler file, search for the the line of code and change it with regex. Additional_packaging.py is automatically executed by ucc-gen as part of the build process - HTH |
ok thank for the feedback (I never realised the |
Yeah, it was never in the documentation, I added it recently (https://splunk.github.io/addonfactory-ucc-generator/how_to_use/#additional_packagingpy-file). I'll leave this issue open, I think this maybe interesting to implement in the future, not committing to it so far. |
I'll rename this issue to track the customisation for the UCC-generated modular inputs and will open a new one to track customisation for the actual REST handlers. By the way, I updated the docs and now it has an example for the custom REST handlers (https://splunk.github.io/addonfactory-ucc-generator/custom_rest_handler/). |
@pmeyerson - This would be huge addition to UCC I think. By any chance can you provide content of additional_packaging.py that you have. |
here's what worked for me - lets me call custom modular input handler functions without having to maintain the scheme arguments when globalConfig.json is updated
HTH |
for reference, here's stub from my custom modular input handler file:
|
@pmeyerson - Much appreciated. This was very helpful!!! |
Separation done similar to: https://splunk.github.io/addonfactory-ucc-generator/advanced/custom_rest_handler/ Fixes #331. Co-authored-by: mahirchavda <mahir.chavda13@gmail.com> --------- Co-authored-by: Artem Rys <rysartem@gmail.com>
So I have
my_custom_modular_input.py
, my custom code for a modular input, which implementsvaliate_input
andstream_events
ucc-gen creates
my_custom.py
, a rest handler skeleton which hasstream_events
,valiate_input
, all the arguments defined in globalConfig.json, and the filename is already linked to the modular input definition.Since I already have
my_custom_modular_input.py
, it would be great if ucc-gen could automatically import this modular when writingmy_custom.py
and use it in thestream_events
andvalidate_input
method calls.I'm currently using some regex and file manipulation with additional_packaging.py which works fine but feels brittle if the format or output of ucc-gen would change.
I feel this would be a very useful feature for folks working with modular input scripts, but if I've missed a better workflow please let me know. Thanks for considering.
The text was updated successfully, but these errors were encountered: