File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -208,6 +208,22 @@ if [ -f "${CURRENT_DIR}/poetry.lock" ]; then
208208 fi
209209 pip install poetry${POETRY_VERSION_SPEC}
210210 poetry config virtualenvs.create false
211+
212+ # Configure custom Poetry repositories from environment variables
213+ # Format: POETRY_REPOSITORIES_<NAME>_URL=<URL>
214+ # Example: POETRY_REPOSITORIES_ARTIFACTORY_URL=https://artifactory.example.com/pypi/simple
215+ for var in $( env | grep ' ^POETRY_REPOSITORIES_.*_URL=' | cut -d= -f1) ; do
216+ # Extract repository name from variable name
217+ # POETRY_REPOSITORIES_ARTIFACTORY_URL -> ARTIFACTORY
218+ repo_name=$( echo " $var " | sed ' s/^POETRY_REPOSITORIES_//' | sed ' s/_URL$//' | tr ' [:upper:]' ' [:lower:]' )
219+ repo_url=" ${! var} "
220+
221+ if [ -n " $repo_url " ]; then
222+ echo " Configuring Poetry repository: $repo_name -> $repo_url "
223+ poetry source add --priority=primary " $repo_name " " $repo_url "
224+ fi
225+ done
226+
211227 # Check if lock file needs updating and regenerate if needed
212228 if ! poetry check --lock 2> /dev/null; then
213229 echo " Lock file out of sync, regenerating..."
Original file line number Diff line number Diff line change 468468
469469 rm ${CURRENT_DIR} /pyproject.toml ${CURRENT_DIR} /poetry.lock
470470 unset PYTHON_VERSION
471+ }
472+
473+ @test " install from poetry.lock with custom repository" {
474+ unset PYTHON_VERSION
475+ export POETRY_REPOSITORIES_ARTIFACTORY_URL=https://pypi.org/simple
476+ cp pyproject.toml poetry.lock ${CURRENT_DIR} /
477+
478+ run /var/lib/tsuru/deploy
479+ assert_success
480+
481+ [[ " $output " == * " poetry.lock detected" * ]]
482+ [[ " $output " == * " Configuring Poetry repository: artifactory -> https://pypi.org/simple" * ]]
483+
484+ pushd ${CURRENT_DIR}
485+ run pip freeze
486+ popd
487+
488+ assert_success
489+ [[ " $output " == * " msgpack" * ]]
490+
491+ rm ${CURRENT_DIR} /pyproject.toml ${CURRENT_DIR} /poetry.lock
492+ unset POETRY_REPOSITORIES_ARTIFACTORY_URL
471493}
You can’t perform that action at this time.
0 commit comments