aboutsummaryrefslogtreecommitdiff
path: root/test/testvol/util.go
blob: 7a0aeba86c61221fd9965c24da777f6472969481 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)
}