pkg/config: fix lint reports
It reported unused functions and I do not know how those happened. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
parent
4b6cdef35b
commit
a6566a1d6c
|
|
@ -1168,27 +1168,6 @@ func IsValidDeviceMode(mode string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolveHomeDir converts a path referencing the home directory via "~"
|
|
||||||
// to an absolute path
|
|
||||||
func resolveHomeDir(path string) (string, error) {
|
|
||||||
// check if the path references the home dir to avoid work
|
|
||||||
// don't use strings.HasPrefix(path, "~") as this doesn't match "~" alone
|
|
||||||
// use strings.HasPrefix(...) to not match "something/~/something"
|
|
||||||
if !(path == "~" || strings.HasPrefix(path, "~/")) {
|
|
||||||
// path does not reference home dir -> Nothing to do
|
|
||||||
return path, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// only get HomeDir when necessary
|
|
||||||
home, err := unshare.HomeDir()
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
// replace the first "~" (start of path) with the HomeDir to resolve "~"
|
|
||||||
return strings.Replace(path, "~", home, 1), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func rootlessConfigPath() (string, error) {
|
func rootlessConfigPath() (string, error) {
|
||||||
if configHome := os.Getenv("XDG_CONFIG_HOME"); configHome != "" {
|
if configHome := os.Getenv("XDG_CONFIG_HOME"); configHome != "" {
|
||||||
return filepath.Join(configHome, _configPath), nil
|
return filepath.Join(configHome, _configPath), nil
|
||||||
|
|
@ -1201,20 +1180,6 @@ func rootlessConfigPath() (string, error) {
|
||||||
return filepath.Join(home, UserOverrideContainersConfig), nil
|
return filepath.Join(home, UserOverrideContainersConfig), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringsEq(a, b []string) bool {
|
|
||||||
if len(a) != len(b) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range a {
|
|
||||||
if a[i] != b[i] {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
configErr error
|
configErr error
|
||||||
configMutex sync.Mutex
|
configMutex sync.Mutex
|
||||||
|
|
|
||||||
|
|
@ -9,37 +9,11 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/parser"
|
"github.com/container-orchestrated-devices/container-device-interface/pkg/parser"
|
||||||
units "github.com/docker/go-units"
|
units "github.com/docker/go-units"
|
||||||
)
|
)
|
||||||
|
|
||||||
// isDirectory tests whether the given path exists and is a directory. It
|
|
||||||
// follows symlinks.
|
|
||||||
func isDirectory(path string) error {
|
|
||||||
path, err := resolveHomeDir(path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
info, err := os.Stat(path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !info.Mode().IsDir() {
|
|
||||||
// Return a PathError to be consistent with os.Stat().
|
|
||||||
return &os.PathError{
|
|
||||||
Op: "stat",
|
|
||||||
Path: path,
|
|
||||||
Err: syscall.ENOTDIR,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *EngineConfig) validatePaths() error {
|
func (c *EngineConfig) validatePaths() error {
|
||||||
// Relative paths can cause nasty bugs, because core paths we use could
|
// Relative paths can cause nasty bugs, because core paths we use could
|
||||||
// shift between runs or even parts of the program. - The OCI runtime
|
// shift between runs or even parts of the program. - The OCI runtime
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue