mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Rename PortainerClient.Auth() to AuthenticateUser()
This commit is contained in:
parent
5d95af3681
commit
22dc5e5d75
@ -13,7 +13,7 @@ type AuthenticateUserResponse struct {
|
||||
Jwt string
|
||||
}
|
||||
|
||||
func (n *portainerClientImp) Auth() (token string, err error) {
|
||||
func (n *portainerClientImp) AuthenticateUser() (token string, err error) {
|
||||
reqBody := AuthenticateUserRequest{
|
||||
Username: n.user,
|
||||
Password: n.password,
|
||||
|
@ -42,7 +42,7 @@ func TestClientAuthenticates(t *testing.T) {
|
||||
Password: "a",
|
||||
UserAgent: "GE007",
|
||||
})
|
||||
token, err := customClient.Auth()
|
||||
token, err := customClient.AuthenticateUser()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, token, "somerandomtoken")
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ type Config struct {
|
||||
|
||||
// PortainerClient represents a Portainer API client
|
||||
type PortainerClient interface {
|
||||
// Auth a user to get an auth token
|
||||
Auth() (token string, err error)
|
||||
// AuthenticateUser a user to get an auth token
|
||||
AuthenticateUser() (token string, err error)
|
||||
|
||||
// Get endpoints
|
||||
EndpointList() ([]portainer.Endpoint, error)
|
||||
@ -155,7 +155,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.Auth()
|
||||
n.token, err = n.AuthenticateUser()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ var loginCmd = &cobra.Command{
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"user": user,
|
||||
}).Debug("Getting auth token")
|
||||
authToken, err := client.Auth()
|
||||
authToken, err := client.AuthenticateUser()
|
||||
common.CheckError(err)
|
||||
|
||||
if viper.GetBool("login.print") {
|
||||
|
Loading…
Reference in New Issue
Block a user