Skip to content

Commit

Permalink
add soriting for iam user
Browse files Browse the repository at this point in the history
  • Loading branch information
aanamshaikh committed Feb 8, 2023
1 parent 7501108 commit a6d4e0c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion internal/aws/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/service/iam"
)


func GetUsers(sess session.Session) []IAMUSerResp {
iamSrv := iam.New(&sess)
result, err := iamSrv.ListUsers(&iam.ListUsersInput{})
Expand All @@ -26,7 +27,7 @@ func GetUsers(sess session.Session) []IAMUSerResp {
ARN: *u.Arn,
CreationTime: IST.Format("Mon Jan _2 15:04:05 2006"),
}
users = append(users, *user)
users = append(users,*user)
}
return users
}
Expand Down
6 changes: 3 additions & 3 deletions internal/render/iamu.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ type IAMU struct {

func (iamu IAMU) Header() Header {
return Header{
HeaderColumn{Name: "User-Id", SortIndicatorIdx: 6, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: false},
HeaderColumn{Name: "User-Name", SortIndicatorIdx: 6, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: false},
HeaderColumn{Name: "User-Id", SortIndicatorIdx: 5, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: false},
HeaderColumn{Name: "User-Name", SortIndicatorIdx: 5, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: false},
HeaderColumn{Name: "ARN", SortIndicatorIdx: -1, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: false},
HeaderColumn{Name: "Created-date", SortIndicatorIdx: -1, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: true},
HeaderColumn{Name: "Created-Date", SortIndicatorIdx: 8, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: true},
}
}

Expand Down
12 changes: 10 additions & 2 deletions internal/view/iamu.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ func NewIAMU(resource string) ResourceViewer {

func (iamu IAMU) bindKeys(aa ui.KeyActions) {
aa.Add(ui.KeyActions{
// ui.KeyShiftI: ui.NewKeyAction("Sort ", iamu.GetTable().SortColCmd("Group-Id", true), true),
// ui.KeyShiftN: ui.NewKeyAction("Sort Group-Name", iamu.GetTable().SortColCmd("Group-Name", true), true),
ui.KeyShiftI: ui.NewKeyAction("Sort User-Id ", iamu.GetTable().SortColCmd("User-Id", true), true),
ui.KeyShiftN: ui.NewKeyAction("Sort User-Name", iamu.GetTable().SortColCmd("User-Name", true), true),
ui.KeyShiftD: ui.NewKeyAction("Sort Created-Date", iamu.GetTable().SortColCmd("Created-Date", true), true),
tcell.KeyEscape: ui.NewKeyAction("Back", iamu.App().PrevCmd, true),
// tcell.KeyEnter: ui.NewKeyAction("View", iamu.enterCmd, true),
})
}

func (iamu *IAMU) enterCmd(evt *tcell.EventKey) *tcell.EventKey {
groupId := iamu.GetTable().GetSelectedItem()
iamu.App().Flash().Info("groupId: " + groupId)
return nil
}

0 comments on commit a6d4e0c

Please sign in to comment.