-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(auto-gen): detect if UCC can auto generate a file under package/default #1220
Conversation
@hetangmodi-crest please provide several examples of how this feature is going to work with existing TAs, let's say Cisco Meraki, Google Workspace, Microsoft Cloud Services and MySQL. |
I've added some example of the mentioned TAs in ADDON-69825. |
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 PR can be a start of a big refactor I wanted to do for quite some time already. Let's discuss it tomorrow.
from os.path import sep | ||
from typing import List, Dict, Any, Union | ||
from logging import Logger | ||
from configparser import ConfigParser |
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 extracted a library from UCC and PSA to parse .conf files, you can find it here - https://github.com/splunk/addonfactory-splunk-conf-parser-lib. It is built on top of configparser
but supports multi lines and comments. I think it would be better to use this one instead of plain configparser
.
if diff_count == len(self.different_files): | ||
self.common_files[src_file] = src_file.split(sep=sep)[-1] | ||
|
||
def print_files(self, logger: Logger) -> None: |
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 checked out your branch and run the following command:
poetry run ucc-gen build --source ../splunk-add-on-for-google-workspace/package
Below is the logging that we provide out of this feature. I think we need to adjust this as it is not entirely clear what a developer should do.
WARNING: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Below are the file(s) with the differences that are not auto generated by the UCC framework. (Optionally), you can raise feature requests for UCC framework at 'https://github.com/splunk/addonfactory-ucc-generator/issues/new/choose' with the output mentioned below.
1) ../splunk-add-on-for-google-workspace/package/default/inputs.conf[activity_report]::interval
Source: 3600, Generated:
2) ../splunk-add-on-for-google-workspace/package/default/inputs.conf[activity_report]::lookbackoffset
Source: 10800, Generated:
3) ../splunk-add-on-for-google-workspace/package/default/inputs.conf[gws_gmail_logs]::interval
Source: 3600, Generated:
4) ../splunk-add-on-for-google-workspace/package/default/inputs.conf[gws_gmail_logs_migrated]::interval
Source: 3600, Generated:
5) ../splunk-add-on-for-google-workspace/package/default/inputs.conf[gws_user_identity]::interval
Source: 3600, Generated:
6) ../splunk-add-on-for-google-workspace/package/default/inputs.conf[gws_alert_center]::interval
Source: 3600, Generated:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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.
The output points the file name with the stanza and property, the Source
means what was present in the source code/ repository and Generated
means the code that was generated by ucc-gen command.
Here, the interval
property in the inputs.conf was present in the source code, but wasn't generated by ucc-gen, hence the Generated
value is empty.
I am converting this PR into a draft. We decided to make some internal refactoring first so this feature can be enabled without touching all the files in the repository. |
I am going to close this PR but keep the branch open in case we would need to see the idea of the implementation. |
Issue number: ADDON-69825
Summary
Changes
For the files created in
package/default
folder - conf files and xml files, the file contents are compared removing/ignoring the comments present in them with the respective libraries used to parse the files. When we compare source code with generated code inoutput
folder,User experience
Before, the user wouldn't know what all features that are continuously added to UCC framework that they have in their source code. After this change, the user/developer would know what all changes they have in their source code which can be safely removed, and additionally, the user could provide their customizations to be accommodated in the UCC framework.
Checklist
If your change doesn't seem to apply, please leave them unchecked.