|
28 | 28 | bundle_validate: "{{ operator_work_dir }}" |
29 | 29 | when: not run_upstream|bool |
30 | 30 |
|
31 | | -- name: "Set the operatorhub checks if enabled" |
| 31 | +- name: "list work_dir" |
| 32 | + shell: "ls {{ work_dir }}" |
| 33 | + |
| 34 | +- name: "Check whether bundle supports v4.9 or higher" |
| 35 | + block: |
| 36 | + - name: Get skopeo inspect json |
| 37 | + shell: "cat {{ work_dir }}/bundle-skopeo-inspect.json" |
| 38 | + register: bundle_skopeo_inspect_json |
| 39 | + |
| 40 | + - name: Convert json to map |
| 41 | + set_fact: |
| 42 | + bundle_skopeo_inspect_map: "{{ bundle_skopeo_inspect_json.stdout | from_json }}" |
| 43 | + |
| 44 | + - name: Determine ocp version annotation |
| 45 | + set_fact: |
| 46 | + ocp_version_annotation: "{{ bundle_skopeo_inspect_map['Labels']['com.redhat.openshift.versions'] }}" |
| 47 | + |
| 48 | + - name: "Determine OCP version range" |
| 49 | + uri: |
| 50 | + url: "https://catalog.redhat.com/api/containers/v1/operators/indices?sort_by=data.ocp_version&ocp_versions_range={{ ocp_version_annotation }}&organization=redhat-operators" |
| 51 | + method: GET |
| 52 | + headers: |
| 53 | + Accept: "application/json" |
| 54 | + status_code: 200 |
| 55 | + return_content: true |
| 56 | + register: supported_indices_json |
| 57 | + retries: 10 |
| 58 | + ignore_errors: true |
| 59 | + |
| 60 | + - name: "Fail if Pyxis response is not 200" |
| 61 | + fail: |
| 62 | + msg: "Error collecting OCP version range from Pyxis. Error message: {{ supported_indices_json.content }}" |
| 63 | + when: supported_indices_json.status != 200 |
| 64 | + |
| 65 | + - name: "Convert output to map" |
| 66 | + set_fact: |
| 67 | + supported_indices: "{{ supported_indices_json.content | from_json }}" |
| 68 | + |
| 69 | + - name: debug |
| 70 | + debug: |
| 71 | + msg: "Indices: {{ supported_indices['data'] }}" |
| 72 | + |
| 73 | + - name: "Set support_v4_9 to false if there are no supported versions" |
| 74 | + set_fact: |
| 75 | + support_v4_9: false |
| 76 | + when: supported_indices['data']|length==0 |
| 77 | + |
| 78 | + - name: "Parse values returned from Pyxis" |
| 79 | + set_fact: |
| 80 | + highest_index: "{{ supported_indices['data'] | last }}" |
| 81 | + when: supported_indices['data']|length>0 |
| 82 | + |
| 83 | + - name: "Determine if v4.9 is supported" |
| 84 | + set_fact: |
| 85 | + support_v4_9: "{{ highest_index['ocp_version'] is version('4.9', '>=') }}" |
| 86 | + when: |
| 87 | + - highest_index is defined |
| 88 | + - highest_index['ocp_version']|length>0 |
| 89 | + |
| 90 | +- name: "Set the operatorhub checks if bundle supports v4.9 or greater" |
32 | 91 | set_fact: |
33 | | - select_optional_tests: "--select-optional name=operatorhub" |
34 | | - when: run_operatorhub_checks|bool |
| 92 | + select_optional_tests: "--select-optional name=operatorhub --optional-values=k8s-version=1.22" |
| 93 | + when: support_v4_9 |
35 | 94 |
|
36 | 95 | - name: "Validate the operator bundle manifest and metadata with operator-sdk bundle validate" |
37 | 96 | shell: "{{ operator_sdk_bin_path }} bundle validate {{ select_optional_tests }} --verbose {{ bundle_validate }} 2>&1" |
|
0 commit comments