Skip to content

Commit 727eb6a

Browse files
authored
Make mage integration:auth work again (#4996)
* Update ESS API * Update UI location
1 parent ce5d51c commit 727eb6a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

magefile.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3065,12 +3065,12 @@ func authESS(ctx context.Context) error {
30653065
// Attempt to use API key to check if it's valid
30663066
for authSuccess := false; !authSuccess; {
30673067
client := ess.NewClient(ess.Config{ApiKey: essAPIKey})
3068-
u, err := client.GetUser(ctx, ess.GetUserRequest{})
3068+
u, err := client.GetAccount(ctx, ess.GetAccountRequest{})
30693069
if err != nil {
30703070
return fmt.Errorf("unable to successfully connect to ESS API: %w", err)
30713071
}
30723072

3073-
if u.User.UserID != 0 {
3073+
if u.ID != "" {
30743074
// We have a user. It indicates that the API key works. All set!
30753075
authSuccess = true
30763076
continue
@@ -3079,7 +3079,7 @@ func authESS(ctx context.Context) error {
30793079
fmt.Fprintln(os.Stderr, "❌ ESS authentication unsuccessful. Retrying...")
30803080

30813081
prompt := fmt.Sprintf("Please provide a ESS API key for %s. To get your API key, "+
3082-
"visit %s/deployment-features/keys:", client.BaseURL(), strings.TrimRight(client.BaseURL(), "/api/v1"))
3082+
"visit %s/account/keys:", client.BaseURL(), strings.TrimRight(client.BaseURL(), "/api/v1"))
30833083
essAPIKey, err = stringPrompt(prompt)
30843084
if err != nil {
30853085
return fmt.Errorf("unable to read ESS API key from prompt: %w", err)

pkg/testing/ess/users.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,23 @@ import (
1010
"fmt"
1111
)
1212

13-
type GetUserRequest struct {
13+
type GetAccountRequest struct {
1414
// For future use
1515
}
1616

17-
type GetUserResponse struct {
18-
User struct {
19-
UserID int `json:"user_id"`
20-
} `json:"user"`
17+
type GetAccountResponse struct {
18+
ID string `json:"id"`
2119
}
2220

23-
// GetUser returns information about the authenticated user
24-
func (c *Client) GetUser(ctx context.Context, req GetUserRequest) (*GetUserResponse, error) {
25-
resp, err := c.doGet(ctx, "users")
21+
// GetAccount returns information about the authenticated user
22+
func (c *Client) GetAccount(ctx context.Context, req GetAccountRequest) (*GetAccountResponse, error) {
23+
resp, err := c.doGet(ctx, "account")
2624
if err != nil {
2725
return nil, fmt.Errorf("error calling get user API: %w", err)
2826
}
2927
defer resp.Body.Close()
3028

31-
var respBody GetUserResponse
29+
var respBody GetAccountResponse
3230
if err := json.NewDecoder(resp.Body).Decode(&respBody); err != nil {
3331
return nil, fmt.Errorf("error parsing get user response: %w", err)
3432
}

0 commit comments

Comments
 (0)