mirror of
https://github.com/containers/podman.git
synced 2025-06-03 03:07:56 +08:00

Also, do a general cleanup of all the timeout code. Changes include: - Convert from int to *uint where possible. Timeouts cannot be negative, hence the uint change; and a timeout of 0 is valid, so we need a new way to detect that the user set a timeout (hence, pointer). - Change name in the database to avoid conflicts between new data type and old one. This will cause timeouts set with 4.2.0 to be lost, but considering nobody is using the feature at present (and the lack of validation means we could have invalid, negative timeouts in the DB) this feels safe. - Ensure volume plugin timeouts can only be used with volumes created using a plugin. Timeouts on the local driver are nonsensical. - Remove the existing test, as it did not use a volume plugin. Write a new test that does. The actual plumbing of the containers.conf timeout in is one line in volume_api.go; the remainder are the above-described cleanups. Signed-off-by: Matthew Heon <mheon@redhat.com>
30 lines
675 B
Go
30 lines
675 B
Go
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/containers/podman/v4/libpod/plugin"
|
|
)
|
|
|
|
const pluginSockDir = "/run/docker/plugins"
|
|
|
|
func getSocketPath(pathOrName string) string {
|
|
if filepath.IsAbs(pathOrName) {
|
|
return pathOrName
|
|
}
|
|
|
|
// only a name join it with the default path
|
|
return filepath.Join(pluginSockDir, pathOrName+".sock")
|
|
}
|
|
|
|
func getPluginName(pathOrName string) string {
|
|
return strings.TrimSuffix(filepath.Base(pathOrName), ".sock")
|
|
}
|
|
|
|
func getPlugin(sockNameOrPath string) (*plugin.VolumePlugin, error) {
|
|
path := getSocketPath(sockNameOrPath)
|
|
name := getPluginName(sockNameOrPath)
|
|
return plugin.GetVolumePlugin(name, path, nil, nil)
|
|
}
|