mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-09 00:16:46 +00:00
Refactor hosts_dir lookup
Applies feedback from #199 to inline the hosts_dir env-var lookup. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
parent
b8ada0d46b
commit
73c7349e36
@ -247,23 +247,25 @@ func prepareEnv(envProcess string, reqEnvVars map[string]string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getMounts() []specs.Mount {
|
func getMounts() []specs.Mount {
|
||||||
wd, _ := os.LookupEnv("hosts_dir")
|
// Prior to hosts_dir env-var, this value was set to
|
||||||
if len(wd) == 0 {
|
// os.Getwd()
|
||||||
wd = "/var/lib/faasd"
|
hostsDir := "/var/lib/faasd"
|
||||||
|
if v, ok := os.LookupEnv("hosts_dir"); ok && len(v) > 0 {
|
||||||
|
hostsDir = v
|
||||||
}
|
}
|
||||||
|
|
||||||
mounts := []specs.Mount{}
|
mounts := []specs.Mount{}
|
||||||
mounts = append(mounts, specs.Mount{
|
mounts = append(mounts, specs.Mount{
|
||||||
Destination: "/etc/resolv.conf",
|
Destination: "/etc/resolv.conf",
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: path.Join(wd, "resolv.conf"),
|
Source: path.Join(hostsDir, "resolv.conf"),
|
||||||
Options: []string{"rbind", "ro"},
|
Options: []string{"rbind", "ro"},
|
||||||
})
|
})
|
||||||
|
|
||||||
mounts = append(mounts, specs.Mount{
|
mounts = append(mounts, specs.Mount{
|
||||||
Destination: "/etc/hosts",
|
Destination: "/etc/hosts",
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: path.Join(wd, "hosts"),
|
Source: path.Join(hostsDir, "hosts"),
|
||||||
Options: []string{"rbind", "ro"},
|
Options: []string{"rbind", "ro"},
|
||||||
})
|
})
|
||||||
return mounts
|
return mounts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user