rename metabase APIClient to avoid confusion (#2305)

This commit is contained in:
mmetc 2023-06-27 15:07:16 +02:00 committed by GitHub
parent e404e0b608
commit 893394ef5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -12,7 +12,7 @@ import (
log "github.com/sirupsen/logrus"
)
type APIClient struct {
type MBClient struct {
CTX *sling.Sling
Client *http.Client
}
@ -35,15 +35,15 @@ var (
}
)
func NewAPIClient(url string) (*APIClient, error) {
func NewMBClient(url string) (*MBClient, error) {
httpClient := &http.Client{Timeout: 20 * time.Second}
return &APIClient{
return &MBClient{
CTX: sling.New().Client(httpClient).Base(url).Set("User-Agent", fmt.Sprintf("crowdsec/%s", version.String())),
Client: httpClient,
}, nil
}
func (h *APIClient) Do(method string, route string, body interface{}) (interface{}, interface{}, error) {
func (h *MBClient) Do(method string, route string, body interface{}) (interface{}, interface{}, error) {
var Success interface{}
var Error interface{}
var resp *http.Response
@ -80,6 +80,6 @@ func (h *APIClient) Do(method string, route string, body interface{}) (interface
}
// Set set headers as key:value
func (h *APIClient) Set(key string, value string) {
func (h *MBClient) Set(key string, value string) {
h.CTX = h.CTX.Set(key, value)
}

View file

@ -14,7 +14,7 @@ type Database struct {
DBUrl string
Model *Model
Config *csconfig.DatabaseCfg
Client *APIClient
Client *MBClient
Details *Details
// in case mysql host is 127.0.0.1 the ip address of mysql/pgsql host will be the docker gateway since metabase run in a container
}
@ -41,7 +41,7 @@ type Model struct {
Schedules map[string]interface{} `json:"schedules"`
}
func NewDatabase(config *csconfig.DatabaseCfg, client *APIClient, remoteDBAddr string) (*Database, error) {
func NewDatabase(config *csconfig.DatabaseCfg, client *MBClient, remoteDBAddr string) (*Database, error) {
var details *Details
database := Database{}

View file

@ -23,7 +23,7 @@ import (
type Metabase struct {
Config *Config
Client *APIClient
Client *MBClient
Container *Container
Database *Database
InternalDBURL string
@ -80,7 +80,7 @@ func (m *Metabase) Init(containerName string) error {
return fmt.Errorf("database '%s' not supported", m.Config.Database.Type)
}
m.Client, err = NewAPIClient(m.Config.ListenURL)
m.Client, err = NewMBClient(m.Config.ListenURL)
if err != nil {
return err
}