moby/pkg/plugins/discovery_unix.go
Sebastiaan van Stijn a44c25c2f1
pkg/plugins: split exported from implementation
Split the exported SpecsPaths from the platform-specific implementations,
so that documentation can be maintained in a single location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:38:11 +02:00

31 lines
852 B
Go

//go:build !windows
package plugins // import "github.com/docker/docker/pkg/plugins"
import (
"path/filepath"
"github.com/docker/docker/pkg/homedir"
"github.com/docker/docker/pkg/rootless"
)
func rootlessConfigPluginsPath() string {
if configHome, err := homedir.GetConfigHome(); err != nil {
return filepath.Join(configHome, "docker/plugins")
}
return "/etc/docker/plugins"
}
func rootlessLibPluginsPath() string {
if libHome, err := homedir.GetLibHome(); err == nil {
return filepath.Join(libHome, "docker/plugins")
}
return "/usr/lib/docker/plugins"
}
// specsPaths is the non-Windows implementation of [SpecsPaths].
func specsPaths() []string {
if rootless.RunningWithRootlessKit() {
return []string{rootlessConfigPluginsPath(), rootlessLibPluginsPath()}
}
return []string{"/etc/docker/plugins", "/usr/lib/docker/plugins"}
}