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(generate): restructure file generation of conf and spec files #1299

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d08b35
feat(restructure): add new build method for web, restmap, server conf…
hetangmodi-crest Jul 16, 2024
27cdc43
doc: add auto doc generation method
hetangmodi-crest Jul 16, 2024
7b0c6a1
feat: add new logic for inputs, alert, tags, eventtypes conf file
hetangmodi-crest Jul 18, 2024
57ba4d4
fix: add changes for app.conf file
hetangmodi-crest Jul 18, 2024
0d1c91d
chore: fix lint failures
hetangmodi-crest Jul 18, 2024
b3bff0e
chore: merge branch 'develop' into feat/restructure-file-generation
hetangmodi-crest Jul 18, 2024
675b7fe
feat: add migrated code for account, settings conf and spec file
hetangmodi-crest Jul 23, 2024
f59a028
test(smoke): fix smoke test for globalConfig everything
hetangmodi-crest Jul 23, 2024
f43d8a7
test(smoke): update smoke tests as per new design
hetangmodi-crest Jul 24, 2024
6c2475e
fix(alerts): update logic to avoid creating empty files
hetangmodi-crest Jul 24, 2024
c9a5c8d
chore: fix mypy and flake8 failures
hetangmodi-crest Jul 24, 2024
eabd032
chore: merge branch 'develop' into feat/restructure-file-generation
hetangmodi-crest Jul 24, 2024
66644e0
ci: fix missing license failure
hetangmodi-crest Jul 24, 2024
6fef598
fix: omit file creation if configs do not exist
hetangmodi-crest Jul 26, 2024
fd0e8b1
feat(generate): generation of XML files
hetangmodi-crest Jul 31, 2024
cd48a8c
ci: add auto updates of docs
hetangmodi-crest Jul 31, 2024
2a152a0
ci: update workflow calls
hetangmodi-crest Jul 31, 2024
22ab4b0
ci:auto updates of docs using ucc-gen-docs command
hetangmodi-crest Aug 1, 2024
f0c4044
ci: updated workflow action
hetangmodi-crest Aug 1, 2024
4db6be8
feat(generate):generation of html files for alerts
hetangmodi-crest Aug 2, 2024
5854ae7
ci: added license in html files
hetangmodi-crest Aug 2, 2024
d1d8880
doc: updated docs regarding generated conf, xml and html files
srv-rr-github-token Aug 2, 2024
250b444
deps: update addonfactory-splunk-conf-parser-lib and add lxml
hetangmodi-crest Aug 5, 2024
cfac087
chore: merge branch 'develop' into feat/restructure-file-generation
hetangmodi-crest Aug 5, 2024
3e4c4a3
chore(html): fix minor syntax and optimization
hetangmodi-crest Aug 8, 2024
2915f28
test(unit): add unit test case for html generation
hetangmodi-crest Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/generated_files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
hetangmodi-crest marked this conversation as resolved.
Show resolved Hide resolved
title: UCC framework generated files
---

Below table describes the files generated by UCC framework

## File Description

| File Name | File Location | File Description |
| ------------ | ------------ | ----------------- |
| app.conf | output/<YOUR_ADDON_NAME>/default | Generates `app.conf` with the details mentioned in globalConfig[meta] |
| inputs.conf | output/<YOUR_ADDON_NAME>/default | Generates `inputs.conf` and `inputs.conf.spec` file for the services mentioned in globalConfig |
| server.conf | output/<YOUR_ADDON_NAME>/default | Generates `server.conf` for the custom conf files created as per configurations in globalConfig |
| restmap.conf | output/<YOUR_ADDON_NAME>/default | Generates `restmap.conf` for the custom REST handlers that are generated based on configs from globalConfig |
| web.conf | output/<YOUR_ADDON_NAME>/default | Generates `web.conf` to expose the endpoints generated in `restmap.conf` which is generated based on configurations from globalConfig. |
| alert_actions.conf | output/<YOUR_ADDON_NAME>/default | Generates `alert_actions.conf` and `alert_actions.conf.spec` file for the custom alert actions defined in globalConfig |
| eventtypes.conf | output/<YOUR_ADDON_NAME>/default | Generates `eventtypes.conf` file if the sourcetype is mentioned in Adaptive Response of custom alert action in globalConfig |
| tags.conf | output/<YOUR_ADDON_NAME>/default | Generates `tags.conf` file based on the `eventtypes.conf` created for custom alert actions. |

5 changes: 3 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ nav:
- Home: "index.md"
- Quickstart: "quickstart.md"
- ".conf files": "dot_conf_files.md"
- Generated Files: "generated_files.md"
- Inputs:
- "inputs/index.md"
- Introduction: "inputs/index.md"
Expand Down Expand Up @@ -91,9 +92,9 @@ nav:
- Custom Warning: "advanced/custom_warning.md"
- Troubleshooting: "troubleshooting.md"
- Contributing: "contributing.md"
- Changelog: "CHANGELOG.md"
- Metadata: "metadata.md"
- Storybook: "storybook/index.html"
- Changelog: "CHANGELOG.md"
- UI Tests:
- Configuration Page:
- General: "ui_tests_config_page_general.md"
Expand All @@ -102,4 +103,4 @@ nav:
- Logging: "ui_tests_config_page_logging.md"
- Proxy: "ui_tests_config_page_proxy.md"
- Alert Action Page: "ui_tests_alert_actions_page.md"
- Input Page: "ui_tests_inputs_page.md"
- Input Page: "ui_tests_inputs_page.md"
75 changes: 0 additions & 75 deletions splunk_add_on_ucc_framework/app_conf.py

This file was deleted.

75 changes: 30 additions & 45 deletions splunk_add_on_ucc_framework/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
utils,
)
from splunk_add_on_ucc_framework import dashboard
from splunk_add_on_ucc_framework import app_conf as app_conf_lib
from splunk_add_on_ucc_framework import meta_conf as meta_conf_lib
from splunk_add_on_ucc_framework import server_conf as server_conf_lib
from splunk_add_on_ucc_framework import app_manifest as app_manifest_lib
from splunk_add_on_ucc_framework import global_config as global_config_lib
from splunk_add_on_ucc_framework import data_ui_generator
Expand All @@ -54,7 +52,8 @@
from splunk_add_on_ucc_framework.commands.openapi_generator import (
ucc_to_oas,
)

from splunk_add_on_ucc_framework.generators.file_generator import begin
from splunk_add_on_ucc_framework.generators.conf_files.create_app_conf import AppConf

logger = logging.getLogger("ucc_gen")

Expand Down Expand Up @@ -522,9 +521,12 @@ def generate(
logger.info(f"Cleaned out directory {output_directory}")
app_manifest = _get_app_manifest(source)
ta_name = app_manifest.get_addon_name()
generated_files = []
ui_available = False

gc_path = _get_and_check_global_config_path(source, config_path)
if gc_path:
ui_available = True
logger.info(f"Using globalConfig file located @ {gc_path}")
global_config = global_config_lib.GlobalConfig(gc_path)
# handle the update of globalConfig before validating
Expand Down Expand Up @@ -590,6 +592,20 @@ def generate(
logger.info(
f"Installed add-on requirements into {ucc_lib_target} from {source}"
)
generated_files.extend(
begin(
global_config=global_config,
input_dir=source,
output_dir=output_directory,
ucc_dir=internal_root_dir,
addon_name=ta_name,
app_manifest=app_manifest,
addon_version=addon_version,
has_ui=ui_available,
)
)
# TODO: all FILES GENERATED object: generated_files, use it for comparison

builder_obj = RestBuilder(scheme, os.path.join(output_directory, ta_name))
builder_obj.build()
_modify_and_replace_token_for_oauth_templates(
Expand All @@ -611,22 +627,6 @@ def generate(
conf_file_names.extend(list(scheme.configs_conf_file_names))
conf_file_names.extend(list(scheme.oauth_conf_file_names))

source_server_conf_path = os.path.join(source, "default", "server.conf")
# For now, only create server.conf only if no server.conf is present in
# the source package.
if not os.path.isfile(source_server_conf_path):
server_conf = server_conf_lib.ServerConf()
server_conf.create_default(conf_file_names)
output_server_conf_path = os.path.join(
output_directory,
ta_name,
"default",
server_conf_lib.SERVER_CONF_FILE_NAME,
)
server_conf.write(output_server_conf_path)
logger.info(
f"Created default {server_conf_lib.SERVER_CONF_FILE_NAME} file in the output folder"
)
if global_config.has_dashboard():
logger.info("Including dashboard")
dashboard_definition_json_path = os.path.join(
Expand Down Expand Up @@ -698,32 +698,17 @@ def generate(
logger.info(
f"Updated {app_manifest_lib.APP_MANIFEST_FILE_NAME} file in the output folder"
)

app_conf = app_conf_lib.AppConf()
output_app_conf_path = os.path.join(
output_directory, ta_name, "default", app_conf_lib.APP_CONF_FILE_NAME
)
app_conf.read(output_app_conf_path)
should_be_visible = False
check_for_updates = "true"
supported_themes = ""
if global_config:
should_be_visible = True
if global_config.meta.get("checkForUpdates") is False:
check_for_updates = "false"
if global_config.meta.get("supportedThemes") is not None:
supported_themes = ", ".join(global_config.meta["supportedThemes"])
app_conf.update(
addon_version,
app_manifest,
conf_file_names,
should_be_visible,
check_for_updates=check_for_updates,
supported_themes=supported_themes,
)
app_conf.write(output_app_conf_path)
logger.info(f"Updated {app_conf_lib.APP_CONF_FILE_NAME} file in the output folder")

# NOTE: merging source and generated 'app.conf' as per previous design
AppConf(
global_config=global_config,
input_dir=source,
output_dir=output_directory,
ucc_dir=internal_root_dir,
addon_name=ta_name,
app_manifest=app_manifest,
addon_version=addon_version,
has_ui=ui_available,
).generate()
license_dir = os.path.abspath(os.path.join(source, os.pardir, "LICENSES"))
if os.path.exists(license_dir):
logger.info("Copy LICENSES directory")
Expand Down
Loading
Loading