Skip to content

Commit

Permalink
refactor: launch ddev adminer by port, remove ddev launcha, move …
Browse files Browse the repository at this point in the history
…`ddev adminer` to project level (#24)
  • Loading branch information
stasadev authored Jul 6, 2024
1 parent d3b0721 commit 22460ca
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 70 deletions.
55 changes: 3 additions & 52 deletions commands/host/adminer
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,11 @@
## Usage: adminer
## Example: "ddev adminer"

if [ "${DDEV_PROJECT_STATUS-running}" != "running" ] && [ -z "$no_recursion" ]; then
echo "Project ${DDEV_PROJECT} is not running, starting it"
ddev start
start_exit_code=$?
if [ $start_exit_code -ne 0 ]; then
exit $start_exit_code
fi
# run this script again, as the environment is updated after "ddev start"
no_recursion=true ddev "$(basename "$0")" "$@"
exit $?
fi

DDEV_ADMINER_PORT=9100
DDEV_ADMINER_HTTPS_PORT=9101

FULLURL=${DDEV_PRIMARY_URL}
HTTPS=""
if [ ${DDEV_PRIMARY_URL%://*} = "https" ]; then HTTPS=true; fi

if [[ ! -z "${GITPOD_INSTANCE_ID}" ]] || [[ "${CODESPACES}" == "true" ]]; then
FULLURL="${FULLURL/-${DDEV_HOST_WEBSERVER_PORT}/-${DDEV_ADMINER_PORT}}"
if [ ${DDEV_PRIMARY_URL%://*} = "https" ]; then
ddev launch $DDEV_PRIMARY_URL:$DDEV_ADMINER_HTTPS_PORT
else
if [ "${HTTPS}" = "" ]; then
FULLURL="${FULLURL%:[0-9]*}:${DDEV_ADMINER_PORT}"
else
FULLURL="${FULLURL%:[0-9]*}:${DDEV_ADMINER_HTTPS_PORT}"
fi
fi

if [ -n "${1:-}" ] ; then
if [[ ${1::1} != "/" ]] ; then
FULLURL="${FULLURL}/";
fi

FULLURL="${FULLURL}${1}";
fi

if [ "${DDEV_DEBUG:-}" = "true" ]; then
printf "FULLURL $FULLURL\n" && exit 0
ddev launch $DDEV_PRIMARY_URL:$DDEV_ADMINER_PORT
fi

case $OSTYPE in
linux-gnu)
if [[ ! -z "${GITPOD_INSTANCE_ID}" ]]; then
gp preview ${FULLURL}
else
xdg-open ${FULLURL}
fi
;;
"darwin"*)
open ${FULLURL}
;;
"win*"* | "msys"*)
start ${FULLURL}
;;
esac

6 changes: 0 additions & 6 deletions commands/host/launcha

This file was deleted.

3 changes: 3 additions & 0 deletions docker-compose.adminer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ services:
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
volumes:
- ".:/mnt/ddev_config"
- "ddev-global-cache:/mnt/ddev-global-cache"
depends_on:
- db

Expand Down
10 changes: 7 additions & 3 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ name: adminer
project_files:
- docker-compose.adminer.yaml
- adminer

global_files:
- commands/host/adminer
- commands/host/launcha

pre_install_actions:
# Ensure we're on DDEV 1.23+. It's required for the `adminer` command (launch by port).
- |
#ddev-nodisplay
#ddev-description:Checking DDEV version
(ddev debug capabilities | grep corepack >/dev/null) || (echo "Please upgrade DDEV to v1.23+ to use this add-on." && false)
9 changes: 0 additions & 9 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ teardown() {
(ddev restart >/dev/null || (echo "# ddev restart returned exit code=%?" >&3 && false))
ddev help adminer | grep adminer >/dev/null

# ddev launcha must return an error
(exit_status=0; (ddev launcha > /dev/null 2>&1) || exit_status=$?; echo $exit_status) | {
read exit_status
if [ $exit_status -eq 0 ]; then
echo "Test failed: ddev launcha exited with no error"
exit 2
fi
}

# echo "# Trying curl -s -L -k https://${PROJNAME}.ddev.site:9101/" >&3
curl --fail -s -L -k https://${PROJNAME}.ddev.site:9101/ | grep 'document.querySelector.*auth.*db' >/dev/null
}

0 comments on commit 22460ca

Please sign in to comment.