2017-09-26 12:50:09 +00:00
|
|
|
package misc
|
|
|
|
|
|
|
|
import (
|
2018-03-20 05:07:19 +00:00
|
|
|
"time"
|
|
|
|
|
2017-09-26 12:50:09 +00:00
|
|
|
"github.com/cuigh/auxo/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-04-24 04:16:42 +00:00
|
|
|
keyDockerEndpoint = "swirl.docker_endpoint"
|
|
|
|
keyDockerAPIVersion = "swirl.docker_api_version"
|
|
|
|
keyDBType = "swirl.db_type"
|
|
|
|
keyDBAddress = "swirl.db_address"
|
|
|
|
keyAuthTimeout = "swirl.auth_timeout"
|
|
|
|
envDockerEndpoint = "DOCKER_ENDPOINT"
|
|
|
|
envDockerAPIVersion = "DOCKER_API_VERSION"
|
|
|
|
envDBType = "DB_TYPE"
|
|
|
|
envDBAddress = "DB_ADDRESS"
|
|
|
|
envAuthTimeout = "AUTH_TIMEOUT"
|
2017-09-26 12:50:09 +00:00
|
|
|
)
|
|
|
|
|
2017-11-22 03:38:24 +00:00
|
|
|
// TimeZones holds some commonly used time-zones.
|
|
|
|
var TimeZones = []struct {
|
|
|
|
Name string
|
|
|
|
Offset int32 // seconds east of UTC
|
|
|
|
}{
|
|
|
|
{"GMT", 0},
|
|
|
|
{"GMT+12", 12 * 60 * 60},
|
|
|
|
{"GMT+11", 11 * 60 * 60},
|
|
|
|
{"GMT+10", 10 * 60 * 60},
|
|
|
|
{"GMT+9", 9 * 60 * 60},
|
|
|
|
{"GMT+8(Asia/Shanghai)", 8 * 60 * 60},
|
|
|
|
{"GMT+7", 7 * 60 * 60},
|
|
|
|
{"GMT+6", 6 * 60 * 60},
|
|
|
|
{"GMT+5", 5 * 60 * 60},
|
|
|
|
{"GMT+4", 4 * 60 * 60},
|
|
|
|
{"GMT+3", 3 * 60 * 60},
|
|
|
|
{"GMT+2", 2 * 60 * 60},
|
|
|
|
{"GMT+1", 1 * 60 * 60},
|
|
|
|
{"GMT-1", -1 * 60 * 60},
|
|
|
|
{"GMT-2", -2 * 60 * 60},
|
|
|
|
{"GMT-3", -3 * 60 * 60},
|
|
|
|
{"GMT-4", -4 * 60 * 60},
|
|
|
|
{"GMT-5", -5 * 60 * 60},
|
|
|
|
{"GMT-6", -6 * 60 * 60},
|
|
|
|
{"GMT-7", -7 * 60 * 60},
|
|
|
|
{"GMT-8", -8 * 60 * 60},
|
|
|
|
{"GMT-9", -9 * 60 * 60},
|
|
|
|
{"GMT-10", -10 * 60 * 60},
|
|
|
|
{"GMT-11", -11 * 60 * 60},
|
|
|
|
{"GMT-12", -12 * 60 * 60},
|
|
|
|
}
|
|
|
|
|
2018-03-20 05:07:19 +00:00
|
|
|
// Options holds custom options of swirl.
|
2017-10-27 12:31:30 +00:00
|
|
|
var Options = &struct {
|
2018-04-24 04:16:42 +00:00
|
|
|
DockerEndpoint string
|
|
|
|
DockerAPIVersion string
|
|
|
|
DBType string
|
|
|
|
DBAddress string
|
|
|
|
AuthTimeout time.Duration
|
2018-03-20 05:07:19 +00:00
|
|
|
}{
|
|
|
|
DBType: "mongo",
|
|
|
|
DBAddress: "localhost:27017/swirl",
|
|
|
|
AuthTimeout: 30 * time.Minute,
|
|
|
|
}
|
2017-09-26 12:50:09 +00:00
|
|
|
|
2018-03-20 05:07:19 +00:00
|
|
|
// BindOptions binds options to environment variables.
|
2017-10-27 12:31:30 +00:00
|
|
|
func BindOptions() {
|
|
|
|
config.BindEnv(keyDockerEndpoint, envDockerEndpoint)
|
2018-04-24 04:16:42 +00:00
|
|
|
config.BindEnv(keyDockerAPIVersion, envDockerAPIVersion)
|
2017-10-27 12:31:30 +00:00
|
|
|
config.BindEnv(keyDBType, envDBType)
|
|
|
|
config.BindEnv(keyDBAddress, envDBAddress)
|
2018-03-20 05:07:19 +00:00
|
|
|
config.BindEnv(keyAuthTimeout, envAuthTimeout)
|
2017-09-26 12:50:09 +00:00
|
|
|
}
|