mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
fix qemu and update docker with tests
This commit is contained in:
@@ -786,9 +786,14 @@ func buildUpstreamsEnv(envMap map[string]string, upstreams []structs.ConsulUpstr
|
||||
}
|
||||
}
|
||||
|
||||
func WithPortMapEnvs(envs map[string]string, ports map[string]int) map[string]string {
|
||||
// SetPortMapEnvs sets the PortMap related environment variables on the map
|
||||
func SetPortMapEnvs(envs map[string]string, ports map[string]int) map[string]string {
|
||||
if envs == nil {
|
||||
envs = map[string]string{}
|
||||
}
|
||||
|
||||
for portLabel, port := range ports {
|
||||
portEnv := PortPrefix + portLabel
|
||||
portEnv := helper.CleanEnvVar(PortPrefix+portLabel, '_')
|
||||
envs[portEnv] = strconv.Itoa(port)
|
||||
}
|
||||
return envs
|
||||
|
||||
@@ -784,3 +784,23 @@ func TestEnvironment_Upstreams(t *testing.T) {
|
||||
require.Equal(t, "127.0.0.1:1234", env["foo"])
|
||||
require.Equal(t, "1234", env["bar"])
|
||||
}
|
||||
|
||||
func TestEnvironment_SetPortMapEnvs(t *testing.T) {
|
||||
envs := map[string]string{
|
||||
"foo": "bar",
|
||||
"NOMAD_PORT_ssh": "2342",
|
||||
}
|
||||
ports := map[string]int{
|
||||
"ssh": 22,
|
||||
"http": 80,
|
||||
}
|
||||
|
||||
envs = SetPortMapEnvs(envs, ports)
|
||||
|
||||
expected := map[string]string{
|
||||
"foo": "bar",
|
||||
"NOMAD_PORT_ssh": "22",
|
||||
"NOMAD_PORT_http": "80",
|
||||
}
|
||||
require.Equal(t, expected, envs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user