mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-21 09:11:07 +02:00
Allow DOCKER_CONFIG to be a filename (#1409)
* Allow DOCKER_CONFIG to be a filename * UnitTest: DockerConfLocation must return a file if it is existent and passed using env, or default if the file is incorrect
This commit is contained in:
+12
-2
@@ -67,8 +67,18 @@ const (
|
||||
// "/kaniko/.docker/config.json".
|
||||
func DockerConfLocation() string {
|
||||
configFile := "config.json"
|
||||
if dockerConfDir := os.Getenv("DOCKER_CONFIG"); dockerConfDir != "" {
|
||||
return filepath.Join(dockerConfDir, configFile)
|
||||
if dockerConfig := os.Getenv("DOCKER_CONFIG"); dockerConfig != "" {
|
||||
file, err := os.Stat(dockerConfig)
|
||||
if err == nil {
|
||||
if file.IsDir() {
|
||||
return filepath.Join(dockerConfig, configFile)
|
||||
}
|
||||
} else {
|
||||
if os.IsNotExist(err) {
|
||||
return string(os.PathSeparator) + filepath.Join("kaniko", ".docker", configFile)
|
||||
}
|
||||
}
|
||||
return filepath.Clean(dockerConfig)
|
||||
}
|
||||
return string(os.PathSeparator) + filepath.Join("kaniko", ".docker", configFile)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user