From 45ce134a66405082eaadb7614a8226c955a92064 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Fri, 24 Nov 2023 14:17:21 +0100 Subject: [PATCH] Fix client bindings install for old status Older versions of pulpcore do not include the python-package in the status response. The solution is to guess the package name from the app_label. This mostly works, because we substitute "_" with "-" anyway. [noissue] --- .../github/.github/workflows/scripts/script.sh.j2 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/templates/github/.github/workflows/scripts/script.sh.j2 b/templates/github/.github/workflows/scripts/script.sh.j2 index 245e10dc..f0e19970 100755 --- a/templates/github/.github/workflows/scripts/script.sh.j2 +++ b/templates/github/.github/workflows/scripts/script.sh.j2 @@ -47,11 +47,15 @@ password password # Some commands like ansible-galaxy specifically require 600 cmd_prefix bash -c "chmod 600 ~pulp/.netrc" -# Workaround: Domains are not supported by the published bindings. +# Infer the client name from the package name by replacing "-" with "_". +# Use the component to infer the package name on older versions of pulpcore. + if [ "$(echo "$REPORTED_STATUS" | jq -r '.domain_enabled')" = "true" ] then + # Workaround: Domains are not supported by the published bindings. + # Generate new bindings for all packages. pushd ../pulp-openapi-generator - for item in $(echo "$REPORTED_STATUS" | jq -r '.versions[].package|sub("-"; "_")') + for item in $(echo "$REPORTED_STATUS" | jq -r '.versions[]|(.package // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")') do ./generate.sh "${item}" python cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" @@ -65,7 +69,7 @@ else {%- for plugin in plugins -%} |select(.component!="{{ plugin.app_label }}") {%- endfor -%} - .package|sub("-"; "_")') + |(.package // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")') do ./generate.sh "${item}" python cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" @@ -74,7 +78,8 @@ else popd fi -echo "$REPORTED_STATUS" | jq -r '.versions[]|(.package|sub("_"; "-")) + "-client==" + .version' > bindings_requirements.txt +# At this point, this is a safeguard only, so let's not make too much fuzz about the old status format. +echo "$REPORTED_STATUS" | jq -r '.versions[]|select(.package)|(.package|sub("_"; "-")) + "-client==" + .version' > bindings_requirements.txt cmd_stdin_prefix bash -c "cat > /tmp/unittest_requirements.txt" < unittest_requirements.txt cmd_stdin_prefix bash -c "cat > /tmp/functest_requirements.txt" < functest_requirements.txt cmd_stdin_prefix bash -c "cat > /tmp/bindings_requirements.txt" < bindings_requirements.txt