Skip to content

Commit

Permalink
Merge pull request #53 from arenadata/adcm-1035-backport
Browse files Browse the repository at this point in the history
ADCM-1035 get adcm user and password for status server from secrets.json file
  • Loading branch information
acmnu authored Dec 16, 2019
2 parents 2f017ff + 81b2591 commit e1c67e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions go/adcm/status/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go/adcm/status/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e1c67e3

Please sign in to comment.