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

fix path issue around repo root and yaml_label_list #214

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions ansible_risk_insight/model_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,24 @@ def load_repository(
repoObj = Repository()

repo_path = ""
repo_to_root = ""
if path == "":
# if path is empty, just load installed collections / roles
repo_path = ""
else:
# otherwise, find the root path by searching playbooks
try:
repo_path = find_best_repo_root_path(path)
repo_to_root = os.path.relpath(path, repo_path)
except Exception as exc:
logger.debug(f'failed to find a root directory for a project in "{path}"; error: {exc}')
# if an exception occurs while finding repo root, use the input path as repo root
repo_path = path

# if `path` and `repo_path` are different, update yaml_label_list
if repo_to_root and yaml_label_list:
yaml_label_list = [(os.path.normpath(os.path.join(repo_to_root, fpath)), label, role_info) for (fpath, label, role_info) in yaml_label_list]

if repo_path != "":
if my_collection_name == "":
my_collection_name = find_collection_name_of_repo(repo_path)
Expand Down
Loading