mirror of
https://github.com/containers/podman.git
synced 2025-07-04 10:10:32 +08:00
Add glob parsing for --env flag
Sometimes you want to add a few environmen variables based on the last field being a "*". Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -112,9 +112,22 @@ func parseEnv(env map[string]string, line string) error {
|
|||||||
if len(data) > 1 {
|
if len(data) > 1 {
|
||||||
env[name] = data[1]
|
env[name] = data[1]
|
||||||
} else {
|
} else {
|
||||||
// if only a pass-through variable is given, clean it up.
|
if strings.HasSuffix(name, "*") {
|
||||||
val, _ := os.LookupEnv(name)
|
name = strings.TrimSuffix(name, "*")
|
||||||
env[name] = val
|
for _, e := range os.Environ() {
|
||||||
|
part := strings.SplitN(e, "=", 2)
|
||||||
|
if len(part) < 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(part[0], name) {
|
||||||
|
env[part[0]] = part[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if only a pass-through variable is given, clean it up.
|
||||||
|
val, _ := os.LookupEnv(name)
|
||||||
|
env[name] = val
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,9 @@ You need to specify multi option commands in the form of a json string.
|
|||||||
|
|
||||||
Set environment variables
|
Set environment variables
|
||||||
|
|
||||||
This option allows you to specify arbitrary environment variables that are available for the process that will be launched inside of the container. If you specify a environment variable without a value, podman will check the host environment for a value or set the environment to "". See **Environment** note below for precedence.
|
This option allows you to specify arbitrary environment variables that are available for the process that will be launched inside of the container. If you specify a environment variable without a value, podman will check the host environment for a value or set the environment to "". If you specify a environment variable ending in --*--, podman will search the host environment for variables starting with the prefix and add them to the container. If you want to add an environment variable with a ***** following it, then you need to set a value.
|
||||||
|
|
||||||
|
See **Environment** note below for precedence.
|
||||||
|
|
||||||
**--env-host**=*true|false*
|
**--env-host**=*true|false*
|
||||||
|
|
||||||
@ -905,16 +907,16 @@ required for VPN, without it containers need to be run with the --net=host flag.
|
|||||||
|
|
||||||
## ENVIRONMENT
|
## ENVIRONMENT
|
||||||
|
|
||||||
Environment variables within containers can be set using multiple different options: This section describes the presidence.
|
Environment variables within containers can be set using multiple different options: This section describes the precedence.
|
||||||
|
|
||||||
Presidence Order:
|
Precedence Order:
|
||||||
**--env-host** : Host environment of the process executing podman is added.
|
**--env-host** : Host environment of the process executing podman is added.
|
||||||
|
|
||||||
Container image : Any enviroment variables specified in the contianer image.
|
Container image : Any enviroment variables specified in the container image.
|
||||||
|
|
||||||
**--env-file** : Any environment variables specfied via env-files. If multiple files specified, then they override each other in order of entry.
|
**--env-file** : Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry.
|
||||||
|
|
||||||
**--env** : Any environment variables specified will overide previous settings.
|
**--env** : Any environment variables specified will override previous settings.
|
||||||
|
|
||||||
## FILES
|
## FILES
|
||||||
|
|
||||||
|
@ -252,7 +252,9 @@ You need to specify multi option commands in the form of a json string.
|
|||||||
|
|
||||||
Set environment variables
|
Set environment variables
|
||||||
|
|
||||||
This option allows you to specify arbitrary environment variables that are available for the process that will be launched inside of the container. If you specify a environment variable without a value, podman will check the host environment for a value or set the environment to "". See **Environment** note below for precedence.
|
This option allows you to specify arbitrary environment variables that are available for the process that will be launched inside of the container. If you specify a environment variable without a value, podman will check the host environment for a value or set the environment to "". If you specify a environment variable ending in --*--, podman will search the host environment for variables starting with the prefix and add them to the container. If you want to add an environment variable with a ***** following it, then you need to set a value.
|
||||||
|
|
||||||
|
See **Environment** note below for precedence.
|
||||||
|
|
||||||
**--env-host**=*true|false*
|
**--env-host**=*true|false*
|
||||||
|
|
||||||
@ -1189,17 +1191,17 @@ required for VPN, without it containers need to be run with the --net=host flag.
|
|||||||
|
|
||||||
## ENVIRONMENT
|
## ENVIRONMENT
|
||||||
|
|
||||||
Environment variables within containers can be set using multiple different options: This section describes the presidence.
|
Environment variables within containers can be set using multiple different options: This section describes the precedence.
|
||||||
|
|
||||||
Presidence Order:
|
Precedence Order:
|
||||||
|
|
||||||
**--env-host** : Host environment of the process executing podman is added.
|
**--env-host** : Host environment of the process executing podman is added.
|
||||||
|
|
||||||
Container image : Any enviroment variables specified in the contianer image.
|
Container image : Any enviroment variables specified in the container image.
|
||||||
|
|
||||||
**--env-file** : Any environment variables specfied via env-files. If multiple files specified, then they override each other in order of entry.
|
**--env-file** : Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry.
|
||||||
|
|
||||||
**--env** : Any environment variables specified will overide previous settings.
|
**--env** : Any environment variables specified will override previous settings.
|
||||||
|
|
||||||
## FILES
|
## FILES
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user