Skip to content

Commit

Permalink
fix: remove targets as a class variable in interface
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoVoges committed Jan 17, 2024
1 parent efbe5e8 commit d8f1447
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion kapitan/inventory/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class InventoryTarget:

class Inventory(ABC):
path: str = "inventory"
targets: dict = {}

def __init__(self, path: str = path, compose_target_name: bool = False):
self.inventory_path = path
Expand All @@ -37,6 +36,8 @@ def __init__(self, path: str = path, compose_target_name: bool = False):
# config
self.compose_target_name = compose_target_name

self.targets = {}

@property
def inventory(self) -> dict:
if not self.targets:
Expand Down
6 changes: 2 additions & 4 deletions tests/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import yaml
import toml
from kapitan.cli import main
from kapitan.resources import get_inventory
from kapitan.utils import directory_hash
from kapitan.cached import reset_cache
from kapitan.targets import validate_matching_target_name
from kapitan.inventory import Inventory
from kapitan.errors import InventoryError


Expand Down Expand Up @@ -136,8 +136,6 @@ def setUp(self):
def test_compile(self):
sys.argv = ["kapitan", "compile", "-c"]
main()
# Compile again to verify caching works as expected
main()
os.remove("./compiled/.kapitan_cache")
compiled_dir_hash = directory_hash(os.getcwd() + "/compiled")
test_compiled_dir_hash = directory_hash(os.getcwd() + "/../../tests/test_kubernetes_compiled")
Expand Down Expand Up @@ -175,7 +173,7 @@ def test_compile_not_matching_targets(self):
def test_compile_vars_target_missing(self):
inventory_path = "inventory"
target_filename = "minikube-es"
target_obj = Inventory(inventory_path).inventory["nodes"][target_filename]["parameters"]["kapitan"]
target_obj = get_inventory(inventory_path).get_target(target_filename)["kapitan"]
# delete vars.target
del target_obj["vars"]["target"]

Expand Down

0 comments on commit d8f1447

Please sign in to comment.