-
Notifications
You must be signed in to change notification settings - Fork 26
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
653081c
commit da97126
Showing
10 changed files
with
128 additions
and
6 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
File renamed without changes.
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,38 @@ | ||
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 IAMUP struct { | ||
Accessor | ||
ctx context.Context | ||
} | ||
|
||
func (iamup *IAMUP) Init(ctx context.Context) { | ||
iamup.ctx = ctx | ||
} | ||
|
||
func (iamup *IAMUP) 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)) | ||
} | ||
userName := fmt.Sprintf("%v", ctx.Value(internal.UserName)) | ||
usrPolicy := aws.GetPoliciesOfUser(*sess, userName) | ||
objs := make([]Object, len(usrPolicy)) | ||
for i, obj := range usrPolicy { | ||
objs[i] = obj | ||
} | ||
return objs, nil | ||
} | ||
|
||
func (iamup *IAMUP) 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
File renamed without changes.
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,33 @@ | ||
package render | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/derailed/tview" | ||
"github.com/one2nc/cloud-lens/internal/aws" | ||
) | ||
|
||
type IamUserPloicy struct { | ||
} | ||
|
||
func (iup IamUserPloicy) Header() Header { | ||
return Header{ | ||
HeaderColumn{Name: "Policy-ARN", SortIndicatorIdx: 7, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: false}, | ||
HeaderColumn{Name: "Policy-Name", SortIndicatorIdx: 7, Align: tview.AlignLeft, Hide: false, Wide: false, MX: false, Time: false}, | ||
} | ||
} | ||
|
||
func (iup IamUserPloicy) Render(o interface{}, ns string, row *Row) error { | ||
usrPolicy, ok := o.(aws.IAMUSerPolicyResponse) | ||
if !ok { | ||
return fmt.Errorf("expected S3Resp, but got %T", o) | ||
} | ||
|
||
row.ID = ns | ||
row.Fields = Fields{ | ||
usrPolicy.PolicyArn, | ||
usrPolicy.PolicyName, | ||
|
||
} | ||
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
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,25 @@ | ||
package view | ||
|
||
import ( | ||
"github.com/gdamore/tcell/v2" | ||
"github.com/one2nc/cloud-lens/internal/ui" | ||
) | ||
|
||
type iamUserPloicy struct { | ||
ResourceViewer | ||
} | ||
|
||
func NewIamUserPloicy(resource string) ResourceViewer { | ||
var up iamUserPloicy | ||
up.ResourceViewer = NewBrowser(resource) | ||
up.AddBindKeysFn(up.bindKeys) | ||
return &up | ||
} | ||
|
||
func (up *iamUserPloicy) bindKeys(aa ui.KeyActions) { | ||
aa.Add(ui.KeyActions{ | ||
tcell.KeyEscape: ui.NewKeyAction("Back", up.App().PrevCmd, true), | ||
ui.KeyShiftA: ui.NewKeyAction("Policy-ARN", up.GetTable().SortColCmd("Policy-ARN", true), true), | ||
ui.KeyShiftN: ui.NewKeyAction("Policy-Name", up.GetTable().SortColCmd("Policy-Name", true), true), | ||
}) | ||
} |