From c6cb9acaf3717c1848558b5b4b36d8a52f609538 Mon Sep 17 00:00:00 2001 From: jctanner Date: Fri, 29 Mar 2024 11:59:41 -0400 Subject: [PATCH] Fix openapi client generation in the playbooks. (#2109) Handle the unique path required for generating the galaxy client. No-Issue Signed-off-by: James Tanner --- .github/workflows/ci_full.yml | 8 ++-- .../tools/roles/pulp_client/files/generate.sh | 30 +++++++++++++ .../tools/roles/pulp_client/tasks/main.yml | 43 ++++++++++++++++--- 3 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh diff --git a/.github/workflows/ci_full.yml b/.github/workflows/ci_full.yml index 14dc4ec6d1..b34b7c74fa 100644 --- a/.github/workflows/ci_full.yml +++ b/.github/workflows/ci_full.yml @@ -89,13 +89,13 @@ jobs: run: pip3 install ansible - name: run the build container playbook - run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v build_container.yaml + run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v build_container.yaml - name: run the start container playbook - run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v start_container.yaml + run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v start_container.yaml - name: run the unit test playbook - run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v run_unit_tests.yaml + run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v run_unit_tests.yaml - name: run the functional test playbook - run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v run_functional_tests.yaml + run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v run_functional_tests.yaml diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh new file mode 100644 index 0000000000..b07c5bf09b --- /dev/null +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh @@ -0,0 +1,30 @@ +#!/bin/bash -x + +set -e + +PULP_IP=$1 +PLUGIN=$2 + +cd ../../.. +if [[ ! -d pulp-openapi-generator ]]; then + git clone https://github.com/pulp/pulp-openapi-generator +fi +cd pulp-openapi-generator; + +export USE_LOCAL_API_JSON=true; +export PULP_URL="https://${PULP_IP}/api/galaxy/pulp/api/v3/"; + +curl -L -k -u admin:password -o status.json "https://${PULP_IP}/api/galaxy/pulp/api/v3/status/"; +curl -L -k -u admin:password -o api.json "https://${PULP_IP}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin=${PLUGIN}"; + +if [ "${PLUGIN}" == "galaxy_ng" ]; then + cat status.json | head + export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"') + echo "REPORTED_VERSION: ${REPORTED_VERSION}" + export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" + echo "FINAL_VERSION: ${FINAL_VERSION}" +else + export VERSION="" +fi; + +bash -x generate.sh ${PLUGIN} python ${VERSION} diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml index deb5e2b533..2dd597f3ba 100644 --- a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml @@ -10,13 +10,41 @@ connection: local register: pulp_ip +#- name: run the generate script +# galaxy_ng.tools.local_run: +# command: > +# cd ../../../pulp-openapi-generator; +# export USE_LOCAL_API_JSON=true; +# export PULP_URL='https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/'; +# curl -L -k -u admin:password -o status.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/status/'; +# curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}'; +# if [ "{{ item }}" == "galaxy_ng" ]; then +# cat status.json | head +# export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"') +# echo "REPORTED_VERSION: ${REPORTED_VERSION}" +# export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" +# echo "FINAL_VERSION: ${FINAL_VERSION}" +# else +# export VERSION="" +# fi; +# bash -x generate.sh {{ item }} python $VERSION +# connection: local +# loop: +# - galaxy_ng +# - pulp_ansible +# - pulp_container +# - pulpcore + +- name: copy the generate script to a tmp location + copy: + src: generate.sh + dest: /tmp/generate.sh + mode: '0777' + connection: local + - name: run the generate script galaxy_ng.tools.local_run: - command: > - cd ../../../pulp-openapi-generator; - export USE_LOCAL_API_JSON=true; - curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}'; - bash -x generate.sh {{ item }} python + command: /tmp/generate.sh {{ pulp_ip.stdout }} {{ item }} connection: local loop: - galaxy_ng @@ -25,9 +53,12 @@ - pulpcore - name: install the generated client inside the pulp container - shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install -e . + shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install . loop: - galaxy_ng - pulp_ansible - pulp_container - pulpcore + +- name: show what we eneded up with + shell: pip3 list | grep -e galaxy -e pulp -e ansible