fix: storage:list reads from attachments, deprecate storage-list trigger
storage:list was calling the storage-list plugn trigger which read -v lines from docker-options. After the install-time migration drains those lines into the attachment store, that source is empty for every migrated app and for any app that only ever used storage:create + storage:mount. The fix moves CommandList to call a new in-process ListAppMountEntries helper that reads attachments directly, surfaces the entry name in JSON output via a new entry_name field, and falls back to the entry name as the host token for k3s entries with no host path so the colon form remains well-formed. The storage-list plugn trigger is kept for back-compat with external callers but emits a deprecation warning and now reads from the same attachment-driven source.
This commit is contained in:
@@ -125,30 +125,31 @@ func detectDistro() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// TriggerStorageList outputs storage mounts for an app
|
||||
// TriggerStorageList outputs storage mounts for an app.
|
||||
//
|
||||
// Deprecated: the storage-list plugn trigger is retained for back-compat
|
||||
// with external plugins that may still call it, but in-process callers
|
||||
// should use storage.ListAppMountEntries directly. A deprecation warning
|
||||
// is emitted on every invocation.
|
||||
func TriggerStorageList(appName string, phase string, format string) error {
|
||||
mounts, err := GetBindMounts(appName, phase)
|
||||
common.LogWarn("the storage-list plugn trigger is deprecated; use the storage-app-mounts trigger or the storage Go package directly")
|
||||
|
||||
rows, err := ListAppMountEntries(appName, phase)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if format == "json" {
|
||||
entries := []StorageListEntry{}
|
||||
for _, mount := range mounts {
|
||||
entries = append(entries, ParseMountPath(mount))
|
||||
}
|
||||
|
||||
output, err := json.Marshal(entries)
|
||||
output, err := json.Marshal(rows)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(output))
|
||||
} else {
|
||||
for _, mount := range mounts {
|
||||
fmt.Println(mount)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
for _, row := range rows {
|
||||
fmt.Println(formatStorageListEntry(row))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user