Skip to content

Commit

Permalink
[CVP-3985] Add spec.skips to parsed_operator_data
Browse files Browse the repository at this point in the history
  • Loading branch information
yashvardhannanavati committed Feb 13, 2024
1 parent fc8885f commit 9c74ef6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
30 changes: 30 additions & 0 deletions Dockerfiles/ci/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_skips_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()

3 changes: 2 additions & 1 deletion roles/parse_operator_bundle/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit 9c74ef6

Please sign in to comment.