Skip to content

Commit

Permalink
feat: implement single microvm query API
Browse files Browse the repository at this point in the history
  • Loading branch information
jmickey committed Oct 27, 2021
1 parent 3217c47 commit 6629990
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion core/application/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,35 @@ package application

import (
"context"
"fmt"

"github.com/weaveworks/flintlock/core/models"
"github.com/weaveworks/flintlock/pkg/log"
)

func (a *app) GetMicroVM(ctx context.Context, id, namespace string) (*models.MicroVM, error) {
return nil, errNotImplemeted
logger := log.GetLogger(ctx).WithField("component", "app")
logger.Trace("querying microvm: ", id, "with namespace: ", namespace)

if id == "" {
return nil, errIDRequired
}

foundMvm, err := a.ports.Repo.Get(ctx, id, namespace)
if err != nil {
return nil, fmt.Errorf("error attempting to locate microvm with id: %s, in namespace: %s: %w", id, namespace, err)
}

if foundMvm == nil {
if foundMvm == nil {
return nil, specNotFoundError{
name: id,
namespace: namespace,
}
}
}

return foundMvm, nil
}

func (a *app) GetAllMicroVM(ctx context.Context, namespace string) ([]*models.MicroVM, error) {
Expand Down

0 comments on commit 6629990

Please sign in to comment.