forked from kgateway-dev/kgateway
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontext.go
37 lines (28 loc) · 1004 Bytes
/
context.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
package runtime
import (
"os"
"github.com/solo-io/gloo/pkg/utils/envutils"
"github.com/solo-io/gloo/test/testutils"
)
// Context contains the set of properties that are defined at runtime by whoever is invoking tests.
// The intention of this is two-fold:
// 1. To provide a transparent definition for the set of runtime inputs that are accepted.
// 2. To ensure that tests are not aware of _how_ inputs are provided (command line, env variable), but
// just are aware _that_ they exist
type Context struct {
// ClusterName is the name of the cluster that will be used to execute the tests in
ClusterName string
// RunSource identifies who/what triggered the test
RunSource RunSource
}
func NewContext() Context {
var runSource = LocalDevelopment
if envutils.IsEnvDefined(testutils.GithubAction) {
runSource = PullRequest
}
return Context{
// ClusterName is derived from the environment variable
ClusterName: os.Getenv(testutils.ClusterName),
RunSource: runSource,
}
}