diff --git a/Dockerfiles/ci/run_tests.py b/Dockerfiles/ci/run_tests.py index 173c625a..ffb19698 100755 --- a/Dockerfiles/ci/run_tests.py +++ b/Dockerfiles/ci/run_tests.py @@ -376,6 +376,36 @@ def test_extract_operator_bundle_with_skiprange_and_without_replaces(self): print(parsed_output) self.assertNotIn('olm_replaces', parsed_output) + def test_all_target_channels_parsing(self): + operator_work_dir = "{}/test_all_target_channels_parsing".format(self.test_dir) + work_dir = operator_work_dir + operator_dir = "{}/test-operator".format(operator_work_dir) + operator_bundle_dir = "{}/operator-bundle".format(operator_work_dir) + bundle_image = "quay.io/cvpops/test-operator:parse-channel" + exec_cmd = "ansible-playbook -vvv -i localhost, --connection local \ + operator-test-playbooks/extract-operator-bundle.yml \ + -e 'operator_dir={operator_dir}' \ + -e 'bundle_image={bundle_image}' \ + -e 'operator_work_dir={operator_work_dir}' \ + -e 'operator_bundle_dir={operator_bundle_dir}' \ + -e 'work_dir={work_dir}'".format(operator_dir=operator_dir, + operator_work_dir=operator_work_dir, + operator_bundle_dir=operator_bundle_dir, + bundle_image=bundle_image, + work_dir=work_dir) + playbook_command = subprocess.run(exec_cmd, shell=True) + + print(playbook_command.returncode) + self.assertTrue(playbook_command.returncode == 0) + self.assertTrue(path.exists("{}/parsed_operator_data.yml".format(work_dir))) + with open("{}/parsed_operator_data.yml".format(work_dir), "r") as fd: + parsed_output = fd.read() + print(parsed_output) + self.assertNotIn('olm_replaces', parsed_output) + parsed_output = yaml.safe_load(fd) + print(parsed_output) + self.assertEqual('target_channels:\n - "4.10"', parsed_output) + if __name__ == '__main__': unittest.main() diff --git a/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 b/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 index d7228cfe..b89a3a14 100644 --- a/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 +++ b/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 @@ -66,3 +66,9 @@ operator_feature_token_auth_azure: "{{ operator_feature_token_auth_azure }}" {% if operator_feature_token_auth_gcp is defined %} operator_feature_token_auth_gcp: "{{ operator_feature_token_auth_gcp }}" {% endif %} +{% if channels is defined %} +target_channels: +{% for channel in channels %} + - "{{ channel }}" +{% endfor %} +{% endif %}