Skip to content

Commit

Permalink
Merge pull request #501 from redhatci/starting_csv
Browse files Browse the repository at this point in the history
Handle startingCSV cases
  • Loading branch information
tonyskapunk authored Dec 10, 2024
2 parents 82bd9f2 + 917a8ca commit 56679bc
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion roles/olm_operator/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,45 @@
namespace: "{{ namespace }}"
spec:
channel: "{{ desired_channel }}"
installPlanApproval: "Automatic"
installPlanApproval: "{{ (starting_csv | default('') | length) | ternary('Manual', 'Automatic') }}"
config:
resources: {}
name: "{{ operator }}"
source: "{{ source }}"
sourceNamespace: "{{ source_ns }}"
startingCSV: "{{ operator_csv }}"

- name: Check for install plans
community.kubernetes.k8s_info:
api: operators.coreos.com/v1alpha1
kind: InstallPlan
namespace: "{{ namespace }}"
register: _oo_install_plans
no_log: true
retries: 5
delay: 5
until:
- _oo_install_plans.resources is defined
- _oo_install_plans.resources | length

- name: Approve only the install plan for the specific CSV
vars:
query: "resources[? spec.approved == `false` && contains(spec.clusterServiceVersionNames, '{{ starting_csv }}')]"
community.kubernetes.k8s:
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: InstallPlan
metadata:
name: "{{ install_plan.metadata.name }}"
namespace: "{{ namespace }}"
spec:
approved: true
loop: "{{ _oo_install_plans | json_query(query) | default([]) }}"
loop_control:
loop_var: install_plan
when:
- starting_csv | default('') | length > 0

- name: Wait for CSV to be ready
community.kubernetes.k8s_info:
api: operators.coreos.com/v1alpha1
Expand Down

0 comments on commit 56679bc

Please sign in to comment.