From fa8ed5d2295d900b2a7c102d32164a399cfca88f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 22 Oct 2022 00:55:17 -0400 Subject: [PATCH 1/2] fix: respect PLUGIN_PATH when checking if a plugin trigger exists Without this, upgrades may fail if the user has enabled a plugin which implements a trigger that is checked for during an upgrade. --- plugins/common/subprocess.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/common/subprocess.go b/plugins/common/subprocess.go index d46b2b2d9..642b06c80 100644 --- a/plugins/common/subprocess.go +++ b/plugins/common/subprocess.go @@ -132,12 +132,13 @@ func PlugnTriggerSetup(triggerName string, args ...string) *sh.Session { // PlugnTriggerExists returns whether a plugin trigger exists (ignoring the existence of any within the 20_events plugin) func PlugnTriggerExists(triggerName string) bool { - pluginPath := MustGetEnv("PLUGIN_ENABLED_PATH") - glob := filepath.Join(pluginPath, "*", triggerName) + pluginPath := MustGetEnv("PLUGIN_PATH") + pluginPathPrefix := filepath.Join(pluginPath, "enabled") + glob := filepath.Join(pluginPathPrefix, "*", triggerName) exists := false files, _ := filepath.Glob(glob) for _, file := range files { - plugin := strings.Trim(strings.TrimPrefix(strings.TrimSuffix(file, "/"+triggerName), pluginPath), "/") + plugin := strings.Trim(strings.TrimPrefix(strings.TrimSuffix(file, "/"+triggerName), pluginPathPrefix), "/") if plugin != "20_events" { exists = true break From b94488f32f90083a038055e187d17debd85774f2 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 22 Oct 2022 15:56:23 -0400 Subject: [PATCH 2/2] fix: set PLUGIN_PATH for golang tests --- plugins/common/common_test.go | 4 ++++ plugins/config/config_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/plugins/common/common_test.go b/plugins/common/common_test.go index 6f30e385d..5502d5ad0 100644 --- a/plugins/common/common_test.go +++ b/plugins/common/common_test.go @@ -21,6 +21,10 @@ var ( ) func setupTests() (err error) { + if err := os.Setenv("PLUGIN_PATH", "/var/lib/dokku/plugins"); err != nil { + return err + } + return os.Setenv("PLUGIN_ENABLED_PATH", "/var/lib/dokku/plugins/enabled") } diff --git a/plugins/config/config_test.go b/plugins/config/config_test.go index 769132c80..797e4d2f3 100644 --- a/plugins/config/config_test.go +++ b/plugins/config/config_test.go @@ -19,6 +19,10 @@ var ( ) func setupTests() (err error) { + if err := os.Setenv("PLUGIN_PATH", "/var/lib/dokku/plugins"); err != nil { + return err + } + return os.Setenv("PLUGIN_ENABLED_PATH", "/var/lib/dokku/plugins/enabled") }