getCustomConfigFile for windows and darwin

podman remote clients that run on windows and darwin cannot use the isRootless to determine the configuration file locations.  here we do by OS and also honor the environment variable.

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude 2020-08-21 10:58:39 -05:00 committed by Daniel J Walsh
parent 0f5b7db0f3
commit 054d133710
4 changed files with 45 additions and 16 deletions

View File

@ -908,21 +908,6 @@ func Path() string {
return OverrideContainersConfig
}
func customConfigFile() (string, error) {
path := os.Getenv("CONTAINERS_CONF")
if path != "" {
return path, nil
}
if unshare.IsRootless() {
path, err := rootlessConfigPath()
if err != nil {
return "", err
}
return path, nil
}
return OverrideContainersConfig, nil
}
// ReadCustomConfig reads the custom config and only generates a config based on it
// If the custom config file does not exists, function will return an empty config
func ReadCustomConfig() (*Config, error) {

View File

@ -0,0 +1,13 @@
package config
import (
"os"
)
func customConfigFile() (string, error) {
path := os.Getenv("CONTAINERS_CONF")
if path != "" {
return path, nil
}
return rootlessConfigPath()
}

View File

@ -1,7 +1,27 @@
package config
import selinux "github.com/opencontainers/selinux/go-selinux"
import (
"os"
"github.com/containers/storage/pkg/unshare"
selinux "github.com/opencontainers/selinux/go-selinux"
)
func selinuxEnabled() bool {
return selinux.GetEnabled()
}
func customConfigFile() (string, error) {
path := os.Getenv("CONTAINERS_CONF")
if path != "" {
return path, nil
}
if unshare.IsRootless() {
path, err := rootlessConfigPath()
if err != nil {
return "", err
}
return path, nil
}
return OverrideContainersConfig, nil
}

View File

@ -0,0 +1,11 @@
package config
import "os"
func customConfigFile() (string, error) {
path := os.Getenv("CONTAINERS_CONF")
if path != "" {
return path, nil
}
return os.Getenv("LOCALAPPDATA"), nil
}