forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
47 lines (38 loc) · 1.08 KB
/
config.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
41
42
43
44
45
46
47
package testkit
import (
"errors"
"fmt"
"log"
"os"
)
const (
gatewayUrlEnvName = "GATEWAY_URL"
namespaceEnvName = "NAMESPACE"
remoteEnvironmentEnvName = "REMOTE_ENVIRONMENT"
)
type TestConfig struct {
GatewayUrl string
Namespace string
RemoteEnvironment string
}
func ReadConfig() (TestConfig, error) {
gatewayUrl, found := os.LookupEnv(gatewayUrlEnvName)
if !found {
return TestConfig{}, errors.New(fmt.Sprintf("failed to read %s environment variable", gatewayUrlEnvName))
}
namespace, found := os.LookupEnv(namespaceEnvName)
if !found {
return TestConfig{}, errors.New(fmt.Sprintf("failed to read %s environment variable", namespaceEnvName))
}
remoteEnvironment, found := os.LookupEnv(remoteEnvironmentEnvName)
if !found {
return TestConfig{}, errors.New(fmt.Sprintf("failed to read %s environment variable", remoteEnvironmentEnvName))
}
config := TestConfig{
GatewayUrl: gatewayUrl,
Namespace: namespace,
RemoteEnvironment: remoteEnvironment,
}
log.Printf("Read configuration: %+v", config)
return config, nil
}