From 81b25912bf7ebc2a19e5f3c01b2156cdd1715a2c Mon Sep 17 00:00:00 2001 From: Konstantin Voschanov Date: Fri, 13 Dec 2019 17:13:58 +0300 Subject: [PATCH] ADCM-1035 get adcm user and password for status server from secrets.json file --- go/adcm/status/api.go | 11 ++++++++--- go/adcm/status/init.go | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/go/adcm/status/api.go b/go/adcm/status/api.go index 17821fc992..65b19ddb22 100644 --- a/go/adcm/status/api.go +++ b/go/adcm/status/api.go @@ -26,11 +26,13 @@ type AdcmApi struct { Url string token string httpClient *http.Client + Secrets *SecretConfig } -func newAdcmApi() *AdcmApi { +func newAdcmApi(secrets *SecretConfig) *AdcmApi { return &AdcmApi{ - Url: "http://127.0.0.1:8000/api/v1", + Url: "http://127.0.0.1:8000/api/v1", + Secrets: secrets, } } @@ -46,7 +48,10 @@ func (api *AdcmApi) getToken() (string, bool) { return api.token, true } resp, err := http.PostForm(api.Url+"/token/", - url.Values{"username": {"admin"}, "password": {"admin"}}) + url.Values{ + "username": {api.Secrets.ADCMUser.User}, + "password": {api.Secrets.ADCMUser.Password}, + }) if err != nil { logg.E.l("getToken: http error: ", err) return "", false diff --git a/go/adcm/status/init.go b/go/adcm/status/init.go index b4c1ead1b6..ac00a6cf23 100644 --- a/go/adcm/status/init.go +++ b/go/adcm/status/init.go @@ -52,7 +52,7 @@ func Start(secrets *SecretConfig, logFile string, logLevel string) { hub.EventWS = newWsHub() go hub.EventWS.run() - hub.AdcmApi = newAdcmApi() + hub.AdcmApi = newAdcmApi(secrets) go func() { time.Sleep(time.Second) hub.AdcmApi.getServiceMap()