37 lines
726 B
Go
37 lines
726 B
Go
package balboa
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// Client for Balboa instance.
|
|
type Client struct {
|
|
addr string
|
|
}
|
|
|
|
// NewClient for Balboa located at address.
|
|
func NewClient(address string) (c *Client) {
|
|
c = &Client{
|
|
addr: address,
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetClient returns the cached session to Balboa. If no cached session
|
|
// is available, or when it is not valid any longer, a new session is
|
|
// created.
|
|
func GetClient() (*Client, error) {
|
|
logrus.Debugf("Getting new Balboa Client")
|
|
// TODO: refactor it in env variable and then in config file
|
|
addr := "http://127.0.0.1:8030"
|
|
if addr == "" {
|
|
return nil, fmt.Errorf("missing Balboa configuration")
|
|
}
|
|
|
|
client := NewClient(addr)
|
|
|
|
return client, nil
|
|
}
|