-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.go
49 lines (45 loc) · 1.33 KB
/
validate.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
package springparse
import (
"fmt"
log "github.com/sirupsen/logrus"
"net/url"
)
// ValidateAwsEnv validates all aws related configration and set defaults from environment variables
func (r *Client) ValidateAwsEnv() error {
if awsElasticSearchURL == "" {
return fmt.Errorf("Please set AWS_ELASTICSEARCH_URL")
}
_, err := url.Parse(awsElasticSearchURL)
if err != nil {
return err
}
if awsRegion == "" {
awsRegion = "us-west-2"
}
return nil
}
// ValidateOtherEnv validates all system info from environment variables.
func (r *Client) ValidateOtherEnv() error {
if logPrefix == "" {
return fmt.Errorf("Please specify LOG_PREFIX for elasticsearch prefix")
}
if serviceRegex == "" {
return fmt.Errorf("Please specify SERVICE_REGEX")
}
if logDirectory == "" {
return fmt.Errorf("Please specify LOG_DIRECTORY")
}
if hostPort == "" {
hostPort = "8080"
}
return nil
}
// ShowConfiguration shows the environment variables being set
func (r *Client) ShowConfiguration() {
log.Info("Starting springparse with the following configuration")
log.Info(fmt.Sprintf("AWS_ELASTICSEARCH_URL: %v", awsElasticSearchURL))
log.Info(fmt.Sprintf("LOG_PREFIX: %v", logPrefix))
log.Info(fmt.Sprintf("LOG_DIRECTORY: %v", logDirectory))
log.Info(fmt.Sprintf("SERVICE_REGEX: %v", serviceRegex))
log.Info(fmt.Sprintf("AWS_REGION: %v", awsRegion))
}