summaryrefslogtreecommitdiff
path: root/internal/config/env.go
diff options
context:
space:
mode:
authorPaul Buetow <35781042+pbuetow@users.noreply.github.com>2021-10-24 18:05:47 +0300
committerGitHub <noreply@github.com>2021-10-24 18:05:47 +0300
commit3d24204754aff155de21b01e9e3d82eb460fb87f (patch)
tree093fb4bff0bdf086188df86ca5d13dc7f8a34e4f /internal/config/env.go
parent6edea198188172c603e10201aa2302a28b7b722f (diff)
parent6cfc4e161f94ab159d4b1ea491ffe6f166fa6204 (diff)
Merge pull request #24 from snonux/develop
Bugfixes around integration tests
Diffstat (limited to 'internal/config/env.go')
-rw-r--r--internal/config/env.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/config/env.go b/internal/config/env.go
index 88b831d..804a10a 100644
--- a/internal/config/env.go
+++ b/internal/config/env.go
@@ -2,6 +2,26 @@ package config
import "os"
+// Env returns true when a given environment variable is set to "yes".
func Env(env string) bool {
return "yes" == os.Getenv(env)
}
+
+// Hostname returns the current hostname. It can be overriden with
+// DTAIL_HOSTNAME_OVERRIDE environment variable (useful for integration tests).
+func Hostname() (string, error) {
+ hostname := os.Getenv("DTAIL_HOSTNAME_OVERRIDE")
+ if len(hostname) > 0 {
+ return hostname, nil
+ }
+ return os.Hostname()
+}
+
+// SSHKnownHostsFile returns the known hosts file path (useful for integration tests)
+func SSHKnownHostsFile() string {
+ if len(os.Getenv("DTAIL_SSH_KNOWN_HOSTS_FILE")) > 0 {
+ return os.Getenv("DTAIL_SSH_KNOWN_HOSTS_FILE")
+ } else {
+ return os.Getenv("HOME") + "/.ssh/known_hosts"
+ }
+}