-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cede8ea
commit 7501108
Showing
8 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package dao | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/one2nc/cloud-lens/internal" | ||
"github.com/one2nc/cloud-lens/internal/aws" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
type IAMU struct { | ||
Accessor | ||
ctx context.Context | ||
} | ||
|
||
func (iamu *IAMU) Init(ctx context.Context) { | ||
iamu.ctx = ctx | ||
} | ||
|
||
func (iamu *IAMU) List(ctx context.Context) ([]Object, error) { | ||
sess, ok := ctx.Value(internal.KeySession).(*session.Session) | ||
if !ok { | ||
log.Err(fmt.Errorf("conversion err: Expected session.session but got %v", sess)) | ||
} | ||
usr := aws.GetUsers(*sess) | ||
objs := make([]Object, len(usr)) | ||
for i, obj := range usr { | ||
objs[i] = obj | ||
} | ||
return objs, nil | ||
} | ||
|
||
func (iamu *IAMU) Get(ctx context.Context, path string) (Object, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package render | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/derailed/tview" | ||
"github.com/one2nc/cloud-lens/internal/aws" | ||
) | ||
|
||
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: "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}, | ||
} | ||
} | ||
|
||
func (iamu IAMU) Render(o interface{}, ns string, row *Row) error { | ||
iamuResp, ok := o.(aws.IAMUSerResp) | ||
if !ok { | ||
return fmt.Errorf("Expected S3Resp, but got %T", o) | ||
} | ||
|
||
row.ID = ns | ||
row.Fields = Fields{ | ||
iamuResp.UserId, | ||
iamuResp.UserName, | ||
iamuResp.ARN, | ||
iamuResp.CreationTime, | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package view | ||
|
||
import ( | ||
"github.com/gdamore/tcell/v2" | ||
"github.com/one2nc/cloud-lens/internal/ui" | ||
) | ||
|
||
type IAMU struct { | ||
ResourceViewer | ||
} | ||
|
||
// NewSG returns a new viewer. | ||
func NewIAMU(resource string) ResourceViewer { | ||
var iamu IAMU | ||
iamu.ResourceViewer = NewBrowser(resource) | ||
iamu.AddBindKeysFn(iamu.bindKeys) | ||
return &iamu | ||
} | ||
|
||
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), | ||
tcell.KeyEscape: ui.NewKeyAction("Back", iamu.App().PrevCmd, true), | ||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters