diff --git a/internal/dao/ec2.go b/internal/dao/ec2.go index 466b3ad..ed0916b 100644 --- a/internal/dao/ec2.go +++ b/internal/dao/ec2.go @@ -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 +} diff --git a/internal/view/ec2.go b/internal/view/ec2.go index b79ee52..a9265a3 100644 --- a/internal/view/ec2.go +++ b/internal/view/ec2.go @@ -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 { @@ -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 }