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:
		
							parent
							
								
									0f5b7db0f3
								
							
						
					
					
						commit
						054d133710
					
				| 
						 | 
				
			
			@ -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) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func customConfigFile() (string, error) {
 | 
			
		||||
	path := os.Getenv("CONTAINERS_CONF")
 | 
			
		||||
	if path != "" {
 | 
			
		||||
		return path, nil
 | 
			
		||||
	}
 | 
			
		||||
	return rootlessConfigPath()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue