mirror of
https://github.com/dokku/dokku.git
synced 2026-05-18 05:05:46 +02:00
fix: move proxy-port properties to proxy plugin and fix CI failures
- Move proxy-port and proxy-ssl-port properties from ports plugin to proxy plugin where they conceptually belong - Generalize proxy:set to handle any property (matching ps:set pattern) instead of only handling the type property - Fix apps:set --global flag parsing (pflag treats --global as a flag, not an argument — must be defined explicitly like ps:set does) - Add missing property-functions source to scheduler-docker-local shell scripts (scheduler-enter, scheduler-run, scheduler-deploy, check-deploy, bin/scheduler-deploy-process-container) - Update nginx-vhosts property references from ports to proxy plugin - Update tests to use proxy:set for proxy-port properties
This commit is contained in:
@@ -122,8 +122,8 @@ The following environment variables have been migrated to plugin properties. Exi
|
||||
| `DOKKU_DISABLE_PROXY` | `dokku proxy:disable <app>` / `dokku proxy:enable <app>` |
|
||||
| `DOKKU_DOCKERFILE_START_CMD` | `dokku ps:set <app> dockerfile-start-cmd <value>` |
|
||||
| `DOKKU_PARALLEL_ARGUMENTS` | Removed. No longer supported. |
|
||||
| `DOKKU_PROXY_PORT` | `dokku ports:set <app> proxy-port <value>` |
|
||||
| `DOKKU_PROXY_SSL_PORT` | `dokku ports:set <app> proxy-ssl-port <value>` |
|
||||
| `DOKKU_PROXY_PORT` | `dokku proxy:set <app> proxy-port <value>` |
|
||||
| `DOKKU_PROXY_SSL_PORT` | `dokku proxy:set <app> proxy-ssl-port <value>` |
|
||||
| `DOKKU_SKIP_ALL_CHECKS` | `dokku checks:disable <app>` |
|
||||
| `DOKKU_SKIP_CLEANUP` | `dokku builder:set <app> skip-cleanup <true\|false>` |
|
||||
| `DOKKU_SKIP_DEFAULT_CHECKS` | `dokku checks:skip <app>` |
|
||||
|
||||
@@ -74,10 +74,16 @@ func main() {
|
||||
}
|
||||
case "set":
|
||||
args := flag.NewFlagSet("apps:set", flag.ExitOnError)
|
||||
global := args.Bool("global", false, "--global: set a global property")
|
||||
args.Parse(os.Args[2:])
|
||||
appName := args.Arg(0)
|
||||
property := args.Arg(1)
|
||||
value := args.Arg(2)
|
||||
if *global {
|
||||
appName = "--global"
|
||||
property = args.Arg(0)
|
||||
value = args.Arg(1)
|
||||
}
|
||||
err = apps.CommandSet(appName, property, value)
|
||||
case "unlock":
|
||||
args := flag.NewFlagSet("apps:unlock", flag.ExitOnError)
|
||||
|
||||
@@ -7,8 +7,8 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
||||
|
||||
fn-nginx-vhosts-migrate-env-vars() {
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property ports proxy-port DOKKU_NGINX_PORT
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property ports proxy-ssl-port DOKKU_NGINX_SSL_PORT
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property proxy proxy-port DOKKU_NGINX_PORT
|
||||
"$PLUGIN_CORE_AVAILABLE_PATH/common/prop" migrate-config-to-property proxy proxy-ssl-port DOKKU_NGINX_SSL_PORT
|
||||
}
|
||||
|
||||
fn-nginx-vhosts-migrate-nginx-conf-sigil() {
|
||||
|
||||
@@ -18,10 +18,10 @@ trigger-nginx-vhosts-pre-disable-vhost() {
|
||||
local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port")
|
||||
|
||||
if [[ "$PROXY_PORT" == "80" ]]; then
|
||||
fn-plugin-property-delete "ports" "$APP" "proxy-port"
|
||||
fn-plugin-property-delete "proxy" "$APP" "proxy-port"
|
||||
fi
|
||||
if [[ "$PROXY_SSL_PORT" == "443" ]]; then
|
||||
fn-plugin-property-delete "ports" "$APP" "proxy-ssl-port"
|
||||
fn-plugin-property-delete "proxy" "$APP" "proxy-ssl-port"
|
||||
fi
|
||||
|
||||
# clear ports if there is a mapping starting with http:80 or https:443
|
||||
|
||||
@@ -18,10 +18,10 @@ trigger-nginx-vhosts-pre-enable-vhost() {
|
||||
local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port")
|
||||
|
||||
if [[ "$PROXY_PORT" == "80" ]]; then
|
||||
fn-plugin-property-delete "ports" "$APP" "proxy-port"
|
||||
fn-plugin-property-delete "proxy" "$APP" "proxy-port"
|
||||
fi
|
||||
if [[ "$PROXY_SSL_PORT" == "443" ]]; then
|
||||
fn-plugin-property-delete "ports" "$APP" "proxy-ssl-port"
|
||||
fn-plugin-property-delete "proxy" "$APP" "proxy-ssl-port"
|
||||
fi
|
||||
|
||||
# clear ports if there is a mapping starting with http:80 or https:443
|
||||
|
||||
@@ -161,7 +161,7 @@ func getDetectedPortMaps(appName string) []PortMap {
|
||||
// getGlobalProxyPort gets the global proxy port
|
||||
func getGlobalProxyPort() int {
|
||||
port := 0
|
||||
value := common.PropertyGet("ports", "--global", "proxy-port")
|
||||
value := common.PropertyGet("proxy", "--global", "proxy-port")
|
||||
if intVar, err := strconv.Atoi(value); err == nil {
|
||||
port = intVar
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func getGlobalProxyPort() int {
|
||||
// getGlobalProxySSLPort gets the global proxy ssl port
|
||||
func getGlobalProxySSLPort() int {
|
||||
port := 0
|
||||
value := common.PropertyGet("ports", "--global", "proxy-ssl-port")
|
||||
value := common.PropertyGet("proxy", "--global", "proxy-ssl-port")
|
||||
if intVar, err := strconv.Atoi(value); err == nil {
|
||||
port = intVar
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func getPortMaps(appName string) []PortMap {
|
||||
// getProxyPort gets the proxy port for an app
|
||||
func getProxyPort(appName string) int {
|
||||
port := 0
|
||||
value := common.PropertyGet("ports", appName, "proxy-port")
|
||||
value := common.PropertyGet("proxy", appName, "proxy-port")
|
||||
if intVar, err := strconv.Atoi(value); err == nil {
|
||||
port = intVar
|
||||
}
|
||||
@@ -205,7 +205,7 @@ func getProxyPort(appName string) int {
|
||||
// getProxySSLPort gets the proxy ssl port for an app
|
||||
func getProxySSLPort(appName string) int {
|
||||
port := 0
|
||||
value := common.PropertyGet("ports", appName, "proxy-ssl-port")
|
||||
value := common.PropertyGet("proxy", appName, "proxy-ssl-port")
|
||||
if intVar, err := strconv.Atoi(value); err == nil {
|
||||
port = intVar
|
||||
}
|
||||
@@ -432,12 +432,12 @@ func setPortMaps(appName string, portMaps []PortMap) error {
|
||||
|
||||
// setProxyPort sets the proxy port for an app
|
||||
func setProxyPort(appName string, port int) error {
|
||||
return common.PropertyWrite("ports", appName, "proxy-port", fmt.Sprint(port))
|
||||
return common.PropertyWrite("proxy", appName, "proxy-port", fmt.Sprint(port))
|
||||
}
|
||||
|
||||
// setProxySSLPort sets the proxy ssl port for an app
|
||||
func setProxySSLPort(appName string, port int) error {
|
||||
return common.PropertyWrite("ports", appName, "proxy-ssl-port", fmt.Sprint(port))
|
||||
return common.PropertyWrite("proxy", appName, "proxy-ssl-port", fmt.Sprint(port))
|
||||
}
|
||||
|
||||
// transformPortMap normalizes a port map string for migration to list properties
|
||||
|
||||
@@ -4,19 +4,6 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
// DefaultProperties is a map of all valid ports properties with corresponding default property values
|
||||
DefaultProperties = map[string]string{
|
||||
"proxy-port": "",
|
||||
"proxy-ssl-port": "",
|
||||
}
|
||||
|
||||
// GlobalProperties is a map of all valid global ports properties
|
||||
GlobalProperties = map[string]bool{
|
||||
"proxy-port": true,
|
||||
"proxy-ssl-port": true,
|
||||
}
|
||||
)
|
||||
|
||||
// PortMap is a struct that contains a scheme:host-port:container-port mapping
|
||||
type PortMap struct {
|
||||
|
||||
@@ -21,16 +21,6 @@ func TriggerInstall() error {
|
||||
ListProperty: true,
|
||||
Transform: transformPortMap,
|
||||
},
|
||||
{
|
||||
ConfigVar: "DOKKU_PROXY_PORT",
|
||||
GlobalConfigVar: "DOKKU_PROXY_PORT",
|
||||
Property: "proxy-port",
|
||||
},
|
||||
{
|
||||
ConfigVar: "DOKKU_PROXY_SSL_PORT",
|
||||
GlobalConfigVar: "DOKKU_PROXY_SSL_PORT",
|
||||
Property: "proxy-ssl-port",
|
||||
},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -166,7 +156,7 @@ func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
|
||||
|
||||
// TriggerPostCertsRemove unsets port properties after SSL cert is removed
|
||||
func TriggerPostCertsRemove(appName string) error {
|
||||
if err := common.PropertyDelete("ports", appName, "proxy-ssl-port"); err != nil {
|
||||
if err := common.PropertyDelete("proxy", appName, "proxy-ssl-port"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -175,15 +165,15 @@ func TriggerPostCertsRemove(appName string) error {
|
||||
|
||||
// TriggerPostCertsUpdate sets port properties after SSL cert is added
|
||||
func TriggerPostCertsUpdate(appName string) error {
|
||||
port := common.PropertyGet("ports", appName, "proxy-port")
|
||||
sslPort := common.PropertyGet("ports", appName, "proxy-ssl-port")
|
||||
port := common.PropertyGet("proxy", appName, "proxy-port")
|
||||
sslPort := common.PropertyGet("proxy", appName, "proxy-ssl-port")
|
||||
portMaps := getPortMaps(appName)
|
||||
|
||||
if port == "80" {
|
||||
common.PropertyDelete("ports", appName, "proxy-port")
|
||||
common.PropertyDelete("proxy", appName, "proxy-port")
|
||||
}
|
||||
if sslPort == "443" {
|
||||
common.PropertyDelete("ports", appName, "proxy-ssl-port")
|
||||
common.PropertyDelete("proxy", appName, "proxy-ssl-port")
|
||||
}
|
||||
|
||||
var http80Ports []PortMap
|
||||
|
||||
@@ -11,13 +11,17 @@ const RunInSerial = 0
|
||||
var (
|
||||
// DefaultProperties is a map of all valid proxy properties with corresponding default property values
|
||||
DefaultProperties = map[string]string{
|
||||
"disabled": "false",
|
||||
"type": "",
|
||||
"disabled": "false",
|
||||
"proxy-port": "",
|
||||
"proxy-ssl-port": "",
|
||||
"type": "",
|
||||
}
|
||||
|
||||
// GlobalProperties is a map of all valid global proxy properties
|
||||
GlobalProperties = map[string]bool{
|
||||
"type": true,
|
||||
"proxy-port": true,
|
||||
"proxy-ssl-port": true,
|
||||
"type": true,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -59,12 +59,14 @@ func main() {
|
||||
global := args.Bool("global", false, "--global: set a global property")
|
||||
args.Parse(os.Args[2:])
|
||||
appName := args.Arg(0)
|
||||
proxyType := args.Arg(1)
|
||||
property := args.Arg(1)
|
||||
value := args.Arg(2)
|
||||
if *global {
|
||||
appName = "--global"
|
||||
proxyType = args.Arg(0)
|
||||
property = args.Arg(0)
|
||||
value = args.Arg(1)
|
||||
}
|
||||
err = proxy.CommandSet(appName, proxyType)
|
||||
err = proxy.CommandSet(appName, property, value)
|
||||
default:
|
||||
err = fmt.Errorf("Invalid plugin subcommand call: %s", subcommand)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package proxy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
@@ -82,22 +81,7 @@ func CommandReport(appName string, format string, infoFlag string) error {
|
||||
}
|
||||
|
||||
// CommandSet sets a proxy for an app
|
||||
func CommandSet(appName string, proxyType string) error {
|
||||
if appName != "--global" {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(proxyType) < 2 {
|
||||
return errors.New("Please specify a proxy type")
|
||||
}
|
||||
|
||||
if strings.Contains(proxyType, ":") {
|
||||
common.LogWarn("Detected potential port mapping instead of proxy type")
|
||||
return errors.New("Consider using ports:set command or specifying a valid proxy")
|
||||
}
|
||||
|
||||
common.CommandPropertySet("proxy", appName, "type", proxyType, DefaultProperties, GlobalProperties)
|
||||
func CommandSet(appName string, property string, value string) error {
|
||||
common.CommandPropertySet("proxy", appName, property, value, DefaultProperties, GlobalProperties)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -28,6 +28,16 @@ func TriggerInstall() error {
|
||||
return value
|
||||
},
|
||||
},
|
||||
{
|
||||
ConfigVar: "DOKKU_PROXY_PORT",
|
||||
GlobalConfigVar: "DOKKU_PROXY_PORT",
|
||||
Property: "proxy-port",
|
||||
},
|
||||
{
|
||||
ConfigVar: "DOKKU_PROXY_SSL_PORT",
|
||||
GlobalConfigVar: "DOKKU_PROXY_SSL_PORT",
|
||||
Property: "proxy-ssl-port",
|
||||
},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions"
|
||||
|
||||
main() {
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/internal-functions"
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ teardown() {
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
run /bin/bash -c "$PLUGIN_CORE_AVAILABLE_PATH/common/prop set ports $TEST_APP proxy-ssl-port 443"
|
||||
run /bin/bash -c "dokku proxy:set $TEST_APP proxy-ssl-port 443"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
@@ -62,7 +62,7 @@ teardown() {
|
||||
|
||||
@test "(nginx-vhosts) proxy:build-config (global proxy-port)" {
|
||||
local GLOBAL_PORT=30999
|
||||
run /bin/bash -c "$PLUGIN_CORE_AVAILABLE_PATH/common/prop set ports --global proxy-port ${GLOBAL_PORT}"
|
||||
run /bin/bash -c "dokku proxy:set --global proxy-port ${GLOBAL_PORT}"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
@@ -74,7 +74,7 @@ teardown() {
|
||||
check_urls "http://${TEST_APP}.${DOKKU_DOMAIN}:${GLOBAL_PORT}"
|
||||
assert_http_success "http://${TEST_APP}.${DOKKU_DOMAIN}:${GLOBAL_PORT}"
|
||||
|
||||
run /bin/bash -c "$PLUGIN_CORE_AVAILABLE_PATH/common/prop del ports --global proxy-port"
|
||||
run /bin/bash -c "dokku proxy:set --global proxy-port"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
Reference in New Issue
Block a user