Add function to portainer client to get current user name

This commit is contained in:
Juan Carlos Mejías Rodríguez 2019-09-09 00:13:00 -04:00
parent 97f04cff31
commit 1674d1879c

View File

@ -63,6 +63,9 @@ type PortainerClient interface {
// Proxy proxies a request to /endpoint/{id}/docker and returns its result
Proxy(endpointID portainer.EndpointID, req *http.Request) (resp *http.Response, err error)
// GetUsername returns the user name used by the client
GetUsername() string
}
type portainerClientImp struct {
@ -197,6 +200,10 @@ func (n *portainerClientImp) AfterResponse(hook func(resp *http.Response) (err e
n.afterResponseHooks = append(n.afterResponseHooks, hook)
}
func (n *portainerClientImp) GetUsername() string {
return n.user
}
// NewClient creates a new Portainer API client
func NewClient(httpClient *http.Client, config Config) PortainerClient {
return &portainerClientImp{