feat: add storage directory mode and removal flags
`storage:create` and `storage:set` accept a `--mode` flag that sets the octal permissions of a docker-local host directory, and `storage:destroy` accepts a `--destroy-host-dir` flag that removes the directory along with its contents. A docker-local entry also honors `--reclaim-policy Delete` at destroy time now, matching how that policy governs a k3s PersistentVolume. Both are limited to the default `/var/lib/dokku/data/storage/<name>` location, the same restriction `--chown` already carries. `storage:set` applies `--chown` and `--mode` to the directory rather than only recording them.
This commit is contained in:
@@ -21,7 +21,7 @@ Additional commands:`
|
||||
|
||||
helpContent = `
|
||||
storage:create <name> [<path>] [flags], Register a named storage entry
|
||||
storage:destroy <name> [--force], Remove a named storage entry (must be unmounted from every app first)
|
||||
storage:destroy <name> [--force] [--destroy-host-dir], Remove a named storage entry (must be unmounted from every app first)
|
||||
storage:ensure-directory [--chown option] <directory>, [DEPRECATED] use storage:create instead
|
||||
storage:exec <name> [-- <cmd>...], Run a command (or shell) in a temporary container that mounts the entry
|
||||
storage:info <name> [--format text|json], Show details for one storage entry
|
||||
@@ -62,19 +62,9 @@ func CommandEnsureDirectory(directory string, chownFlag string) error {
|
||||
if chownID != "false" {
|
||||
common.LogVerboseQuiet(fmt.Sprintf("Setting directory ownership to %s:%s", chownID, chownID))
|
||||
|
||||
pluginPath := common.MustGetEnv("PLUGIN_AVAILABLE_PATH")
|
||||
chownScript := filepath.Join(pluginPath, "storage", "bin", "chown-storage-dir")
|
||||
|
||||
result, err := common.CallExecCommand(common.ExecCommandInput{
|
||||
Command: "sudo",
|
||||
Args: []string{chownScript, directory, chownID},
|
||||
})
|
||||
if err != nil {
|
||||
if err := callStorageDirScript("chown-storage-dir", directory, chownID); err != nil {
|
||||
return fmt.Errorf("Unable to set directory ownership: %s", err.Error())
|
||||
}
|
||||
if result.ExitCode != 0 {
|
||||
return fmt.Errorf("Unable to set directory ownership: %s", result.StderrContents())
|
||||
}
|
||||
}
|
||||
|
||||
common.LogVerboseQuiet("Directory ready for mounting")
|
||||
|
||||
Reference in New Issue
Block a user