From b2e931fad3ff486d0365fe828bb0a195687795da Mon Sep 17 00:00:00 2001 From: Yashvardhan Nanavati Date: Fri, 9 Feb 2024 15:34:19 -0500 Subject: [PATCH] [CVP-3985] Add spec.skips to parsed_operator_data --- Dockerfiles/ci/run_tests.py | 30 +++++++++++++++++++ roles/parse_operator_bundle/tasks/main.yml | 3 +- .../templates/parsed_operator_data.yml.j2 | 6 ++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Dockerfiles/ci/run_tests.py b/Dockerfiles/ci/run_tests.py index cbd0068d..270cc61d 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_extract_operator_bundle_with_skiprange_and_skips_without_replaces(self): + operator_work_dir = "{}/test_extract_operator_bundle_with_skiprange_and_without_replaces".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:with-skiprange-and-skips-but-without-replaces" + 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) + self.assertIn('olm_skips:\n', parsed_output) + self.assertIn('- local-storage-operator.v4.15.0-202312121223\n', parsed_output) + if __name__ == '__main__': unittest.main() diff --git a/roles/parse_operator_bundle/tasks/main.yml b/roles/parse_operator_bundle/tasks/main.yml index 5dfe5376..6f6b0e6b 100644 --- a/roles/parse_operator_bundle/tasks/main.yml +++ b/roles/parse_operator_bundle/tasks/main.yml @@ -126,10 +126,11 @@ operator_feature_token_auth_gcp: "{{ (csv_vars | from_yaml).metadata.annotations['features.operators.openshift.io/token-auth-gcp'] | default(omit) }}" ignore_errors: true - - name: "Determine olm.skipRange and olm.replaces values" + - name: "Determine olm.skipRange, spec.replaces and spec.skips values" set_fact: olm_skipRange: "{{ (csv_vars | from_yaml).metadata.annotations['olm.skipRange'] | default(omit) }}" olm_replaces: "{{ (csv_vars | from_yaml).spec['replaces'] | default(omit) }}" + olm_skips: "{{ (csv_vars | from_yaml).spec['skips'] | default(omit) }}" ignore_errors: true - name: "Determine operator_allnamespaces_support" 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..ef448dec 100644 --- a/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 +++ b/roles/parse_operator_bundle/templates/parsed_operator_data.yml.j2 @@ -36,6 +36,12 @@ olm_skipRange: "{{ olm_skipRange }}" {% if olm_replaces is defined %} olm_replaces: "{{ olm_replaces }}" {% endif %} +{% if olm_skips is defined %} +olm_skips: +{% for olm_skip in olm_skips %} + - {{ olm_skip }} +{% endfor %} +{% endif %} {% if operator_feature_disconnected is defined %} operator_feature_disconnected: "{{ operator_feature_disconnected }}" {% endif %}