-
Notifications
You must be signed in to change notification settings - Fork 30
feat: base code for supporting custom search command #1693
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
Conversation
@@ -58,7 +65,7 @@ def _validate_config_against_schema(self) -> None: | |||
Validates config against JSON schema. | |||
Raises jsonschema.ValidationError if config is not valid. | |||
""" | |||
schema_path = os.path.join(self._source_dir, "schema", "schema.json") | |||
schema_path = os.path.join(self._internal_root_dir, "schema", "schema.json") |
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.
Why this change?
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 "source_dir" seemed an ambiguous variable name - does source_dir point to source code of add-on that is being built or UCC code source, hence, I have renamed the _source_dir
to _internal_root_dir
, otherwise there is no functionality change.
from splunk_add_on_ucc_framework.const import SPLUNK_COMMANDS | ||
|
||
|
||
def test_command_list_up_to_date(): |
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.
Not sure it belongs to the unit tests. Maybe a script that eventually runs periodically.
@kkedziak-splunk @sgoral-splunk what do you think?
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 way that ServiceNow add-on commands are mentioned in the Splunk docs, and if we make this list periodically updated, we won't be able to know if Splunk ever introduced new commands in its docs that actually belong to an add-on. Hence, I think keeping this as a test (as contributed by @kkedziak-splunk) would make more sense, as we would require a human to verify the alteration in command list, if it ever happens.
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.
maybe we will be able to fetch data without snow commands from this url: "https://docs.splunk.com/Documentation/Splunk/9.4.1/SearchReference/ListOfSearchCommands" ?
this way we would be able to periodically update base commands via auto scripts. If no, I'm ok to go with this "test" approach.
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.
@artemrys do you propose to schedule a github workflow with a cron schedule?
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.
Maybe let's proceed with this approach for now and we will see how it works. If needed we can create ticket to change that later. What do you think @hetangmodi-crest @kkedziak-splunk @artemrys ?
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 have created the ticket for it. We can look into it later.
ADDON-80607
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.
If this PR does not generate these files, let's leave them out.
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.
Same below.
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.
These files are not generated, they are intended to contain the search command logic and must be provided by the user.
Removing them will cause the build to fail because of this validation. We cannot move the validation elsewhere, as this is a pre-check for generating custom command files.
from splunk_add_on_ucc_framework.const import SPLUNK_COMMANDS | ||
|
||
|
||
def test_command_list_up_to_date(): |
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.
maybe we will be able to fetch data without snow commands from this url: "https://docs.splunk.com/Documentation/Splunk/9.4.1/SearchReference/ListOfSearchCommands" ?
this way we would be able to periodically update base commands via auto scripts. If no, I'm ok to go with this "test" approach.
@hetangmodi-crest fossa is failing so let's rebase after ucc-gen validation changes are reverted |
**Issue number:** ADDON-76780 ### PR Type **What kind of change does this PR introduce?** * [x] Feature * [ ] Bug Fix * [ ] Refactoring (no functional or API changes) * [x] Documentation Update * [ ] Maintenance (dependency updates, CI, etc.) ## Summary ### Changes This PR includes the generation of the `searchbnf.conf` file for the custom search command. ### User experience After defining a valid configuration for the custom search command in `globalConfig.json`, the `searchbnf.conf` file will be generated. ## Checklist If an item doesn't apply to your changes, leave it unchecked. ### Review * [x] self-review - I have performed a self-review of this change according to the [development guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines) * [x] Changes are documented. The documentation is understandable, examples work [(more info)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#documentation-guidelines) * [x] PR title and description follows the [contributing principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests) * [ ] meeting - I have scheduled a meeting or recorded a demo to explain these changes (if there is a video, put a link below and in the ticket) ### Tests See [the testing doc](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test). * [x] Unit - tests have been added/modified to cover the changes * [x] Smoke - tests have been added/modified to cover the changes * [ ] UI - tests have been added/modified to cover the changes * [x] coverage - I have checked the code coverage of my changes [(see more)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#checking-the-code-coverage) **Demo/meeting:** *Reviewers are encouraged to request meetings or demos if any part of the change is unclear*
**Issue number:** ADDON-76780, ADDON-79647 ### PR Type **What kind of change does this PR introduce?** * [x] Feature * [ ] Bug Fix * [ ] Refactoring (no functional or API changes) * [x] Documentation Update * [ ] Maintenance (dependency updates, CI, etc.) ## Summary ### Changes This PR includes the generation of the `commands.conf` file for the custom search command. ### User experience After defining a valid configuration for the custom search command in `globalConfig.json`, the `commands.conf` file will be generated. ## Checklist If an item doesn't apply to your changes, leave it unchecked. ### Review * [x] self-review - I have performed a self-review of this change according to the [development guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines) * [x] Changes are documented. The documentation is understandable, examples work [(more info)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#documentation-guidelines) * [x] PR title and description follows the [contributing principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests) * [ ] meeting - I have scheduled a meeting or recorded a demo to explain these changes (if there is a video, put a link below and in the ticket) ### Tests See [the testing doc](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test). * [x] Unit - tests have been added/modified to cover the changes * [x] Smoke - tests have been added/modified to cover the changes * [ ] UI - tests have been added/modified to cover the changes * [x] coverage - I have checked the code coverage of my changes [(see more)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#checking-the-code-coverage) **Demo/meeting:** *Reviewers are encouraged to request meetings or demos if any part of the change is unclear*
**Issue number:** ADDON-76780 ### PR Type **What kind of change does this PR introduce?** * [x] Feature * [ ] Bug Fix * [ ] Refactoring (no functional or API changes) * [x] Documentation Update * [ ] Maintenance (dependency updates, CI, etc.) ## Summary ### Changes This PR contains generation of template `python files` (which will import logic from the files provided by the users) for the custom search command. For now, we are not supporting generation of python files for `Transforming/Reporting` command. ### User experience After defining required and valid configuration for custom search command in globalconfig.json, required template python files (based on the command type specified by the user) will be generated for the users, which will import logic from the files provided by the users. ## Checklist If an item doesn't apply to your changes, leave it unchecked. ### Review * [x] self-review - I have performed a self-review of this change according to the [development guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines) * [x] Changes are documented. The documentation is understandable, examples work [(more info)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#documentation-guidelines) * [x] PR title and description follows the [contributing principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests) * [ ] meeting - I have scheduled a meeting or recorded a demo to explain these changes (if there is a video, put a link below and in the ticket) ### Tests See [the testing doc](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test). * [x] Unit - tests have been added/modified to cover the changes * [x] Smoke - tests have been added/modified to cover the changes * [ ] UI - tests have been added/modified to cover the changes * [x] coverage - I have checked the code coverage of my changes [(see more)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#checking-the-code-coverage) **Demo/meeting:** *Reviewers are encouraged to request meetings or demos if any part of the change is unclear*
b54ca97
Code Coverage 🎉
|
Issue number: ADDON-76780, ADDON-79646
PR Type
What kind of change does this PR introduce?
Summary
Changes
This PR contains the centralized code which is required for supporting the custom search command feature.
From this branch we will be having at least 3 separate PR's
commands.conf
-> feat: generation ofcommands.conf
#1694searchbnf.conf
-> feat: generation ofsearchbnf.conf
#1695Python files
-> feat: generation of python files for custom search command #1697User experience
No change in the user experience as of now. As we have not covered generation of files in this PR.
Checklist
If an item doesn't apply to your changes, leave it unchecked.
Review
Tests
See the testing doc.
Demo/meeting:
Reviewers are encouraged to request meetings or demos if any part of the change is unclear