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: ucc-gen generates beautiful import_declare_test.py #342

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@ jobs:
with:
app_path: tests/slimmed
included_tags: ${{ matrix.tags }}
lint-expected-outputs:
# Only import_declare_test.py for now.
name: Lints expected_output_global_config_inputs_configuration_alerts folder generated by ucc-gen
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install black
run: pip install black
- name: Install isort
run: pip install isort
- name: Run black
run: black --check tests/expected_output_global_config_inputs_configuration_alerts/Splunk_TA_UCCExample/bin/import_declare_test.py
- name: Run isort
run: isort --check tests/expected_output_global_config_inputs_configuration_alerts/Splunk_TA_UCCExample/bin/import_declare_test.py
lint:
runs-on: ubuntu-latest
name: Lint Code Base
Expand Down
9 changes: 4 additions & 5 deletions splunk_add_on_ucc_framework/uccrestbuilder/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,13 @@ class GlobalConfigPostProcessor:
import {import_declare_name}
"""

_import_declare_content = """
import os
import sys
_import_declare_content = """import os
import re
import sys
from os.path import dirname

ta_name = '{ta_name}'
pattern = re.compile(r'[\\\\/]etc[\\\\/]apps[\\\\/][^\\\\/]+[\\\\/]bin[\\\\/]?$')
ta_name = "{ta_name}"
pattern = re.compile(r"[\\\\/]etc[\\\\/]apps[\\\\/][^\\\\/]+[\\\\/]bin[\\\\/]?$")
new_paths = [path for path in sys.path if not pattern.search(path) or ta_name in path]
new_paths.append(os.path.join(dirname(dirname(__file__)), "lib"))
new_paths.insert(0, os.path.sep.join([os.path.dirname(__file__), ta_name]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

import os
import sys
import re
import sys
from os.path import dirname

ta_name = 'Splunk_TA_UCCExample'
pattern = re.compile(r'[\\/]etc[\\/]apps[\\/][^\\/]+[\\/]bin[\\/]?$')
ta_name = "Splunk_TA_UCCExample"
pattern = re.compile(r"[\\/]etc[\\/]apps[\\/][^\\/]+[\\/]bin[\\/]?$")
new_paths = [path for path in sys.path if not pattern.search(path) or ta_name in path]
new_paths.append(os.path.join(dirname(dirname(__file__)), "lib"))
new_paths.insert(0, os.path.sep.join([os.path.dirname(__file__), ta_name]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

import os
import sys
import re
import sys
from os.path import dirname

ta_name = 'Splunk_TA_UCCExample'
pattern = re.compile(r'[\\/]etc[\\/]apps[\\/][^\\/]+[\\/]bin[\\/]?$')
ta_name = "Splunk_TA_UCCExample"
pattern = re.compile(r"[\\/]etc[\\/]apps[\\/][^\\/]+[\\/]bin[\\/]?$")
new_paths = [path for path in sys.path if not pattern.search(path) or ta_name in path]
new_paths.append(os.path.join(dirname(dirname(__file__)), "lib"))
new_paths.insert(0, os.path.sep.join([os.path.dirname(__file__), ta_name]))
Expand Down