Skip to content

Commit

Permalink
rename metabase APIClient to avoid confusion (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Jun 27, 2023
1 parent e404e0b commit 893394e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions pkg/metabase/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
log "github.com/sirupsen/logrus"
)

type APIClient struct {
type MBClient struct {
CTX *sling.Sling
Client *http.Client
}
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions pkg/metabase/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/metabase/metabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

type Metabase struct {
Config *Config
Client *APIClient
Client *MBClient
Container *Container
Database *Database
InternalDBURL string
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 893394e

Please sign in to comment.