-
Notifications
You must be signed in to change notification settings - Fork 5
/
iamclientfactory.go
33 lines (29 loc) · 1.03 KB
/
iamclientfactory.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
// Copyright (c) 2021 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
package factory
import (
"github.com/AccelByte/accelbyte-go-sdk/iam-sdk/pkg/iamclient"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository"
"github.com/sirupsen/logrus"
"strings"
)
var iamClientInstance *iamclient.JusticeIamService
func NewIamClient(configRepository repository.ConfigRepository) *iamclient.JusticeIamService {
if iamClientInstance == nil {
baseUrl := configRepository.GetJusticeBaseUrl()
if len(baseUrl) > 0 {
logrus.Infof("Base URL : %v", baseUrl)
baseUrlSplit := strings.Split(baseUrl, "://")
httpClientConfig := &iamclient.TransportConfig{
Host: baseUrlSplit[1],
BasePath: "",
Schemes: []string{baseUrlSplit[0]},
}
iamClientInstance = iamclient.NewHTTPClientWithConfig(nil, httpClientConfig)
} else {
iamClientInstance = iamclient.NewHTTPClient(nil)
}
}
return iamClientInstance
}