mirror of
https://github.com/docker/cli.git
synced 2025-09-02 10:21:16 +03:00
import environment variables that are present
previously docker did import environment variables if they were present but created them if they were not when it was asked via a --env-file cli option to import but not create them. fix is to only import the variable into the environment if it is present. additionally do not import variable names of zero-length (which are lines w/ a potential variable definition w/o a variable name). refs: - https://github.com/docker/for-linux/issues/284 Signed-off-by: Tom Klingenberg <tklingenberg@lastflood.net>
This commit is contained in:
@@ -19,10 +19,10 @@ func ReadKVStrings(files []string, override []string) ([]string, error) {
|
||||
// present in the file with additional pairs specified in the override parameter.
|
||||
// If a key has no value, it will get the value from the environment.
|
||||
func ReadKVEnvStrings(files []string, override []string) ([]string, error) {
|
||||
return readKVStrings(files, override, os.Getenv)
|
||||
return readKVStrings(files, override, os.LookupEnv)
|
||||
}
|
||||
|
||||
func readKVStrings(files []string, override []string, emptyFn func(string) string) ([]string, error) {
|
||||
func readKVStrings(files []string, override []string, emptyFn func(string) (string, bool)) ([]string, error) {
|
||||
variables := []string{}
|
||||
for _, ef := range files {
|
||||
parsedVars, err := parseKeyValueFile(ef, emptyFn)
|
||||
|
Reference in New Issue
Block a user