From 53b13b1c76327f55be2063f6e30a2b792711d59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Mej=C3=ADas=20Rodr=C3=ADguez?= Date: Mon, 26 Aug 2019 01:13:43 -0400 Subject: [PATCH] Rename PortainerClient.Authenticate() to Auth() --- client/client.go | 8 ++++---- client/client_test.go | 2 +- cmd/login.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/client.go b/client/client.go index b89c9c7..c75bfe4 100644 --- a/client/client.go +++ b/client/client.go @@ -31,8 +31,8 @@ type Config struct { // PortainerClient represents a Portainer API client type PortainerClient interface { - // Authenticate a user to get an auth token - Authenticate() (token string, err error) + // Auth a user to get an auth token + Auth() (token string, err error) // Get endpoints GetEndpoints() ([]portainer.Endpoint, error) @@ -185,7 +185,7 @@ func (n *portainerClientImp) doJSON(uri, method string, headers http.Header, req func (n *portainerClientImp) doJSONWithToken(uri, method string, headers http.Header, request interface{}, response interface{}) (err error) { // Ensure there is an auth token if n.token == "" { - n.token, err = n.Authenticate() + n.token, err = n.Auth() if err != nil { return } @@ -203,7 +203,7 @@ func (n *portainerClientImp) AfterResponse(hook func(resp *http.Response) (err e n.afterResponseHooks = append(n.afterResponseHooks, hook) } -func (n *portainerClientImp) Authenticate() (token string, err error) { +func (n *portainerClientImp) Auth() (token string, err error) { reqBody := AuthenticateUserRequest{ Username: n.user, Password: n.password, diff --git a/client/client_test.go b/client/client_test.go index b932259..88726c2 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -69,7 +69,7 @@ func TestClientAuthenticates(t *testing.T) { Password: "a", UserAgent: "GE007", }) - token, err := customClient.Authenticate() + token, err := customClient.Auth() assert.Nil(t, err) assert.Equal(t, token, "somerandomtoken") } diff --git a/cmd/login.go b/cmd/login.go index f0fad9b..a3047dc 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -22,7 +22,7 @@ var loginCmd = &cobra.Command{ logrus.WithFields(logrus.Fields{ "user": user, }).Debug("Getting auth token") - authToken, err := client.Authenticate() + authToken, err := client.Auth() common.CheckError(err) if viper.GetBool("login.print") {