-
Notifications
You must be signed in to change notification settings - Fork 7
/
parameter.go
87 lines (74 loc) · 2.46 KB
/
parameter.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package e2e
import (
"fmt"
"os"
"github.com/aliyun/aliyun-datahub-sdk-go/datahub"
)
var accessId = ""
var accessKey = ""
var endpoint = ""
var projectName = ""
var tupleTopicName = ""
var blobTopicName = ""
var batchTupleTopicName = ""
var batchBlobTopicName = ""
var client = datahub.New(accessId, accessKey, endpoint)
var batchClient = datahub.NewBatchClient(accessId, accessKey, endpoint)
func init() {
var reinit = false
if len(accessId) == 0 {
accessId = os.Getenv("ACCESS_ID")
if len(accessId) > 0 {
reinit = true
fmt.Printf("Inited accessId from ENV ACCESS_ID: %s\n", accessId)
}
}
if len(accessKey) == 0 {
accessKey = os.Getenv("ACCESS_KEY")
if len(accessKey) > 0 {
reinit = true
fmt.Printf("Inited accessKey from ENV ACCESS_KEY: %s\n", accessKey)
}
}
if len(endpoint) == 0 {
endpoint = os.Getenv("ENDPOINT")
if len(endpoint) > 0 {
reinit = true
fmt.Printf("Inited endpoint from ENV ENDPOINT: %s\n", endpoint)
}
}
if reinit == true {
client = datahub.New(accessId, accessKey, endpoint)
batchClient = datahub.NewBatchClient(accessId, accessKey, endpoint)
}
if len(projectName) == 0 {
projectName = os.Getenv("PROJECT_NAME")
if len(projectName) > 0 {
fmt.Printf("Inited projectName from ENV PROJECT_NAME: %s\n", projectName)
}
}
if len(tupleTopicName) == 0 {
tupleTopicName = os.Getenv("TUPLE_TOPIC_NAME")
if len(tupleTopicName) > 0 {
fmt.Printf("Inited tupleTopicName from ENV TUPLE_TOPIC_NAME: %s\n", tupleTopicName)
}
}
if len(blobTopicName) == 0 {
blobTopicName = os.Getenv("BLOB_TOPIC_NAME")
if len(blobTopicName) > 0 {
fmt.Printf("Inited blobTopicName from ENV BLOB_TOPIC_NAME: %s\n", blobTopicName)
}
}
if len(batchTupleTopicName) == 0 {
batchTupleTopicName = os.Getenv("BATCH_TUPLE_TOPIC_NAME")
if len(batchTupleTopicName) > 0 {
fmt.Printf("Inited batchTupleTopicName from ENV BATCH_TUPLE_TOPIC_NAME: %s\n", batchTupleTopicName)
}
}
if len(batchBlobTopicName) == 0 {
batchBlobTopicName = os.Getenv("BATCH_BLOB_TOPIC_NAME")
if len(batchBlobTopicName) > 0 {
fmt.Printf("Inited batchBlobTopicName from ENV BATCH_BLOB_TOPIC_NAME: %s\n", batchBlobTopicName)
}
}
}