Skip to content

additional_packaging.py file

To extend the build process, you can create a additional_packaging.py file in the same file level where you have your globalConfig file.

This file should at least have:

  • the cleanup_output_files function, which accepts output_path (str), add-on name (str) as its arguments.
  • the additional_packaging function, which accepts add-on name (str) as its only argument.

First the cleanup_output_files function would be called from ucc-gen build process and then additional_packaging function.

See the following example for proper usage:

  • Build custom UI after ucc-gen finishes all its necessary steps.
  • Use a workaround for a ucc-gen feature that has not been implemented.

Example

Below is an example of additional_packaging.py containing both the implementations of functions.

from os.path import sep, exists, dirname, realpath, join
from os import remove, system, _exit, WEXITSTATUS

def cleanup_output_files(output_path: str, ta_name: str) -> None:
    """
    prepare a list for the files to be deleted after the source code has been copied to output directory
    """
    files_to_delete = []
    files_to_delete.append(sep.join([output_path, ta_name, "default", "redundant.conf"]))
    files_to_delete.append(sep.join([output_path, ta_name, "bin", "splunk_ta_uccexample_rh_example_input_two.py"]))
    files_to_delete.append(sep.join([output_path, ta_name, "bin", "example_input_one.py"]))
    files_to_delete.append(sep.join([output_path, ta_name, "bin", "splunk_ta_uccexample_rh_example_input_one.py"]))
    files_to_delete.append(sep.join([output_path, ta_name, "bin", "file_does_not_exist.py"]))
    files_to_delete.append(sep.join([output_path, ta_name, "default", "nav", "views", "file_copied_from_source_code.xml"]))

    for delete_file in files_to_delete:
        try:
            remove(delete_file)
        except (FileNotFoundError):
            # simply pass if the file doesn't exist
            pass