/
init.go
62 lines (50 loc) · 1.38 KB
/
init.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
// Copyright The Linux Foundation and each contributor to CommunityBridge.
// SPDX-License-Identifier: MIT
package init
import (
"os"
log "github.com/communitybridge/easycla-api/logging"
)
const (
// ServiceName is the name of the service - this is used in logs and as a environment prefix
ServiceName = "CLA_SERVICE"
// DefaultStage is the default run-time environment, typically one of: dev, test, staging or prod
DefaultStage = "dev"
)
var (
stage string
)
// CommonInit initializes the common properties
func CommonInit() {
stage = os.Getenv("STAGE")
if stage == "" {
log.Debugf("STAGE environment variable is not set. Using default: %s", DefaultStage)
stage = DefaultStage
} else {
log.Debugf("STAGE set to: %s", DefaultStage)
}
}
/*
// getProperty is a common routine to bind and return the specified environment variable
func getProperty(property string) string {
err := viper.BindEnv(property)
if err != nil {
log.Fatalf("Unable to load property: %s - value not defined or empty", property)
}
value := viper.GetString(property)
if value == "" {
err := fmt.Errorf("%s environment variable cannot be empty", property)
log.Fatal(err.Error())
}
return value
}
*/
// Init initialization logic for all the handlers
func Init() {
CommonInit()
AWSInit()
}
// GetStage returns the deployment stage, e.g. dev, test, stage or prod
func GetStage() string {
return stage
}