From 917342ff36bdaa37f4c9ea868fd7996adeda73f4 Mon Sep 17 00:00:00 2001 From: Jim Madge Date: Tue, 22 Oct 2024 15:06:48 +0100 Subject: [PATCH] Expand arguments --- .github/workflows/test.yaml | 2 +- entrypoint.sh | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bb38c83..e873f1a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,7 +21,7 @@ jobs: run: docker compose up -d - name: Wait for Nexus to start - run: sleep 180 + run: sleep 120 - name: Show nexus allowlist container logs run: docker compose logs allowlist diff --git a/entrypoint.sh b/entrypoint.sh index 0baa1fc..3cea716 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,11 +5,6 @@ export ALLOWLIST_DIR=/allowlists export PYPI_ALLOWLIST="$ALLOWLIST_DIR"/pypi.allowlist export CRAN_ALLOWLIST="$ALLOWLIST_DIR"/cran.allowlist -export CONNECT_ARGS="--admin-password $NEXUS_ADMIN_PASSWORD --nexus-host $NEXUS_HOST --nexus-port $NEXUS_PORT" -if [ -n "$NEXUS_PATH" ]; then - export CONNECT_ARGS="$CONNECT_ARGS --nexus-path $NEXUS_PATH" -fi - timestamp() { date -Is } @@ -41,14 +36,14 @@ nexus-allowlist --version # Initial configuration if [ -f "$NEXUS_DATA_DIR/admin.password" ]; then echo "$(timestamp) Initial password file present, running initial configuration" - nexus-allowlist "$CONNECT_ARGS" change-initial-password --path "$NEXUS_DATA_DIR" - nexus-allowlist "$CONNECT_ARGS" initial-configuration --packages "$NEXUS_PACKAGES" --pypi-package-file "$ALLOWLIST_DIR/pypi.allowlist" --cran-package-file "$ALLOWLIST_DIR/cran.allowlist" + nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" change-initial-password --path "$NEXUS_DATA_DIR" + nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" initial-configuration --packages "$NEXUS_PACKAGES" --pypi-package-file "$ALLOWLIST_DIR/pypi.allowlist" --cran-package-file "$ALLOWLIST_DIR/cran.allowlist" else echo "$(timestamp) No initial password file found, skipping initial configuration" fi # Test authentication -if ! nexus-allowlist "$CONNECT_ARGS" test-authentication; then +if ! nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" test-authentication; then echo "$(timestamp) API authentication test failed, exiting" exit 1 fi @@ -56,13 +51,13 @@ fi if [ -n "$ENTR_FALLBACK" ]; then echo "$(timestamp) Using fallback file monitoring" # Run allowlist configuration now - nexus-allowlist "$CONNECT_ARGS" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST" + nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST" # Periodically check for modification of allowlist files and run configuration again when they are hash=$(hashes) while true; do new_hash=$(hashes) if [ "$hash" != "$new_hash" ]; then - nexus-allowlist "$CONNECT_ARGS" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST" + nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST" hash=$new_hash fi sleep 5 @@ -70,5 +65,5 @@ if [ -n "$ENTR_FALLBACK" ]; then else echo "$(timestamp) Using entr for file monitoring" # Run allowlist configuration now, and again whenever allowlist files are modified - find "$ALLOWLIST_DIR"/*.allowlist | entr -n nexus-allowlist "$CONNECT_ARGS" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST" + find "$ALLOWLIST_DIR"/*.allowlist | entr -n nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST" fi