Files
dokku/plugins/storage/src/triggers/triggers.go
T
Jose Diaz-Gonzalez b612285392 fix: honor storage attachment process types at deploy time
An attachment's process type was recorded, reported and used to scope `storage:mount --replace` and `storage:unmount --all`, but nothing read it when the volume was actually mounted, so `storage:mount <app> <entry> --container-dir <path> --process-type web` bound the volume into every process rather than only `web`. Both schedulers now scope a mount to the process type it was declared for, and containers that belong to no process type - a `dokku run` one-off, an `app.json` deploy task, a k3s cron job - receive default-scoped mounts only. A container path can now be claimed by a single mount per process type, and `storage:migrate` drains process-scoped `-v` lines out of `docker-options` rather than only the default-scoped ones.
2026-09-21 18:08:42 -04:00

66 lines
1.9 KiB
Go

package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/dokku/dokku/plugins/common"
"github.com/dokku/dokku/plugins/storage"
)
func main() {
parts := strings.Split(os.Args[0], "/")
trigger := parts[len(parts)-1]
flag.Parse()
var err error
switch trigger {
case "install":
err = storage.TriggerInstall()
case "storage-list":
appName := flag.Arg(0)
phase := flag.Arg(1)
format := flag.Arg(2)
err = storage.TriggerStorageList(appName, phase, format)
case "storage-app-mounts":
appName := flag.Arg(0)
phase := flag.Arg(1)
err = storage.TriggerStorageAppMounts(appName, phase)
case "docker-args-process-deploy":
appName := flag.Arg(0)
processType := flag.Arg(3)
err = storage.TriggerDockerArgs(appName, storage.PhaseDeploy, processType)
case "docker-args-deploy":
// No longer registered in the plugin Makefile; storage emits its
// deploy-phase flags through docker-args-process-deploy, which every
// caller of this trigger also invokes. The case remains so a symlink
// left behind by an older build resolves to a no-op rather than
// falling through to the error below and failing the deploy.
err = nil
case "docker-args-run":
// A `dokku run` container belongs to no process type, so only
// default-scoped attachments apply.
appName := flag.Arg(0)
err = storage.TriggerDockerArgs(appName, storage.PhaseRun, storage.DefaultProcessType)
case "post-delete":
appName := flag.Arg(0)
err = storage.TriggerPostDelete(appName)
case "post-app-clone-setup":
oldName := flag.Arg(0)
newName := flag.Arg(1)
err = storage.TriggerPostAppCloneSetup(oldName, newName)
case "post-app-rename-setup":
oldName := flag.Arg(0)
newName := flag.Arg(1)
err = storage.TriggerPostAppRenameSetup(oldName, newName)
default:
err = fmt.Errorf("Invalid plugin trigger call: %s", trigger)
}
if err != nil {
common.LogFailWithError(err)
}
}