summary refs log tree commit diff stats
path: root/cmd/cetus/env.go
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-03-25 00:13:51 +0530
committerAndinus <andinus@nand.sh>2020-03-25 00:13:51 +0530
commit3ee3715ae7777dd6c1804974e2e293406fd1fe54 (patch)
treef035e76ff9ce48d03299381d03906eaff76140dc /cmd/cetus/env.go
parent28e35c0b0b996e17bd94a5b9e78fda90086ba85e (diff)
downloadcetus-3ee3715ae7777dd6c1804974e2e293406fd1fe54.tar.gz
Add apod support & fix errors
Diffstat (limited to 'cmd/cetus/env.go')
-rw-r--r--cmd/cetus/env.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd/cetus/env.go b/cmd/cetus/env.go
new file mode 100644
index 0000000..9288c35
--- /dev/null
+++ b/cmd/cetus/env.go
@@ -0,0 +1,18 @@
+package main
+
+import "os"
+
+// getEnv will check if the the key exists, if it does then it'll
+// return the value otherwise it will return fallback string.
+func getEnv(key, fallback string) string {
+	// We use os.LookupEnv instead of using os.GetEnv and checking
+	// if the length equals 0 because environment variable can be
+	// set and be of length 0. User could've set key="" which
+	// means the variable was set but the length is 0. There is no
+	// reason why user would want to do this over here though.
+	value, exists := os.LookupEnv(key)
+	if !exists {
+		value = fallback
+	}
+	return value
+}