Skip to content
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

Draft
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

hetangmodi-crest
Copy link
Contributor

@hetangmodi-crest hetangmodi-crest commented Jun 1, 2024

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 in output folder,

  • If no changes are found, we tell the user that the file can be removed from their repository/ source code.
  • If changes (in other words, customizations) are found, we suggest the user to raise enhancement requests via GitHub issues of UCC framework.

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.

@hetangmodi-crest hetangmodi-crest added the enhancement New feature or request label Jun 1, 2024
@hetangmodi-crest hetangmodi-crest self-assigned this Jun 1, 2024
@hetangmodi-crest hetangmodi-crest changed the title Feat/diff checker auto generation feat(auto-gen): notify users for existing features of UCC framework Jun 1, 2024
@hetangmodi-crest hetangmodi-crest marked this pull request as ready for review June 1, 2024 07:25
@hetangmodi-crest hetangmodi-crest requested review from a team as code owners June 1, 2024 07:25
@artemrys
Copy link
Member

artemrys commented Jun 4, 2024

@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.

@hetangmodi-crest
Copy link
Contributor Author

@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.

@artemrys artemrys changed the title feat(auto-gen): notify users for existing features of UCC framework feat(auto-gen): detect if UCC can auto generate a file under package/default Jun 20, 2024
Copy link
Member

@artemrys artemrys left a 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
Copy link
Member

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:
Copy link
Member

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:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Copy link
Contributor Author

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.

@artemrys artemrys marked this pull request as draft June 24, 2024 12:44
@artemrys
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants