@@ -54,75 +54,62 @@ password password
5454# Some commands like ansible-galaxy specifically require 600
5555cmd_prefix bash -c " chmod 600 ~pulp/.netrc"
5656
57- # Generate and install binding
57+ # Generate bindings
58+ # ##################
59+
60+ touch bindings_requirements.txt
5861pushd ../pulp-openapi-generator
59- if pulp debug has-plugin --name " core" --specifier " >=3.44.0.dev"
60- then
6162 # Use app_label to generate api.json and package to produce the proper package name.
6263
63- if [ " $( jq -r ' .domain_enabled' <<< " $REPORTED_STATUS" ) " = " true" ]
64+ # Workaround: Domains are not supported by the published bindings.
65+ # Sadly: Different pulpcore-versions aren't either...
66+ # So we exclude the prebuilt ones only for domains disabled.
67+ if [ " $( jq -r ' .domain_enabled' <<< " ${REPORTED_STATUS}" ) " = " true" ] || [ " $( jq -r ' .online_workers[0].pulp_href|startswith("/pulp/api/v3/")' <<< " ${REPORTED_STATUS}" ) " = " false" ]
6468 then
65- # Workaround: Domains are not supported by the published bindings.
66- # Generate new bindings for all packages.
67- for item in $( jq -r ' .versions[] | tojson' <<< " $REPORTED_STATUS" )
68- do
69- echo $item
70- COMPONENT=" $( jq -r ' .component' <<< " $item" ) "
71- VERSION=" $( jq -r ' .version' <<< " $item" ) "
72- MODULE=" $( jq -r ' .module' <<< " $item" ) "
73- PACKAGE=" ${MODULE%% .* } "
74- curl --fail-with-body -k -o api.json " ${PULP_URL}${PULP_API_ROOT} api/v3/docs/api.json?bindings&component=$COMPONENT "
75- USE_LOCAL_API_JSON=1 ./generate.sh " ${PACKAGE} " python " ${VERSION} "
76- cmd_prefix pip3 install " /root/pulp-openapi-generator/${PACKAGE} -client"
77- sudo rm -rf " ./${PACKAGE} -client"
78- done
69+ BUILT_CLIENTS=" "
7970 else
80- # Sadly: Different pulpcore-versions aren't either...
81- for item in $( jq -r ' .versions[]| select(.component!="python")| tojson' <<< " $REPORTED_STATUS" )
82- do
83- echo $item
84- COMPONENT=" $( jq -r ' .component' <<< " $item" ) "
85- VERSION=" $( jq -r ' .version' <<< " $item" ) "
86- MODULE=" $( jq -r ' .module' <<< " $item" ) "
87- PACKAGE=" ${MODULE%% .* } "
88- curl --fail-with-body -k -o api.json " ${PULP_URL}${PULP_API_ROOT} api/v3/docs/api.json?bindings&component=$COMPONENT "
89- USE_LOCAL_API_JSON=1 ./generate.sh " ${PACKAGE} " python " ${VERSION} "
90- cmd_prefix pip3 install " /root/pulp-openapi-generator/${PACKAGE} -client"
91- sudo rm -rf " ./${PACKAGE} -client"
92- done
71+ BUILT_CLIENTS=" python "
9372 fi
94- else
95- # Infer the client name from the package name by replacing "-" with "_".
96- # Use the component to infer the package name on older versions of pulpcore.
9773
98- if [ " $( echo " $REPORTED_STATUS " | jq -r ' .domain_enabled' ) " = " true" ]
99- then
100- # Workaround: Domains are not supported by the published bindings.
101- # Generate new bindings for all packages.
102- for item in $( echo " $REPORTED_STATUS " | jq -r ' .versions[]|(.package // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")' )
103- do
104- ./generate.sh " ${item} " python
105- cmd_prefix pip3 install " /root/pulp-openapi-generator/${item} -client"
106- sudo rm -rf " ./${item} -client"
107- done
108- else
109- # Sadly: Different pulpcore-versions aren't either...
110- for item in $( echo " $REPORTED_STATUS " | jq -r ' .versions[]|select(.component!="python")|(.package // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")' )
111- do
112- ./generate.sh " ${item} " python
113- cmd_prefix pip3 install " /root/pulp-openapi-generator/${item} -client"
114- sudo rm -rf " ./${item} -client"
115- done
116- fi
117- fi
74+ for ITEM in $( jq -r ' .versions[] | tojson' <<< " ${REPORTED_STATUS}" )
75+ do
76+ COMPONENT=" $( jq -r ' .component' <<< " ${ITEM}" ) "
77+ VERSION=" $( jq -r ' .version' <<< " ${ITEM}" | python3 -c " from packaging.version import Version; print(Version(input()))" ) "
78+ # On older status endpoints, the module was not provided, but the package should be accurate
79+ # there, because we did not merge plugins into pulpcore back then.
80+ MODULE=" $( jq -r ' .module // (.package|gsub("-"; "_"))' <<< " ${ITEM}" ) "
81+ PACKAGE=" ${MODULE%% .* } "
82+ if [[ ! " ${BUILT_CLIENTS} " =~ " ${COMPONENT} " ]]
83+ then
84+ rm -rf " ./${PACKAGE} -client"
85+ cmd_prefix pulpcore-manager openapi --bindings --component " ${COMPONENT} " > " ${COMPONENT} -api.json"
86+ ./gen-client.sh " ${COMPONENT} -api.json" " ${COMPONENT} " python " ${PACKAGE} "
87+ pushd " ${PACKAGE} -client"
88+ python setup.py sdist bdist_wheel --python-tag py3
89+ popd
90+ else
91+ if [ ! -f " ${PACKAGE} -client/dist/${PACKAGE} _client-${VERSION} -py3-none-any.whl" ]
92+ then
93+ ls -lR " ${PACKAGE} -client/"
94+ echo " Error: Client bindings for ${COMPONENT} not found."
95+ echo " File ${PACKAGE} -client/dist/${PACKAGE} _client-${VERSION} -py3-none-any.whl missing."
96+ exit 1
97+ fi
98+ fi
99+ echo " /root/pulp-openapi-generator/${PACKAGE} -client/dist/${PACKAGE} _client-${VERSION} -py3-none-any.whl" >> " ../pulp_python/bindings_requirements.txt"
100+ done
118101popd
119102
120- # At this point, this is a safeguard only, so let's not make too much fuzz about the old status format.
121- echo " $REPORTED_STATUS " | jq -r ' .versions[]|select(.package)|(.package|sub("_"; "-")) + "-client==" + .version' > bindings_requirements.txt
103+ # Install test requirements
104+ # ##########################
105+
106+ # Add a safeguard to make sure the proper versions of the clients are installed.
107+ echo " $REPORTED_STATUS " | jq -r ' .versions[]|select(.package)|(.package|sub("_"; "-")) + "-client==" + .version' > bindings_constraints.txt
122108cmd_stdin_prefix bash -c " cat > /tmp/unittest_requirements.txt" < unittest_requirements.txt
123109cmd_stdin_prefix bash -c " cat > /tmp/functest_requirements.txt" < functest_requirements.txt
124110cmd_stdin_prefix bash -c " cat > /tmp/bindings_requirements.txt" < bindings_requirements.txt
125- cmd_prefix pip3 install -r /tmp/unittest_requirements.txt -r /tmp/functest_requirements.txt -r /tmp/bindings_requirements.txt
111+ cmd_stdin_prefix bash -c " cat > /tmp/bindings_constraints.txt" < bindings_constraints.txt
112+ cmd_prefix pip3 install -r /tmp/unittest_requirements.txt -r /tmp/functest_requirements.txt -r /tmp/bindings_requirements.txt -c /tmp/bindings_constraints.txt
126113
127114CERTIFI=$( cmd_prefix python3 -c ' import certifi; print(certifi.where())' )
128115cmd_prefix bash -c " cat /etc/pulp/certs/pulp_webserver.crt >> '$CERTIFI '"
0 commit comments