Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaysomani07 committed Feb 14, 2023
2 parents f9ac6b4 + fb83df0 commit ecc0646
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 3 deletions.
9 changes: 9 additions & 0 deletions internal/dao/ec2_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ func (ei *EC2I) List(ctx context.Context) ([]Object, error) {
func (ei *EC2I) Get(ctx context.Context, path string) (Object, error) {
return nil, nil
}

func (ei *EC2I) Describe(imageId string) (string, error) {
sess, ok := ei.ctx.Value(internal.KeySession).(*session.Session)
if !ok {
log.Err(fmt.Errorf("conversion err: Expected session.session but got %v", sess))
}
res := aws.GetSingleAMI(*sess, imageId).GoString()
return res, nil
}
9 changes: 9 additions & 0 deletions internal/dao/ec2_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ func (es *EC2S) List(ctx context.Context) ([]Object, error) {
func (es *EC2S) Get(ctx context.Context, path string) (Object, error) {
return nil, nil
}

func (es *EC2S) Describe(snapshotId string) (string, error) {
sess, ok := es.ctx.Value(internal.KeySession).(*session.Session)
if !ok {
log.Err(fmt.Errorf("conversion err: Expected session.session but got %v", sess))
}
res := aws.GetSingleSnapshot(*sess, snapshotId).GoString()
return res, nil
}
9 changes: 9 additions & 0 deletions internal/dao/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ func (v *VPC) List(ctx context.Context) ([]Object, error) {
func (ei *VPC) Get(ctx context.Context, path string) (Object, error) {
return nil, nil
}

func (v *VPC) Describe(vpcId string) (string, error) {
sess, ok := v.ctx.Value(internal.KeySession).(*session.Session)
if !ok {
log.Err(fmt.Errorf("conversion err: Expected session.session but got %v", sess))
}
res := aws.GetSingleVPC(*sess, vpcId).GoString()
return res, nil
}
16 changes: 15 additions & 1 deletion internal/view/ec2_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,19 @@ func (ei *EC2I) bindKeys(aa ui.KeyActions) {
aa.Add(ui.KeyActions{
ui.KeyShiftI: ui.NewKeyAction("Sort Image-Id", ei.GetTable().SortColCmd("Image-Id", true), true),
tcell.KeyEscape: ui.NewKeyAction("Back", ei.App().PrevCmd, true),
tcell.KeyEnter: ui.NewKeyAction("View", ei.enterCmd, true),
})
}
}

func (ei *EC2I) enterCmd(evt *tcell.EventKey) *tcell.EventKey {
imageId := ei.GetTable().GetSelectedItem()
if imageId != "" {
f := describeResource
if ei.GetTable().enterFn != nil {
f = ei.GetTable().enterFn
}
f(ei.App(), ei.GetTable().GetModel(), ei.Resource(), imageId)
ei.App().Flash().Info("Image-Id: " + imageId)
}
return nil
}
16 changes: 15 additions & 1 deletion internal/view/ec2_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,22 @@ func NewEC2S(resource string) ResourceViewer {
func (es *EC2S) bindKeys(aa ui.KeyActions) {
aa.Add(ui.KeyActions{
ui.KeyShiftI: ui.NewKeyAction("Sort Snapshot-Id", es.GetTable().SortColCmd("Snapshot-Id", true), true),
ui.KeyShiftV: ui.NewKeyAction("Sort Volume-Size", es.GetTable().SortColCmd("Volume-Size", true), true),
ui.KeyShiftS: ui.NewKeyAction("Sort Volume-Size", es.GetTable().SortColCmd("Volume-Size", true), true),
ui.KeyShiftT: ui.NewKeyAction("Sort Start-Time", es.GetTable().SortColCmd("Start-Time", true), true),
tcell.KeyEscape: ui.NewKeyAction("Back", es.App().PrevCmd, true),
tcell.KeyEnter: ui.NewKeyAction("View", es.enterCmd, true),
})
}

func (es *EC2S) enterCmd(evt *tcell.EventKey) *tcell.EventKey {
snapshotId := es.GetTable().GetSelectedItem()
if snapshotId != "" {
f := describeResource
if es.GetTable().enterFn != nil {
f = es.GetTable().enterFn
}
f(es.App(), es.GetTable().GetModel(), es.Resource(), snapshotId)
es.App().Flash().Info("Snapshot-Id: " + snapshotId)
}
return nil
}
15 changes: 15 additions & 0 deletions internal/view/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,20 @@ func (v *VPC) bindKeys(aa ui.KeyActions) {
ui.KeyShiftI: ui.NewKeyAction("Sort VPC-Id", v.GetTable().SortColCmd("VPC-Id", true), true),
ui.KeyShiftS: ui.NewKeyAction("Sort VPC-State", v.GetTable().SortColCmd("VPC-State", true), true),
tcell.KeyEscape: ui.NewKeyAction("Back", v.App().PrevCmd, false),
tcell.KeyEnter: ui.NewKeyAction("View", v.enterCmd, false),
})
}

func (v *VPC) enterCmd(evt *tcell.EventKey) *tcell.EventKey {
vpcId := v.GetTable().GetSelectedItem()
if vpcId != "" {
f := describeResource
if v.GetTable().enterFn != nil {
f = v.GetTable().enterFn
}
f(v.App(), v.GetTable().GetModel(), v.Resource(), vpcId)
v.App().Flash().Info("VPC Id: " + vpcId)
}

return nil
}
1 change: 0 additions & 1 deletion populator/populator.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ func CreateLambdaFunction(sessions []*session.Session) error {
params := &lambda.CreateFunctionInput{
FunctionName: aws.String("lambdaaa-func-" + strconv.Itoa(gofakeit.Number(0, 999999))),
//Runtime: aws.String(*aws.String("python3.7")),
//Runtime: aws.String("go1.x"),
Role: aws.String("arn:aws:iam::000000000000:role/Andre"),
Code: &lambda.FunctionCode{
ZipFile: codeBytes,
Expand Down

0 comments on commit ecc0646

Please sign in to comment.