From a3cf27fd82fa6dafd198f171aff49d3bd3254c50 Mon Sep 17 00:00:00 2001 From: Hirokuni Kitahara Date: Thu, 25 Apr 2024 21:26:33 +0900 Subject: [PATCH] update dependencies (#226) * update dependencies Signed-off-by: hirokuni-kitahara * remove variable_manager which was not used Signed-off-by: hirokuni-kitahara --------- Signed-off-by: hirokuni-kitahara --- ansible_risk_insight/loader.py | 8 +++---- ansible_risk_insight/models.py | 2 +- ansible_risk_insight/tree.py | 3 --- ansible_risk_insight/variable_manager.py | 28 ------------------------ pyproject.toml | 5 ++--- 5 files changed, 7 insertions(+), 39 deletions(-) delete mode 100644 ansible_risk_insight/variable_manager.py diff --git a/ansible_risk_insight/loader.py b/ansible_risk_insight/loader.py index 55f27971f..b6644b6fa 100644 --- a/ansible_risk_insight/loader.py +++ b/ansible_risk_insight/loader.py @@ -17,7 +17,6 @@ import os import pathlib import json -import pygit2 import pkg_resources from .models import LoadType @@ -59,9 +58,10 @@ def get_loader_version(): return version # try to get version from commit ID in source code repository try: - script_dir = pathlib.Path(__file__).parent.resolve() - repo = pygit2.Repository(script_dir) - version = repo.head.target + # TODO: consider how to get git version if it is needed + _ = pathlib.Path(__file__).parent.resolve() + # repo = pygit2.Repository(script_dir) + # version = repo.head.target except Exception: pass return version diff --git a/ansible_risk_insight/models.py b/ansible_risk_insight/models.py index 7773b8842..8d6c8c13a 100644 --- a/ansible_risk_insight/models.py +++ b/ansible_risk_insight/models.py @@ -24,7 +24,7 @@ from copy import deepcopy import json import jsonpickle -import Levenshtein +from rapidfuzz.distance import Levenshtein import ansible_risk_insight.yaml as ariyaml from ansible.module_utils.parsing.convert_bool import boolean from .keyutil import ( diff --git a/ansible_risk_insight/tree.py b/ansible_risk_insight/tree.py index 41cfcf900..0e47d2f6e 100644 --- a/ansible_risk_insight/tree.py +++ b/ansible_risk_insight/tree.py @@ -39,7 +39,6 @@ ) from .model_loader import load_builtin_modules from .risk_assessment_model import RAMClient -from .variable_manager import VariableManager obj_type_dict = { @@ -466,8 +465,6 @@ def __init__( # TODO: dependency check, especially for # collection dependencies for role - self.var_manager: VariableManager = VariableManager() - self.target_playbook_path = target_playbook_path self.load_all_taskfiles = load_all_taskfiles diff --git a/ansible_risk_insight/variable_manager.py b/ansible_risk_insight/variable_manager.py deleted file mode 100644 index f711679ec..000000000 --- a/ansible_risk_insight/variable_manager.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- mode:python; coding:utf-8 -*- - -# Copyright (c) 2022 IBM Corp. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from dataclasses import dataclass -from ansible.template import Templar - - -@dataclass -class VariableManager(object): - root_dir: str = "" - - def resolve(self, variables, data): - templar = Templar(variables=variables) - resolved_data = templar.template(data) - return resolved_data diff --git a/pyproject.toml b/pyproject.toml index 957191497..f29d4c8e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,17 +14,16 @@ classifiers = [ ] dependencies = [ "gitdb", - "pygit2", "joblib", "jsonpickle", "PyYAML", "smmap", "tabulate", "requests", - "ansible", + "ansible-core", "ruamel.yaml", "filelock", - "Levenshtein", + "rapidfuzz", ] dynamic = ["version"]