Rename client to cachedClient

This commit is contained in:
Juan Carlos Mejías Rodríguez 2019-08-02 16:32:26 -04:00
parent 64619fc90f
commit a0d75c8df9

View File

@ -16,7 +16,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
var client *PortainerClient var cachedClient *PortainerClient
type ClientConfig struct { type ClientConfig struct {
Url string Url string
@ -305,14 +305,14 @@ func NewClient(config ClientConfig) (c *PortainerClient, err error) {
// Get the cached client or a new one // Get the cached client or a new one
func GetClient() (c *PortainerClient, err error) { func GetClient() (c *PortainerClient, err error) {
if client == nil { if cachedClient == nil {
client, err = NewClient(ClientConfig{ cachedClient, err = NewClient(ClientConfig{
Url: viper.GetString("url"), Url: viper.GetString("url"),
User: viper.GetString("user"), User: viper.GetString("user"),
Password: viper.GetString("password"), Password: viper.GetString("password"),
Token: viper.GetString("auth-token"), Token: viper.GetString("auth-token"),
}) })
} }
c = client c = cachedClient
return return
} }