Skip to content

Commit f3d653a

Browse files
authored
user: Fix key show command (#106)
Fixes `ecctl user key show` command where the required number of arguments was invalid and the UserID used in the pkg layer was the key ID instead of the UserID. Signed-off-by: Marc Lopez <marc5.12@outlook.com>
1 parent f8eb428 commit f3d653a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

cmd/user/key/show.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ import (
2727
var showCmd = &cobra.Command{
2828
Use: "show --user=<user id> <key id>",
2929
Short: "Shows the API key details for the specified user",
30-
PreRunE: cobra.MinimumNArgs(2),
30+
PreRunE: cobra.MinimumNArgs(1),
3131
RunE: func(cmd *cobra.Command, args []string) error {
32+
user, _ := cmd.Flags().GetString("user")
3233
res, err := userauthadmin.GetKey(userauthadmin.GetKeyParams{
33-
UserID: args[0],
34+
UserID: user,
3435
API: ecctl.Get().API,
35-
ID: args[1],
36+
ID: args[0],
3637
})
3738
if err != nil {
3839
return err

pkg/user/auth/admin/getkey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func GetKey(params GetKeyParams) (*models.APIKeyResponse, error) {
6363
res, err := params.V1API.Authentication.GetUserAPIKey(
6464
authentication.NewGetUserAPIKeyParams().
6565
WithAPIKeyID(params.ID).
66-
WithUserID(params.ID),
66+
WithUserID(params.UserID),
6767
params.AuthWriter,
6868
)
6969

0 commit comments

Comments
 (0)