diff --git a/core/plans/microvm_create.go b/core/plans/microvm_create.go new file mode 100644 index 000000000..4cfd9f399 --- /dev/null +++ b/core/plans/microvm_create.go @@ -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 µvmCreatePlan{ + 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 +} diff --git a/core/plans/types.go b/core/plans/types.go new file mode 100644 index 000000000..52d33675d --- /dev/null +++ b/core/plans/types.go @@ -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 +} diff --git a/pkg/planner/actuator_test.go b/pkg/planner/actuator_test.go index 2ee8aecd7..620a17fd3 100644 --- a/pkg/planner/actuator_test.go +++ b/pkg/planner/actuator_test.go @@ -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 +} diff --git a/pkg/planner/planner.go b/pkg/planner/planner.go index 78c80e690..1ec152fd7 100644 --- a/pkg/planner/planner.go +++ b/pkg/planner/planner.go @@ -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) }