From cbe940f8ecbfd4a81d53d1b29e781656c1d2a19b Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Mon, 10 Apr 2017 20:28:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=20Accounts?= =?UTF-8?q?=20API=20=D0=B2=D1=8B=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=20=D0=B2=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D1=8B=20=D0=BE?= =?UTF-8?q?=D0=BA=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.dev.yml | 4 ++++ docker-compose.prod.yml | 4 ++++ lib/worker/supports.go | 10 +++------- minecraft-skinsystem.go | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index c5e919d..fd1f743 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -12,6 +12,10 @@ services: - redis - rabbitmq - statsd + environment: + ACCOUNTS_API_ID: "" + ACCOUNTS_API_SECRET: "" + STATSD_ADDR: "" redis: extends: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 3c86b31..9d8bc79 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -8,6 +8,10 @@ services: - redis - rabbitmq restart: always + environment: + ACCOUNTS_API_ID: "" + ACCOUNTS_API_SECRET: "" + STATSD_ADDR: "" redis: extends: diff --git a/lib/worker/supports.go b/lib/worker/supports.go index e370521..4d1f58a 100644 --- a/lib/worker/supports.go +++ b/lib/worker/supports.go @@ -5,6 +5,8 @@ import ( "elyby/minecraft-skinsystem/lib/external/accounts" ) +var AccountsTokenConfig *accounts.TokenRequest + var token *accounts.Token const repeatsLimit = 3 @@ -40,13 +42,7 @@ func _getByField(field string, value string) (accounts.AccountInfoResponse, erro func getToken() (*accounts.Token, error) { if token == nil { - tempToken, err := accounts.GetToken(accounts.TokenRequest{ - Id: "skinsystem", - Secret: "qugFIaCjec3LMA", - Scopes: []string{ - "internal_account_info", - }, - }) + tempToken, err := accounts.GetToken(*AccountsTokenConfig) if err != nil { return &accounts.Token{}, err } diff --git a/minecraft-skinsystem.go b/minecraft-skinsystem.go index b8eefb6..c684279 100644 --- a/minecraft-skinsystem.go +++ b/minecraft-skinsystem.go @@ -19,6 +19,7 @@ import ( "elyby/minecraft-skinsystem/lib/routes" "elyby/minecraft-skinsystem/lib/services" "elyby/minecraft-skinsystem/lib/worker" + "elyby/minecraft-skinsystem/lib/external/accounts" ) const redisPoolSize int = 10 @@ -28,6 +29,20 @@ func main() { runtime.GOMAXPROCS(runtime.NumCPU()) + accountsApiId := os.Getenv("ACCOUNTS_API_ID") + accountsApiSecret := os.Getenv("ACCOUNTS_API_SECRET") + if accountsApiId == "" || accountsApiSecret == "" { + log.Fatal("ACCOUNTS_API params must be provided") + } + + worker.AccountsTokenConfig = &accounts.TokenRequest{ + Id: accountsApiId, + Secret: accountsApiSecret, + Scopes: []string{ + "internal_account_info", + }, + } + log.Println("Connecting to redis") var redisString = os.Getenv("REDIS_ADDR") @@ -62,6 +77,7 @@ func main() { // statsd var statsdString = os.Getenv("STATSD_ADDR") + statsdString = "" if (statsdString != "") { log.Println("Connecting to statsd") hostname, _ := os.Hostname()