diff --git a/sat/cli/bootprep/input/configuration.py b/sat/cli/bootprep/input/configuration.py index 48c5189d..b65db81f 100644 --- a/sat/cli/bootprep/input/configuration.py +++ b/sat/cli/bootprep/input/configuration.py @@ -313,21 +313,25 @@ class AdditionalInventory(InputConfigurationLayerBase): """Additional inventory data for a CFS configuration""" @property + @jinja_rendered def clone_url(self): """str: the clone URL for the additional inventory""" return self.layer_data['url'] @property + @jinja_rendered def commit(self): """str or None: the commit hash or None if branch was specified instead""" return self.layer_data.get('commit') @property + @jinja_rendered def branch(self): """str or None: the branch or None if commit was specified instead""" return self.layer_data.get('branch') @property + @jinja_rendered def name(self): """str or None: the optional name of the additional inventory""" return self.layer_data.get('name') diff --git a/tests/cli/bootprep/input/test_configuration.py b/tests/cli/bootprep/input/test_configuration.py index 00a5d9b2..0b128264 100644 --- a/tests/cli/bootprep/input/test_configuration.py +++ b/tests/cli/bootprep/input/test_configuration.py @@ -560,6 +560,19 @@ def test_clone_url_property(self): self.mock_cfs_client) self.assertEqual(self.repo_url, additional_inventory.clone_url) + def test_clone_url_jinja_rendered(self): + """Test the clone_url property when it uses Jinja2 templating""" + repo_name = 'foo-inventory' + self.jinja_env.globals['test'] = { + 'repo_name': repo_name + } + + self.data_with_commit['url'] = 'https://api-gw-service.nmn.local/vcs/cray/{{test.repo_name}}.git' + additional_inventory = AdditionalInventory(self.data_with_commit, self.jinja_env, + self.mock_cfs_client) + self.assertEqual(f'https://api-gw-service.nmn.local/vcs/cray/{repo_name}.git', + additional_inventory.clone_url) + def test_commit_property_specified(self): """Test the commit property when specified""" additional_inventory = AdditionalInventory(self.data_with_commit, self.jinja_env, @@ -572,6 +585,18 @@ def test_commit_property_unspecified(self): self.mock_cfs_client) self.assertIsNone(additional_inventory.commit) + def test_commit_property_jinja_rendered(self): + """Test the commit property when it uses Jinja2 templating""" + commit_hash = 'abc1234' + self.jinja_env.globals['test'] = { + 'commit_hash': commit_hash + } + + self.data_with_commit['commit'] = '{{test.commit_hash}}' + additional_inventory = AdditionalInventory(self.data_with_commit, self.jinja_env, + self.mock_cfs_client) + self.assertEqual(commit_hash, additional_inventory.commit) + def test_branch_property_specified(self): """"Test the branch property when specified""" additional_inventory = AdditionalInventory(self.data_with_branch, self.jinja_env, @@ -584,6 +609,18 @@ def test_branch_property_not_specified(self): self.mock_cfs_client) self.assertIsNone(additional_inventory.branch) + def test_branch_property_jinja_rendered(self): + """Test the branch property when it uses Jinja2 templating""" + branch_name = 'integration' + self.jinja_env.globals['test'] = { + 'branch_name': branch_name + } + + self.data_with_branch['branch'] = '{{test.branch_name}}' + additional_inventory = AdditionalInventory(self.data_with_branch, self.jinja_env, + self.mock_cfs_client) + self.assertEqual(branch_name, additional_inventory.branch) + def test_name_property_specified(self): """Test the name property when specified""" additional_inventory = AdditionalInventory(self.data_with_name, self.jinja_env, @@ -596,6 +633,18 @@ def test_name_property_not_specified(self): self.mock_cfs_client) self.assertIsNone(additional_inventory.name) + def test_name_property_jinja_rendered(self): + """Test the name property when it uses Jinja2 templating""" + name = 'inventory' + self.jinja_env.globals['test'] = { + 'name': name + } + + self.data_with_name['name'] = '{{test.name}}' + additional_inventory = AdditionalInventory(self.data_with_name, self.jinja_env, + self.mock_cfs_client) + self.assertEqual(name, additional_inventory.name) + def test_get_cfs_api_data_no_resolve_branches(self): """Test get_cfs_api_data method without branch resolution""" additional_inventory = AdditionalInventory(self.data_with_name, self.jinja_env,