Skip to content

Commit

Permalink
Add describe json for ec2
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaysomani07 committed Feb 8, 2023
1 parent a382d8d commit 18ba9c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
9 changes: 9 additions & 0 deletions internal/dao/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ func (e *EC2) List(ctx context.Context) ([]Object, error) {
func (e *EC2) Get(ctx context.Context, path string) (Object, error) {
return nil, nil
}

func (e *EC2) Describe(instanceId string) (string, error) {
sess, ok := e.ctx.Value(internal.KeySession).(*session.Session)
if !ok {
log.Err(fmt.Errorf("conversion err: Expected session.session but got %v", sess))
}
res := aws.GetSingleInstance(*sess, instanceId).GoString()
return res, nil
}
15 changes: 5 additions & 10 deletions internal/view/ec2.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package view

import (
"fmt"

"github.com/gdamore/tcell/v2"
"github.com/one2nc/cloud-lens/internal/ui"
"github.com/rs/zerolog/log"
)

type EC2 struct {
Expand Down Expand Up @@ -34,16 +31,14 @@ func (e *EC2) bindKeys(aa ui.KeyActions) {
})
}

func (e *EC2) describeInstace(app *App, model ui.Tabular, resource string) {
log.Info().Msg(fmt.Sprintf("TODO: describe: %v", resource))
// if err := app.inject(co); err != nil {
// app.Flash().Err(err)
// }
}

func (e *EC2) enterCmd(evt *tcell.EventKey) *tcell.EventKey {
instanceId := e.GetTable().GetSelectedItem()
e.App().Flash().Info("Instance-Id: " + instanceId)

f := describeResource
if e.GetTable().enterFn != nil {
f = e.GetTable().enterFn
}
f(e.App(), e.GetTable().GetModel(), e.Resource(), instanceId)
return nil
}

0 comments on commit 18ba9c0

Please sign in to comment.