forked from mongodb/mongo-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.go
40 lines (33 loc) · 960 Bytes
/
env.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package env
import (
"fmt"
"os"
)
func notFoundErr(varname string) error {
return fmt.Errorf("env variable %q not set", varname)
}
func get(varname string) string {
return os.Getenv(varname)
}
func mustGet(varname string) (string, error) {
val := get(varname)
if val == "" {
return "", notFoundErr(varname)
}
return val, nil
}
// EvgIsPatch returns whether the current evergreen task is a patch,
// based on the value of an env variable set by the evg project file.
func EvgIsPatch() bool {
return get("EVG_IS_PATCH") != ""
}
// EvgBuildID returns the build_id of the current evergreen task,
// based on the value of an env variable set by the evg project file.
func EvgBuildID() (string, error) {
return mustGet("EVG_BUILD_ID")
}
// EvgVariant returns the variant name for the current evergreen task,
// based on the value of an env variable set by the evg project file.
func EvgVariant() (string, error) {
return mustGet("EVG_VARIANT")
}