diff --git a/templates/docs/docs/Makefile.j2 b/templates/docs/docs/Makefile.j2 index 444cc125..2bba6ef3 100644 --- a/templates/docs/docs/Makefile.j2 +++ b/templates/docs/docs/Makefile.j2 @@ -12,7 +12,6 @@ DIAGRAM_BUILD_DIR = _diagrams PULP_URL ?= http://localhost:24817 PULP_API_ROOT ?= /pulp/ - # Internal variables. PULP_V3_API_JSON_URL := ${PULP_URL}${PULP_API_ROOT}api/v3/docs/api.json PAPEROPT_a4 = -D latex_paper_size=a4 @@ -69,7 +68,12 @@ endif $(BUILDDIR)/html/api.json: mkdir -p $(BUILDDIR)/html - curl --fail -o $(BUILDDIR)/html/api.json "$(PULP_V3_API_JSON_URL)?plugin={{ plugin_name | snake }}&include_html=1" + if pulp debug has-plugin --name core --specifier ">=3.44.0.dev"; \ + then \ + curl --fail -o $(BUILDDIR)/html/api.json "$(PULP_V3_API_JSON_URL)?component={{ plugins | map(attribute="app_label") | join(",") }}&include_html=1"; \ + else \ + curl --fail -o $(BUILDDIR)/html/api.json "$(PULP_V3_API_JSON_URL)?plugin={{ plugin_name | snake }}&include_html=1"; \ + fi html: $(BUILDDIR)/html/api.json $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html diff --git a/templates/github/.github/workflows/scripts/install_python_client.sh.j2 b/templates/github/.github/workflows/scripts/install_python_client.sh.j2 index c34ed014..f552d44f 100755 --- a/templates/github/.github/workflows/scripts/install_python_client.sh.j2 +++ b/templates/github/.github/workflows/scripts/install_python_client.sh.j2 @@ -9,7 +9,10 @@ cd "$(dirname "$(realpath -e "$0")")"/../../.. source .github/workflows/scripts/utils.sh -export PULP_URL="${PULP_URL:-{{ pulp_scheme }}://pulp}" +PULP_URL="${PULP_URL:-{{ pulp_scheme }}://pulp}" +export PULP_URL +PULP_API_ROOT="${PULP_API_ROOT:-/pulp/}" +export PULP_API_ROOT REPORTED_STATUS="$(pulp status)" REPORTED_VERSION="$(echo "$REPORTED_STATUS" | jq --arg plugin "{{ plugin_app_label }}" -r '.versions[] | select(.component == $plugin) | .version')" @@ -18,7 +21,15 @@ VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import V pushd ../pulp-openapi-generator {%- for plugin in plugins %} rm -rf {{ plugin.name | snake }}-client -./generate.sh {{ plugin.name | snake }} python "$VERSION" + +if pulp debug has-plugin --name "core" --specifier ">=3.44.0.dev" +then + curl --fail-with-body -k -o api.json "${PULP_URL}${PULP_API_ROOT}api/v3/docs/api.json?bindings&component={{ plugin.app_label }}" + USE_LOCAL_API_JSON=1 ./generate.sh {{ plugin.name | snake }} python "$VERSION" +else + ./generate.sh {{ plugin.name | snake }} python "$VERSION" +fi + pushd {{ plugin.name | snake }}-client python setup.py sdist bdist_wheel --python-tag py3 diff --git a/templates/github/.github/workflows/scripts/install_ruby_client.sh.j2 b/templates/github/.github/workflows/scripts/install_ruby_client.sh.j2 index 5f994ab2..ca7291b4 100755 --- a/templates/github/.github/workflows/scripts/install_ruby_client.sh.j2 +++ b/templates/github/.github/workflows/scripts/install_ruby_client.sh.j2 @@ -9,8 +9,10 @@ cd "$(dirname "$(realpath -e "$0")")"/../../.. source .github/workflows/scripts/utils.sh -export PULP_URL="${PULP_URL:-{{ pulp_scheme }}://pulp}" - +PULP_URL="${PULP_URL:-{{ pulp_scheme }}://pulp}" +export PULP_URL +PULP_API_ROOT="${PULP_API_ROOT:-/pulp/}" +export PULP_API_ROOT REPORTED_STATUS="$(pulp status)" REPORTED_VERSION="$(echo "$REPORTED_STATUS" | jq --arg plugin "{{ plugin_app_label }}" -r '.versions[] | select(.component == $plugin) | .version')" @@ -19,7 +21,15 @@ VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import V pushd ../pulp-openapi-generator {%- for plugin in plugins %} rm -rf {{ plugin.name | snake }}-client -./generate.sh {{ plugin.name | snake }} ruby "$VERSION" + +if pulp debug has-plugin --name "core" --specifier ">=3.44.0.dev" +then + curl --fail-with-body -k -o api.json "${PULP_URL}${PULP_API_ROOT}api/v3/docs/api.json?bindings&component={{ plugin.app_label }}" + USE_LOCAL_API_JSON=1 ./generate.sh {{ plugin.name | snake }} ruby "$VERSION" +else + ./generate.sh {{ plugin.name | snake }} ruby "$VERSION" +fi + pushd {{ plugin.name | snake }}-client gem build {{ plugin.name | snake }}_client gem install --both "./{{ plugin.name | snake }}_client-$VERSION.gem" diff --git a/templates/github/.github/workflows/scripts/script.sh.j2 b/templates/github/.github/workflows/scripts/script.sh.j2 index e454d509..67819bdf 100755 --- a/templates/github/.github/workflows/scripts/script.sh.j2 +++ b/templates/github/.github/workflows/scripts/script.sh.j2 @@ -46,36 +46,76 @@ password password # Some commands like ansible-galaxy specifically require 600 cmd_prefix bash -c "chmod 600 ~pulp/.netrc" -# 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" ] +# Generate and install binding +pushd ../pulp-openapi-generator +if pulp debug has-plugin --name "core" --specifier ">=3.44.0.dev" 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 // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")') - do - ./generate.sh "${item}" python - cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" - sudo rm -rf "./${item}-client" - done - popd + # Use app_label to generate api.json and package to produce the proper package name. + + if [ "$(jq -r '.domain_enabled' <<<"$REPORTED_STATUS")" = "true" ] + then + # Workaround: Domains are not supported by the published bindings. + # Generate new bindings for all packages. + for item in $(jq -r '.versions[] | tojson' <<<"$REPORTED_STATUS") + do + echo $item + COMPONENT="$(jq -r '.component' <<<"$item")" + VERSION="$(jq -r '.version' <<<"$item")" + MODULE="$(jq -r '.module' <<<"$item")" + PACKAGE="${MODULE%%.*}" + curl --fail-with-body -k -o api.json "${PULP_URL}${PULP_API_ROOT}api/v3/docs/api.json?bindings&component=$COMPONENT" + USE_LOCAL_API_JSON=1 ./generate.sh "${PACKAGE}" python "${VERSION}" + cmd_prefix pip3 install "/root/pulp-openapi-generator/${PACKAGE}-client" + sudo rm -rf "./${PACKAGE}-client" + done + else + # Sadly: Different pulpcore-versions aren't either... + for item in $(jq -r '.versions[] + {%- for plugin in plugins -%} + | select(.component!="{{ plugin.app_label }}") + {%- endfor -%} + | tojson' <<<"$REPORTED_STATUS") + do + echo $item + COMPONENT="$(jq -r '.component' <<<"$item")" + VERSION="$(jq -r '.version' <<<"$item")" + MODULE="$(jq -r '.module' <<<"$item")" + PACKAGE="${MODULE%%.*}" + curl --fail-with-body -k -o api.json "${PULP_URL}${PULP_API_ROOT}api/v3/docs/api.json?bindings&component=$COMPONENT" + USE_LOCAL_API_JSON=1 ./generate.sh "${PACKAGE}" python "${VERSION}" + cmd_prefix pip3 install "/root/pulp-openapi-generator/${PACKAGE}-client" + sudo rm -rf "./${PACKAGE}-client" + done + fi else - # Sadly: Different pulpcore-versions aren't either... - pushd ../pulp-openapi-generator - for item in $(echo "$REPORTED_STATUS" | jq -r '.versions[] - {%- for plugin in plugins -%} - |select(.component!="{{ plugin.app_label }}") - {%- endfor -%} - |(.package // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")') - do - ./generate.sh "${item}" python - cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" - sudo rm -rf "./${item}-client" - done - popd + # 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. + 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" + sudo rm -rf "./${item}-client" + done + else + # Sadly: Different pulpcore-versions aren't either... + for item in $(echo "$REPORTED_STATUS" | jq -r '.versions[] + {%- for plugin in plugins -%} + |select(.component!="{{ plugin.app_label }}") + {%- endfor -%} + |(.package // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")') + do + ./generate.sh "${item}" python + cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" + sudo rm -rf "./${item}-client" + done + fi fi +popd # 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