refactor: drop unmaintained ls subcommand
The correct way to handle getting the status should be ps:report. Also cleaned up an issue where ps:report failed to catch errors for non-running containers.
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
dokku_ls_cmd() {
|
||||
declare desc="lists installed apps with status"
|
||||
local cmd="ls"
|
||||
local installed_apps=$(dokku_apps)
|
||||
local dokku_app
|
||||
|
||||
dokku_col_log_info1_quiet "App Name" "Container Type" "Container Id" "Status"
|
||||
|
||||
for dokku_app in $installed_apps; do
|
||||
local APP=$(basename "$dokku_app")
|
||||
local DOKKU_APP_CIDS=$(get_app_container_ids "$APP")
|
||||
local DOCKER_RUNNING_CONTAINERS=$(docker ps -q --no-trunc)
|
||||
if [[ -n $DOKKU_APP_CIDS ]]; then
|
||||
local DOKKU_APP_CID
|
||||
for DOKKU_APP_CID in $DOKKU_APP_CIDS; do
|
||||
local DOKKU_APP_CONTAINER_STATUS="stopped"
|
||||
[[ $DOCKER_RUNNING_CONTAINERS =~ $DOKKU_APP_CID ]] && local DOKKU_APP_CONTAINER_STATUS="running"
|
||||
local DOKKU_APP_CONTAINER_TYPE=$(grep -l "$DOKKU_APP_CID" "$DOKKU_ROOT/$APP"/CONTAINER.* | awk -F '/' '{ print $5 }' | awk -F '.' '{ print $2 }')
|
||||
dokku_col_log_msg "$APP" "$DOKKU_APP_CONTAINER_TYPE" "${DOKKU_APP_CID:0:12}" "$DOKKU_APP_CONTAINER_STATUS"
|
||||
done
|
||||
else
|
||||
dokku_col_log_msg "$APP" "NOT_DEPLOYED" "NOT_DEPLOYED" "NOT_DEPLOYED"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
dokku_ls_cmd "$@"
|
||||
@@ -13,7 +13,7 @@ report_single_app() {
|
||||
local APP_CIDS=$(get_app_container_ids "$APP"); local PROCS=0; local RUNNING=""
|
||||
|
||||
for CID in $APP_CIDS; do
|
||||
local APP_CONTAINER_STATUS=$(docker inspect -f '{{.State.Running}}' "$CID" 2>/dev/null || true)
|
||||
local APP_CONTAINER_STATUS=$(docker inspect -f '{{.State.Running}}' "$CID" 2> /dev/null || true)
|
||||
if [[ "$APP_CONTAINER_STATUS" == "true" ]]; then RUNNING+="0"; else RUNNING+="1"; fi
|
||||
PROCS=$((PROCS + 1))
|
||||
done
|
||||
@@ -38,7 +38,7 @@ report_single_app() {
|
||||
for CONTAINER_FILE in $CONTAINER_FILES; do
|
||||
CID=$(< "$DOKKU_ROOT/$APP/$CONTAINER_FILE")
|
||||
APP_CONTAINER_STATUS=$(docker inspect -f '{{.State.Running}}' "$CID" 2> /dev/null)
|
||||
[[ -z "$APP_CONTAINER_STATUS" ]] && APP_CONTAINER_STATUS="dead"
|
||||
[[ -z "$APP_CONTAINER_STATUS" ]] && APP_CONTAINER_STATUS="missing"
|
||||
STATUSES+=("${CONTAINER_FILE#*.}:$APP_CONTAINER_STATUS#${CID:0:12}")
|
||||
done
|
||||
local flag_map=(
|
||||
|
||||
@@ -147,12 +147,7 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku ls"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku --quiet ls | grep $TEST_APP | grep -q stopped"
|
||||
run bash -c "dokku --quiet ps:report $TEST_APP | grep -q exited"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
Reference in New Issue
Block a user