feat: implement nginx:show-config for k3s plugin

This allows users to see what nginx configs are in use for their applications.

Closes #7291
This commit is contained in:
Jose Diaz-Gonzalez
2024-10-21 22:08:53 -04:00
parent 778f563611
commit 90e8cac12f
7 changed files with 151 additions and 10 deletions

View File

@@ -158,8 +158,21 @@ cmd-nginx-show-config() {
declare cmd="nginx:show-config"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
local proxy_type
verify_app_name "$APP"
proxy_type="$(plugn trigger proxy-type "$APP")"
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
plugn trigger scheduler-proxy-config "$DOKKU_SCHEDULER" "$APP" "$proxy_type"
return $?
fi
if [[ "$proxy_type" != "nginx" ]]; then
dokku_log_fail "This command is only available for apps with the nginx proxy type"
fi
if [[ ! -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
dokku_log_fail "No nginx.conf exists for $APP"
fi

View File

@@ -66,6 +66,7 @@ restart_nginx() {
nginx_logs() {
declare desc="display app nginx logs"
declare NGINX_LOGS_TYPE="${1#nginx:}" APP="$2"
local proxy_type
local NGINX_LOGS_TYPE=${NGINX_LOGS_TYPE%-logs}
local NGINX_LOGS_PATH="$("fn-nginx-computed-${NGINX_LOGS_TYPE}-log-path" "$APP")"
@@ -74,6 +75,8 @@ nginx_logs() {
dokku_log_fail "$NGINX_LOGS_TYPE logs are disabled for this app"
fi
proxy_type="$(plugn trigger proxy-type "$APP")"
local tail=false
local num=0
if [[ $3 == "-t" ]]; then
@@ -84,7 +87,7 @@ nginx_logs() {
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
plugn trigger scheduler-proxy-logs "$DOKKU_SCHEDULER" "$APP" "nginx" "$NGINX_LOGS_TYPE" "$tail" "$num"
plugn trigger scheduler-proxy-logs "$DOKKU_SCHEDULER" "$APP" "$proxy_type" "$NGINX_LOGS_TYPE" "$tail" "$num"
return $?
fi