Skip to content

Commit

Permalink
wiop
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Case <[email protected]>
  • Loading branch information
richardcase committed Aug 26, 2021
1 parent a1aff98 commit 0792598
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
52 changes: 52 additions & 0 deletions core/plans/microvm_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package plans

import (
"context"

"github.com/weaveworks/reignite/core/models"
"github.com/weaveworks/reignite/core/ports"
"github.com/weaveworks/reignite/pkg/log"
"github.com/weaveworks/reignite/pkg/planner"
)

type MicroVMCreatePlanInput struct {
ID *models.VMID
}

func MicroVMCreatePlan(input *MicroVMCreatePlanInput, providers *ProvidersInput) planner.Plan {
return &microvmCreatePlan{
vmid: input.ID,
vmProvider: providers.MicroVMProvider,
vmRepo: providers.MicroVMRepo,
eventSvc: providers.EventService,
imageSvc: providers.ImageService,
}
}

type microvmCreatePlan struct {
vmid *models.VMID

vmProvider ports.MicroVMProvider
vmRepo ports.MicroVMRepository
eventSvc ports.EventService
imageSvc ports.ImageService
}

func (p *microvmCreatePlan) Name() string {
return "microvm_reconcile"
}

// Create will create the plan to reconcile a microvm.
func (p *microvmCreatePlan) Create(ctx context.Context) ([]planner.Procedure, error) {
logger := log.GetLogger(ctx)
logger.Debugf("creating plan for microvm %s", p.vmid.String())

procs := []planner.Procedure{}

return procs, nil
}

// Result is the result of the plan
func (p *microvmCreatePlan) Result() interface{} {
return nil
}
11 changes: 11 additions & 0 deletions core/plans/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package plans

import "github.com/weaveworks/reignite/core/ports"

// Providers input is a type to be used as input to plans.
type ProvidersInput struct {
MicroVMProvider ports.MicroVMProvider
MicroVMRepo ports.MicroVMRepository
EventService ports.EventService
ImageService ports.ImageService
}
4 changes: 4 additions & 0 deletions pkg/planner/actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,7 @@ func (p *testProc) Do(ctx context.Context) ([]planner.Procedure, error) {

return p.ChildProcs, nil
}

func (p *testProc) ShouldDo(ctx context.Context) (bool, error) {
return true, nil
}
2 changes: 2 additions & 0 deletions pkg/planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ type Procedure interface {
Name() string
// Do will perform the operation/procedure.
Do(ctx context.Context) ([]Procedure, error)
// ShouldDo tests if this procedure should be done and therefore included in a plan.
ShouldDo(ctx context.Context) (bool, error)
}

0 comments on commit 0792598

Please sign in to comment.